Changeset 2591
 Timestamp:
 04/10/07 14:25:32 (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/loci/visbio/overlays/OverlayBox.java
r2534 r2591 49 49 } 50 50 51 //  Static OverlayObject API methods  52 /** Returns the types of statistics reported by this overlay */ 53 public static String[] getStatTypes() { 54 return new String[] {"Coordinates", "Center", "Width", "Height", "Area", 55 "Perimeter"}; 56 } 57 51 58 //  OverlayObject API methods  52 59 53 60 /** Gets VisAD data object representing this overlay. */ 54 61 public DataImpl getData() { 55 if (x1 == x2  y1 == y2) return null; // don't try to render a zeroarea box 62 if (x1 == x2  y1 == y2) return null; 63 // don't try to render a zeroarea box 56 64 RealTupleType domain = overlay.getDomainType(); 57 65 TupleType range = overlay.getRangeType(); … … 201 209 // and flip if need be. 202 210 // I've set up the code in this section based on the 203 // suppositio in that the box is oriented like this:211 // supposition that the box is oriented like this: 204 212 // 205 213 // (x1, y1) ++ … … 210 218 // which means x1 is supposed to be _less_ than x2, but inconsistently, 211 219 // y1 is supposed to be _greater_ than y2. 220 212 221 float[][] c; 213 222 boolean flipX = x2 > x1; … … 218 227 float yy2 = flipY ? y2 : y1; 219 228 220 int rangeSamplesLength = 16; 221 SampledSet domainSet = null; 222 if (2 * delta > xx2  xx1  2 * delta > yy1  yy2) { 223 // if box is narrower than twice the width the highlighting 224 // band would be, 225 // just throw down a translucent rectangle over the box 226 227 rangeSamplesLength = 4; 228 229 float[][] setSamples = { 230 {xx1  delta, xx2 + delta, xx1  delta, xx2 + delta}, 231 {yy1 + delta, yy1 + delta, yy2  delta, yy2  delta}}; 232 233 try { 234 domainSet = new Gridded2DSet(domain, setSamples, 2, 2, 235 null, null, null, false); 236 } 237 catch (VisADException ex) { ex.printStackTrace(); } 238 } 239 else { 240 // construct a trapezoidal highlighting band for each of the 241 // four line segments which constitute the box 242 c = new float[][]{{xx1, yy1}, {xx2, yy2}}; 243 244 float[][] s1 = 245 {{c[0][0]  delta, c[1][0] + delta, c[0][0] + delta, c[1][0]  delta}, 246 {c[0][1] + delta, c[0][1] + delta, c[0][1]  delta, c[0][1]  delta}}; 247 float[][] s2 = 248 {{c[1][0] + delta, c[1][0] + delta, c[1][0]  delta, c[1][0]  delta}, 249 {c[0][1] + delta, c[1][1]  delta, c[0][1]  delta, c[1][1] + delta}}; 250 float[][] s3 = 251 {{c[1][0] + delta, c[0][0]  delta, c[1][0]  delta, c[0][0] + delta}, 252 {c[1][1]  delta, c[1][1]  delta, c[1][1] + delta, c[1][1] + delta}}; 253 float[][] s4 = 254 {{c[0][0]  delta, c[0][0]  delta, c[0][0] + delta, c[0][0] + delta}, 255 {c[1][1]  delta, c[0][1] + delta, c[1][1] + delta, c[0][1]  delta}}; 256 257 float[][][] setSamples = {s1, s2, s3, s4}; 258 259 Gridded2DSet[] segments = new Gridded2DSet[4]; 260 for (int i=0; i<4; i++) { 261 Gridded2DSet segment = null; 262 try { 263 segment = new Gridded2DSet (domain, setSamples[i], 2, 2, null, null, 264 null, 265 false); 266 } 267 catch (VisADException exc) { exc.printStackTrace(); } 268 segments[i] = segment; 269 } 270 271 try { domainSet = new UnionSet(domain, segments); } 272 catch (VisADException exc) { exc.printStackTrace(); } 273 } // end else 274 275 //************************************************************** 229 // just throw down a translucent rectangle over the box 230 float[][] setSamples = { 231 {xx1  delta, xx2 + delta, xx1  delta, xx2 + delta}, 232 {yy1 + delta, yy1 + delta, yy2  delta, yy2  delta}}; 276 233 277 234 // construct range samples 278 float[][] rangeSamples = new float[4][ rangeSamplesLength];235 float[][] rangeSamples = new float[4][4]; 279 236 float r = GLOW_COLOR.getRed() / 255f; 280 237 float g = GLOW_COLOR.getGreen() / 255f; … … 286 243 287 244 // construct field 245 Gridded2DSet domainSet = null; 288 246 FlatField field = null; 289 247 try { 248 domainSet = new Gridded2DSet(domain, setSamples, 2, 2, 249 null, null, null, false); 290 250 FunctionType fieldType = new FunctionType(domain, range); 291 251 field = new FlatField(fieldType, domainSet);
Note: See TracChangeset
for help on using the changeset viewer.