Java Code Examples for ij.gui.GenericDialog#getChoices()
The following examples show how to use
ij.gui.GenericDialog#getChoices() .
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: DrawTableValuesPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean dialogItemChanged(GenericDialog gd, AWTEvent evt) { if (gd.wasCanceled() || gd.wasOKed()) { return true; } @SuppressWarnings({ "unchecked" }) Vector<Choice> choices = gd.getChoices(); if (choices == null) { IJ.log("empty choices array..."); return false; } // Change of the data table if (evt.getSource() == choices.get(0)) { String tableName = ((Choice) evt.getSource()).getSelectedItem(); Frame tableFrame = WindowManager.getFrame(tableName); this.table = ((TextWindow) tableFrame).getTextPanel().getResultsTable(); // Choose current headings String[] headings = this.table.getHeadings(); replaceStrings(choices.get(1), headings, chooseDefaultHeading(headings, xPosHeaderName)); replaceStrings(choices.get(2), headings, chooseDefaultHeading(headings, yPosHeaderName)); replaceStrings(choices.get(3), headings, chooseDefaultHeading(headings, valueHeaderName)); } return true; }
Example 2
Source File: ThresholderOrbit.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
void convertStack(ImagePlus imp) { if (imp.getStack().isVirtual()) { IJ.error("Thresholder", "This command does not work with virtual stacks.\nUse Image>Duplicate to convert to a normal stack."); return; } boolean thresholdSet = imp.getProcessor().getMinThreshold()!=ImageProcessor.NO_THRESHOLD; this.imp = imp; if (!IJ.isMacro()) { method = staticMethod; background = staticBackground; useLocal = staticUseLocal; if (!thresholdSet) updateThreshold(imp); } if (thresholdSet) useLocal = false; GenericDialog gd = new GenericDialog("Convert Stack to Binary"); gd.addChoice("Method:", methods, method); gd.addChoice("Background:", backgrounds, background); gd.addCheckbox("Calculate threshold for each image", useLocal); gd.addCheckbox("Black background (mask)", Prefs.blackBackground); choices = gd.getChoices(); ((Choice)choices.elementAt(0)).addItemListener(this); ((Choice)choices.elementAt(1)).addItemListener(this); gd.showDialog(); if (gd.wasCanceled()) return; this.imp = null; method = gd.getNextChoice(); background = gd.getNextChoice(); useLocal = gd.getNextBoolean(); boolean saveBlackBackground = Prefs.blackBackground; Prefs.blackBackground = gd.getNextBoolean(); if (!IJ.isMacro()) { staticMethod = method; staticBackground = background; staticUseLocal = useLocal; } Undo.reset(); if (useLocal) convertStackToBinary(imp); else applyThreshold(imp); Prefs.blackBackground = saveBlackBackground; }
Example 3
Source File: LabelToValuePlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean dialogItemChanged(GenericDialog gd, AWTEvent evt) { if (gd.wasCanceled() || gd.wasOKed()) { return true; } @SuppressWarnings("rawtypes") Vector choices = gd.getChoices(); if (choices == null) { IJ.log("empty choices array..."); return false; } // Change of the data table if (evt.getSource() == choices.get(0)) { String tableName = ((Choice) evt.getSource()).getSelectedItem(); Frame tableFrame = WindowManager.getFrame(tableName); this.table = ((TextWindow) tableFrame).getTextPanel().getResultsTable(); // Choose current heading String[] headings = this.table.getHeadings(); String defaultHeading = headings[0]; if (defaultHeading.equals("Label") && headings.length > 1) { defaultHeading = headings[1]; } Choice headingChoice = (Choice) choices.get(1); headingChoice.removeAll(); for (String heading : headings) { headingChoice.add(heading); } headingChoice.select(defaultHeading); changeColumnHeader(defaultHeading); } // Change of the column heading if (evt.getSource() == choices.get(1)) { String headerName = ((Choice) evt.getSource()).getSelectedItem(); changeColumnHeader(headerName); } return true; }
Example 4
Source File: BoundingBoxGUI.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
/** * Query the necessary parameters for the bounding box * * @param fusion - the fusion for which the bounding box is computed, can be null * @param imgExport - the export module used, can be null * @return */ public boolean queryParameters( final Fusion fusion, final ImgExport imgExport, final boolean allowModifyDimensions ) { final boolean compress = fusion == null ? false : fusion.compressBoundingBoxDialog(); final boolean supportsDownsampling = fusion == null ? false : fusion.supportsDownsampling(); final boolean supports16BitUnsigned = fusion == null ? false : fusion.supports16BitUnsigned(); final GenericDialog gd = getSimpleDialog( compress, allowModifyDimensions ); if ( !compress ) gd.addMessage( "" ); if ( supportsDownsampling ) gd.addSlider( "Downsample fused dataset", 1.0, 10.0, BoundingBoxGUI.staticDownsampling ); if ( supports16BitUnsigned ) gd.addChoice( "Pixel_type", pixelTypes, pixelTypes[ defaultPixelType ] ); if ( fusion != null && imgExport != null ) gd.addChoice( "ImgLib2_container", imgTypes, imgTypes[ defaultImgType ] ); if ( fusion != null ) fusion.queryAdditionalParameters( gd ); if ( imgExport != null ) imgExport.queryAdditionalParameters( gd, spimData ); gd.addMessage( "Estimated size: ", GUIHelper.largestatusfont, GUIHelper.good ); Label l1 = (Label)gd.getMessage(); gd.addMessage( "???x???x??? pixels", GUIHelper.smallStatusFont, GUIHelper.good ); Label l2 = (Label)gd.getMessage(); final ManageListeners m = new ManageListeners( gd, gd.getNumericFields(), gd.getChoices(), l1, l2, fusion, imgExport, supportsDownsampling, supports16BitUnsigned ); if ( fusion != null ) fusion.registerAdditionalListeners( m ); m.update(); gd.showDialog(); if ( gd.wasCanceled() ) return false; if ( allowModifyDimensions ) { this.min[ 0 ] = (int)Math.round( gd.getNextNumber() ); this.min[ 1 ] = (int)Math.round( gd.getNextNumber() ); this.min[ 2 ] = (int)Math.round( gd.getNextNumber() ); this.max[ 0 ] = (int)Math.round( gd.getNextNumber() ); this.max[ 1 ] = (int)Math.round( gd.getNextNumber() ); this.max[ 2 ] = (int)Math.round( gd.getNextNumber() ); } else { setNFIndex( gd, 6 ); } if ( supportsDownsampling ) this.downsampling = BoundingBoxGUI.staticDownsampling = (int)Math.round( gd.getNextNumber() ); else this.downsampling = 1; if ( supports16BitUnsigned ) this.pixelType = BoundingBoxGUI.defaultPixelType = gd.getNextChoiceIndex(); else this.pixelType = BoundingBoxGUI.defaultPixelType = 0; //32-bit if ( fusion != null && imgExport != null ) this.imgtype = BoundingBoxGUI.defaultImgType = gd.getNextChoiceIndex(); if ( min[ 0 ] > max[ 0 ] || min[ 1 ] > max[ 1 ] || min[ 2 ] > max[ 2 ] ) { IOFunctions.println( "Invalid coordinates, min cannot be larger than max" ); return false; } if ( fusion != null ) if ( !fusion.parseAdditionalParameters( gd ) ) return false; if ( imgExport != null ) if ( !imgExport.parseAdditionalParameters( gd, spimData ) ) return false; BoundingBoxGUI.defaultMin[ 0 ] = min[ 0 ]; BoundingBoxGUI.defaultMin[ 1 ] = min[ 1 ]; BoundingBoxGUI.defaultMin[ 2 ] = min[ 2 ]; BoundingBoxGUI.defaultMax[ 0 ] = max[ 0 ]; BoundingBoxGUI.defaultMax[ 1 ] = max[ 1 ]; BoundingBoxGUI.defaultMax[ 2 ] = max[ 2 ]; return true; }
Example 5
Source File: SnippetCreator.java From Scripts with GNU General Public License v3.0 | 4 votes |
@Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { final Object source = (e == null) ? null : e.getSource(); final Vector<?> choices = gd.getChoices(); final Vector<?> fields = gd.getStringFields(); final Button[] buttons = gd.getButtons(); final Choice fChoice = (Choice) choices.elementAt(0); final TextField fField = (TextField) fields.elementAt(0); final Button okButton = buttons[0]; sFilename = gd.getNextString(); sType = gd.getNextChoiceIndex(); infoMsg = (MultiLineLabel) gd.getMessage(); // Populate text area if (source == fChoice) { String header = ""; switch (sType) { case BSH: header = bshHeader(); break; case CLJ: header = cljHeader(); break; case GRV: header = grvHeader(); break; case IJM: header = ijmHeader(); break; case JS: header = jsHeader(); break; case PY: header = pyHeader(); break; case RB: header = rbHeader(); break; } if (header != "") appendToTextArea(header); // Ensure adequate filename extension if (!sFilename.endsWith(S_EXTS[sType])) { final int index = sFilename.lastIndexOf("."); if (index > -1) sFilename = sFilename.substring(0, index); sFilename += S_EXTS[sType]; fField.setText(sFilename); } } // Adjust labels and fields final File f = new File(Utils.getMyRoutinesDir() + sFilename); final boolean invalidName = invalidFilename(sFilename); okButton.setLabel(f.exists() ? "Replace and Open" : " Create and Open "); fField.setForeground((f.exists()||invalidName) ? Color.RED : Color.BLACK); // Adjust messages final StringBuilder sb = new StringBuilder(); if (invalidName) { sb.append("\nInvalid Filename"); } else if (f.exists()) { sb.append("File already exists in BAR/My_Routines!"); } else if (sFilename.indexOf("_") == -1) { sb.append("\nFile does not contain an underscore"); sb.append("\nand will not be listed in the BAR Menu."); } else { sb.append("\nFile will be listed in the BAR Menu."); } infoMsg.setText(sb.toString()); infoMsg.setForeground(Color.DARK_GRAY); return !invalidName; }