KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > taskblocks > graph > Task


1 /*
2  * Copyright (C) Jakub Neubauer, 2007
3  *
4  * This file is part of TaskBlocks
5  *
6  * TaskBlocks is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * TaskBlocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */

19
20 package taskblocks.graph;
21
22 import java.awt.Rectangle JavaDoc;
23
24 import taskblocks.ArrayUtils;
25 import taskblocks.Utils;
26
27 /**
28  * Representation of task displayed in TaskGraphComponent. Used internally by TaskGraphComponent.
29  */

30 class Task extends GraphObject {
31     
32     /** User object (from the model) */
33     Object JavaDoc _userObject;
34     
35     /** Row (man) that contains this task */
36     TaskRow _row;
37     
38     /** Connections that points TO this task */
39     Connection[] _incommingConnections;
40     
41     /** Connections going from this task */
42     Connection[] _outgoingConnections;
43     
44     /** How many working days the task takes */
45     private long _duration;
46     
47     /** When the task starts */
48     private long _startTime;
49     
50     /** Finish time is automatically counted from startTime and duration */
51     private long _finishTime;
52     
53     /** Bouds of the displayed task rectangle (in pixels, on the TaskGraphComponent) */
54     Rectangle JavaDoc _bounds = new Rectangle JavaDoc();
55     
56     /** 1 bit information used in algorythms traversing through the task dependency graph */
57     boolean _flag;
58     
59     TaskGraphRepresentation _builder;
60     
61     Task(Object JavaDoc userObject, TaskGraphRepresentation builder) {
62         _userObject = userObject;
63         _builder = builder;
64     }
65     
66     public void addIncommingConnection(Connection c) {
67         _incommingConnections = (Connection[])ArrayUtils.addToArray(_incommingConnections, c);
68     }
69     
70     public void addOutgoingConnection(Connection c) {
71         _outgoingConnections = (Connection[])ArrayUtils.addToArray(_outgoingConnections, c);
72     }
73     
74     private void repairStartTime() {
75         _startTime = Utils.repairStartTime(_startTime);
76     }
77
78     public long getDuration() {
79         return _duration;
80     }
81
82     public void setDuration(long duration) {
83         long oldDuration = _duration;
84         this._duration = duration;
85         _finishTime = Utils.countFinishTime(_startTime, _duration);
86         if(oldDuration != _duration) {
87             _builder.setDirty();
88         }
89     }
90
91     public long getFinishTime() {
92         return _finishTime;
93     }
94
95     public long getStartTime() {
96         return _startTime;
97     }
98
99     public void setStartTime(long time) {
100         long oldTime = _startTime;
101         _startTime = time;
102         repairStartTime();
103         _finishTime = Utils.countFinishTime(_startTime, _duration);
104         if(_startTime != oldTime) {
105             _builder.setDirty();
106         }
107     }
108
109     public long getRealDuration() {
110         return _finishTime - _startTime;
111     }
112     
113     public TaskRow getRow() {
114         return _row;
115     }
116
117 }
118
Popular Tags