/** * Creates a dialog box, allowing the user to enter the requested width, height, x & y * coordinates, slice number for a Region Of Interest, option for oval, and option for whether x & * y coordinates to be centered. */ void showDialog() { Calibration cal = imp.getCalibration(); int digits = 0; if (scaledUnits && cal.scaled()) digits = 2; Roi roi = imp.getRoi(); if (roi == null) drawRoi(); GenericDialog gd = new GenericDialog("Specify"); gd.addNumericField("Width:", width, digits); gd.addNumericField("Height:", height, digits); gd.addNumericField("X coordinate:", xRoi, digits); gd.addNumericField("Y coordinate:", yRoi, digits); if (stackSize > 1) gd.addNumericField("Slice:", iSlice, 0); gd.addCheckbox("Oval", oval); gd.addCheckbox("Constrain square/circle", square); gd.addCheckbox("Centered", centered); if (cal.scaled()) { boolean unitsMatch = cal.getXUnit().equals(cal.getYUnit()); String units = unitsMatch ? cal.getUnits() : cal.getXUnit() + " x " + cal.getYUnit(); gd.addCheckbox("Scaled units (" + units + ")", scaledUnits); } fields = gd.getNumericFields(); gd.addDialogListener(this); gd.showDialog(); if (gd.wasCanceled()) { if (roi == null) imp.deleteRoi(); else // *ALWAYS* restore initial ROI when cancelled imp.setRoi(roi); } }