/** * If the wrapped {@link PolygonRoi} is not associated with an * {@link ImagePlus}, then this method will always throw an * {@code UnsupportedOperationException}. Otherwise, the vertex will be * removed provided the index is valid. */ @Override public void removeVertex(final int index) { if (getRoi().getImage() != null) { final double x = getRoi().getFloatPolygon().xpoints[index]; final double y = getRoi().getFloatPolygon().ypoints[index]; getRoi().deleteHandle(x, y); } else throw new UnsupportedOperationException("removeVertex"); }
/** Creates a point selection using floating point coordinates. */ public static void makePoint(double x, double y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint((int)Math.round(x), (int)Math.round(y)); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }
/** Creates a point selection using floating point coordinates. */ public static void makePoint(double x, double y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint((int)Math.round(x), (int)Math.round(y)); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }
/** * If the wrapped {@link PolygonRoi} is not associated with an * {@link ImagePlus}, then this method will always throw an * {@code UnsupportedOperationException}. Otherwise, the vertex will be * removed provided the index is valid. */ @Override public void removeVertex(final int index) { if (getRoi().getImage() != null) { final double x = getRoi().getFloatPolygon().xpoints[index]; final double y = getRoi().getFloatPolygon().ypoints[index]; getRoi().deleteHandle(x, y); } else Rois.unsupported("removeVertex"); }
protected void mouseDownInHandle(int handle, int sx, int sy) { if (state==CONSTRUCTING) return; int ox=ic.offScreenX(sx), oy=ic.offScreenY(sy); double oxd=ic.offScreenXD(sx), oyd=ic.offScreenYD(sy); if ((IJ.altKeyDown()||IJ.controlKeyDown()) && !(nPoints<=3 && type!=POINT) && !(this instanceof RotatedRectRoi)) { deleteHandle(oxd, oyd); return; } else if (IJ.shiftKeyDown() && type!=POINT && !(this instanceof RotatedRectRoi)) { addHandle(oxd, oyd); return; } state = MOVING_HANDLE; activeHandle = handle; int m = (int)(10.0/ic.getMagnification()); xClipMin=ox-m; yClipMin=oy-m; xClipMax=ox+m; yClipMax=oy+m; }
protected void mouseDownInHandle(int handle, int sx, int sy) { if (state==CONSTRUCTING) return; int ox=ic.offScreenX(sx), oy=ic.offScreenY(sy); double oxd=ic.offScreenXD(sx), oyd=ic.offScreenYD(sy); if ((IJ.altKeyDown()||IJ.controlKeyDown()) && !(nPoints<=3 && type!=POINT) && !(this instanceof RotatedRectRoi)) { deleteHandle(oxd, oyd); return; } else if (IJ.shiftKeyDown() && type!=POINT && !(this instanceof RotatedRectRoi)) { addHandle(oxd, oyd); return; } state = MOVING_HANDLE; activeHandle = handle; int m = (int)(10.0/ic.getMagnification()); xClipMin=ox-m; yClipMin=oy-m; xClipMax=ox+m; yClipMax=oy+m; }
/** Creates a point selection using integer coordinates.. */ public static void makePoint(int x, int y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint(x, y); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }
/** Creates a point selection using integer coordinates.. */ public static void makePoint(int x, int y) { ImagePlus img = getImage(); Roi roi = img.getRoi(); if (shiftKeyDown() && roi!=null && roi.getType()==Roi.POINT) { Polygon p = roi.getPolygon(); p.addPoint(x, y); img.setRoi(new PointRoi(p.xpoints, p.ypoints, p.npoints)); IJ.setKeyUp(KeyEvent.VK_SHIFT); } else if (altKeyDown() && roi!=null && roi.getType()==Roi.POINT) { ((PolygonRoi)roi).deleteHandle(x, y); IJ.setKeyUp(KeyEvent.VK_ALT); } else img.setRoi(new PointRoi(x, y)); }