/** * Wraps an ImageJ 1.x {@link PolygonRoi} as an ImgLib2 {@link Polygon2D}. * * @param poly the {@code PolygonRoi} to be wrapped */ public UnmodifiablePolygonRoiWrapper(final PolygonRoi poly) { super(poly); if (poly.getType() != Roi.FREEROI && poly.getType() != Roi.TRACED_ROI) throw new IllegalArgumentException("Cannot wrap " + poly .getTypeAsString() + " as Polygon2D"); }
@Override public boolean supportedType(final PolygonRoi src) { final boolean supportedType = src.getType() == Roi.POLYGON || src .getType() == Roi.TRACED_ROI || src.getType() == Roi.FREEROI; // EllipseRoi and RotatedRectRoi are both PolygonRois & FREEROI return supportedType && !src.isSplineFit() && !(src instanceof RotatedRectRoi) && !(src instanceof EllipseRoi); } }
/** * Wraps an ImageJ 1.x {@link PolygonRoi} as an ImgLib2 {@link Polygon2D}. * * @param poly the {@code PolygonRoi} to be wrapped */ public PolygonRoiWrapper(final PolygonRoi poly) { super(poly); if (poly.getType() != Roi.POLYGON) throw new IllegalArgumentException( "Cannot wrap " + poly.getTypeAsString() + " as Polygon2D"); if (poly.isSplineFit()) throw new IllegalArgumentException("Cannot wrap " + "spline fitted polygons"); }
/** * 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"); }
@Override public Polyline convert(final PolygonRoi src) { if (src.getType() == Roi.POLYLINE) return new PolylineRoiWrapper(src); return new UnmodifiablePolylineRoiWrapper(src); }
/** * 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"); }
@Override public Polygon2D convert(final PolygonRoi src) { if (src.getType() == Roi.POLYGON) return new PolygonRoiWrapper(src); return new UnmodifiablePolygonRoiWrapper(src); }
public PolygonRoiPublic(PolygonRoi roi) { this(getXCoordinates(roi), getYCoordinates(roi), getNCoordinates(roi), roi.getType()); }
protected PolygonRoi flipROI(PolygonRoi roi) { if (roi.isSplineFit()) { roi = (PolygonRoi)roi.clone(); roi.removeSplineFit(); } Polygon polygon = roi.getPolygon(); for (int i = 0; i < polygon.npoints / 2; i++) { int dummy = polygon.xpoints[i]; polygon.xpoints[i] = polygon.xpoints[polygon.npoints - 1 - i]; polygon.xpoints[polygon.npoints - 1 - i] = dummy; dummy = polygon.ypoints[i]; polygon.ypoints[i] = polygon.ypoints[polygon.npoints - 1 - i]; polygon.ypoints[polygon.npoints - 1 - i] = dummy; } return new PolygonRoi(polygon, roi.getType()); }
int type = roi.getType()==Roi.FREELINE?Roi.POLYLINE:Roi.POLYGON; if (type==Roi.POLYLINE && distance>0.0) { x[i2] = (float)x2;
int type = roi.getType()==Roi.FREELINE?Roi.POLYLINE:Roi.POLYGON; if (type==Roi.POLYLINE && distance>0.0) { x[i2] = x2 + r.x;
int type = roi.getType()==Roi.FREELINE?Roi.POLYLINE:Roi.POLYGON; if (type==Roi.POLYLINE && distance>0.0) { x[i2] = x2 + r.x;
int type = roi.getType()==Roi.FREELINE?Roi.POLYLINE:Roi.POLYGON; if (type==Roi.POLYLINE && distance>0.0) { x[i2] = (float)x2;
if (roi.isSplineFit()) roi.removeSplineFit(); int type = roi.getType(); int n = roi.getNCoordinates(); double len = roi.getLength();
if (roi.isSplineFit()) roi.removeSplineFit(); int type = roi.getType(); int n = roi.getNCoordinates(); double len = roi.getLength();