1 51 52 package org.jfree.data.statistics; 53 54 import java.util.List ; 55 56 import org.jfree.data.KeyedObjects2D; 57 import org.jfree.data.Range; 58 import org.jfree.data.RangeInfo; 59 import org.jfree.data.general.AbstractDataset; 60 61 67 public class DefaultStatisticalCategoryDataset extends AbstractDataset 68 implements StatisticalCategoryDataset, RangeInfo { 69 70 71 private KeyedObjects2D data; 72 73 74 private double minimumRangeValue; 75 76 77 private double maximumRangeValue; 78 79 80 private Range rangeBounds; 81 82 85 public DefaultStatisticalCategoryDataset() { 86 this.data = new KeyedObjects2D(); 87 this.minimumRangeValue = 0.0; 88 this.maximumRangeValue = 0.0; 89 this.rangeBounds = new Range(0.0, 0.0); 90 } 91 92 100 public Number getMeanValue(int row, int column) { 101 Number result = null; 102 MeanAndStandardDeviation masd 103 = (MeanAndStandardDeviation) this.data.getObject(row, column); 104 if (masd != null) { 105 result = masd.getMean(); 106 } 107 return result; 108 } 109 110 119 public Number getValue(int row, int column) { 120 return getMeanValue(row, column); 121 } 122 123 132 public Number getValue(Comparable rowKey, Comparable columnKey) { 133 return getMeanValue(rowKey, columnKey); 134 } 135 136 144 public Number getMeanValue(Comparable rowKey, Comparable columnKey) { 145 Number result = null; 146 MeanAndStandardDeviation masd 147 = (MeanAndStandardDeviation) this.data.getObject(rowKey, columnKey); 148 if (masd != null) { 149 result = masd.getMean(); 150 } 151 return result; 152 } 153 154 162 public Number getStdDevValue(int row, int column) { 163 Number result = null; 164 MeanAndStandardDeviation masd 165 = (MeanAndStandardDeviation) this.data.getObject(row, column); 166 if (masd != null) { 167 result = masd.getStandardDeviation(); 168 } 169 return result; 170 } 171 172 180 public Number getStdDevValue(Comparable rowKey, Comparable columnKey) { 181 Number result = null; 182 MeanAndStandardDeviation masd 183 = (MeanAndStandardDeviation) this.data.getObject(rowKey, columnKey); 184 if (masd != null) { 185 result = masd.getStandardDeviation(); 186 } 187 return result; 188 } 189 190 197 public int getColumnIndex(Comparable key) { 198 return this.data.getColumnIndex(key); 199 } 200 201 208 public Comparable getColumnKey(int column) { 209 return this.data.getColumnKey(column); 210 } 211 212 217 public List getColumnKeys() { 218 return this.data.getColumnKeys(); 219 } 220 221 228 public int getRowIndex(Comparable key) { 229 return this.data.getRowIndex(key); 230 } 231 232 239 public Comparable getRowKey(int row) { 240 return this.data.getRowKey(row); 241 } 242 243 248 public List getRowKeys() { 249 return this.data.getRowKeys(); 250 } 251 252 257 public int getRowCount() { 258 return this.data.getRowCount(); 259 } 260 261 266 public int getColumnCount() { 267 return this.data.getColumnCount(); 268 } 269 270 278 public void add(double mean, double standardDeviation, 279 Comparable rowKey, Comparable columnKey) { 280 add(new Double (mean), new Double (standardDeviation), rowKey, columnKey); 281 } 282 283 291 public void add(Number mean, Number standardDeviation, 292 Comparable rowKey, Comparable columnKey) { 293 MeanAndStandardDeviation item = new MeanAndStandardDeviation( 294 mean, standardDeviation 295 ); 296 this.data.addObject(item, rowKey, columnKey); 297 double m = 0.0; 298 double sd = 0.0; 299 if (mean != null) { 300 m = mean.doubleValue(); 301 } 302 if (standardDeviation != null) { 303 sd = standardDeviation.doubleValue(); 304 } 305 306 if ((m + sd) > this.maximumRangeValue) { 307 this.maximumRangeValue = m + sd; 308 this.rangeBounds = new Range( 309 this.minimumRangeValue, this.maximumRangeValue 310 ); 311 } 312 if ((m - sd) < this.minimumRangeValue) { 313 this.minimumRangeValue = m - sd; 314 this.rangeBounds = new Range( 315 this.minimumRangeValue, this.maximumRangeValue 316 ); 317 } 318 fireDatasetChanged(); 319 } 320 321 330 public double getRangeLowerBound(boolean includeInterval) { 331 return this.minimumRangeValue; 332 } 333 334 343 public double getRangeUpperBound(boolean includeInterval) { 344 return this.maximumRangeValue; 345 } 346 347 355 public Range getRangeBounds(boolean includeInterval) { 356 return this.rangeBounds; 357 } 358 359 366 public boolean equals(Object obj) { 367 if (obj == this) { 368 return true; 369 } 370 if (!(obj instanceof DefaultStatisticalCategoryDataset)) { 371 return false; 372 } 373 DefaultStatisticalCategoryDataset that 374 = (DefaultStatisticalCategoryDataset) obj; 375 if (!this.data.equals(that.data)) { 376 return false; 377 } 378 return true; 379 } 380 } 381 | Popular Tags |