Example #1
0
 /** Returns a copy of this PolygonRoi. */
 public synchronized Object clone() {
   PolygonRoi r = (PolygonRoi) super.clone();
   if (xpf != null) {
     r.xpf = new float[maxPoints];
     r.ypf = new float[maxPoints];
   } else {
     r.xp = new int[maxPoints];
     r.yp = new int[maxPoints];
   }
   r.xp2 = new int[maxPoints];
   r.yp2 = new int[maxPoints];
   for (int i = 0; i < nPoints; i++) {
     if (xpf != null) {
       r.xpf[i] = xpf[i];
       r.ypf[i] = ypf[i];
     } else {
       r.xp[i] = xp[i];
       r.yp[i] = yp[i];
     }
     r.xp2[i] = xp2[i];
     r.yp2[i] = yp2[i];
   }
   if (xSpline != null) {
     r.xSpline = new float[splinePoints];
     r.ySpline = new float[splinePoints];
     r.splinePoints = splinePoints;
     for (int i = 0; i < splinePoints; i++) {
       r.xSpline[i] = xSpline[i];
       r.ySpline[i] = ySpline[i];
     }
   }
   return r;
 }
 public void mouseMoved(MouseEvent e) {
   // if (ij==null) return;
   int sx = e.getX();
   int sy = e.getY();
   int ox = offScreenX(sx);
   int oy = offScreenY(sy);
   flags = e.getModifiers();
   setCursor(sx, sy, ox, oy);
   IJ.setInputEvent(e);
   Roi roi = imp.getRoi();
   if (roi != null
       && (roi.getType() == Roi.POLYGON
           || roi.getType() == Roi.POLYLINE
           || roi.getType() == Roi.ANGLE)
       && roi.getState() == roi.CONSTRUCTING) {
     PolygonRoi pRoi = (PolygonRoi) roi;
     pRoi.handleMouseMove(ox, oy);
   } else {
     if (ox < imageWidth && oy < imageHeight) {
       ImageWindow win = imp.getWindow();
       // Cursor must move at least 12 pixels before text
       // displayed using IJ.showStatus() is overwritten.
       if ((sx - sx2) * (sx - sx2) + (sy - sy2) * (sy - sy2) > 144) showCursorStatus = true;
       if (win != null && showCursorStatus) win.mouseMoved(ox, oy);
     } else IJ.showStatus("");
   }
 }