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

Method setupDialog

ij/src/main/java/ij/gui/PlotDialog.java:126–303  ·  view source on GitHub ↗

Setting up the dialog fields and initial parameters. The input is read in the dialogItemChanged method, which must have exactly the same structure of 'if' blocks and matching 'get' methods for each input field. @return false on error

(GenericDialog gd)

Source from the content-addressed store, hash-verified

124 * have exactly the same structure of 'if' blocks and matching 'get' methods for each input field.
125 * @return false on error */
126 private boolean setupDialog(GenericDialog gd) {
127 double[] currentMinMax = plot.getLimits();
128 boolean livePlot = plot.plotMaker != null;
129
130 int xDigits = plot.logXAxis ? -2 : Plot.getDigits(currentMinMax[0], currentMinMax[1], 0.005*Math.abs(currentMinMax[1]-currentMinMax[0]), 6, 0);
131 if (dialogType == SET_RANGE || dialogType == X_AXIS) {
132 gd.addNumericField("X_From", currentMinMax[0], xDigits, 6, "*");
133 gd.addToSameRow();
134 gd.addNumericField("To", currentMinMax[1], xDigits, 6, "*");
135 gd.setInsets(0, 20, 0); //top, left, bottom
136 if (livePlot)
137 gd.addCheckbox("Fix_X Range While Live", (plot.templateFlags & Plot.X_RANGE) != 0);
138 gd.addCheckbox("Log_X Axis **", (plot.hasFlag(Plot.X_LOG_NUMBERS)));
139 xLogCheckbox = lastCheckboxAdded(gd);
140 enableDisableLogCheckbox(xLogCheckbox, currentMinMax[0], currentMinMax[1]);
141 }
142 int yDigits = plot.logYAxis ? -2 : Plot.getDigits(currentMinMax[2], currentMinMax[3], 0.005*Math.abs(currentMinMax[3]-currentMinMax[2]), 6, 0);
143 if (dialogType == SET_RANGE || dialogType == Y_AXIS) {
144 gd.setInsets(20, 0, 3); //top, left, bottom
145 gd.addNumericField("Y_From", currentMinMax[2], yDigits, 6, "*");
146 gd.addToSameRow();
147 gd.addNumericField("To", currentMinMax[3], yDigits, 6, "*");
148 if (livePlot)
149 gd.addCheckbox("Fix_Y Range While Live", (plot.templateFlags & Plot.Y_RANGE) != 0);
150 gd.addCheckbox("Log_Y Axis **", (plot.hasFlag(Plot.Y_LOG_NUMBERS)));
151 yLogCheckbox = lastCheckboxAdded(gd);
152 enableDisableLogCheckbox(yLogCheckbox, currentMinMax[2], currentMinMax[3]);
153 }
154 if (dialogType >= X_LEFT && dialogType <= Y_TOP) {
155 int digits = dialogType < Y_BOTTOM ? xDigits : yDigits;
156 gd.addNumericField(HEADINGS[dialogType], currentMinMax[dialogType - X_LEFT], digits, 6, "*");
157 }
158
159 if (dialogType == AXIS_OPTIONS || dialogType == X_AXIS || dialogType == Y_AXIS) {
160 int flags = plot.getFlags();
161 final String[] labels = new String[] {" Draw Grid", " Major Ticks", " Minor Ticks", " Ticks if Logarithmic", " Numbers"};
162 final int[] xFlags = new int[] {Plot.X_GRID, Plot.X_TICKS, Plot.X_MINOR_TICKS, Plot.X_LOG_TICKS, Plot.X_NUMBERS};
163 int rows = xFlags.length;
164 int columns = dialogType == AXIS_OPTIONS ? 2 : 1;
165 String[] allLabels = new String[rows*columns];
166 boolean[] defaultValues = new boolean[rows*columns];
167 String[] headings = dialogType == AXIS_OPTIONS ? new String[]{"X Axis", "Y Axis"} : null;
168 int i=0;
169 for (int l=0; l<xFlags.length; l++) {
170 String label = labels[l];
171 boolean xFlag = getFlag(flags, xFlags[l]);
172 boolean yFlag = getFlag(flags, xFlags[l]<<1); //y flags are shifted up one bit
173 if (dialogType == AXIS_OPTIONS || dialogType == X_AXIS) {
174 allLabels[i] = labels[l];
175 defaultValues[i++] = xFlag;
176 }
177 if (dialogType == AXIS_OPTIONS || dialogType == Y_AXIS) {
178 allLabels[i] = labels[l];
179 defaultValues[i++] = yFlag;
180 }
181 }
182 if (dialogType == X_AXIS || dialogType == Y_AXIS)
183 gd.setInsets(15, 20, 0); //top, left, bottom

Callers 1

showDialogMethod · 0.95

Calls 15

getDigitsMethod · 0.95
lastCheckboxAddedMethod · 0.95
getFlagMethod · 0.95
getIDListMethod · 0.95
getImageMethod · 0.95
getPropertyMethod · 0.95
errorMethod · 0.95
getTitleMethod · 0.95
getIDMethod · 0.95
getLimitsMethod · 0.80
setInsetsMethod · 0.80

Tested by

no test coverage detected