1 42 43 package org.jfree.data.xy; 44 45 import java.io.Serializable ; 46 import java.util.List ; 47 48 import org.jfree.data.general.DatasetChangeEvent; 49 import org.jfree.util.ObjectUtilities; 50 51 58 public class YIntervalSeriesCollection extends AbstractIntervalXYDataset 59 implements IntervalXYDataset, Serializable { 60 61 62 private List data; 63 64 67 public YIntervalSeriesCollection() { 68 this.data = new java.util.ArrayList (); 69 } 70 71 77 public void addSeries(YIntervalSeries series) { 78 if (series == null) { 79 throw new IllegalArgumentException ("Null 'series' argument."); 80 } 81 this.data.add(series); 82 series.addChangeListener(this); 83 fireDatasetChanged(); 84 } 85 86 91 public int getSeriesCount() { 92 return this.data.size(); 93 } 94 95 105 public YIntervalSeries getSeries(int series) { 106 if ((series < 0) || (series >= getSeriesCount())) { 107 throw new IllegalArgumentException ("Series index out of bounds"); 108 } 109 return (YIntervalSeries) this.data.get(series); 110 } 111 112 123 public Comparable getSeriesKey(int series) { 124 return getSeries(series).getKey(); 126 } 127 128 138 public int getItemCount(int series) { 139 return getSeries(series).getItemCount(); 141 } 142 143 151 public Number getX(int series, int item) { 152 YIntervalSeries s = (YIntervalSeries) this.data.get(series); 153 YIntervalDataItem di = (YIntervalDataItem) s.getDataItem(item); 154 return di.getX(); 155 } 156 157 165 public Number getY(int series, int item) { 166 YIntervalSeries s = (YIntervalSeries) this.data.get(series); 167 YIntervalDataItem di = (YIntervalDataItem) s.getDataItem(item); 168 return new Double (di.getYValue()); 169 } 170 171 180 public Number getStartX(int series, int item) { 181 return getX(series, item); 182 } 183 184 193 public Number getEndX(int series, int item) { 194 return getX(series, item); 195 } 196 197 205 public Number getStartY(int series, int item) { 206 YIntervalSeries s = (YIntervalSeries) this.data.get(series); 207 YIntervalDataItem di = (YIntervalDataItem) s.getDataItem(item); 208 return new Double (di.getYLowValue()); 209 } 210 211 219 public Number getEndY(int series, int item) { 220 YIntervalSeries s = (YIntervalSeries) this.data.get(series); 221 YIntervalDataItem di = (YIntervalDataItem) s.getDataItem(item); 222 return new Double (di.getYHighValue()); 223 } 224 225 232 public boolean equals(Object obj) { 233 if (obj == this) { 234 return true; 235 } 236 if (!(obj instanceof YIntervalSeriesCollection)) { 237 return false; 238 } 239 YIntervalSeriesCollection that = (YIntervalSeriesCollection) obj; 240 return ObjectUtilities.equal(this.data, that.data); 241 } 242 243 } 244 | Popular Tags |