/** Returns the number of points in this selection; equivalent to getPolygon().npoints. */ public int size() { return getPolygon().npoints; }
/** Returns the number of points in this selection; equivalent to getPolygon().npoints. */ public int size() { return getPolygon().npoints; }
/** Draws an elliptical shape. */ public void drawOval(int x, int y, int width, int height) { if ((long)width*height>4*this.width*this.height) return; OvalRoi oval = new OvalRoi(x, y, width, height); drawPolygon(oval.getPolygon()); }
/** Fills an elliptical shape. */ public void fillOval(int x, int y, int width, int height) { if ((long)width*height>4*this.width*this.height) return; OvalRoi oval = new OvalRoi(x, y, width, height); fillPolygon(oval.getPolygon()); }
/** Draws an elliptical shape. */ public void drawOval(int x, int y, int width, int height) { if ((long)width*height>4*this.width*this.height) return; OvalRoi oval = new OvalRoi(x, y, width, height); drawPolygon(oval.getPolygon()); }
/** Fills an elliptical shape. */ public void fillOval(int x, int y, int width, int height) { if ((long)width*height>4*this.width*this.height) return; OvalRoi oval = new OvalRoi(x, y, width, height); fillPolygon(oval.getPolygon()); }
@Override public void mouseDragged(MouseEvent e) { if(!doDraw) return; OvalRoi roi = new OvalRoi(e.getX() - r, e.getY() - r, 2 * r, 2 * r); Polygon p = roi.getPolygon(); int n = p.npoints; Polygon q = new Polygon(new int[n], new int[n], n); for(int i = 0; i < n; i++) { Point3d picked = getPickPoint(p.xpoints[i], p.ypoints[i]); if(picked == null) continue; q.xpoints[i] = (int)Math.round(picked.x); q.ypoints[i] = (int)Math.round(picked.y); } bProcessor.fillPolygon(q); imp.updateAndDraw(); }
@Override public void mouseDragged(MouseEvent e) { if(!doDraw) return; OvalRoi roi = new OvalRoi(e.getX() - r, e.getY() - r, 2 * r, 2 * r); Polygon p = roi.getPolygon(); int n = p.npoints; Polygon q = new Polygon(new int[n], new int[n], n); for(int i = 0; i < n; i++) { Point3d picked = getPickPoint(p.xpoints[i], p.ypoints[i]); if(picked == null) continue; q.xpoints[i] = (int)Math.round(picked.x); q.ypoints[i] = (int)Math.round(picked.y); } bProcessor.fillPolygon(q); imp.updateAndDraw(); }
/** This method could get tones of improvement, which should be pumped upstream into ImageJ's RoiBrush class which is creating it at every while(true) {} iteration!!! * The returned area has its coordinates centered around 0,0 */ static public Area makeBrush(int diameter, double mag) { if (diameter < 1) return null; if (mag >= 1) return new Area(new OvalRoi(-diameter/2, -diameter/2, diameter, diameter).getPolygon()); // else, create a smaller brush and transform it up, i.e. less precise, less points to store -but precision matches what the eye sees, and allows for much better storage -less points. int screen_diameter = (int)(diameter * mag); if (0 == screen_diameter) return null; // can't paint at this mag with this diameter Area brush = new Area(new OvalRoi(-screen_diameter/2, -screen_diameter/2, screen_diameter, screen_diameter).getPolygon()); // scale to world coordinates AffineTransform at = new AffineTransform(); at.scale(1/mag, 1/mag); return brush.createTransformedArea(at); // smooth out edges /* Polygon pol = new OvalRoi(-diameter/2, -diameter/2, diameter, diameter).getPolygon(); Polygon pol2 = new Polygon(); // cheap and fast: skip every other point, since all will be square angles for (int i=0; i<pol.npoints; i+=2) { pol2.addPoint(pol.xpoints[i], pol.ypoints[i]); } return new Area(pol2); // the above works nice, but then the fill and fill-remove don't work properly (there are traces in the edges) // Needs a workround: before adding/substracting, enlarge the polygon to have square edges */ }
/** Returns this OvalRoi as a FloatPolygon. */ public FloatPolygon getFloatPolygon() { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); }
/** Returns this OvalRoi as a FloatPolygon. */ public FloatPolygon getFloatPolygon() { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); }
/** Draws an outline of this OvalRoi on the image. */ public void drawPixels(ImageProcessor ip) { Polygon p = getPolygon(); if (p.npoints>0) { int saveWidth = ip.getLineWidth(); if (getStrokeWidth()>1f) ip.setLineWidth((int)Math.round(getStrokeWidth())); ip.drawPolygon(p); ip.setLineWidth(saveWidth); } if (Line.getWidth()>1 || getStrokeWidth()>1) updateFullWindow = true; }
/** Draws an outline of this OvalRoi on the image. */ public void drawPixels(ImageProcessor ip) { Polygon p = getPolygon(); if (p.npoints>0) { int saveWidth = ip.getLineWidth(); if (getStrokeWidth()>1f) ip.setLineWidth((int)Math.round(getStrokeWidth())); ip.drawPolygon(p); ip.setLineWidth(saveWidth); } if (Line.getWidth()>1 || getStrokeWidth()>1) updateFullWindow = true; }
MetadataStore store, int roiNum, int shape, int c, int z, int t) Rectangle vnRectBounds = roi.getPolygon().getBounds(); int x = vnRectBounds.x; int y = vnRectBounds.y;
MetadataStore store, int roiNum, int shape, int c, int z, int t) Rectangle vnRectBounds = roi.getPolygon().getBounds(); int x = vnRectBounds.x; int y = vnRectBounds.y;