public FloatPolygon duplicate() { int n = this.npoints; float[] xpoints = new float[n]; float[] ypoints = new float[n]; System.arraycopy(this.xpoints, 0, xpoints, 0, n); System.arraycopy(this.ypoints, 0, ypoints, 0, n); return new FloatPolygon(xpoints, ypoints, n); }
public FloatPolygon duplicate() { int n = this.npoints; float[] xpoints = new float[n]; float[] ypoints = new float[n]; System.arraycopy(this.xpoints, 0, xpoints, 0, n); System.arraycopy(this.ypoints, 0, ypoints, 0, n); return new FloatPolygon(xpoints, ypoints, n); }
void makePolygonRelative() { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; for (int i=0; i<nPoints; i++) { xpf[i] = xpf[i]-x; ypf[i] = ypf[i]-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; }
void makePolygonRelative() { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; bounds = null; for (int i=0; i<nPoints; i++) { xpf[i] = xpf[i]-x; ypf[i] = ypf[i]-y; } }
void makePolygonRelative() { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; for (int i=0; i<nPoints; i++) { xpf[i] = xpf[i]-x; ypf[i] = ypf[i]-y; } }
void makePolygonRelative() { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; bounds = null; for (int i=0; i<nPoints; i++) { xpf[i] = xpf[i]-x; ypf[i] = ypf[i]-y; } }
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; }
/** Returns, as a FloatPolygon, the two points that define this line. */ public FloatPolygon getFloatPoints() { FloatPolygon p = new FloatPolygon(); p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); return p; }
public boolean contains(int x, int y) { if (!super.contains(x, y)) return false; if (xSpline!=null) { FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); return poly.contains(x-this.x, y-this.y); } else if (xpf!=null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); return poly.contains(x-this.x, y-this.y); } else { Polygon poly = new Polygon(xp, yp, nPoints); return poly.contains(x-this.x, y-this.y); } }
/** Returns, as a FloatPolygon, the two points that define this line. */ public FloatPolygon getFloatPoints() { FloatPolygon p = new FloatPolygon(); p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); return p; }
public boolean contains(int x, int y) { if (!super.contains(x, y)) return false; if (xSpline!=null) { FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); return poly.contains(x-this.x, y-this.y); } else if (xpf!=null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); return poly.contains(x-this.x, y-this.y); } else { Polygon poly = new Polygon(xp, yp, nPoints); return poly.contains(x-this.x, y-this.y); } }
/** Returns this OvalRoi as a FloatPolygon. */ public FloatPolygon getFloatPolygon() { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); }
/** Returns this OvalRoi as a FloatPolygon. */ public FloatPolygon getFloatPolygon() { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); }
/** Returns this polygon or polyline as float arrays. */ public FloatPolygon getFloatPolygon() { int n = xSpline!=null?splinePoints:nPoints; float[] xpoints2 = new float[n]; float[] ypoints2 = new float[n]; float xbase = (float)getXBase(); float ybase = (float)getYBase(); if (xSpline!=null) { for (int i=0; i<n; i++) { xpoints2[i] = xSpline[i] + xbase; ypoints2[i] = ySpline[i] + ybase; } } else if (xpf!=null) { for (int i=0; i<n; i++) { xpoints2[i] = xpf[i] + xbase; ypoints2[i] = ypf[i] + ybase; } } else { for (int i=0; i<n; i++) { xpoints2[i] = xp[i] + x; ypoints2[i] = yp[i] + y; } } return new FloatPolygon(xpoints2, ypoints2, n); }
public FloatPolygon getNonSplineFloatPolygon() { if (xpf!=null) { FloatPolygon p = (new FloatPolygon(xpf, ypf, nPoints)).duplicate(); float xbase = (float)getXBase(); float ybase = (float)getYBase(); for (int i=0; i<p.npoints; i++) { p.xpoints[i] += xbase; p.ypoints[i] += ybase; } return p; } else return getFloatPolygon(); }
public FloatPolygon getNonSplineFloatPolygon() { if (xpf!=null) { FloatPolygon p = (new FloatPolygon(xpf, ypf, nPoints)).duplicate(); float xbase = (float)getXBase(); float ybase = (float)getYBase(); for (int i=0; i<p.npoints; i++) { p.xpoints[i] += xbase; p.ypoints[i] += ybase; } return p; } else return getFloatPolygon(); }
/** 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; }