@Override public double realMin(final int d) { if (d != 0 && d != 1) throw new IllegalArgumentException( "Invalid dimension " + d); // Bounds of the underlying roi are not updated when the width changes, so // in order to ensure this occurs it needs to be subtracted. This may result // in a bounding box which is slightly larger than needed. return d == 0 ? roi.getXBase() - roi.getStrokeWidth() / 2 : roi.getYBase() - roi.getStrokeWidth() / 2; }
@Override public double realMax(final int d) { if (d != 0 && d != 1) throw new IllegalArgumentException( "Invalid dimension " + d); // Bounds of the underlying roi are not updated when the width changes, so // in order to ensure this occurs it needs to be added. This may result in a // bounding box which is slightly larger than needed. return d == 0 ? roi.getXBase() + roi.getFloatWidth() + roi .getStrokeWidth() / 2 : roi.getYBase() + roi.getFloatHeight() + roi .getStrokeWidth() / 2; }
/** * Wraps an ImageJ 1.x {@link PolygonRoi} as an ImgLib2 {@link Polyline}. * * @param poly the {@code PolygonRoi} to be wrapped */ public PolylineRoiWrapper(final PolygonRoi poly) { super(poly); if (poly.getType() != Roi.POLYLINE) throw new IllegalArgumentException( "Cannot wrap " + poly.getTypeAsString() + " as Polyline"); if (poly.getStrokeWidth() != 0) throw new IllegalArgumentException( "Cannot wrap polylines with non-zero width"); if (poly.isSplineFit()) throw new IllegalArgumentException("Cannot wrap " + "spline fitted polylines"); }
/** * Wraps an ImageJ 1.x {@link PolygonRoi} as an ImgLib2 {@link Polyline}. * * @param poly the {@code PolygonRoi} to be wrapped */ public UnmodifiablePolylineRoiWrapper(final PolygonRoi poly) { super(poly); if (poly.getType() != Roi.FREELINE && poly.getType() != Roi.ANGLE) throw new IllegalArgumentException("Cannot wrap " + poly .getTypeAsString() + " as Polyline"); if (poly.getStrokeWidth() != 0) throw new IllegalArgumentException( "Cannot wrap polylines with non-zero width"); if (poly.isSplineFit()) throw new IllegalArgumentException("Cannot wrap " + "spline fitted polylines"); }
public void drawPixels(ImageProcessor ip) { int saveWidth = ip.getLineWidth(); if (getStrokeWidth()>1f) ip.setLineWidth((int)Math.round(getStrokeWidth())); double xbase = getXBase(); double ybase = getYBase(); if (xSpline!=null) { ip.moveTo((int)Math.round(xbase+xSpline[0]), (int)Math.round(ybase+ySpline[0])); for (int i=1; i<splinePoints; i++) ip.lineTo((int)Math.round(xbase+xSpline[i]), (int)Math.round(ybase+ySpline[i])); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo((int)Math.round(xbase+xSpline[0]), (int)Math.round(ybase+ySpline[0])); } else if (xpf!=null) { ip.moveTo((int)Math.round(xbase+xpf[0]), (int)Math.round(ybase+ypf[0])); for (int i=1; i<nPoints; i++) ip.lineTo((int)Math.round(xbase+xpf[i]), (int)Math.round(ybase+ypf[i])); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo((int)Math.round(xbase+xpf[0]), (int)Math.round(ybase+ypf[0])); } else { ip.moveTo(x+xp[0], y+yp[0]); for (int i=1; i<nPoints; i++) ip.lineTo(x+xp[i], y+yp[i]); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo(x+xp[0], y+yp[0]); } ip.setLineWidth(saveWidth); updateFullWindow = true; }
public void drawPixels(ImageProcessor ip) { int saveWidth = ip.getLineWidth(); if (getStrokeWidth()>1f) ip.setLineWidth((int)Math.round(getStrokeWidth())); double xbase = getXBase(); double ybase = getYBase(); if (xSpline!=null) { ip.moveTo((int)Math.round(xbase+xSpline[0]), (int)Math.round(ybase+ySpline[0])); for (int i=1; i<splinePoints; i++) ip.lineTo((int)Math.round(xbase+xSpline[i]), (int)Math.round(ybase+ySpline[i])); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo((int)Math.round(xbase+xSpline[0]), (int)Math.round(ybase+ySpline[0])); } else if (xpf!=null) { ip.moveTo((int)Math.round(xbase+xpf[0]), (int)Math.round(ybase+ypf[0])); for (int i=1; i<nPoints; i++) ip.lineTo((int)Math.round(xbase+xpf[i]), (int)Math.round(ybase+ypf[i])); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo((int)Math.round(xbase+xpf[0]), (int)Math.round(ybase+ypf[0])); } else { ip.moveTo(x+xp[0], y+yp[0]); for (int i=1; i<nPoints; i++) ip.lineTo(x+xp[i], y+yp[i]); if (type==POLYGON || type==FREEROI || type==TRACED_ROI) ip.lineTo(x+xp[0], y+yp[0]); } ip.setLineWidth(saveWidth); updateFullWindow = true; }
@Override public boolean supportedType(final PolygonRoi src) { final boolean supportedType = src.getType() == Roi.POLYLINE || src .getType() == Roi.ANGLE || src.getType() == Roi.FREELINE; return supportedType && src.getStrokeWidth() == 0 && !src.isSplineFit(); }
/** * {@inheritDoc} * <p> * This includes some additional points near the vertices of the polyline. * </p> */ @Override public boolean test(final RealLocalizable t) { final float[] x = roi.getFloatPolygon().xpoints; final float[] y = roi.getFloatPolygon().ypoints; final double xt = t.getDoublePosition(0); final double yt = t.getDoublePosition(1); for (int i = 1; i < getRoi().getNCoordinates(); i++) { if (lineContains(x[i - 1], y[i - 1], x[i], y[i], xt, yt, roi .getStrokeWidth())) return true; } return false; }
double mag = ic.getMagnification(); int handleSize = type==POINT?HANDLE_SIZE+12:HANDLE_SIZE; double strokeWidth = getStrokeWidth(); if (strokeWidth<1.0) strokeWidth=1.0; if (handleSize<strokeWidth && isLine())
double mag = ic.getMagnification(); int handleSize = type==POINT?HANDLE_SIZE+12:HANDLE_SIZE; double strokeWidth = getStrokeWidth(); if (strokeWidth<1.0) strokeWidth=1.0; if (handleSize<strokeWidth && isLine())
store.setPolylineTheT(unwrap(t), roiNum, shape); if (roi.getStrokeWidth() > 0) { store.setPolylineStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape); store.setPolygonTheT(unwrap(t), roiNum, shape); if (roi.getStrokeWidth() > 0) { store.setPolygonStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape);
store.setPolylineTheT(unwrap(t), roiNum, shape); if (roi.getStrokeWidth() > 0) { store.setPolylineStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape); store.setPolygonTheT(unwrap(t), roiNum, shape); if (roi.getStrokeWidth() > 0) { store.setPolygonStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape);
p.setStrokeWidth(roi.getStrokeWidth()); p.setStrokeColor(roi.getStrokeColor()); p.setDrawOffset(roi.getDrawOffset());
p.setStrokeWidth(roi.getStrokeWidth()); p.setStrokeColor(roi.getStrokeColor()); p.setName(roi.getName());
p.setStrokeWidth(roi.getStrokeWidth()); p.setStrokeColor(roi.getStrokeColor()); p.setDrawOffset(roi.getDrawOffset());
p.setStrokeWidth(roi.getStrokeWidth()); p.setStrokeColor(roi.getStrokeColor()); p.setName(roi.getName());
if (mag<1.0) margin = (int)(margin/mag); margin = (int)(margin+getStrokeWidth()); if (IJ.altKeyDown()) margin+=20;
if (mag<1.0) margin = (int)(margin/mag); margin = (int)(margin+getStrokeWidth()); if (IJ.altKeyDown()) margin+=20;