1 38 39 package org.jfree.data; 40 41 import java.util.Date ; 42 43 48 public class DefaultHighLowDataset extends AbstractSeriesDataset implements HighLowDataset { 49 50 51 private String seriesName; 52 53 54 private Date [] date; 55 56 57 private Number [] high; 58 59 60 private Number [] low; 61 62 63 private Number [] open; 64 65 66 private Number [] close; 67 68 69 private Number [] volume; 70 71 85 public DefaultHighLowDataset(String seriesName, 86 Date [] date, 87 double[] high, double[] low, 88 double[] open, double[] close, 89 double[] volume) { 90 91 this.seriesName = seriesName; 92 this.date = date; 93 this.high = createNumberArray(high); 94 this.low = createNumberArray(low); 95 this.open = createNumberArray(open); 96 this.close = createNumberArray(close); 97 this.volume = createNumberArray(volume); 98 99 } 100 101 107 public String getSeriesName(int i) { 108 return this.seriesName; 109 } 110 111 121 public Number getXValue(int series, int item) { 122 return new Long (date[item].getTime()); 123 } 124 125 135 public Date getXDate(int series, int item) { 136 return date[item]; 137 } 138 139 149 public Number getYValue(int series, int item) { 150 return getCloseValue(series, item); 151 } 152 153 161 public Number getHighValue(int series, int item) { 162 return high[item]; 163 } 164 165 173 public Number getLowValue(int series, int item) { 174 return low[item]; 175 } 176 177 185 public Number getOpenValue(int series, int item) { 186 return open[item]; 187 } 188 189 197 public Number getCloseValue(int series, int item) { 198 return close[item]; 199 } 200 201 209 public Number getVolumeValue(int series, int item) { 210 return volume[item]; 211 } 212 213 220 public int getSeriesCount() { 221 return 1; 222 } 223 224 231 public int getItemCount(int series) { 232 return date.length; 233 } 234 235 242 public static Number [] createNumberArray(double[] data) { 243 244 Number [] result = new Number [data.length]; 245 246 for (int i = 0; i < data.length; i++) { 247 result[i] = new Double (data[i]); 248 } 249 250 return result; 251 252 } 253 254 } 255 | Popular Tags |