/** 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 Rectangle2D.Double getFloatBounds() { if (npoints==0) return new Rectangle2D.Double(); if (bounds==null) calculateBounds(xpoints, ypoints, npoints); return new Rectangle2D.Double(minX, minY, maxX-minX, maxY-minY); }
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); } }
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; } }
private void resetSplineFitBoundingRect() { if (splinePoints==0) return; float xbase = (float)getXBase(); float ybase = (float)getYBase(); float xSpline0 = xSpline[0]; float ySpline0 = ySpline[0]; for (int i=0; i<splinePoints; i++) { xSpline[i] = xSpline[i]+xbase; ySpline[i] = ySpline[i]+ybase; } FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); Rectangle r = poly.getBounds(); x = r.x;; y = r.y; width = r.width; height = r.height; bounds = poly.getFloatBounds(); xbase = (float)bounds.x; ybase = (float)bounds.y; for (int i=0; i<splinePoints; i++) { xSpline[i] -= xbase; ySpline[i] -= ybase; } for (int i=0; i<nPoints; i++) { xpf[i] -= xSpline0 - xSpline[0]; ypf[i] -= ySpline0 - ySpline[0]; } }
final double interval, final boolean isLine) { final double length = p.getLength(isLine); final int npoints2 = (int)((length*1.2)/interval); final float[] xpoints2 = new float[npoints2]; } while (--n2>0); return new FloatPolygon(xpoints2, ypoints2, 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); }
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 void addPoint(double x, double y) { addPoint((float)x, (float)y); }
private RectangleOverlay createRectangleOverlay(final Roi roi) { final RectangleOverlay overlay = new RectangleOverlay(getContext()); final RectangleRegionOfInterest region = overlay.getRegionOfInterest(); final FloatPolygon poly = roi.getFloatPolygon(); final Double bounds = poly.getFloatBounds(); region.setOrigin(bounds.x, 0); region.setOrigin(bounds.y, 1); region.setExtent(bounds.width, 0); region.setExtent(bounds.height, 1); assignPropertiesToOverlay(overlay, roi); return overlay; }
private void resetSplineFitBoundingRect() { if (splinePoints==0) return; float xbase = (float)getXBase(); float ybase = (float)getYBase(); float xSpline0 = xSpline[0]; float ySpline0 = ySpline[0]; for (int i=0; i<splinePoints; i++) { xSpline[i] = xSpline[i]+xbase; ySpline[i] = ySpline[i]+ybase; } FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); Rectangle r = poly.getBounds(); x = r.x;; y = r.y; width = r.width; height = r.height; bounds = poly.getFloatBounds(); xbase = (float)bounds.x; ybase = (float)bounds.y; for (int i=0; i<splinePoints; i++) { xSpline[i] -= xbase; ySpline[i] -= ybase; } for (int i=0; i<nPoints; i++) { xpf[i] -= xSpline0 - xSpline[0]; ypf[i] -= ySpline0 - ySpline[0]; } }
interval = Math.abs(interval); boolean isLine = this.isLine(); double length = p.getLength(isLine); yPoints[jj] = (float) destYArr[jj]; FloatPolygon fPoly = new FloatPolygon(xPoints, yPoints); return fPoly;
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; bounds = null; for (int i=0; i<nPoints; i++) { xpf[i] = xpf[i]-x; ypf[i] = ypf[i]-y; } }
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 void addPoint(double x, double y) { addPoint((float)x, (float)y); }
private EllipseOverlay createEllipseOverlay(final Roi roi) { final EllipseOverlay overlay = new EllipseOverlay(getContext()); final EllipseRegionOfInterest region = overlay.getRegionOfInterest(); final FloatPolygon poly = roi.getFloatPolygon(); final Double bounds = poly.getFloatBounds(); final double radiusX = bounds.width / 2.0; final double radiusY = bounds.height / 2.0; region.setOrigin(bounds.x + radiusX, 0); region.setOrigin(bounds.y + radiusY, 1); region.setRadius(radiusX, 0); region.setRadius(radiusY, 1); assignPropertiesToOverlay(overlay, roi); return overlay; }
/** 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; }
private void resetSubPixelBoundingRect() { //IJ.log("resetSubPixelBoundingRect: "+state+" "+bounds); if (xSpline!=null) { resetSplineFitBoundingRect(); return; } float xbase = (float)getXBase(); float ybase = (float)getYBase(); 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.x; ybase = (float)bounds.y; for (int i=0; i<nPoints; i++) { xpf[i] -= xbase; ypf[i] -= ybase; } }
interval = Math.abs(interval); boolean isLine = this.isLine(); double length = p.getLength(isLine); yPoints[jj] = (float) destYArr[jj]; FloatPolygon fPoly = new FloatPolygon(xPoints, yPoints); return fPoly;