1 43 44 package org.jfree.data.general; 45 46 import java.util.Set ; 47 import java.util.TreeSet ; 48 49 import org.jfree.data.DefaultKeyedValues2D; 50 51 57 public class WaferMapDataset extends AbstractDataset { 58 59 63 private DefaultKeyedValues2D data; 64 65 66 private int maxChipX; 67 68 69 private int maxChipY; 70 71 72 private double chipSpace; 73 74 75 private Double maxValue; 76 77 78 private Double minValue; 79 80 81 private static final double DEFAULT_CHIP_SPACE = 1d; 82 83 89 public WaferMapDataset(int maxChipX, int maxChipY) { 90 this(maxChipX, maxChipY, null); 91 } 92 93 100 public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) { 101 102 this.maxValue = new Double (Double.NEGATIVE_INFINITY); 103 this.minValue = new Double (Double.POSITIVE_INFINITY); 104 this.data = new DefaultKeyedValues2D(); 105 106 this.maxChipX = maxChipX; 107 this.maxChipY = maxChipY; 108 if (chipSpace == null) { 109 this.chipSpace = DEFAULT_CHIP_SPACE; 110 } 111 else { 112 this.chipSpace = chipSpace.doubleValue(); 113 } 114 115 } 116 117 124 public void addValue(Number value, Comparable chipx, Comparable chipy) { 125 setValue(value, chipx, chipy); 126 } 127 128 135 public void addValue(int v, int x, int y) { 136 setValue(new Double (v), new Integer (x), new Integer (y)); 137 } 138 139 146 public void setValue(Number value, Comparable chipx, Comparable chipy) { 147 this.data.setValue(value, chipx, chipy); 148 if (isMaxValue(value)) { 149 this.maxValue = (Double ) value; 150 } 151 if (isMinValue(value)) { 152 this.minValue = (Double ) value; 153 } 154 } 155 156 161 public int getUniqueValueCount() { 162 return getUniqueValues().size(); 163 } 164 165 170 public Set getUniqueValues() { 171 Set unique = new TreeSet (); 172 for (int r = 0; r < this.data.getRowCount(); r++) { 174 for (int c = 0; c < this.data.getColumnCount(); c++) { 175 Number value = this.data.getValue(r, c); 176 if (value != null) { 177 unique.add(value); 178 } 179 } 180 } 181 return unique; 182 } 183 184 192 public Number getChipValue(int chipx, int chipy) { 193 return getChipValue(new Integer (chipx), new Integer (chipy)); 194 } 195 196 204 public Number getChipValue(Comparable chipx, Comparable chipy) { 205 int rowIndex = this.data.getRowIndex(chipx); 206 if (rowIndex < 0) { 207 return null; 208 } 209 int colIndex = this.data.getColumnIndex(chipy); 210 if (colIndex < 0) { 211 return null; 212 } 213 return this.data.getValue(rowIndex, colIndex); 214 } 215 216 223 public boolean isMaxValue(Number check) { 224 if (check.doubleValue() > this.maxValue.doubleValue()) { 225 return true; 226 } 227 return false; 228 } 229 230 237 public boolean isMinValue(Number check) { 238 if (check.doubleValue() < this.minValue.doubleValue()) { 239 return true; 240 } 241 return false; 242 } 243 244 249 public Number getMaxValue() { 250 return this.maxValue; 251 } 252 253 258 public Number getMinValue() { 259 return this.minValue; 260 } 261 262 267 public int getMaxChipX() { 268 return this.maxChipX; 269 } 270 271 276 public void setMaxChipX(int maxChipX) { 277 this.maxChipX = maxChipX; 278 } 279 280 285 public int getMaxChipY() { 286 return this.maxChipY; 287 } 288 289 294 public void setMaxChipY(int maxChipY) { 295 this.maxChipY = maxChipY; 296 } 297 298 303 public double getChipSpace() { 304 return this.chipSpace; 305 } 306 307 312 public void setChipSpace(double space) { 313 this.chipSpace = space; 314 } 315 316 } 317 | Popular Tags |