/** Returns the number of points in this selection; equivalent to getPolygon().npoints. */ public int size() { return getStrokeWidth()<=1?2:4; }
/** Returns the number of points in this selection; equivalent to getPolygon().npoints. */ public int size() { return getStrokeWidth()<=1?2:4; }
public boolean contains(int x, int y) { if (getStrokeWidth()>1) { if ((x==x1&&y==y1) || (x==x2&&y==y2)) return true; else return getPolygon().contains(x,y); } else return false; }
protected void mouseDownInHandle(int handle, int sx, int sy) { state = MOVING_HANDLE; activeHandle = handle; if (getStrokeWidth()<=3) ic.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); }
@Override public Iterator<Point> iterator() { if (getStrokeWidth() <= 1.0) return new PointIterator(this); // use the specific thin-line iterator else return super.iterator(); // fall back on Roi's iterator }
public boolean contains(int x, int y) { if (getStrokeWidth()>1) { if ((x==x1&&y==y1) || (x==x2&&y==y2)) return true; else return getPolygon().contains(x,y); } else return false; }
@Override public Iterator<Point> iterator() { if (getStrokeWidth() <= 1.0) return new PointIterator(this); // use the specific thin-line iterator else return super.iterator(); // fall back on Roi's iterator }
protected void mouseDownInHandle(int handle, int sx, int sy) { state = MOVING_HANDLE; activeHandle = handle; if (getStrokeWidth()<=3) ic.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); }
/** Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1. */ public int isHandle(int sx, int sy) { int size = HANDLE_SIZE+5; if (getStrokeWidth()>1) size += (int)Math.log(getStrokeWidth()); int halfSize = size/2; double offset = getOffset(0.5); int sx1 = ic.screenXD(x+x1R+offset) - halfSize; int sy1 = ic.screenYD(y+y1R+offset) - halfSize; int sx2 = ic.screenXD(x+x2R+offset) - halfSize; int sy2 = ic.screenYD(y+y2R+offset) - halfSize; int sx3 = sx1 + (sx2-sx1)/2-1; int sy3 = sy1 + (sy2-sy1)/2-1; if (sx>=sx1&&sx<=sx1+size&&sy>=sy1&&sy<=sy1+size) return 0; if (sx>=sx2&&sx<=sx2+size&&sy>=sy2&&sy<=sy2+size) return 1; if (sx>=sx3&&sx<=sx3+size+2&&sy>=sy3&&sy<=sy3+size+2) return 2; return -1; }
/** Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1. */ public int isHandle(int sx, int sy) { int size = HANDLE_SIZE+5; if (getStrokeWidth()>1) size += (int)Math.log(getStrokeWidth()); int halfSize = size/2; double offset = getOffset(0.5); int sx1 = ic.screenXD(x+x1R+offset) - halfSize; int sy1 = ic.screenYD(y+y1R+offset) - halfSize; int sx2 = ic.screenXD(x+x2R+offset) - halfSize; int sy2 = ic.screenYD(y+y2R+offset) - halfSize; int sx3 = sx1 + (sx2-sx1)/2-1; int sy3 = sy1 + (sy2-sy1)/2-1; if (sx>=sx1&&sx<=sx1+size&&sy>=sy1&&sy<=sy1+size) return 0; if (sx>=sx2&&sx<=sx2+size&&sy>=sy2&&sy<=sy2+size) return 1; if (sx>=sx3&&sx<=sx3+size+2&&sy>=sy3&&sy<=sy3+size+2) return 2; return -1; }
x1d=x+x1R; y1d=y+y1R; x2d=x+x2R; y2d=y+y2R; FloatPolygon p = new FloatPolygon(); if (getStrokeWidth()<=1) { p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); } else { double angle = Math.atan2(y1d-y2d, x2d-x1d); double width2 = getStrokeWidth()/2.0; double p1x = x1d + Math.cos(angle+Math.PI/2d)*width2; double p1y = y1d - Math.sin(angle+Math.PI/2d)*width2;
x1d=x+x1R; y1d=y+y1R; x2d=x+x2R; y2d=y+y2R; FloatPolygon p = new FloatPolygon(); if (getStrokeWidth()<=1) { p.addPoint((float)x1d, (float)y1d); p.addPoint((float)x2d, (float)y2d); } else { double angle = Math.atan2(y1d-y2d, x2d-x1d); double width2 = getStrokeWidth()/2.0; double p1x = x1d + Math.cos(angle+Math.PI/2d)*width2; double p1y = y1d - Math.sin(angle+Math.PI/2d)*width2;
dy = oy-(y1d+(y2d-y1d)/2); x1d+=dx; y1d+=dy; x2d+=dx; y2d+=dy; if (getStrokeWidth()>1) { x1d+=xHandleOffset; y1d+=yHandleOffset; x2d+=xHandleOffset; y2d+=yHandleOffset;
/** Returns the pixel values along this line. */ public double[] getPixels() { double[] profile; if (getStrokeWidth()<=1) { ImageProcessor ip = imp.getProcessor(); profile = ip.getLine(x1d, y1d, x2d, y2d); } else { ImageProcessor ip2 = (new Straightener()).rotateLine(imp,(int)getStrokeWidth()); if (ip2==null) return new double[0]; int width = ip2.getWidth(); int height = ip2.getHeight(); if (ip2 instanceof FloatProcessor) return ProfilePlot.getColumnAverageProfile(new Rectangle(0,0,width,height),ip2); profile = new double[width]; double[] aLine; ip2.setInterpolate(false); for (int y=0; y<height; y++) { aLine = ip2.getLine(0, y, width-1, y); for (int i=0; i<width; i++) profile[i] += aLine[i]; } for (int i=0; i<width; i++) profile[i] /= height; } return profile; }
/** Returns the pixel values along this line. */ public double[] getPixels() { double[] profile; if (getStrokeWidth()<=1) { ImageProcessor ip = imp.getProcessor(); profile = ip.getLine(x1d, y1d, x2d, y2d); } else { ImageProcessor ip2 = (new Straightener()).rotateLine(imp,(int)getStrokeWidth()); if (ip2==null) return new double[0]; int width = ip2.getWidth(); int height = ip2.getHeight(); if (ip2 instanceof FloatProcessor) return ProfilePlot.getColumnAverageProfile(new Rectangle(0,0,width,height),ip2); profile = new double[width]; double[] aLine; ip2.setInterpolate(false); for (int y=0; y<height; y++) { aLine = ip2.getLine(0, y, width-1, y); for (int i=0; i<width; i++) profile[i] += aLine[i]; } for (int i=0; i<width; i++) profile[i] /= height; } return profile; }
Line vLine = new Line(); GridPane.setMargin(vLine, vMargin); System.out.println(vLine.getStrokeWidth()); vLine.endYProperty().bind(height); gridPane.add(vLine, i, 0, 1, nextRow);
if (roi.getStrokeWidth() > 0) { store.setLineStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape);
if (roi.getStrokeWidth() > 0) { store.setLineStrokeWidth(new Length((roi.getStrokeWidth()), UNITS.PIXEL), roiNum, shape);
public void drawPixels(ImageProcessor ip) { ip.setLineWidth(1); double x = getXBase(); double y = getYBase(); x1d=x+x1R; y1d=y+y1R; x2d=x+x2R; y2d=y+y2R; double offset = getOffset(0.5); if (getStrokeWidth()<=1) { ip.moveTo((int)(x1d+offset), (int)(y1d+offset)); ip.lineTo((int)(x2d+offset), (int)(y2d+offset)); } else { Polygon p = null; if (offset>0.0) { FloatPolygon fp = getFloatPolygon(); for (int i=0; i<fp.npoints; i++) { fp.xpoints[i] += offset; fp.ypoints[i] += offset; } p = new Polygon(toIntR(fp.xpoints), toIntR(fp.ypoints), fp.npoints); } else p = getPolygon(); ip.drawPolygon(p); updateFullWindow = true; } }
public void drawPixels(ImageProcessor ip) { ip.setLineWidth(1); double x = getXBase(); double y = getYBase(); x1d=x+x1R; y1d=y+y1R; x2d=x+x2R; y2d=y+y2R; double offset = getOffset(0.5); if (getStrokeWidth()<=1) { ip.moveTo((int)(x1d+offset), (int)(y1d+offset)); ip.lineTo((int)(x2d+offset), (int)(y2d+offset)); } else { Polygon p = null; if (offset>0.0) { FloatPolygon fp = getFloatPolygon(); for (int i=0; i<fp.npoints; i++) { fp.xpoints[i] += offset; fp.ypoints[i] += offset; } p = new Polygon(toIntR(fp.xpoints), toIntR(fp.ypoints), fp.npoints); } else p = getPolygon(); ip.drawPolygon(p); updateFullWindow = true; } }