1 48 49 package org.jfree.data.xy; 50 51 import org.jfree.data.DefaultKeyedValues2D; 52 import org.jfree.data.DomainInfo; 53 import org.jfree.data.Range; 54 import org.jfree.data.general.DatasetChangeEvent; 55 import org.jfree.data.general.DatasetUtilities; 56 57 72 public class CategoryTableXYDataset extends AbstractIntervalXYDataset 73 implements TableXYDataset, 74 IntervalXYDataset, 75 DomainInfo { 76 77 80 private DefaultKeyedValues2D values; 81 82 83 private IntervalXYDelegate intervalDelegate; 84 85 88 public CategoryTableXYDataset() { 89 this.values = new DefaultKeyedValues2D(true); 90 this.intervalDelegate = new IntervalXYDelegate(this); 91 addChangeListener(this.intervalDelegate); 92 } 93 94 102 public void add(double x, double y, String seriesName) { 103 add(new Double (x), new Double (y), seriesName, true); 104 } 105 106 115 public void add(Number x, Number y, String seriesName, boolean notify) { 116 this.values.addValue(y, (Comparable ) x, seriesName); 117 if (notify) { 118 fireDatasetChanged(); 119 } 120 } 121 122 128 public void remove(double x, String seriesName) { 129 remove(new Double (x), seriesName, true); 130 } 131 132 139 public void remove(Number x, String seriesName, boolean notify) { 140 this.values.removeValue((Comparable ) x, seriesName); 141 if (notify) { 142 fireDatasetChanged(); 143 } 144 } 145 146 147 152 public int getSeriesCount() { 153 return this.values.getColumnCount(); 154 } 155 156 163 public Comparable getSeriesKey(int series) { 164 return this.values.getColumnKey(series); 165 } 166 167 172 public int getItemCount() { 173 return this.values.getRowCount(); 174 } 175 176 184 public int getItemCount(int series) { 185 return getItemCount(); } 188 189 197 public Number getX(int series, int item) { 198 return (Number ) this.values.getRowKey(item); 199 } 200 201 209 public Number getStartX(int series, int item) { 210 return this.intervalDelegate.getStartX(series, item); 211 } 212 213 221 public Number getEndX(int series, int item) { 222 return this.intervalDelegate.getEndX(series, item); 223 } 224 225 233 public Number getY(int series, int item) { 234 return this.values.getValue(item, series); 235 } 236 237 245 public Number getStartY(int series, int item) { 246 return getY(series, item); 247 } 248 249 257 public Number getEndY(int series, int item) { 258 return getY(series, item); 259 } 260 261 269 public double getDomainLowerBound(boolean includeInterval) { 270 return this.intervalDelegate.getDomainLowerBound(includeInterval); 271 } 272 273 281 public double getDomainUpperBound(boolean includeInterval) { 282 return this.intervalDelegate.getDomainUpperBound(includeInterval); 283 } 284 285 293 public Range getDomainBounds(boolean includeInterval) { 294 if (includeInterval) { 295 return this.intervalDelegate.getDomainBounds(includeInterval); 296 } 297 else { 298 return DatasetUtilities.iterateDomainBounds(this, includeInterval); 299 } 300 } 301 302 307 public double getIntervalPositionFactor() { 308 return this.intervalDelegate.getIntervalPositionFactor(); 309 } 310 311 319 public void setIntervalPositionFactor(double d) { 320 this.intervalDelegate.setIntervalPositionFactor(d); 321 fireDatasetChanged(); 322 } 323 324 329 public double getIntervalWidth() { 330 return this.intervalDelegate.getIntervalWidth(); 331 } 332 333 339 public void setIntervalWidth(double d) { 340 this.intervalDelegate.setFixedIntervalWidth(d); 341 fireDatasetChanged(); 342 } 343 344 349 public boolean isAutoWidth() { 350 return this.intervalDelegate.isAutoWidth(); 351 } 352 353 359 public void setAutoWidth(boolean b) { 360 this.intervalDelegate.setAutoWidth(b); 361 fireDatasetChanged(); 362 } 363 364 371 public boolean equals(Object obj) { 372 if (!(obj instanceof CategoryTableXYDataset)) { 373 return false; 374 } 375 CategoryTableXYDataset that = (CategoryTableXYDataset) obj; 376 if (!this.intervalDelegate.equals(that.intervalDelegate)) { 377 return false; 378 } 379 if (!this.values.equals(that.values)) { 380 return false; 381 } 382 return true; 383 } 384 385 } 386 | Popular Tags |