Changeset 2246


Ignore:
Timestamp:
02/08/07 14:06:04 (13 years ago)
Author:
sorber
Message:

Misc small changes: removed visible flag from TransientSelect Box, OverlayObject mouse methods take visad.DisplayEvents as a parameter.

Location:
trunk/loci/visbio/overlays
Files:
11 edited

Legend:

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

    r2095 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** ArrowTool is the tool for creating arrow overlays. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5657 
    5758  /** Instructs this tool to respond to a mouse release. */ 
    58   public void mouseUp(int px, int py, 
     59  public void mouseUp(DisplayEvent e, int px, int py, 
    5960    float dx, float dy, int[] pos, int mods) 
    6061  { 
     
    6667 
    6768  /** Instructs this tool to respond to a mouse drag. */ 
    68   public void mouseDrag(int px, int py, 
     69  public void mouseDrag(DisplayEvent e, int px, int py, 
    6970    float dx, float dy, int[] pos, int mods) 
    7071  { 
  • trunk/loci/visbio/overlays/BoxTool.java

    r2123 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** BoxTool is the tool for creating box overlays. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5657 
    5758  /** Instructs this tool to respond to a mouse release. */ 
    58   public void mouseUp(int px, int py, 
     59  public void mouseUp(DisplayEvent e, int px, int py, 
    5960    float dx, float dy, int[] pos, int mods) 
    6061  { 
     
    7172 
    7273  /** Instructs this tool to respond to a mouse drag. */ 
    73   public void mouseDrag(int px, int py, 
     74  public void mouseDrag(DisplayEvent e, int px, int py, 
    7475    float dx, float dy, int[] pos, int mods) 
    7576  { 
  • trunk/loci/visbio/overlays/FreeformTool.java

    r2096 r2246  
    2828import java.awt.event.InputEvent; 
    2929import java.util.Vector; 
     30import visad.DisplayEvent; 
    3031 
    3132/** FreeformTool is the tool for creating freeform objects. */ 
     
    7172  /** Tendril wraps info about an edit to a curve */ 
    7273  protected Tendril tendril; 
     74 
     75  /** Stores the current mode (ERASE, CHILL, DRAW, EDIT) */ 
    7376  protected int mode; 
    7477 
    75   protected float[][] pre, post; // chunks of curve tracked in redrawing 
     78  /** Chunks of curve tracked during EDIT */ 
     79  protected float[][] pre, post;  
    7680 
    7781  // -- Constructor -- 
     
    8892 
    8993  /** Instructs this tool to respond to a mouse press. */ 
    90   public void mouseDown(int px, int py, 
     94  public void mouseDown(DisplayEvent e, int px, int py, 
    9195    float dx, float dy, int[] pos, int mods) 
    9296  { 
    9397    boolean ctl = (mods & InputEvent.CTRL_MASK) != 0; 
     98     
    9499    OverlayFreeform target = getClosestFreeform(dx, dy); 
    95100    if (target != null) { 
     
    158163  } // end mouseDown 
    159164 
     165  /** Instructs this tool to respond to a mouse drag. */ 
     166  public void mouseDrag(DisplayEvent e, int px, int py, 
     167    float dx, float dy, int[] pos, int mods) 
     168  { 
     169    boolean shift = (mods & InputEvent.SHIFT_MASK) != 0; 
     170    boolean ctl = (mods & InputEvent.CTRL_MASK) != 0; 
     171 
     172    if (ctl && mode == DRAW) { 
     173        freeform.truncateNodeArray(); 
     174        setMode(ERASE); 
     175    } 
     176 
     177    if (mode == DRAW) { 
     178      // compute distance to endpoints of nearby freeforms 
     179      int index = -1; 
     180      boolean closerToHead = false; 
     181      double minDist = Double.MAX_VALUE; 
     182 
     183      for (int i=0; i<otherFreefs.size(); i++) { 
     184        OverlayFreeform f = (OverlayFreeform) otherFreefs.get(i); 
     185        float[] head = f.getNodeCoords(0); 
     186        float[] tail = f.getNodeCoords(f.getNumNodes()-1); 
     187 
     188        double[] headd = {(double) head[0], (double) head[1]}; 
     189        double[] taild = {(double) tail[0], (double) tail[1]}; 
     190        double[] drag = {(double) dx, (double) dy}; 
     191 
     192        double hdist = MathUtil.getDistance(drag, headd); 
     193        double tdist = MathUtil.getDistance(drag, taild); 
     194 
     195        boolean isHead = hdist < tdist ? true : false; 
     196        double dist = isHead ? hdist : tdist; 
     197 
     198        if (dist < minDist) { 
     199          minDist = dist; 
     200          index = i; 
     201          closerToHead = isHead; 
     202        } 
     203      } 
     204 
     205      if (minDist < DRAW_THRESH) { 
     206        connectFreeforms(freeform, 
     207          (OverlayFreeform) otherFreefs.get(index), closerToHead); 
     208        setMode(CHILL); 
     209      } 
     210      else { 
     211        // compute distance from last node 
     212        float lastX = freeform.getLastNodeX(); 
     213        float lastY = freeform.getLastNodeY(); 
     214        float distX = dx - lastX; 
     215        float distY = dy - lastY; 
     216        double dist = Math.sqrt (distX*distX + distY*distY); 
     217 
     218        if (dist > DRAW_THRESH) { 
     219          freeform.setNextNode(dx, dy); 
     220          double len = freeform.getCurveLength(); 
     221          freeform.setCurveLength(len + dist); 
     222          // I debated whether to update this realtime.  This is an efficient 
     223          // method, but updating realtime for erasing requires an O(n) 
     224          // operation every time a node is deleted. 
     225          freeform.setBoundaries(dx, dy); 
     226        } 
     227        // mode remains DRAW 
     228      } 
     229    } 
     230    else if (mode == ERASE) { 
     231      if (freeform == null) { 
     232        OverlayFreeform target = getClosestFreeform(dx, dy); 
     233        if (target != null) freeform = target; 
     234      } 
     235 
     236      // delete an end node if you're near enough 
     237      float[] beg = freeform.getNodeCoords (0); 
     238      float[] end = freeform.getNodeCoords (freeform.getNumNodes() - 1); 
     239 
     240      double[] drag = {(double) dx, (double) dy}; 
     241      double[] begd = {(double) beg[0], (double) beg[1]}; 
     242      double[] endd = {(double) end[0], (double) end[1]}; 
     243 
     244      double bdist = MathUtil.getDistance(drag, begd); 
     245      double edist = MathUtil.getDistance(drag, endd); 
     246 
     247      boolean closerToEnd = edist < bdist ? true : false; 
     248      double mdist = closerToEnd ? edist : bdist; 
     249 
     250      if (mdist < DRAW_THRESH) { 
     251        if (!closerToEnd) freeform.reverseNodes(); 
     252        if (ctl) { 
     253          double[] nearest = new double[2], pd = new double[2]; 
     254          float[] p; 
     255          double delta; 
     256          int index; 
     257          if (closerToEnd) nearest = endd; 
     258          else nearest = begd; 
     259 
     260          // adjust curve length 
     261          index = freeform.getNumNodes()-1; // last node in freef 
     262          p = freeform.getNodeCoords(index); 
     263          pd[0] = (double) p[0]; 
     264          pd[1] = (double) p[1]; 
     265 
     266          delta = MathUtil.getDistance (nearest, pd); 
     267          freeform.setCurveLength(freeform.getCurveLength() - delta); 
     268 
     269          // delete last node node 
     270          freeform.deleteNode(index); 
     271          // WARNING: this is O(n) expensive. 
     272          // Maybe remove it and just update at mouseUp? 
     273          freeform.updateBoundingBox(); 
     274        } 
     275        else setMode(DRAW); 
     276        if (freeform.getNumNodes() == 0) setMode(CHILL); 
     277      } 
     278      else { 
     279        // do nothing if too far from curve 
     280      } 
     281    } 
     282    else if (mode == EDIT) { 
     283      // extend tendril and or reconnect 
     284      // get coords of prev node 
     285      float[] pcoordsf; 
     286      if (tendril.tip >= 0) { 
     287        // previous node is tendril.tip 
     288        pcoordsf = freeform.getNodeCoords(tendril.tip); 
     289      } 
     290      else { 
     291        // previous node is tendril.start 
     292        pcoordsf = freeform.getNodeCoords(tendril.start); 
     293      } 
     294 
     295      double[] pcoordsd = {(double) pcoordsf[0], (double) pcoordsf[1]}; 
     296      // coords of this mouseDrag event 
     297      double[] thiscoords = {(double) dx, (double) dy}; 
     298      double dragDist = MathUtil.getDistance(pcoordsd, thiscoords); 
     299 
     300      // compute distance to pre, post chunks of curve 
     301      double[] distSegWtPre = MathUtil.getDistSegWt(pre, dx, dy); 
     302      double[] distSegWtPost = MathUtil.getDistSegWt(post, dx, dy); 
     303 
     304      boolean equalsCase = false; 
     305      if (distSegWtPre[0] == distSegWtPost[0]) equalsCase = true; 
     306      // Drag is equally close to both segments, wait for next drag. 
     307      // This case is extremely unlikely. 
     308 
     309      boolean closerToPost = (distSegWtPre[0] > distSegWtPost[0]); 
     310      double[] distSegWt = (closerToPost) ? distSegWtPost : distSegWtPre; 
     311      double minDist = distSegWt[0]; 
     312      int seg = (int) distSegWt[1]; 
     313      double weight = distSegWt[2]; 
     314      // ACS TODO what about equals case? wait for next drag? 
     315 
     316      // if not close to curve insert node, else reconnect 
     317      if (minDist > RECONNECT_THRESH) { 
     318        // insert a node at the drag point if drag went far enough 
     319        if (dragDist > DRAW_THRESH) { 
     320          // first drag only 
     321          if (tendril.tip < 0) { 
     322            freeform.insertNode(tendril.stop, dx, dy); 
     323            tendril.stop++; 
     324            tendril.tip = tendril.start + 1; 
     325          } 
     326          else { // later drags 
     327            freeform.insertNode(tendril.tip+1, pcoordsf[0], pcoordsf[1]); 
     328            freeform.insertNode(tendril.tip+1, dx, dy); 
     329            tendril.tip++; 
     330            tendril.stop += 2; 
     331          } 
     332        } 
     333        // tendril.tip always points to a lone node (except for before first 
     334        // drag, where it doesn't point to a node at all) 
     335      } 
     336      else if (!shift && !equalsCase) { 
     337        // reconnect with curve and delete nodes; 
     338        if (tendril.tip < 0) { 
     339          // tendril hasn't begun.  Do nothing. 
     340        } 
     341        else { 
     342          //if (dragDist > DRAW_THRESH) { 
     343            // insert a node first at drag point, then reconnect 
     344            // skip this case:  There's the possibility that this drag point 
     345            // is across the curve from the previous drag point, which might 
     346            // result in a unintended zig-zag. 
     347          //} 
     348 
     349          // insert node at nearest point 
     350          int offset = (closerToPost) ? 1 + tendril.stop : 0; 
     351          // offset points to either post[0] or pre[0] 
     352          int endIndex = 0; // lame initial value. 
     353          if (weight == 0.0) { 
     354            endIndex = seg + offset; 
     355          } 
     356          else if (weight == 1.0) { 
     357            endIndex = seg + 1 + offset; 
     358          } 
     359          else { 
     360            // determine projection on seg. 
     361            float[] a = freeform.getNodeCoords(seg + offset); 
     362            float[] b = freeform.getNodeCoords(seg + 1 + offset); 
     363            float[] newXY = computePtOnSegment(a, b, (float) weight); 
     364            int insertIndex = seg + 1 + offset; 
     365            freeform.insertNode(insertIndex, newXY[0], newXY[1]); 
     366            if (!closerToPost) { 
     367              tendril.increment(); 
     368            } 
     369            endIndex = insertIndex; 
     370          } 
     371 
     372          if (tendril.tip < endIndex) { 
     373            freeform.deleteBetween(tendril.tip, endIndex); 
     374          } 
     375          else { 
     376            freeform.deleteBetween(endIndex, tendril.tip); 
     377          } 
     378          freeform.computeLength(); 
     379          setMode(CHILL); 
     380        } 
     381      } // end reconnect logic 
     382 
     383    } 
     384    overlay.notifyListeners(new TransformEvent(overlay)); 
     385  } // end mouseDrag 
     386 
     387  /** Instructs this tool to respond to a mouse release. */ 
     388  public void mouseUp(DisplayEvent e, int px, int py,  
     389      float dx, float dy, int[] pos, int mods) { 
     390    //print ("mouseUp", "mouseUp begun. mode = " + mode); 
     391    if (mode == DRAW) { 
     392      freeform.truncateNodeArray(); 
     393    } 
     394    else if (mode == EDIT) { 
     395      // save coords of tendril root 
     396      float[] c = freeform.getNodeCoords(tendril.start); 
     397      freeform.deleteBetween(tendril.start-1, tendril.stop+1); 
     398      if (tendril.nodal) { 
     399        freeform.insertNode(tendril.start, c[0], c[1]); 
     400      } 
     401    } 
     402 
     403    if (mode != CHILL) setMode(CHILL); 
     404    overlay.notifyListeners(new TransformEvent(overlay)); 
     405    ((OverlayWidget) overlay.getControls()).refreshListSelection(); 
     406  } 
     407 
     408  // -- Helper methods for mouse methods 
     409   
    160410  /** Slices a freeform in two. */ 
    161411  private void slice(OverlayFreeform freef, 
     
    236486  } 
    237487 
    238   /** Instructs this tool to respond to a mouse release. */ 
    239   public void mouseUp(int px, int py, float dx, float dy, int[] pos, int mods) { 
    240     //print ("mouseUp", "mouseUp begun. mode = " + mode); 
    241     if (mode == DRAW) { 
    242       freeform.truncateNodeArray(); 
    243     } 
    244     else if (mode == EDIT) { 
    245       // save coords of tendril root 
    246       float[] c = freeform.getNodeCoords(tendril.start); 
    247       freeform.deleteBetween(tendril.start-1, tendril.stop+1); 
    248       if (tendril.nodal) { 
    249         freeform.insertNode(tendril.start, c[0], c[1]); 
    250       } 
    251     } 
    252  
    253     if (mode != CHILL) setMode(CHILL); 
    254     overlay.notifyListeners(new TransformEvent(overlay)); 
    255     ((OverlayWidget) overlay.getControls()).refreshListSelection(); 
    256   } 
    257  
    258488  /** 
    259489   * Changes the edit mode. Depending on the new mode, some properties may 
     
    288518    } 
    289519  } 
    290  
    291   /** Instructs this tool to respond to a mouse drag. */ 
    292   public void mouseDrag(int px, int py, 
    293     float dx, float dy, int[] pos, int mods) 
    294   { 
    295     boolean shift = (mods & InputEvent.SHIFT_MASK) != 0; 
    296     boolean ctl = (mods & InputEvent.CTRL_MASK) != 0; 
    297  
    298     if (ctl && mode == DRAW) { 
    299         freeform.truncateNodeArray(); 
    300         setMode(ERASE); 
    301     } 
    302  
    303     if (mode == DRAW) { 
    304       // compute distance to endpoints of nearby freeforms 
    305       int index = -1; 
    306       boolean closerToHead = false; 
    307       double minDist = Double.MAX_VALUE; 
    308  
    309       for (int i=0; i<otherFreefs.size(); i++) { 
    310         OverlayFreeform f = (OverlayFreeform) otherFreefs.get(i); 
    311         float[] head = f.getNodeCoords(0); 
    312         float[] tail = f.getNodeCoords(f.getNumNodes()-1); 
    313  
    314         double[] headd = {(double) head[0], (double) head[1]}; 
    315         double[] taild = {(double) tail[0], (double) tail[1]}; 
    316         double[] drag = {(double) dx, (double) dy}; 
    317  
    318         double hdist = MathUtil.getDistance(drag, headd); 
    319         double tdist = MathUtil.getDistance(drag, taild); 
    320  
    321         boolean isHead = hdist < tdist ? true : false; 
    322         double dist = isHead ? hdist : tdist; 
    323  
    324         if (dist < minDist) { 
    325           minDist = dist; 
    326           index = i; 
    327           closerToHead = isHead; 
    328         } 
    329       } 
    330  
    331       if (minDist < DRAW_THRESH) { 
    332         connectFreeforms(freeform, 
    333           (OverlayFreeform) otherFreefs.get(index), closerToHead); 
    334         setMode(CHILL); 
    335       } 
    336       else { 
    337         // compute distance from last node 
    338         float lastX = freeform.getLastNodeX(); 
    339         float lastY = freeform.getLastNodeY(); 
    340         float distX = dx - lastX; 
    341         float distY = dy - lastY; 
    342         double dist = Math.sqrt (distX*distX + distY*distY); 
    343  
    344         if (dist > DRAW_THRESH) { 
    345           freeform.setNextNode(dx, dy); 
    346           double len = freeform.getCurveLength(); 
    347           freeform.setCurveLength(len + dist); 
    348           // I debated whether to update this realtime.  This is an efficient 
    349           // method, but updating realtime for erasing requires an O(n) 
    350           // operation every time a node is deleted. 
    351           freeform.setBoundaries(dx, dy); 
    352         } 
    353         // mode remains DRAW 
    354       } 
    355     } 
    356     else if (mode == ERASE) { 
    357       if (freeform == null) { 
    358         OverlayFreeform target = getClosestFreeform(dx, dy); 
    359         if (target != null) freeform = target; 
    360       } 
    361  
    362       // delete an end node if you're near enough 
    363       float[] beg = freeform.getNodeCoords (0); 
    364       float[] end = freeform.getNodeCoords (freeform.getNumNodes() - 1); 
    365  
    366       double[] drag = {(double) dx, (double) dy}; 
    367       double[] begd = {(double) beg[0], (double) beg[1]}; 
    368       double[] endd = {(double) end[0], (double) end[1]}; 
    369  
    370       double bdist = MathUtil.getDistance(drag, begd); 
    371       double edist = MathUtil.getDistance(drag, endd); 
    372  
    373       boolean closerToEnd = edist < bdist ? true : false; 
    374       double mdist = closerToEnd ? edist : bdist; 
    375  
    376       if (mdist < DRAW_THRESH) { 
    377         if (!closerToEnd) freeform.reverseNodes(); 
    378         if (ctl) { 
    379           double[] nearest = new double[2], pd = new double[2]; 
    380           float[] p; 
    381           double delta; 
    382           int index; 
    383           if (closerToEnd) nearest = endd; 
    384           else nearest = begd; 
    385  
    386           // adjust curve length 
    387           index = freeform.getNumNodes()-1; // last node in freef 
    388           p = freeform.getNodeCoords(index); 
    389           pd[0] = (double) p[0]; 
    390           pd[1] = (double) p[1]; 
    391  
    392           delta = MathUtil.getDistance (nearest, pd); 
    393           freeform.setCurveLength(freeform.getCurveLength() - delta); 
    394  
    395           // delete last node node 
    396           freeform.deleteNode(index); 
    397           // WARNING: this is O(n) expensive. 
    398           // Maybe remove it and just update at mouseUp? 
    399           freeform.updateBoundingBox(); 
    400         } 
    401         else setMode(DRAW); 
    402         if (freeform.getNumNodes() == 0) setMode(CHILL); 
    403       } 
    404       else { 
    405         // do nothing if too far from curve 
    406       } 
    407     } 
    408     else if (mode == EDIT) { 
    409       // extend tendril and or reconnect 
    410       // get coords of prev node 
    411       float[] pcoordsf; 
    412       if (tendril.tip >= 0) { 
    413         // previous node is tendril.tip 
    414         pcoordsf = freeform.getNodeCoords(tendril.tip); 
    415       } 
    416       else { 
    417         // previous node is tendril.start 
    418         pcoordsf = freeform.getNodeCoords(tendril.start); 
    419       } 
    420  
    421       double[] pcoordsd = {(double) pcoordsf[0], (double) pcoordsf[1]}; 
    422       // coords of this mouseDrag event 
    423       double[] thiscoords = {(double) dx, (double) dy}; 
    424       double dragDist = MathUtil.getDistance(pcoordsd, thiscoords); 
    425  
    426       // compute distance to pre, post chunks of curve 
    427       double[] distSegWtPre = MathUtil.getDistSegWt(pre, dx, dy); 
    428       double[] distSegWtPost = MathUtil.getDistSegWt(post, dx, dy); 
    429  
    430       boolean equalsCase = false; 
    431       if (distSegWtPre[0] == distSegWtPost[0]) equalsCase = true; 
    432       // Drag is equally close to both segments, wait for next drag. 
    433       // This case is extremely unlikely. 
    434  
    435       boolean closerToPost = (distSegWtPre[0] > distSegWtPost[0]); 
    436       double[] distSegWt = (closerToPost) ? distSegWtPost : distSegWtPre; 
    437       double minDist = distSegWt[0]; 
    438       int seg = (int) distSegWt[1]; 
    439       double weight = distSegWt[2]; 
    440       // ACS TODO what about equals case? wait for next drag? 
    441  
    442       // if not close to curve insert node, else reconnect 
    443       if (minDist > RECONNECT_THRESH) { 
    444         // insert a node at the drag point if drag went far enough 
    445         if (dragDist > DRAW_THRESH) { 
    446           // first drag only 
    447           if (tendril.tip < 0) { 
    448             freeform.insertNode(tendril.stop, dx, dy); 
    449             tendril.stop++; 
    450             tendril.tip = tendril.start + 1; 
    451           } 
    452           else { // later drags 
    453             freeform.insertNode(tendril.tip+1, pcoordsf[0], pcoordsf[1]); 
    454             freeform.insertNode(tendril.tip+1, dx, dy); 
    455             tendril.tip++; 
    456             tendril.stop += 2; 
    457           } 
    458         } 
    459         // tendril.tip always points to a lone node (except for before first 
    460         // drag, where it doesn't point to a node at all) 
    461       } 
    462       else if (!shift && !equalsCase) { 
    463         // reconnect with curve and delete nodes; 
    464         if (tendril.tip < 0) { 
    465           // tendril hasn't begun.  Do nothing. 
    466         } 
    467         else { 
    468           //if (dragDist > DRAW_THRESH) { 
    469             // insert a node first at drag point, then reconnect 
    470             // skip this case:  There's the possibility that this drag point 
    471             // is across the curve from the previous drag point, which might 
    472             // result in a unintended zig-zag. 
    473           //} 
    474  
    475           // insert node at nearest point 
    476           int offset = (closerToPost) ? 1 + tendril.stop : 0; 
    477           // offset points to either post[0] or pre[0] 
    478           int endIndex = 0; // lame initial value. 
    479           if (weight == 0.0) { 
    480             endIndex = seg + offset; 
    481           } 
    482           else if (weight == 1.0) { 
    483             endIndex = seg + 1 + offset; 
    484           } 
    485           else { 
    486             // determine projection on seg. 
    487             float[] a = freeform.getNodeCoords(seg + offset); 
    488             float[] b = freeform.getNodeCoords(seg + 1 + offset); 
    489             float[] newXY = computePtOnSegment(a, b, (float) weight); 
    490             int insertIndex = seg + 1 + offset; 
    491             freeform.insertNode(insertIndex, newXY[0], newXY[1]); 
    492             if (!closerToPost) { 
    493               tendril.increment(); 
    494             } 
    495             endIndex = insertIndex; 
    496           } 
    497  
    498           if (tendril.tip < endIndex) { 
    499             freeform.deleteBetween(tendril.tip, endIndex); 
    500           } 
    501           else { 
    502             freeform.deleteBetween(endIndex, tendril.tip); 
    503           } 
    504           freeform.computeLength(); 
    505           setMode(CHILL); 
    506         } 
    507       } // end reconnect logic 
    508  
    509     } 
    510     overlay.notifyListeners(new TransformEvent(overlay)); 
    511   } // end mouseDrag 
    512  
    513   //-- Additional methods 
    514520 
    515521  /** 
  • trunk/loci/visbio/overlays/LineTool.java

    r2123 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** LineTool is the tool for creating measurement lines. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5455 
    5556  /** Instructs this tool to respond to a mouse release. */ 
    56   public void mouseUp(int px, int py, 
     57  public void mouseUp(DisplayEvent e, int px, int py, 
    5758    float dx, float dy, int[] pos, int mods) 
    5859  { 
     
    6768 
    6869  /** Instructs this tool to respond to a mouse drag. */ 
    69   public void mouseDrag(int px, int py, 
     70  public void mouseDrag(DisplayEvent e, int px, int py, 
    7071    float dx, float dy, int[] pos, int mods) 
    7172  { 
  • trunk/loci/visbio/overlays/MarkerTool.java

    r2095 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** MarkerTool is the tool for creating measurement markers. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5455 
    5556  /** Instructs this tool to respond to a mouse release. */ 
    56   public void mouseUp(int px, int py, 
     57  public void mouseUp(DisplayEvent e, int px, int py, 
    5758    float dx, float dy, int[] pos, int mods) 
    5859  { 
     
    6465 
    6566  /** Instructs this tool to respond to a mouse drag. */ 
    66   public void mouseDrag(int px, int py, 
     67  public void mouseDrag(DisplayEvent e, int px, int py, 
    6768    float dx, float dy, int[] pos, int mods) 
    6869  { 
  • trunk/loci/visbio/overlays/OvalTool.java

    r2123 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** OvalTool is the tool for creating oval overlays. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5657 
    5758  /** Instructs this tool to respond to a mouse release. */ 
    58   public void mouseUp(int px, int py, 
     59  public void mouseUp(DisplayEvent e, int px, int py, 
    5960    float dx, float dy, int[] pos, int mods) 
    6061  { 
     
    7172 
    7273  /** Instructs this tool to respond to a mouse drag. */ 
    73   public void mouseDrag(int px, int py, 
     74  public void mouseDrag(DisplayEvent e, int px, int py, 
    7475    float dx, float dy, int[] pos, int mods) 
    7576  { 
  • trunk/loci/visbio/overlays/OverlayTool.java

    r2095 r2246  
    2323 
    2424package loci.visbio.overlays; 
     25 
     26import visad.DisplayEvent; 
    2527 
    2628/** OverlayTool is the superclass of all overlay tools. */ 
     
    5759  /** 
    5860   * Instructs this tool to respond to a mouse press. 
     61   * @param e DisplayEvent corresponding to this mouse press. 
    5962   * @param px X coordinate of mouse press in pixel coordinate system. 
    6063   * @param py Y coordinate of mouse press in pixel coordinate system. 
     
    6467   * @param mods Modifiers of mouse press. 
    6568   */ 
    66   public void mouseDown(int px, int py, 
     69  public void mouseDown(DisplayEvent e, int px, int py, 
    6770    float dx, float dy, int[] pos, int mods) 
    6871  { 
     
    7174  /** 
    7275   * Instructs this tool to respond to a mouse release. 
     76   * @param e DisplayEvent corresponding to this mouse release. 
    7377   * @param px X coordinate of mouse release in pixel coordinate system. 
    7478   * @param py Y coordinate of mouse release in pixel coordinate system. 
     
    7882   * @param mods Modifiers of mouse release. 
    7983   */ 
    80   public void mouseUp(int px, int py, 
     84  public void mouseUp(DisplayEvent e, int px, int py, 
    8185    float dx, float dy, int[] pos, int mods) 
    8286  { 
     
    8589  /** 
    8690   * Instructs this tool to respond to a mouse drag. 
     91   * @param e DisplayEvent corresponding to this mouse drag. 
    8792   * @param px X coordinate of mouse drag in pixel coordinate system. 
    8893   * @param py Y coordinate of mouse drag in pixel coordinate system. 
     
    9297   * @param mods Modifiers of mouse drag. 
    9398   */ 
    94   public void mouseDrag(int px, int py, 
     99  public void mouseDrag(DisplayEvent e, int px, int py, 
    95100    float dx, float dy, int[] pos, int mods) 
    96101  { 
  • trunk/loci/visbio/overlays/OverlayTransform.java

    r2096 r2246  
    589589 
    590590        // retrieve select box data 
    591         if (selectBox != null && selectBox.isVisible()) { 
     591        if (selectBox != null) { 
    592592            selectData = selectBox.getData(); 
    593593        } 
    594  
     594         
     595        // display only non-null data objects 
    595596        Vector v = new Vector(); 
    596597        if (selectData != null) v.add(selectData); 
     
    701702        int px = e.getX(), py = e.getY(); 
    702703        double[] coords = DisplayUtil.pixelToDomain(display, px, py); 
    703         tool.mouseDown(px, py, 
     704        tool.mouseDown(e, px, py, 
    704705          (float) coords[0], (float) coords[1], pos, e.getModifiers()); 
     706        /* 
     707        //  Temporary testing junk 
     708        // pixel coords  
     709        System.out.println("Pixel coords (native) = (" + px + "," + py + ")"); // TEMP 
     710        // pixel to cursor 
     711        double[] ccoords = DisplayUtil.pixelToCursor(display, px, py);  
     712        System.out.println("pixelToCursor coords = (" + ccoords[0] + "," + ccoords[1]); 
     713        // cursor to domain 
     714        double[] dcoords  = DisplayUtil.cursorToDomain(display, ccoords); 
     715        System.out.println("cursorToDomain coords = (" + dcoords[0] + "," + dcoords[1]); 
     716        System.out.println("pixelToDomain coords = (" + coords[0] + "," + coords[1]); 
     717 
     718        // domain to cursor 
     719        double[] dccoords = DisplayUtil.domainToCursor(display, dcoords); 
     720        System.out.println("domainToCursor coords = (" + dccoords[0] + "," + dccoords[1]); 
     721 
     722        // cursor to pixel  
     723        int[] cpcoords = DisplayUtil.cursorToPixel(display, dccoords); // TEMP 
     724        System.out.println("cursorToPixel coords = (" + cpcoords[0] + "," + cpcoords[1]); 
     725        */ 
    705726      } 
    706727    } 
     
    714735        int px = e.getX(), py = e.getY(); 
    715736        double[] coords = DisplayUtil.pixelToDomain(display, px, py); 
    716         tool.mouseDrag(px, py, 
     737        tool.mouseDrag(e, px, py, 
    717738          (float) coords[0], (float) coords[1], pos, e.getModifiers()); 
    718739      } 
     
    772793      int px = e.getX(), py = e.getY(); 
    773794      double[] coords = DisplayUtil.pixelToDomain(display, px, py); 
    774       tool.mouseUp(px, py, 
     795      tool.mouseUp(e, px, py, 
    775796        (float) coords[0], (float) coords[1], pos, e.getModifiers()); 
    776797    } 
  • trunk/loci/visbio/overlays/PointerTool.java

    r2170 r2246  
    2626import java.awt.event.InputEvent; 
    2727import loci.visbio.data.TransformEvent; 
     28import visad.DisplayEvent; 
    2829import java.util.Vector; 
    2930 
     
    6566 
    6667  /** Instructs this tool to respond to a mouse press. */ 
    67   public void mouseDown(int px, int py, 
     68  public void mouseDown(DisplayEvent e, int px, int py, 
    6869    float dx, float dy, int[] pos, int mods) 
    6970  { 
     
    144145 
    145146  /** Instructs this tool to respond to a mouse release. */ 
    146   public void mouseUp(int px, int py, 
     147  public void mouseUp(DisplayEvent e, int px, int py, 
    147148    float dx, float dy, int[] pos, int mods) 
    148149  { 
     
    165166 
    166167  /** Instructs this tool to respond to a mouse drag. */ 
    167   public void mouseDrag(int px, int py, 
     168  public void mouseDrag(DisplayEvent e, int px, int py, 
    168169    float dx, float dy, int[] pos, int mods) 
    169170  { 
  • trunk/loci/visbio/overlays/TextTool.java

    r2095 r2246  
    2525 
    2626import loci.visbio.data.TransformEvent; 
     27import visad.DisplayEvent; 
    2728 
    2829/** TextTool is the tool for creating text overlays. */ 
     
    4445 
    4546  /** Instructs this tool to respond to a mouse press. */ 
    46   public void mouseDown(int px, int py, 
     47  public void mouseDown(DisplayEvent e, int px, int py, 
    4748    float dx, float dy, int[] pos, int mods) 
    4849  { 
     
    5556 
    5657  /** Instructs this tool to respond to a mouse release. */ 
    57   public void mouseUp(int px, int py, 
     58  public void mouseUp(DisplayEvent e, int px, int py, 
    5859    float dx, float dy, int[] pos, int mods) 
    5960  { 
     
    6566 
    6667  /** Instructs this tool to respond to a mouse drag. */ 
    67   public void mouseDrag(int px, int py, 
     68  public void mouseDrag(DisplayEvent e, int px, int py, 
    6869    float dx, float dy, int[] pos, int mods) 
    6970  { 
  • trunk/loci/visbio/overlays/TransientSelectBox.java

    r2096 r2246  
    5151  private OverlayTransform overlay; 
    5252 
    53   /** Whether the box is visible; toggled off if box 
    54    *  boundaries would form an invalid GriddedSet */ 
    55   private boolean visible; 
    56  
    5753  // -- Constructor -- 
    5854 
    59   /** Constructs a selection box 
    60    *  Initially, the box has zero area and is not visible 
     55  /** Constructs a selection box. 
    6156   */ 
    6257  public TransientSelectBox(OverlayTransform overlay, 
     
    6863    y1 = downY; 
    6964    y2 = downY; 
     65    // initially box has zero area. 
    7066    color = Color.green; 
    71     visible = false; 
    7267  } 
    7368 
     
    7873    x2 = x; 
    7974    y2 = y; 
    80     // toggle visible.  If x1 == x2 || y1 == y2, GriddedSet invalid. 
    81     if (x1 != x2 && y1 != y2) visible = true; 
    82     else visible = false; 
    8375  } 
    8476 
    85   /** Returns a VisAD data object representing this box 
    86    *  The data object is compound, consisting of 2 parts: 
     77  /** Returns a VisAD data object representing this box. 
     78   *  The data object is compound, comprising 2 parts: 
    8779   *  1) a solid GriddedSet of manifold dimension 1, the outline 
    8880   *  2) a semi-transparent GriddedSet of manifold dimension 2, the interior 
    8981   */ 
    9082  public DataImpl getData() { 
     83    if (x1 == x2 || y1 == y2) return null;  // don't construct a data object 
     84    // for a zero-area box 
     85     
    9186    RealTupleType domain = overlay.getDomainType(); 
    9287    TupleType range = overlay.getRangeType(); 
     
    154149  } 
    155150 
    156   /** Whether this select box is visible */ 
    157   public boolean isVisible() { return visible; } 
    158  
    159151  /** Gets X coordinate of the overlay's first endpoint. */ 
    160152  public float getX1() { return x1; } 
Note: See TracChangeset for help on using the changeset viewer.