/** Set the location of the ROI in image coordinates. */ public void setLocation(double x, double y) { setLocation((int)x, (int)y); if ((int)x==x && (int)y==y) return; if (bounds!=null) { bounds.x = x; bounds.y = y; } else bounds = new Rectangle2D.Double(x, y, width, height); subPixel = true; }
/** Set the location of the ROI in image coordinates. */ public void setLocation(double x, double y) { setLocation((int)x, (int)y); if ((int)x==x && (int)y==y) return; if (bounds!=null) { bounds.x = x; bounds.y = y; } else bounds = new Rectangle2D.Double(x, y, width, height); subPixel = true; }
/** Moves all the ROIs in this overlay. */ public void translate(int dx, int dy) { Roi[] rois = toArray(); for (int i=0; i<rois.length; i++) { Roi roi = rois[i]; if (roi.subPixelResolution()) { Rectangle2D r = roi.getFloatBounds(); roi.setLocation(r.getX()+dx, r.getY()+dy); } else { Rectangle r = roi.getBounds(); roi.setLocation(r.x+dx, r.y+dy); } } }
public void setLocation(int x, int y) { super.setLocation(x, y); double xx = getXBase(); double yy = getYBase(); x1d=xx+x1R; y1d=yy+y1R; x2d=xx+x2R; y2d=yy+y2R; x1=(int)x1d; y1=(int)y1d; x2=(int)x2d; y2=(int)y2d; }
public void setLocation(double x, double y) { super.setLocation(x, y); if ((int)x!=x || (int)y!=y) { subPixel = true; if (xpf==null && xp!=null) { xpf = toFloat(xp); ypf = toFloat(yp); } } }
/** Moves all the ROIs in this overlay. */ public void translate(int dx, int dy) { Roi[] rois = toArray(); for (int i=0; i<rois.length; i++) { Roi roi = rois[i]; if (roi.subPixelResolution()) { Rectangle2D r = roi.getFloatBounds(); roi.setLocation(r.getX()+dx, r.getY()+dy); } else { Rectangle r = roi.getBounds(); roi.setLocation(r.x+dx, r.y+dy); } } }
private static Roi scaleShape(ShapeRoi roi, double xscale, double yscale, boolean centered) { Rectangle r = roi.getBounds(); Shape shape = roi.getShape(); AffineTransform at = new AffineTransform(); at.scale(xscale, yscale); if (!centered) at.translate(r.x, r.y); Shape shape2 = at.createTransformedShape(shape); Roi roi2 = new ShapeRoi(shape2); if (centered) { int xbase = (int)(centered?r.x-(r.width*xscale-r.width)/2.0:r.x); int ybase = (int)(centered?r.y-(r.height*yscale-r.height)/2.0:r.y); roi2.setLocation(xbase, ybase); } return roi2; }
@Override public void updateBounds() { // Update ImageJ 1.x Roi location final double x = position[0] - rect.getFloatWidth() / 2; final double y = position[1] - rect.getFloatHeight() / 2; rect.setLocation(x, y); }
public void setLocation(int x, int y) { super.setLocation(x, y); double xx = getXBase(); double yy = getYBase(); x1d=xx+x1R; y1d=yy+y1R; x2d=xx+x2R; y2d=yy+y2R; x1=(int)x1d; y1=(int)y1d; x2=(int)x2d; y2=(int)y2d; }
public void setLocation(double x, double y) { super.setLocation(x, y); if ((int)x!=x || (int)y!=y) { subPixel = true; if (xpf==null && xp!=null) { xpf = toFloat(xp); ypf = toFloat(yp); } } }
/** Moves all the ROIs in this overlay. * Marcel Boeglin, October 2013 */ public void translate(double dx, double dy) { Roi[] rois = toArray(); boolean intArgs = (int)dx==dx && (int)dy==dy; for (int i=0; i<rois.length; i++) { Roi roi = rois[i]; if (roi.subPixelResolution() || !intArgs) { Rectangle2D r = roi.getFloatBounds(); roi.setLocation(r.getX()+dx, r.getY()+dy); } else { Rectangle r = roi.getBounds(); roi.setLocation(r.x+(int)dx, r.y+(int)dy); } } }
private static Roi scaleShape(ShapeRoi roi, double xscale, double yscale, boolean centered) { Rectangle r = roi.getBounds(); Shape shape = roi.getShape(); AffineTransform at = new AffineTransform(); at.scale(xscale, yscale); if (!centered) at.translate(r.x, r.y); Shape shape2 = at.createTransformedShape(shape); Roi roi2 = new ShapeRoi(shape2); if (centered) { int xbase = (int)(centered?r.x-(r.width*xscale-r.width)/2.0:r.x); int ybase = (int)(centered?r.y-(r.height*yscale-r.height)/2.0:r.y); roi2.setLocation(xbase, ybase); } return roi2; }
/** Moves the selected ROIs or all the ROIs if none are selected. */ public void translate(double dx, double dy) { Roi[] rois = getSelectedRoisAsArray(); for (int i=0; i<rois.length; i++) { Roi roi = rois[i]; Rectangle2D r = roi.getFloatBounds(); roi.setLocation(r.getX()+dx, r.getY()+dy); } ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) imp.draw(); }
/** Moves the selected ROIs or all the ROIs if none are selected. */ public void translate(double dx, double dy) { Roi[] rois = getSelectedRoisAsArray(); for (int i=0; i<rois.length; i++) { Roi roi = rois[i]; Rectangle2D r = roi.getFloatBounds(); roi.setLocation(r.getX()+dx, r.getY()+dy); } ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) imp.draw(); }
void setSelectionLocation() { int x = (int)Math.round(getFirstArg()); int y = (int)Math.round(getLastArg()); ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (roi==null) interp.error("Selection required"); roi.setLocation(x, y); imp.draw(); }
public void restoreRoi() { if (Roi.previousRoi!=null) { Roi pRoi = Roi.previousRoi; Rectangle r = pRoi.getBounds(); if (r.width<=width||r.height<=height||(r.x<width&&r.y<height)||isSmaller(pRoi)) { // will it (mostly) fit in this image? roi = (Roi)pRoi.clone(); roi.setImage(this); if (r.x>=width || r.y>=height || (r.x+r.width)<0 || (r.y+r.height)<0) // does it need to be moved? roi.setLocation((width-r.width)/2, (height-r.height)/2); else if (r.width==width && r.height==height) // is it the same size as the image roi.setLocation(0, 0); draw(); roi.notifyListeners(RoiListener.CREATED); } } }
void setSelectionLocation() { int x = (int)Math.round(getFirstArg()); int y = (int)Math.round(getLastArg()); ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (roi==null) interp.error("Selection required"); roi.setLocation(x, y); imp.draw(); }
void moveRoi(int sx, int sy){ xNew = ic.offScreenX(sx); yNew = ic.offScreenY(sy); dx1 = xNew - startX; dy1 = yNew - startY; if (dx1==0 && dy2==0) return; startX = xNew; startY = yNew; dx = roi.getXBase() + dx1; dy = roi.getYBase() + dy1; roi.setLocation(dx, dy); imp2.draw(); }
void moveRoi(int sx, int sy){ xNew = ic.offScreenX(sx); yNew = ic.offScreenY(sy); dx1 = xNew - startX; dy1 = yNew - startY; if (dx1==0 && dy2==0) return; startX = xNew; startY = yNew; dx = roi.getXBase() + dx1; dy = roi.getYBase() + dy1; roi.setLocation(dx, dy); imp2.draw(); }
void showInternalClipboard() { ImagePlus clipboard = ImagePlus.getClipboard(); if (clipboard!=null) { ImageProcessor ip = clipboard.getProcessor(); ImagePlus imp2 = new ImagePlus("Clipboard", ip.duplicate()); Roi roi = clipboard.getRoi(); imp2.deleteRoi(); if (roi!=null && roi.isArea() && roi.getType()!=Roi.RECTANGLE) { roi = (Roi)roi.clone(); roi.setLocation(0, 0); imp2.setRoi(roi); IJ.run(imp2, "Clear Outside", null); imp2.deleteRoi(); } WindowManager.checkForDuplicateName = true; imp2.show(); } else IJ.error("The internal clipboard is empty."); }