@Override public TranslatableROI translate(double dx, double dy) { if (dx == 0 && dy == 0) return this; // Shift the bounds return new RectangleROI(getBoundsX()+dx, getBoundsY()+dy, getBoundsWidth(), getBoundsHeight(), getC(), getZ(), getT()); }
@Override public double getScaledArea(double pixelWidth, double pixelHeight) { return getBoundsWidth() * getBoundsHeight() * pixelWidth * pixelHeight; }
@Override public ROI duplicate() { RectangleROI duplicate = new RectangleROI(); duplicate.x = x; duplicate.x2 = x2; duplicate.y= y; duplicate.y2 = y2; duplicate.c = c; duplicate.z = z; duplicate.t = t; return duplicate; }
@Override RectangleROI createROI(double x, double y, double width, double height, int c, int z, int t) { return new RectangleROI(x, y, width, height, c, z, t); }
@Override public double getScaledPerimeter(double pixelWidth, double pixelHeight) { return (getBoundsWidth() * pixelWidth + getBoundsHeight() * pixelHeight) * 2; }
private Object readResolve() { RectangleROI roi = new RectangleROI(x, y, x2-x, y2-y, c, z, t); return roi; }
/** * Get a PathShape from an Area. * This will try to return a PathRectangleROI or PathPolygonROI if possible, * or PathAreaROI if neither of the other classes can adequately represent the area. * * In the input shape is an Ellipse2D then an EllipseROI will be returned. * * @param area * @param c * @param z * @param t * @param flatness - can be used to prefer polygons, see Shape.getPathIterator(AffineTransform at, double flatness) * @return */ public static PathShape getShapeROI(Shape shape, int c, int z, int t, double flatness) { if (shape instanceof Rectangle2D) { Rectangle2D bounds = shape.getBounds2D(); return new RectangleROI(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), c, z, t); } if (shape instanceof Ellipse2D) { Rectangle2D bounds = shape.getBounds2D(); return new EllipseROI(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), c, z, t); } return getShapeROI(new Area(shape), c, z, t, flatness); }
tile = new RectangleROI(x, y, width, height); else if (!trimToROI) { tile = new RectangleROI(x, y, width, height); else continue; if (tileArea.isRectangular()) { Rectangle2D bounds2 = tileArea.getBounds2D(); tile = new RectangleROI(bounds2.getX(), bounds2.getY(), bounds2.getWidth(), bounds2.getHeight());
Shape shape = getShape(pathArea); if (shape.contains(boundsTile)) pathROI = new RectangleROI(boundsTile.getX(), boundsTile.getY(), boundsTile.getWidth(), boundsTile.getHeight(), parentROI.getC(), parentROI.getZ(), parentROI.getT()); else if (pathArea instanceof RectangleROI) { Rectangle2D bounds2 = boundsTile.createIntersection(bounds); pathROI = new RectangleROI(bounds2.getX(), bounds2.getY(), bounds2.getWidth(), bounds2.getHeight(), parentROI.getC(), parentROI.getZ(), parentROI.getT());
public static void createSelectAllObject(final boolean setSelected) { ImageData<?> imageData = getCurrentImageData(); if (imageData == null) return; ImageServer<?> server = imageData.getServer(); PathObject pathObject = new PathAnnotationObject(new RectangleROI(0, 0, server.getWidth(), server.getHeight(), 0, 0, 0)); imageData.getHierarchy().addPathObject(pathObject, false); if (setSelected) imageData.getHierarchy().getSelectionModel().setSelectedObject(pathObject); }
public static Collection<? extends ROI> computeTiledROIs(ImageData<?> imageData, PathObject parentObject, ImmutableDimension sizePreferred, ImmutableDimension sizeMax, boolean fixedSize, int overlap) { ROI parentROI = parentObject.getROI(); if (parentROI == null) parentROI = new RectangleROI(0, 0, imageData.getServer().getWidth(), imageData.getServer().getHeight()); return computeTiledROIs(parentROI, sizePreferred, sizeMax, fixedSize, overlap); }
if (area.isRectangular()) { Rectangle2D bounds = area.getBounds2D(); return new RectangleROI(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), c, z, t);