1 37 38 package org.jfree.chart.demo; 39 40 import org.jfree.data.AbstractDataset; 41 import org.jfree.data.DatasetChangeListener; 42 import org.jfree.data.IntervalXYDataset; 43 44 49 public class SimpleIntervalXYDataset2 extends AbstractDataset implements IntervalXYDataset { 50 51 52 private Double [] yStart; 53 54 55 private Double [] yEnd = new Double [3]; 56 57 58 private Double [] x = new Double [3]; 59 60 65 public SimpleIntervalXYDataset2(int itemCount) { 66 67 x = new Double [itemCount]; 68 yStart = new Double [itemCount]; 69 yEnd = new Double [itemCount]; 70 71 double base = 100; 72 for (int i = 1; i <= itemCount; i++) { 73 x[i - 1] = new Double (i); 74 base = base * (1 + (Math.random() / 10 - 0.05)); 75 yStart[i - 1] = new Double (base); 76 yEnd[i - 1] = new Double (yStart[i - 1].doubleValue() + Math.random() * 30); 77 } 78 } 79 80 85 public int getSeriesCount() { 86 return 1; 87 } 88 89 96 public String getSeriesName(int series) { 97 return "Series 1"; 98 } 99 100 107 public int getItemCount(int series) { 108 return x.length; 109 } 110 111 122 public Number getXValue(int series, int item) { 123 return x[item]; 124 } 125 126 134 public Number getYValue(int series, int item) { 135 return yEnd[item]; 136 } 137 138 146 public Number getStartXValue(int series, int item) { 147 return x[item]; 148 } 149 150 158 public Number getEndXValue(int series, int item) { 159 return x[item]; 160 } 161 162 170 public Number getStartYValue(int series, int item) { 171 return yStart[item]; 172 } 173 174 182 public Number getEndYValue(int series, int item) { 183 return yEnd[item]; 184 } 185 186 191 public void addChangeListener(DatasetChangeListener listener) { 192 } 193 194 199 public void removeChangeListener(DatasetChangeListener listener) { 200 } 201 202 } 203 | Popular Tags |