1 52 53 package org.jfree.data.general; 54 55 import org.jfree.data.xy.AbstractIntervalXYDataset; 56 import org.jfree.data.xy.OHLCDataset; 57 import org.jfree.data.xy.IntervalXYDataset; 58 import org.jfree.data.xy.XYDataset; 59 60 66 public class SubSeriesDataset extends AbstractIntervalXYDataset 67 implements OHLCDataset, 68 IntervalXYDataset, 69 CombinationDataset { 70 71 72 private SeriesDataset parent = null; 73 74 75 private int[] map; 77 84 public SubSeriesDataset(SeriesDataset parent, int[] map) { 85 this.parent = parent; 86 this.map = map; 87 } 88 89 96 public SubSeriesDataset(SeriesDataset parent, int series) { 97 this(parent, new int[] {series}); 98 } 99 100 104 115 public Number getHigh(int series, int item) { 116 return ((OHLCDataset) this.parent).getHigh(this.map[series], item); 117 } 118 119 128 public double getHighValue(int series, int item) { 129 double result = Double.NaN; 130 Number high = getHigh(series, item); 131 if (high != null) { 132 result = high.doubleValue(); 133 } 134 return result; 135 } 136 137 148 public Number getLow(int series, int item) { 149 return ((OHLCDataset) this.parent).getLow(this.map[series], item); 150 } 151 152 161 public double getLowValue(int series, int item) { 162 double result = Double.NaN; 163 Number low = getLow(series, item); 164 if (low != null) { 165 result = low.doubleValue(); 166 } 167 return result; 168 } 169 170 181 public Number getOpen(int series, int item) { 182 return ((OHLCDataset) this.parent).getOpen(this.map[series], item); 183 } 184 185 194 public double getOpenValue(int series, int item) { 195 double result = Double.NaN; 196 Number open = getOpen(series, item); 197 if (open != null) { 198 result = open.doubleValue(); 199 } 200 return result; 201 } 202 203 214 public Number getClose(int series, int item) { 215 return ((OHLCDataset) this.parent).getClose(this.map[series], item); 216 } 217 218 227 public double getCloseValue(int series, int item) { 228 double result = Double.NaN; 229 Number close = getClose(series, item); 230 if (close != null) { 231 result = close.doubleValue(); 232 } 233 return result; 234 } 235 236 247 public Number getVolume(int series, int item) { 248 return ((OHLCDataset) this.parent).getVolume(this.map[series], item); 249 } 250 251 260 public double getVolumeValue(int series, int item) { 261 double result = Double.NaN; 262 Number volume = getVolume(series, item); 263 if (volume != null) { 264 result = volume.doubleValue(); 265 } 266 return result; 267 } 268 269 273 284 public Number getX(int series, int item) { 285 return ((XYDataset) this.parent).getX(this.map[series], item); 286 } 287 288 299 public Number getY(int series, int item) { 300 return ((XYDataset) this.parent).getY(this.map[series], item); 301 } 302 303 313 public int getItemCount(int series) { 314 return ((XYDataset) this.parent).getItemCount(this.map[series]); 315 } 316 317 321 326 public int getSeriesCount() { 327 return this.map.length; 328 } 329 330 337 public Comparable getSeriesKey(int series) { 338 return this.parent.getSeriesKey(this.map[series]); 339 } 340 341 345 353 public Number getStartX(int series, int item) { 354 if (this.parent instanceof IntervalXYDataset) { 355 return ((IntervalXYDataset) this.parent).getStartX( 356 this.map[series], item 357 ); 358 } 359 else { 360 return getX(series, item); 361 } 362 } 363 364 372 public Number getEndX(int series, int item) { 373 if (this.parent instanceof IntervalXYDataset) { 374 return ((IntervalXYDataset) this.parent).getEndX( 375 this.map[series], item 376 ); 377 } 378 else { 379 return getX(series, item); 380 } 381 } 382 383 391 public Number getStartY(int series, int item) { 392 if (this.parent instanceof IntervalXYDataset) { 393 return ((IntervalXYDataset) this.parent).getStartY( 394 this.map[series], item 395 ); 396 } 397 else { 398 return getY(series, item); 399 } 400 } 401 402 410 public Number getEndY(int series, int item) { 411 if (this.parent instanceof IntervalXYDataset) { 412 return ((IntervalXYDataset) this.parent).getEndY( 413 this.map[series], item 414 ); 415 } 416 else { 417 return getY(series, item); 418 } 419 } 420 421 425 430 public SeriesDataset getParent() { 431 return this.parent; 432 } 433 434 439 public int[] getMap() { 440 return (int[]) this.map.clone(); 441 } 442 443 } 444 | Popular Tags |