MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / showDialog

Method showDialog

ij/src/main/java/ij/plugin/Histogram.java:96–164  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

94 }
95
96 boolean showDialog(ImagePlus imp) {
97 if (!IJ.isMacro()) {
98 nBins = HistogramWindow.nBins;
99 useImageMinAndMax = staticUseImageMinAndMax;
100 xMin=staticXMin; xMax=staticXMax;
101 yMax = staticYMax;
102 stackHistogram = staticStackHistogram;
103 }
104 ImageProcessor ip = imp.getProcessor();
105 double min = ip.getMin();
106 double max = ip.getMax();
107 if (imp.getID()!=imageID || (min==xMin&&min==xMax))
108 useImageMinAndMax = true;
109 if (imp.getID()!=imageID || useImageMinAndMax) {
110 xMin = min;
111 xMax = max;
112 Calibration cal = imp.getCalibration();
113 xMin = cal.getCValue(xMin);
114 xMax = cal.getCValue(xMax);
115 }
116 defaultMin = IJ.d2s(xMin,2);
117 defaultMax = IJ.d2s(xMax,2);
118 imageID = imp.getID();
119 int stackSize = imp.getStackSize();
120 GenericDialog gd = new GenericDialog("Histogram");
121 gd.addNumericField("Bins:", nBins, 0);
122 gd.addCheckbox("Use pixel value range", useImageMinAndMax);
123 gd.setInsets(5, 40, 10);
124 gd.addMessage("or use:");
125 int fwidth = 8;
126 int nwidth = Math.max(IJ.d2s(xMin,2).length(), IJ.d2s(xMax,2).length());
127 if (nwidth>fwidth) fwidth = nwidth;
128 int digits = -2; // use scientific notation if needed
129 if (xMin==(int)xMin && xMax==(int)xMax)
130 digits = 0;
131 gd.addNumericField("X_min:", xMin, digits, fwidth, null);
132 gd.addNumericField("X_max:", xMax, digits, fwidth, null);
133 gd.setInsets(15, 0, 10);
134 gd.addStringField("Y_max:", yMax, fwidth);
135 if (stackSize>1)
136 gd.addCheckbox("Stack histogram", stackHistogram);
137 Vector numbers = gd.getNumericFields();
138 if (numbers!=null) {
139 minField = (TextField)numbers.elementAt(1);
140 minField.addTextListener(this);
141 maxField = (TextField)numbers.elementAt(2);
142 maxField.addTextListener(this);
143 }
144 checkbox = (Checkbox)(gd.getCheckboxes().elementAt(0));
145 gd.showDialog();
146 if (gd.wasCanceled())
147 return false;
148 nBins = (int)gd.getNextNumber();
149 useImageMinAndMax = gd.getNextBoolean();
150 xMin = gd.getNextNumber();
151 xMax = gd.getNextNumber();
152 yMax = gd.getNextString();
153 stackHistogram = (stackSize>1)?gd.getNextBoolean():false;

Callers 1

runMethod · 0.95

Calls 15

isMacroMethod · 0.95
getMinMethod · 0.95
getMaxMethod · 0.95
getCValueMethod · 0.95
d2sMethod · 0.95
addNumericFieldMethod · 0.95
addCheckboxMethod · 0.95
setInsetsMethod · 0.95
addMessageMethod · 0.95
addStringFieldMethod · 0.95
getNumericFieldsMethod · 0.95
getCheckboxesMethod · 0.95

Tested by

no test coverage detected