/** Returns the angle in degrees between the specified line and a horizontal line. */ public double getFloatAngle(double x1, double y1, double x2, double y2) { double dx = x2-x1; double dy = y1-y2; if (imp!=null && !IJ.altKeyDown()) { Calibration cal = imp.getCalibration(); dx *= cal.pixelWidth; dy *= cal.pixelHeight; } return (180.0/Math.PI)*Math.atan2(dy, dx); }
/** Returns the angle in degrees between the specified line and a horizontal line. */ public double getFloatAngle(double x1, double y1, double x2, double y2) { double dx = x2-x1; double dy = y1-y2; if (imp!=null && !IJ.altKeyDown()) { Calibration cal = imp.getCalibration(); dx *= cal.pixelWidth; dy *= cal.pixelHeight; } return (180.0/Math.PI)*Math.atan2(dy, dx); }
/** Returns the length of this line. */ public double getLength() { if (imp==null || IJ.altKeyDown()) return getRawLength(); else { Calibration cal = imp.getCalibration(); return Math.sqrt((x2d-x1d)*cal.pixelWidth*(x2d-x1d)*cal.pixelWidth + (y2d-y1d)*cal.pixelHeight*(y2d-y1d)*cal.pixelHeight); } }
/** Returns the length of this line. */ public double getLength() { if (imp==null || IJ.altKeyDown()) return getRawLength(); else { Calibration cal = imp.getCalibration(); return Math.sqrt((x2d-x1d)*cal.pixelWidth*(x2d-x1d)*cal.pixelWidth + (y2d-y1d)*cal.pixelHeight*(y2d-y1d)*cal.pixelHeight); } }
double isKeyDown() { double value = 0.0; String key = getStringArg().toLowerCase(Locale.US); if (key.indexOf("alt")!=-1) value = IJ.altKeyDown()==true?1.0:0.0; else if (key.indexOf("shift")!=-1) value = IJ.shiftKeyDown()==true?1.0:0.0; else if (key.indexOf("space")!=-1) value = IJ.spaceBarDown()==true?1.0:0.0; else interp.error("Invalid key"); return value; }
double isKeyDown() { double value = 0.0; String key = getStringArg().toLowerCase(Locale.US); if (key.indexOf("alt")!=-1) value = IJ.altKeyDown()==true?1.0:0.0; else if (key.indexOf("shift")!=-1) value = IJ.shiftKeyDown()==true?1.0:0.0; else if (key.indexOf("space")!=-1) value = IJ.spaceBarDown()==true?1.0:0.0; else interp.error("Invalid key"); return value; }
/** Adds the current selection to the ROI Manager, using the specified color (a 6 digit hex string) and line width. */ public boolean runCommand(String cmd, String hexColor, double lineWidth) { if (hexColor==null && lineWidth==1.0 && (IJ.altKeyDown()&&!Interpreter.isBatchMode())) addRoi(true); else { Color color = hexColor!=null?Colors.decode(hexColor, Color.cyan):null; addRoi(null, false, color, (int)Math.round(lineWidth)); } return true; }
/** Adds the current selection to the ROI Manager, using the specified color (a 6 digit hex string) and line width. */ public boolean runCommand(String cmd, String hexColor, double lineWidth) { if (hexColor==null && lineWidth==1.0 && (IJ.altKeyDown()&&!Interpreter.isBatchMode())) addRoi(true); else { Color color = hexColor!=null?Colors.decode(hexColor, Color.cyan):null; addRoi(null, false, color, (int)Math.round(lineWidth)); } return true; }
/** * @deprecated * replaced by ImageProcessor.draw(Roi) */ public void draw(ImageProcessor ip) { ip.setColor(Toolbar.getForegroundColor()); roi.drawPixels(ip); if (IJ.altKeyDown()) drawLabel(ip); }
public void run(String arg) { if (arg.equals("set")) {doOptions(); return;} imp = IJ.getImage(); if (firstTime) plotVertically = Prefs.verticalProfile || IJ.altKeyDown(); Plot plot = getPlot(); firstTime = false; if (plot==null) return; plot.setPlotMaker(this); plot.show(); }
public void run(String arg) { if (arg.equals("set")) {doOptions(); return;} imp = IJ.getImage(); if (firstTime) plotVertically = Prefs.verticalProfile || IJ.altKeyDown(); Plot plot = getPlot(); firstTime = false; if (plot==null) return; plot.setPlotMaker(this); plot.show(); }
/** * @deprecated * replaced by ImageProcessor.draw(Roi) */ public void draw(ImageProcessor ip) { ip.setColor(Toolbar.getForegroundColor()); roi.drawPixels(ip); if (IJ.altKeyDown()) drawLabel(ip); }
public void showStatus() { double[] p = getParams(); double dx = p[2] - p[0]; double dy = p[3] - p[1]; double major = Math.sqrt(dx*dx+dy*dy); double minor = major*p[4]; double angle = getFloatAngle(p[0], p[1], p[2], p[3]); if (imp!=null && !IJ.altKeyDown()) { Calibration cal = imp.getCalibration(); if (cal.scaled()) { dx *= cal.pixelWidth; dy *= cal.pixelHeight; major = Math.sqrt(dx*dx+dy*dy); minor = major*p[4]; } } IJ.showStatus("major=" + IJ.d2s(major)+", minor=" + IJ.d2s(minor)+", angle=" + IJ.d2s(angle)); }
boolean setProperties(String title, Roi roi) { if ((roi instanceof PointRoi) && Toolbar.getMultiPointMode() && IJ.altKeyDown()) { ((PointRoi)roi).displayCounts(); return true; } Frame f = WindowManager.getFrontWindow(); if (f!=null && f.getTitle().indexOf("3D Viewer")!=-1) return false; if (roi==null) { IJ.error("This command requires a selection."); return false; } RoiProperties rp = new RoiProperties(title, roi); boolean ok = rp.showDialog(); if (IJ.debugMode) IJ.log(roi.getDebugInfo()); return ok; }
Variable[] getProfile() { interp.getParens(); ImagePlus imp = getImage(); if (imp.getRoi()==null) interp.error("Selection required"); ProfilePlot pp = new ProfilePlot(imp, IJ.altKeyDown()); double[] array = pp.getProfile(); if (array==null) {interp.done=true; return null;} else return new Variable(array).getArray(); }
Variable[] getProfile() { interp.getParens(); ImagePlus imp = getImage(); if (imp.getRoi()==null) interp.error("Selection required"); ProfilePlot pp = new ProfilePlot(imp, IJ.altKeyDown()); double[] array = pp.getProfile(); if (array==null) {interp.done=true; return null;} else return new Variable(array).getArray(); }
/** 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)); }
/** 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)); }