1 38 39 package org.jfree.data; 40 41 import java.util.Set ; 42 import java.util.TreeSet ; 43 44 49 public class WaferMapDataset extends AbstractDataset { 50 51 52 private DefaultKeyedValues2D data; 53 54 55 private int maxChipX; 56 57 58 private int maxChipY; 59 60 61 private double chipSpace; 62 63 64 private Double maxValue; 65 66 67 private Double minValue; 68 69 70 private static final double DEFAULT_CHIP_SPACE = 1d; 71 72 78 public WaferMapDataset(int maxChipX, int maxChipY) { 79 this(maxChipX, maxChipY, null); 80 } 81 82 89 public WaferMapDataset( int maxChipX, int maxChipY, Number chipSpace) { 90 91 this.maxValue = new Double (Double.NEGATIVE_INFINITY); 92 this.minValue = new Double (Double.POSITIVE_INFINITY); 93 this.data = new DefaultKeyedValues2D(); 94 95 this.maxChipX = maxChipX; 96 this.maxChipY = maxChipY; 97 if (chipSpace == null) { 98 this.chipSpace = DEFAULT_CHIP_SPACE; 99 } 100 else { 101 this.chipSpace = chipSpace.doubleValue(); 102 } 103 104 } 105 106 113 public void addValue(Number value, Comparable chipx, Comparable chipy) { 114 setValue(value, chipx, chipy); 115 } 116 117 124 public void addValue( int v, int x, int y) { 125 setValue(new Double (v), new Integer (x), new Integer (y)); 126 } 127 128 135 public void setValue(Number value, Comparable chipx, Comparable chipy) { 136 this.data.setValue( value, chipx, chipy ); 137 if( isMaxValue(value) ) this.maxValue = (Double )value; 138 if( isMinValue(value) ) this.minValue = (Double )value; 139 } 140 141 146 public int getUniqueValueCount() { 147 return getUniqueValues().size(); 148 } 149 150 155 public Set getUniqueValues() { 156 Set unique = new TreeSet (); 157 for (int r = 0; r < data.getRowCount(); r++) { 159 for(int c = 0; c < data.getColumnCount(); c++) { 160 Number value = data.getValue(r, c); 161 if (value != null) { 162 unique.add(value); 163 } 164 } 165 } 166 return unique; 167 } 168 169 177 public Number getChipValue(int chipx, int chipy) { 178 return getChipValue(new Integer (chipx), new Integer (chipy)); 179 } 180 181 189 public Number getChipValue(Comparable chipx, Comparable chipy) { 190 int rowIndex = data.getRowIndex(chipx); 191 if (rowIndex < 0) { 192 return null; 193 } 194 int colIndex = data.getColumnIndex(chipy); 195 if (colIndex < 0) { 196 return null; 197 } 198 return this.data.getValue(rowIndex, colIndex); 199 } 200 201 208 public boolean isMaxValue(Number check) { 209 if (check.doubleValue() > this.maxValue.doubleValue()) { 210 return true; 211 } 212 return false; 213 } 214 215 222 public boolean isMinValue(Number check) { 223 if (check.doubleValue() < this.minValue.doubleValue()) { 224 return true; 225 } 226 return false; 227 } 228 229 234 public Number getMaxValue() { 235 return this.maxValue; 236 } 237 238 243 public Number getMinValue() { 244 return this.minValue; 245 } 246 247 252 public int getMaxChipX() { 253 return maxChipX; 254 } 255 256 261 public void setMaxChipX(int maxChipX) { 262 this.maxChipX = maxChipX; 263 } 264 265 270 public int getMaxChipY() { 271 return maxChipY; 272 } 273 274 279 public void setMaxChipY(int maxChipY) { 280 this.maxChipY = maxChipY; 281 } 282 283 288 public double getChipSpace() { 289 return chipSpace; 290 } 291 292 297 public void setChipSpace(double space) { 298 this.chipSpace = space; 299 } 300 301 } 302 | Popular Tags |