public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { if (doOptions) { this.imp = imp; this.pfr = pfr; GenericDialog gd = new GenericDialog("Binary Options"); gd.addNumericField("Iterations (1-" + MAX_ITERATIONS + "):", iterations, 0, 3, ""); gd.addNumericField("Count (1-8):", count, 0, 3, ""); gd.addCheckbox("Black background", Prefs.blackBackground); gd.addCheckbox("Pad edges when eroding", Prefs.padEdges); gd.addChoice("EDM output:", outputTypes, outputTypes[EDM.getOutputType()]); if (imp != null) { gd.addChoice("Do:", operations, operation); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); previewing = true; } gd.addHelp(IJ.URL + "/docs/menus/process.html#options"); gd.showDialog(); previewing = false; if (gd.wasCanceled()) return DONE; if (imp == null) { // options dialog only, no do/preview dialogItemChanged(gd, null); // read dialog result return DONE; } return operation.equals(NO_OPERATION) ? DONE : IJ.setupDialog(imp, flags); } else { // no dialog, 'arg' is operation type if (!((ByteProcessor) imp.getProcessor()).isBinary()) { IJ.error("8-bit binary (black and white only) image required."); return DONE; } return IJ.setupDialog(imp, flags); } }
public int setup(String arg, ImagePlus imp) { this.arg = arg; this.imp = imp; IJ.register(ParticleAnalyzer.class); if (imp == null) { IJ.noImage(); return DONE; } if (imp.getBitDepth() == 24 && !isThresholdedRGB(imp)) { IJ.error( "Particle Analyzer", "RGB images must be thresholded using\n" + "Image>Adjust>Color Threshold."); return DONE; } if (!showDialog()) return DONE; int baseFlags = DOES_ALL + NO_CHANGES + NO_UNDO; int flags = IJ.setupDialog(imp, baseFlags); processStack = (flags & DOES_STACKS) != 0; slice = 0; saveRoi = imp.getRoi(); if (saveRoi != null && saveRoi.getType() != Roi.RECTANGLE && saveRoi.isArea()) polygon = saveRoi.getPolygon(); imp.startTiming(); nextFontSize = defaultFontSize; nextLineWidth = 1; return flags; }
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { this.pfr = pfr; String macroOptions = Macro.getOptions(); if (macroOptions != null) { if (macroOptions.indexOf(" interpolate") != -1) macroOptions.replaceAll(" interpolate", " interpolation=Bilinear"); else if (macroOptions.indexOf(" interpolation=") == -1) macroOptions = macroOptions + " interpolation=None"; Macro.setOptions(macroOptions); } gd = new GenericDialog("Rotate", IJ.getInstance()); gd.addNumericField("Angle (degrees):", angle, (int) angle == angle ? 1 : 2); gd.addNumericField("Grid Lines:", gridLines, 0); gd.addChoice("Interpolation:", methods, methods[interpolationMethod]); if (bitDepth == 8 || bitDepth == 24) gd.addCheckbox("Fill with Background Color", fillWithBackground); if (canEnlarge) gd.addCheckbox("Enlarge Image to Fit Result", enlarge); else enlarge = false; gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); drawGridLines(0); if (gd.wasCanceled()) { return DONE; } if (!enlarge) flags |= KEEP_PREVIEW; // standard filter without enlarge else if (imp.getStackSize() == 1) flags |= NO_CHANGES; // undoable as a "compound filter" return IJ.setupDialog(imp, flags); }
/** * Called by the PlugInFilterRunner after setup. Asks the user in case of a stack and prepares a * separate ouptut stack if required */ public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { this.pfr = pfr; int width = imp.getWidth(); int height = imp.getHeight(); // ask whether to process all slices of stack & prepare stack // (if required) for writing into it in parallel threads flags = IJ.setupDialog(imp, flags); if ((flags & DOES_STACKS) != 0 && outImageType != BYTE_OVERWRITE) { outStack = new ImageStack(width, height, imp.getStackSize()); maxFinder.setNPasses(imp.getStackSize()); } return flags; } // public int showDialog