Exemple #1
0
 void finishPolygon() {
   if (xpf != null) {
     FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints);
     Rectangle r = poly.getBounds();
     x = r.x;
     y = r.y;
     width = r.width;
     height = r.height;
     bounds = poly.getFloatBounds();
     float xbase = (float) bounds.getX();
     float ybase = (float) bounds.getY();
     for (int i = 0; i < nPoints; i++) {
       xpf[i] -= xbase;
       ypf[i] -= ybase;
     }
   } else {
     Polygon poly = new Polygon(xp, yp, nPoints);
     Rectangle r = poly.getBounds();
     x = r.x;
     y = r.y;
     width = r.width;
     height = r.height;
     for (int i = 0; i < nPoints; i++) {
       xp[i] = xp[i] - x;
       yp[i] = yp[i] - y;
     }
     bounds = null;
   }
   if (nPoints < 2
       || (!(type == FREELINE || type == POLYLINE || type == ANGLE)
           && (nPoints < 3 || width == 0 || height == 0))) {
     if (imp != null) imp.deleteRoi();
     if (type != POINT) return;
   }
   state = NORMAL;
   if (imp != null && !(type == TRACED_ROI)) imp.draw(x - 5, y - 5, width + 10, height + 10);
   oldX = x;
   oldY = y;
   oldWidth = width;
   oldHeight = height;
   if (Recorder.record
       && userCreated
       && (type == POLYGON
           || type == POLYLINE
           || type == ANGLE
           || (type == POINT && Recorder.scriptMode() && nPoints == 3)))
     Recorder.recordRoi(getPolygon(), type);
   if (type != POINT) modifyRoi();
   LineWidthAdjuster.update();
 }
Exemple #2
0
 void resetSubPixelBoundingRect() {
   float xbase = x, ybase = y;
   if (bounds != null) {
     xbase = (float) bounds.x;
     ybase = (float) bounds.y;
   }
   for (int i = 0; i < nPoints; i++) {
     xpf[i] = xpf[i] + xbase;
     ypf[i] = ypf[i] + ybase;
   }
   FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints);
   Rectangle r = poly.getBounds();
   x = r.x;
   y = r.y;
   width = r.width;
   height = r.height;
   bounds = poly.getFloatBounds();
   xbase = (float) bounds.getX();
   ybase = (float) bounds.getY();
   for (int i = 0; i < nPoints; i++) {
     xpf[i] -= xbase;
     ypf[i] -= ybase;
   }
 }