public void addPoint(double x, double y) { addPoint((float)x, (float)y); }
public void addPoint(double x, double y) { addPoint((float)x, (float)y); }
public FloatPolygon getRotationCenter() { double xcenter = x1d + (x2d-x1d)/2.0; double ycenter = y1d + (y2d-y1d)/2.0; FloatPolygon p = new FloatPolygon(); p.addPoint(xcenter,ycenter); return p; }
public FloatPolygon getRotationCenter() { double xcenter = x1d + (x2d-x1d)/2.0; double ycenter = y1d + (y2d-y1d)/2.0; FloatPolygon p = new FloatPolygon(); p.addPoint(xcenter,ycenter); return p; }
public FloatPolygon getRotationCenter() { FloatPolygon p = new FloatPolygon(); Rectangle2D r = getFloatBounds(); if (Double.isNaN(xcenter)) { xcenter = r.getX()+r.getWidth()/2.0; ycenter = r.getY()+r.getHeight()/2.0; } p.addPoint(xcenter,ycenter); return p; }
public FloatPolygon getRotationCenter() { FloatPolygon p = new FloatPolygon(); Rectangle2D r = getFloatBounds(); if (Double.isNaN(xcenter)) { xcenter = r.getX()+r.getWidth()/2.0; ycenter = r.getY()+r.getHeight()/2.0; } p.addPoint(xcenter,ycenter); return p; }
FloatPolygon p = new FloatPolygon(); if (getStrokeWidth()<=1) { p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); } else { double angle = Math.atan2(y1d-y2d, x2d-x1d); double p4x = x2d + Math.cos(angle+Math.PI/2d)*width2; double p4y = y2d - Math.sin(angle+Math.PI/2d)*width2; p.addPoint((float)p1x, (float)p1y); p.addPoint((float)p2x, (float)p2y); p.addPoint((float)p3x, (float)p3y); p.addPoint((float)p4x, (float)p4y);
FloatPolygon p = new FloatPolygon(); if (getStrokeWidth()<=1) { p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); } else { double angle = Math.atan2(y1d-y2d, x2d-x1d); double p4x = x2d + Math.cos(angle+Math.PI/2d)*width2; double p4y = y2d - Math.sin(angle+Math.PI/2d)*width2; p.addPoint((float)p1x, (float)p1y); p.addPoint((float)p2x, (float)p2y); p.addPoint((float)p3x, (float)p3y); p.addPoint((float)p4x, (float)p4y);
private void addPolyLineToOverlay(final FloatPolygon p, final int z_position, final int roi_id, final Overlay overlay) { if (p.npoints > 0) { if (p.npoints == 1) { // create 1-pixel length lines for single points p.xpoints[0] -= 0.5f; p.ypoints[0] -= 0.5f; p.addPoint(p.xpoints[0] + 0.5f, p.ypoints[0] + 0.5f); } final PolygonRoi polyline = new PolygonRoi(p, Roi.FREELINE); polyline.enableSubPixelResolution(); // polyline.fitSplineForStraightening(); if (name == null) setDefaultName(); polyline.setStrokeColor(getColor()); polyline.setName(String.format(name + "-%04d-Z%d", roi_id, z_position)); polyline.setPosition(z_position + 1); // index 1 overlay.add(polyline); } }
/** Returns the coordinates of the pixels inside this ROI as a FloatPolygon. * @see #getContainedPoints() * @see #iterator() */ public FloatPolygon getContainedFloatPoints() { Roi roi2 = this; if (isLine()) { if (getStrokeWidth()<=1) return roi2.getInterpolatedPolygon(); else roi2 = Selection.lineToArea(this); } ImageProcessor mask = roi2.getMask(); Rectangle bounds = roi2.getBounds(); FloatPolygon points = new FloatPolygon(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.addPoint((float)(bounds.x+x),(float)(bounds.y+y)); } } return points; }
/** Returns the coordinates of the pixels inside this ROI as a FloatPolygon. * @see #getContainedPoints() * @see #iterator() */ public FloatPolygon getContainedFloatPoints() { Roi roi2 = this; if (isLine()) { if (getStrokeWidth()<=1) return roi2.getInterpolatedPolygon(); else roi2 = Selection.lineToArea(this); } ImageProcessor mask = roi2.getMask(); Rectangle bounds = roi2.getBounds(); FloatPolygon points = new FloatPolygon(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.addPoint((float)(bounds.x+x),(float)(bounds.y+y)); } } return points; }