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