Java Code Examples for ij.gui.GenericDialog#addHelp()
The following examples show how to use
ij.gui.GenericDialog#addHelp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnalyzeSkeleton_.java From AnalyzeSkeleton with GNU General Public License v3.0 | 6 votes |
private void createSettingsDialog() { settingsDialog = new GenericDialog("Analyze Skeleton"); Font headerFont = new Font("SansSerif", Font.BOLD, 12); settingsDialog.setInsets(0, 0, 0); settingsDialog.addMessage("Elimination of Loops:", headerFont); settingsDialog.addChoice("Prune cycle method: ", AnalyzeSkeleton_.pruneCyclesModes, AnalyzeSkeleton_.pruneCyclesModes[pruneIndex]); settingsDialog.setInsets(20, 0, -15); //default top inset for 1st checkbox is 15 settingsDialog.addMessage("Elimination of End-points:", headerFont); settingsDialog.addCheckbox("Prune ends", pruneEnds); settingsDialog.addCheckbox("Exclude ROI from pruning", protectRoi); settingsDialog.setInsets(20, 0, 0); //default top inset for subsequent checkboxes is 0 settingsDialog.addMessage("Results and Output:", headerFont); settingsDialog.addCheckbox("Calculate largest shortest path", calculateShortestPath); settingsDialog.addCheckbox("Show detailed info", verbose); settingsDialog.addCheckbox("Display labeled skeletons", displaySkeletons); settingsDialog.addHelp(HELP_URL); dialogItemChanged(settingsDialog, null); }
Example 2
Source File: ShenCastan.java From Scripts with GNU General Public License v3.0 | 6 votes |
/** Displays the dialog prompt. */ @Override public int showDialog(final ImagePlus imp, final String command, final PlugInFilterRunner pfr) { this.pfr = pfr; final String msg = "<html><div WIDTH=350>" + "<a href='https://github.com/tferr/Scripts/blob/master/Segmentation/README.md#shen-castan-edge-detector'>" + "Shen-Castan</a> filtering is an edge detection technique. It is an alternative " + "to other popular approaches such as " + "<a href='http://en.wikipedia.org/wiki/Canny_edge_detector'>Canny</a>-" + "<a href='http://en.wikipedia.org/wiki/Deriche_edge_detector'>Deriche</a> filtering.</p>" + "<p>The Shen-Castan coefficient corresponds to a smooting factor <i>alpha</i>. " + "<i>Alpha</i> can vary between 0 (high smoothing, suitable for noisy images) " + "and 1 (no smoothing, suitable for non-noisy images).</p></div></html>"; final GenericDialog gd = new GenericDialog(command); gd.addSlider("Coefficient:", 0.0001d, 1.0001d, f); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.addHelp(msg); gd.showDialog(); if (gd.wasCanceled() || !dialogItemChanged(gd, null)) // read parameters return DONE; return IJ.setupDialog(imp, flags); }
Example 3
Source File: BinaryOrbit.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
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 (!imp.getProcessor().isBinary()) { IJ.error("8-bit binary (black and white only) image required."); return DONE; } return IJ.setupDialog(imp, flags); } }
Example 4
Source File: ChamferDistanceMapPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { // Store user data this.imagePlus = imp; this.baseImage = imp.getProcessor().duplicate(); this.pfr = pfr; // Create a new generic dialog with appropriate options GenericDialog gd = new GenericDialog("Chamfer Distance Map"); gd.addChoice("Distances", ChamferWeights.getAllLabels(), ChamferWeights.BORGEFORS.toString()); String[] outputTypes = new String[]{"32 bits", "16 bits"}; gd.addChoice("Output Type", outputTypes, outputTypes[0]); gd.addCheckbox("Normalize weights", true); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); previewing = true; gd.addHelp("https://imagej.net/MorphoLibJ"); gd.showDialog(); previewing = false; // test cancel if (gd.wasCanceled()) return DONE; // set up current parameters String weightLabel = gd.getNextChoice(); floatProcessing = gd.getNextChoiceIndex() == 0; normalize = gd.getNextBoolean(); // identify which weights should be used weights = ChamferWeights.fromLabel(weightLabel); return flags; }
Example 5
Source File: MorphologicalFilterPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { // Normal setup this.imagePlus = imp; this.baseImage = imp.getProcessor().duplicate(); // Create the configuration dialog GenericDialog gd = new GenericDialog("Morphological Filters"); gd.addChoice("Operation", Operation.getAllLabels(), this.op.toString()); gd.addChoice("Element", Strel.Shape.getAllLabels(), this.shape.toString()); gd.addNumericField("Radius (in pixels)", this.radius, 0); gd.addCheckbox("Show Element", false); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); previewing = true; gd.addHelp("http://imagej.net/MorphoLibJ#Morphological_filters"); gd.showDialog(); previewing = false; if (gd.wasCanceled()) { resetPreview(); return DONE; } parseDialogParameters(gd); // clean up an return gd.dispose(); return flags; }
Example 6
Source File: RegionalMinAndMaxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { // Normal setup this.imagePlus = imp; this.baseImage = imp.getProcessor().duplicate(); // Create the configuration dialog GenericDialog gd = new GenericDialog("Regional Min & Max"); gd.addChoice("Operation", Operation.getAllLabels(), Operation.REGIONAL_MINIMA.label); gd.addChoice("Connectivity", connectivityLabels, connectivityLabels[0]); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); previewing = true; gd.addHelp("https://imagej.net/MorphoLibJ"); gd.showDialog(); previewing = false; if (gd.wasCanceled()) return DONE; parseDialogParameters(gd); // clean up an return gd.dispose(); return flags; }
Example 7
Source File: ExtendedMinAndMaxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { // Normal setup this.imagePlus = imp; this.baseImage = imp.getProcessor().duplicate(); // Create the configuration dialog GenericDialog gd = new GenericDialog("Extended Min & Max"); gd.addChoice("Operation", Operation.getAllLabels(), Operation.EXTENDED_MINIMA.label); boolean isGray8 = (this.baseImage instanceof ByteProcessor); double minValue = isGray8 ? 1 : this.baseImage.getMin(); double maxValue = isGray8 ? 255 : this.baseImage.getMax(); gd.addSlider("Dynamic", minValue, maxValue, 10); gd.addChoice("Connectivity", connectivityLabels, connectivityLabels[0]); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); previewing = true; gd.addHelp("https://imagej.net/MorphoLibJ"); gd.showDialog(); previewing = false; if (gd.wasCanceled()) { return DONE; } parseDialogParameters(gd); // clean up an return gd.dispose(); return flags; }
Example 8
Source File: Commander.java From Scripts with GNU General Public License v3.0 | 5 votes |
void showOptionsDialog() { log("Prompting for options..."); final GenericDialog gd = new GenericDialog("Commander Preferences", frame); gd.addNumericField("Maximum number of items in file list", maxSize, 0); gd.addCheckbox("Hide Commander after opening a file", hideOnOpen); gd.addCheckbox("Open IJM files in ImageJ 1 (legacy) editor", ijmLegacy); gd.addCheckbox("Enable Tooltips (toggling requires a restart)", tooltips); gd.addMessage(""); gd.addCheckbox("Clear Favorites", false); gd.addCheckbox("Clear Recent folders", false); gd.addCheckbox("Clear Saved searches", false); gd.enableYesNoCancel("OK", "Defaults..."); gd.addHelp(helpMessage()); gd.showDialog(); if (gd.wasCanceled()) { log("Prompt dismissed..."); return; } else if (gd.wasOKed()) { maxSize = (int) Math.max(1, gd.getNextNumber()); hideOnOpen = gd.getNextBoolean(); ijmLegacy = gd.getNextBoolean(); tooltips = gd.getNextBoolean(); if (gd.getNextBoolean()) clearBookmarks(); if (gd.getNextBoolean()) clearRecentPaths(); if (gd.getNextBoolean()) clearSearches(); } else { clearPreferences(); } updateList(); }
Example 9
Source File: RankFiltersOrbit.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { if (filterType == DESPECKLE) { filterType = MEDIAN; radius = 1.0; } else { GenericDialog gd = new GenericDialog(command+"..."); radius = lastRadius[filterType]<=0 ? 2 : lastRadius[filterType]; gd.addNumericField("Radius", radius, 1, 6, "pixels"); int digits = imp.getType() == ImagePlus.GRAY32 ? 2 : 0; if (filterType==OUTLIERS) { gd.addNumericField("Threshold", lastThreshold, digits); gd.addChoice("Which outliers", outlierStrings, outlierStrings[lastWhichOutliers]); gd.addHelp(IJ.URL+"/docs/menus/process.html#outliers"); } else if (filterType==REMOVE_NAN) gd.addHelp(IJ.URL+"/docs/menus/process.html#nans"); gd.addPreviewCheckbox(pfr); //passing pfr makes the filter ready for preview gd.addDialogListener(this); //the DialogItemChanged method will be called on user input gd.showDialog(); //display the dialog; preview runs in the now if (gd.wasCanceled()) return DONE; IJ.register(this.getClass()); //protect static class variables (filter parameters) from garbage collection if (Macro.getOptions() == null) { //interactive only: remember parameters entered lastRadius[filterType] = radius; if (filterType == OUTLIERS) { lastThreshold = threshold; lastWhichOutliers = whichOutliers; } } } this.pfr = pfr; flags = IJ.setupDialog(imp, flags); //ask whether to process all slices of stack (if a stack) if ((flags&DOES_STACKS)!=0) { int size = imp.getWidth() * imp.getHeight(); Roi roi = imp.getRoi(); if (roi != null) { Rectangle roiRect = roi.getBounds(); size = roiRect.width * roiRect.height; } double workToDo = size*(double)radius; //estimate computing time (arb. units) if (filterType==MEAN || filterType==VARIANCE) workToDo *= 0.5; else if (filterType==MEDIAN) workToDo *= radius*0.5; if (workToDo < 1e6 && imp.getImageStackSize()>=numThreads) { numThreads = 1; //for fast operations, avoid overhead of multi-threading in each image flags |= PARALLELIZE_STACKS; } } return flags; }
Example 10
Source File: DistanceTransformWatershed.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public int showDialog( ImagePlus imp, String command, PlugInFilterRunner pfr ) { if( !BinaryImages.isBinaryImage( imp ) ) { IJ.error( "Distance Transform Watershed", "Input image is not" + " binary (8-bit with only 0 or 255 values)" ); return DONE; } // Store user data this.imagePlus = imp; this.baseImage = imp.getProcessor().duplicate(); this.pfr = pfr; // Create a new generic dialog with appropriate options GenericDialog gd = new GenericDialog( "Distance Transform Watershed" ); gd.setInsets( 0, 0, 0 ); gd.addMessage( "Distance map options:", new Font( "SansSerif", Font.BOLD, 12 ) ); gd.addChoice( "Distances", ChamferWeights.getAllLabels(), weightLabel ); String[] outputTypes = new String[]{"32 bits", "16 bits"}; gd.addChoice( "Output Type", outputTypes, outputTypes[ floatProcessing ? 0:1 ]); gd.setInsets( 0, 0, 0 ); gd.addCheckbox( "Normalize weights", normalize ); gd.setInsets( 20, 0, 0 ); gd.addMessage( "Watershed options:", new Font( "SansSerif", Font.BOLD, 12 ) ); gd.addNumericField( "Dynamic", dynamic, 2 ); gd.addChoice( "Connectivity", Conn2D.getAllLabels(), connLabel ); gd.setInsets( 20, 0, 0 ); gd.addPreviewCheckbox( pfr ); gd.addDialogListener(this); previewing = true; gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" ); gd.showDialog(); previewing = false; // test cancel if (gd.wasCanceled()) return DONE; // set up current parameters weightLabel = gd.getNextChoice(); floatProcessing = gd.getNextChoiceIndex() == 0; normalize = gd.getNextBoolean(); dynamic = (int) gd.getNextNumber(); connLabel = gd.getNextChoice(); connectivity = Conn2D.fromLabel( connLabel ).getValue(); // identify which weights should be used weights = ChamferWeights.fromLabel( weightLabel ); return flags; }
Example 11
Source File: DistanceTransformWatershed3D.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Plugin run method */ public void run(String arg) { ImagePlus image = WindowManager.getCurrentImage(); if ( image == null ) { IJ.error("Distance Transform Watershed 3D", "Need at least one image to work"); return; } if( !BinaryImages.isBinaryImage( image ) ) { IJ.error( "Distance Transform Watershed 3D", "Input image is not" + " binary (8-bit with only 0 or 255 values)" ); } // Create a new generic dialog with appropriate options GenericDialog gd = new GenericDialog( "Distance Transform Watershed 3D" ); gd.setInsets( 0, 0, 0 ); gd.addMessage( "Distance map options:", new Font( "SansSerif", Font.BOLD, 12 ) ); gd.addChoice( "Distances", ChamferWeights3D.getAllLabels(), weightLabel ); String[] outputTypes = new String[]{"32 bits", "16 bits"}; gd.addChoice( "Output Type", outputTypes, outputTypes[ floatProcessing ? 0:1 ]); gd.setInsets( 0, 0, 0 ); gd.addCheckbox( "Normalize weights", normalize ); gd.setInsets( 20, 0, 0 ); gd.addMessage( "Watershed options:", new Font( "SansSerif", Font.BOLD, 12 ) ); gd.addNumericField( "Dynamic", dynamic, 2 ); gd.addChoice( "Connectivity", Conn3D.getAllLabels(), connectivity.label ); gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" ); gd.showDialog(); // test cancel if ( gd.wasCanceled() ) return; // set up current parameters weightLabel = gd.getNextChoice(); floatProcessing = gd.getNextChoiceIndex() == 0; normalize = gd.getNextBoolean(); dynamic = (int) gd.getNextNumber(); connectivity = Conn3D.fromLabel( gd.getNextChoice() ); // identify which weights should be used weights = ChamferWeights3D.fromLabel( weightLabel ); long t0 = System.currentTimeMillis(); final ImagePlus result; if (floatProcessing) result = processFloat( image, weights.getFloatWeights(), normalize ); else result = processShort( image, weights.getShortWeights(), normalize ); Images3D.optimizeDisplayRange( result ); // Display the result image result.show(); result.setSlice( image.getCurrentSlice() ); // Display elapsed time long t1 = System.currentTimeMillis(); IJUtils.showElapsedTime( "Distance Transform Watershed 3D", t1 - t0, image ); }
Example 12
Source File: InteractivePlotter.java From Scripts with GNU General Public License v3.0 | 4 votes |
private void setPlotOptions() { if (plot == null) return; final int DEF_LINE_WIDTH = 1; final int DEF_MAX_INTERVALS = 12; final int DEF_TICK_LENGTH = 7; final int DEF_MINOR_TICK_LENGTH = 3; final int[] NUM_DEFAULTS = { DEF_LINE_WIDTH, DEF_MAX_INTERVALS, DEF_TICK_LENGTH, DEF_MINOR_TICK_LENGTH }; final String DEF_BACKGROUND_COLOR = "white"; final String title = plot.getTitle(); final GenericDialog ogd = new GenericDialog("Options for " + title); ogd.setInsets(0, 10, 10); ogd.addMessage("This prompt allows you access customizations that\n" + "are not accessible through the plot's \"More \u00bb\" menu"); if (!pwClosed) ogd.addStringField("Plot title:", title, 27); ogd.addSlider("Line width:", 1, 20, 1); ogd.addSlider("Max. n. of intervals:", 1, 40, 12); ogd.addSlider("Major ticks length:", 1, 14, 7); ogd.addSlider("Minor ticks length:", 1, 14, 3); ogd.addChoice("Backgrond color:", Colors.colors, DEF_BACKGROUND_COLOR); final Panel buttonPanel = new Panel(); final Button fontButton = new Button(" Text & Font... "); fontButton.addActionListener(ogd); buttonPanel.add(fontButton); final Button templateButton = new Button("Apply Template..."); templateButton.addActionListener(ogd); buttonPanel.add(templateButton); ogd.addPanel(buttonPanel, GridBagConstraints.EAST, new Insets(0, 0, 0, 0)); ogd.hideCancelButton(); ogd.addHelp(""); ogd.setHelpLabel("Apply Defaults"); ogd.addDialogListener(new DialogListener() { @Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { if (e != null && e.toString().contains("Apply Defaults")) { @SuppressWarnings("unchecked") final Vector<TextField> nFields = gd.getNumericFields(); for (final TextField field : nFields) field.setText(Integer.toString(NUM_DEFAULTS[nFields.indexOf(field)])); @SuppressWarnings("unchecked") final Vector<Choice> nChoices = gd.getChoices(); nChoices.firstElement().select(DEF_BACKGROUND_COLOR); } else if (e != null && e.toString().contains("Font")) { setPlotFont(); return true; } else if (e != null && e.toString().contains("Template")) { setTemplate(); return true; } plot.setLineWidth((int) ogd.getNextNumber()); plot.setMaxIntervals((int) ogd.getNextNumber()); plot.setTickLength((int) ogd.getNextNumber()); plot.setBackgroundColor(Colors.colors[ogd.getNextChoiceIndex()]); plot.updateImage(); return true; } }); showAsSubDialog(ogd); if (!ogd.wasOKed()) return; if (!pwClosed) plot.getImagePlus().setTitle(WindowManager.makeUniqueName(ogd.getNextString())); }
Example 13
Source File: InteractivePlotter.java From Scripts with GNU General Public License v3.0 | 4 votes |
private void setPlotFont() { if (plot == null) return; final String[] FONTS = new String[] { Font.SANS_SERIF, Font.MONOSPACED, Font.SERIF }; final String[] STYLES = { "Plain", "Bold", "Italic", "Bold+Italic" }; final String[] JUSTIFICATIONS = { "Left", "Center", "Right" }; final String[] SCOPES = { "Plot", "Both Axes Titles", "X-axis Title", "Y-axis Title" }; final String[] CHOICE_DEFAULTS = { FONTS[0], STYLES[0], JUSTIFICATIONS[0], SCOPES[0] }; final int[] INT_STYLES = { Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD + Font.ITALIC }; final int[] INT_JUSTIFICATIONS = { Plot.LEFT, Plot.CENTER, Plot.RIGHT }; final int DEF_SIZE = 12; final boolean DEF_ANTIALISED = true; final GenericDialog fgd = new GenericDialog("Font Options"); fgd.addChoice("Type:", FONTS, CHOICE_DEFAULTS[0]); fgd.addChoice("Style:", STYLES, CHOICE_DEFAULTS[1]); fgd.addChoice("Justification:", JUSTIFICATIONS, CHOICE_DEFAULTS[2]); fgd.addSlider("Size:", 9, 24, DEF_SIZE); fgd.setInsets(0, 20, 15); fgd.addCheckbox("Antialiased text", DEF_ANTIALISED); fgd.addChoice("Apply to:", SCOPES, CHOICE_DEFAULTS[3]); fgd.hideCancelButton(); fgd.addHelp(""); fgd.setHelpLabel("Apply Defaults"); fgd.addDialogListener(new DialogListener() { @Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { if (e != null && e.toString().contains("Apply Defaults")) { @SuppressWarnings("unchecked") final Vector<Choice> nChoices = gd.getChoices(); for (final Choice choice : nChoices) choice.select(CHOICE_DEFAULTS[nChoices.indexOf(choice)]); ((TextField) gd.getNumericFields().get(0)).setText(Integer.toString(DEF_SIZE)); ((Checkbox) gd.getCheckboxes().get(0)).setState(DEF_ANTIALISED); } final String type = FONTS[fgd.getNextChoiceIndex()]; final int style = INT_STYLES[fgd.getNextChoiceIndex()]; final int justification = INT_JUSTIFICATIONS[fgd.getNextChoiceIndex()]; final int size = (int) fgd.getNextNumber(); final int scopeIdx = fgd.getNextChoiceIndex(); plot.setJustification(justification); plot.setAntialiasedText(fgd.getNextBoolean()); final Font font = new Font(type, style, size); switch (scopeIdx) { case 1: // SCOPES[1] plot.setXLabelFont(font); plot.setYLabelFont(font); break; case 2: // SCOPES[2] plot.setXLabelFont(font); break; case 3: // SCOPES[3] plot.setYLabelFont(font); break; default: plot.setFont(font); plot.setXLabelFont(font); plot.setYLabelFont(font); break; } plot.updateImage(); return true; } }); showAsSubDialog(fgd); if (!fgd.wasOKed()) return; }