1 44 45 package org.jfree.data.gantt; 46 47 import java.io.Serializable ; 48 import java.util.Date ; 49 import java.util.List ; 50 51 import org.jfree.data.time.SimpleTimePeriod; 52 import org.jfree.data.time.TimePeriod; 53 import org.jfree.util.ObjectUtilities; 54 import org.jfree.util.PublicCloneable; 55 56 60 public class Task implements Cloneable , PublicCloneable, Serializable { 61 62 63 private static final long serialVersionUID = 1094303785346988894L; 64 65 66 private String description; 67 68 69 private TimePeriod duration; 70 71 72 private Double percentComplete; 73 74 75 private List subtasks; 76 77 84 public Task(String description, TimePeriod duration) { 85 if (description == null) { 86 throw new IllegalArgumentException ("Null 'description' argument."); 87 } 88 this.description = description; 89 this.duration = duration; 90 this.percentComplete = null; 91 this.subtasks = new java.util.ArrayList (); 92 } 93 94 102 public Task(String description, Date start, Date end) { 103 this(description, new SimpleTimePeriod(start, end)); 104 } 105 106 111 public String getDescription() { 112 return this.description; 113 } 114 115 120 public void setDescription(String description) { 121 if (description == null) { 122 throw new IllegalArgumentException ("Null 'description' argument."); 123 } 124 this.description = description; 125 } 126 127 132 public TimePeriod getDuration() { 133 return this.duration; 134 } 135 136 141 public void setDuration(TimePeriod duration) { 142 this.duration = duration; 143 } 144 145 150 public Double getPercentComplete() { 151 return this.percentComplete; 152 } 153 154 159 public void setPercentComplete(Double percent) { 160 this.percentComplete = percent; 161 } 162 163 168 public void setPercentComplete(double percent) { 169 setPercentComplete(new Double (percent)); 170 } 171 172 177 public void addSubtask(Task subtask) { 178 if (subtask == null) { 179 throw new IllegalArgumentException ("Null 'subtask' argument."); 180 } 181 this.subtasks.add(subtask); 182 } 183 184 189 public void removeSubtask(Task subtask) { 190 this.subtasks.remove(subtask); 191 } 192 193 198 public int getSubtaskCount() { 199 return this.subtasks.size(); 200 } 201 202 209 public Task getSubtask(int index) { 210 return (Task) this.subtasks.get(index); 211 } 212 213 220 public boolean equals(Object object) { 221 if (object == this) { 222 return true; 223 } 224 if (!(object instanceof Task)) { 225 return false; 226 } 227 Task that = (Task) object; 228 if (!ObjectUtilities.equal(this.description, that.description)) { 229 return false; 230 } 231 if (!ObjectUtilities.equal(this.duration, that.duration)) { 232 return false; 233 } 234 if (!ObjectUtilities.equal(this.percentComplete, 235 that.percentComplete)) { 236 return false; 237 } 238 if (!ObjectUtilities.equal(this.subtasks, that.subtasks)) { 239 return false; 240 } 241 return true; 242 } 243 244 252 public Object clone() throws CloneNotSupportedException { 253 Task clone = (Task) super.clone(); 254 return clone; 255 } 256 257 } 258 | Popular Tags |