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 XYIntervalSeriesCollection extends AbstractIntervalXYDataset 59 implements IntervalXYDataset, Serializable { 60 61 62 private List data; 63 64 67 public XYIntervalSeriesCollection() { 68 this.data = new java.util.ArrayList (); 69 } 70 71 77 public void addSeries(XYIntervalSeries 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 XYIntervalSeries getSeries(int series) { 106 if ((series < 0) || (series >= getSeriesCount())) { 107 throw new IllegalArgumentException ("Series index out of bounds"); 108 } 109 return (XYIntervalSeries) 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 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 153 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 154 return di.getX(); 155 } 156 157 165 public Number getY(int series, int item) { 166 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 167 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 168 return new Double (di.getYValue()); 169 } 170 171 179 public Number getStartX(int series, int item) { 180 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 181 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 182 return new Double (di.getXLowValue()); 183 } 184 185 193 public Number getEndX(int series, int item) { 194 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 195 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 196 return new Double (di.getXHighValue()); 197 } 198 199 208 public Number getStartY(int series, int item) { 209 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 210 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 211 return new Double (di.getYLowValue()); 212 } 213 214 223 public Number getEndY(int series, int item) { 224 XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); 225 XYIntervalDataItem di = (XYIntervalDataItem) s.getDataItem(item); 226 return new Double (di.getYHighValue()); 227 } 228 229 236 public boolean equals(Object obj) { 237 if (obj == this) { 238 return true; 239 } 240 if (!(obj instanceof XYIntervalSeriesCollection)) { 241 return false; 242 } 243 XYIntervalSeriesCollection that = (XYIntervalSeriesCollection) obj; 244 return ObjectUtilities.equal(this.data, that.data); 245 } 246 247 } 248 | Popular Tags |