Changeset 2591


Ignore:
Timestamp:
04/10/07 14:25:32 (13 years ago)
Author:
sorber
Message:

Replaced hollow selection grid with filled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/overlays/OverlayBox.java

    r2534 r2591  
    4949  } 
    5050 
     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 
    5158  // -- OverlayObject API methods -- 
    5259 
    5360  /** Gets VisAD data object representing this overlay. */ 
    5461  public DataImpl getData() { 
    55     if (x1 == x2 || y1 == y2) return null; // don't try to render a zero-area box 
     62    if (x1 == x2 || y1 == y2) return null;  
     63    // don't try to render a zero-area box 
    5664    RealTupleType domain = overlay.getDomainType(); 
    5765    TupleType range = overlay.getRangeType(); 
     
    201209    // and flip if need be. 
    202210    // I've set up the code in this section based on the  
    203     // suppositioin that the box is oriented like this: 
     211    // supposition that the box is oriented like this: 
    204212    // 
    205213    // (x1, y1) +--------+ 
     
    210218    // which means x1 is supposed to be _less_ than x2, but inconsistently, 
    211219    // y1 is supposed to be _greater_ than y2. 
     220 
    212221    float[][] c; 
    213222    boolean flipX = x2 > x1; 
     
    218227    float yy2 = flipY ? y2 : y1; 
    219228 
    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}}; 
    276233     
    277234    // construct range samples 
    278     float[][] rangeSamples = new float[4][rangeSamplesLength]; 
     235    float[][] rangeSamples = new float[4][4]; 
    279236    float r = GLOW_COLOR.getRed() / 255f; 
    280237    float g = GLOW_COLOR.getGreen() / 255f; 
     
    286243 
    287244    // construct field 
     245    Gridded2DSet domainSet = null; 
    288246    FlatField field = null; 
    289247    try { 
     248      domainSet = new Gridded2DSet(domain, setSamples, 2, 2, 
     249        null, null, null, false); 
    290250      FunctionType fieldType = new FunctionType(domain, range); 
    291251      field = new FlatField(fieldType, domainSet); 
Note: See TracChangeset for help on using the changeset viewer.