1 45 46 package org.jfree.data.gantt; 47 48 import java.util.Collections ; 49 import java.util.List ; 50 51 import org.jfree.data.general.Series; 52 53 59 public class TaskSeries extends Series { 60 61 62 private List tasks; 63 64 69 public TaskSeries(String name) { 70 super(name); 71 this.tasks = new java.util.ArrayList (); 72 } 73 74 81 public void add(Task task) { 82 if (task == null) { 83 throw new IllegalArgumentException ("Null 'task' argument."); 84 } 85 this.tasks.add(task); 86 fireSeriesChanged(); 87 } 88 89 96 public void remove(Task task) { 97 this.tasks.remove(task); 98 fireSeriesChanged(); 99 } 100 101 106 public void removeAll() { 107 this.tasks.clear(); 108 fireSeriesChanged(); 109 } 110 111 116 public int getItemCount() { 117 return this.tasks.size(); 118 } 119 120 127 public Task get(int index) { 128 return (Task) this.tasks.get(index); 129 } 130 131 138 public Task get(String description) { 139 Task result = null; 140 int count = this.tasks.size(); 141 for (int i = 0; i < count; i++) { 142 Task t = (Task) this.tasks.get(i); 143 if (t.getDescription().equals(description)) { 144 result = t; 145 break; 146 } 147 } 148 return result; 149 } 150 151 156 public List getTasks() { 157 return Collections.unmodifiableList(this.tasks); 158 } 159 160 167 public boolean equals(Object obj) { 168 if (obj == this) { 169 return true; 170 } 171 if (!(obj instanceof TaskSeries)) { 172 return false; 173 } 174 if (!super.equals(obj)) { 175 return false; 176 } 177 TaskSeries that = (TaskSeries) obj; 178 if (!this.tasks.equals(that.tasks)) { 179 return false; 180 } 181 return true; 182 } 183 184 } 185 | Popular Tags |