Implements the Analyze/Plot Profile and Edit/Options/Profile Plot Options commands.
| 9 | |
| 10 | /** Implements the Analyze/Plot Profile and Edit/Options/Profile Plot Options commands. */ |
| 11 | public class Profiler implements PlugIn, PlotMaker { |
| 12 | ImagePlus imp; |
| 13 | boolean firstTime = true; |
| 14 | boolean plotVertically; |
| 15 | |
| 16 | @AstroImageJ(reason = "Set plot in window's imp", modified = true) |
| 17 | public void run(String arg) { |
| 18 | if (arg.equals("set")) { |
| 19 | doOptions(); |
| 20 | return; |
| 21 | } |
| 22 | imp = IJ.getImage(); |
| 23 | if (firstTime) |
| 24 | plotVertically = Prefs.verticalProfile || IJ.altKeyDown(); |
| 25 | Plot plot = getPlot(); |
| 26 | firstTime = false; |
| 27 | if (plot==null) |
| 28 | return; |
| 29 | plot.setPlotMaker(this); |
| 30 | plot.show().getImagePlus().setPlot(plot); |
| 31 | Roi roi = imp.getRoi(); |
| 32 | if (roi!=null && roi.getType()==Roi.RECTANGLE) |
| 33 | plot.getImagePlus().setProperty ("Label", plotVertically ? "vertical" : "horizontal"); |
| 34 | } |
| 35 | |
| 36 | public Plot getPlot() { |
| 37 | Roi roi = imp.getRoi(); |
| 38 | if (roi==null || !(roi.isLine()||roi.getType()==Roi.RECTANGLE||(roi instanceof RotatedRectRoi))) { |
| 39 | if (firstTime) |
| 40 | IJ.error("Plot Profile", "Line or rectangular selection required"); |
| 41 | return null; |
| 42 | } |
| 43 | ProfilePlot pp = new ProfilePlot(imp, plotVertically); |
| 44 | return pp.getPlot(); |
| 45 | } |
| 46 | |
| 47 | public ImagePlus getSourceImage() { |
| 48 | return imp; |
| 49 | } |
| 50 | |
| 51 | public void doOptions() { |
| 52 | double ymin = ProfilePlot.getFixedMin(); |
| 53 | double ymax = ProfilePlot.getFixedMax(); |
| 54 | boolean fixedScale = ymin!=0.0 || ymax!=0.0; |
| 55 | boolean wasFixedScale = fixedScale; |
| 56 | GenericDialog gd = new GenericDialog("Plot Defaults"); |
| 57 | gd.setInsets(4,0,0); |
| 58 | gd.addMessage("---------- Plot Defaults ---------"); |
| 59 | gd.addNumericField("Width:", PlotWindow.plotWidth, 0); |
| 60 | gd.addNumericField("Height:", PlotWindow.plotHeight, 0); |
| 61 | gd.addNumericField("Font size:", PlotWindow.getDefaultFontSize()); |
| 62 | gd.setInsets(5,20,0); //distance to previous |
| 63 | //gd.addCheckbox("Draw grid lines", !PlotWindow.noGridLines); |
| 64 | gd.addCheckbox("Draw_ticks", !PlotWindow.noTicks); |
| 65 | gd.addCheckbox("Auto-close", PlotWindow.autoClose); |
| 66 | gd.addCheckbox("List values", PlotWindow.listValues); |
| 67 | gd.setInsets(15,0,0); |
| 68 | gd.addMessage("------- Profile Plot Options -------"); |
nothing calls this directly
no outgoing calls
no test coverage detected