@Override protected GenericDialog constructDialog() { final long needMB = needMem / 1048576; final long availMB = availMem / 1048576; GenericDialog gd = new GenericDialog("Bio-Formats Memory Usage"); gd.addMessage("Warning: It will require approximately " + needMB + " MB to open this dataset.\nHowever, only " + availMB + " MB is currently available. You may receive an error\n" + "message about insufficient memory. Are you sure you want to proceed?"); return gd; }
/** Displays a message in a dialog box with the specified title. Returns false if the user pressed "Cancel". */ public static boolean showMessageWithCancel(String title, String msg) { GenericDialog gd = new GenericDialog(title); gd.addMessage(msg); gd.showDialog(); return !gd.wasCanceled(); }
public static void main(String[] args) { //new FileListDatasetDefinition().createDataset(); //new WildcardFileListChooser().getFileList().forEach( f -> System.out.println( f.getAbsolutePath() ) ); GenericDialog gd = new GenericDialog( "A" ); gd.addMessage( getColoredHtmlFromPattern( "a{b}c{d}e{aaaaaaaaaa}aa{bbbbbbbbbbbb}ccccc{ddddddd}", true ) ); System.out.println( getColoredHtmlFromPattern( "a{b}c{d}e", false ) ); gd.showDialog(); }
/** Creates a new Layer asking for z and thickness, and adds it to the parent and returns it. Returns null if the dialog was canceled.*/ static public Layer create(final Project project, final LayerSet parent) { if (null == parent) return null; final GenericDialog gd = ControlWindow.makeGenericDialog("New Layer"); gd.addMessage("In pixels:"); // TODO set elsewhere the units! gd.addNumericField("z coordinate: ", 0.0D, 3); gd.addNumericField("thickness: ", 1.0D, 3); gd.showDialog(); if (gd.wasCanceled()) return null; try { final double z = gd.getNextNumber(); final double thickness = gd.getNextNumber(); if (Double.isNaN(z) || Double.isNaN(thickness)) return null; final Layer layer = new Layer(project, z, thickness, parent); parent.add(layer); parent.recreateBuckets(layer, true); return layer; } catch (final Exception e) {} return null; }
/** Displays a message in a dialog box with the specified title. Returns false if the user pressed "Cancel". */ public static boolean showMessageWithCancel(String title, String msg) { GenericDialog gd = new GenericDialog(title); gd.addMessage(msg); gd.showDialog(); return !gd.wasCanceled(); }
private static void cancel() { boolean ok; final GenericDialog gd = new GenericDialog("Cancel?"); gd.addMessage("Really Cancel?"); gd.showDialog(); ok = gd.wasOKed(); if (ok) { clear(); } }
@Override protected GenericDialog constructDialog() { final long needMB = needMem / 1048576; final long availMB = availMem / 1048576; GenericDialog gd = new GenericDialog("Bio-Formats Memory Usage"); gd.addMessage("Warning: It will require approximately " + needMB + " MB to open this dataset.\nHowever, only " + availMB + " MB is currently available. You may receive an error\n" + "message about insufficient memory. Are you sure you want to proceed?"); return gd; }
/** Create a new LayerSet in the middle of the parent Layer. */ public LayerSet create(Layer parent_layer) { if (null == parent_layer) return null; GenericDialog gd = ControlWindow.makeGenericDialog("New Layer Set"); gd.addMessage("In pixels:"); gd.addNumericField("width: ", this.layer_width, 3); gd.addNumericField("height: ", this.layer_height, 3); gd.showDialog(); if (gd.wasCanceled()) return null; try { float width = (float)gd.getNextNumber(); float height = (float)gd.getNextNumber(); if (Double.isNaN(width) || Double.isNaN(height)) return null; if (0 == width || 0 == height) { Utils.showMessage("Cannot accept zero width or height for LayerSet dimensions."); return null; } // make a new LayerSet with x,y in the middle of the parent_layer return new LayerSet(project, "Layer Set", parent_layer.getParent().getLayerWidth() / 2, parent_layer.getParent().getLayerHeight() / 2, parent_layer, width/2, height/2); } catch (Exception e) { Utils.log("LayerSet.create: " + e); } return null; }
int showOptionDialog(int w1, int h1,int w, int h) { String[] options = new String[]{"inserting a cropped image", "inserting a reduced size image", "resizing the destination stack by adding border pixels", "resizing the destination stack by scaling it up"}; GenericDialog gd = new GenericDialog("Options"); gd.addMessage("The image does not fit. Source: "+w1+"x"+h1+" pixels. Dest.: "+w+"x"+h+" pixels."); gd.addChoice("Adjust by", options, options[0]); gd.showDialog(); if (gd.wasCanceled()) return QUIT; return gd.getNextChoiceIndex(); } public void windowClosing(WindowEvent e) {
public void actionPerformed(ActionEvent actionEvent) { GenericDialog gd = new GenericDialog("Sure?"); gd.addMessage("Are You Sure?"); gd.showDialog(); if (gd.wasOKed()) { watcher.cancel(); frame.dispose(); } } }
private boolean GUI() { GenericDialog gd = new GenericDialog("Lipschitz filter v"+Lipschitz_Version); gd.addNumericField("Slope", m_Slope, 2); String[] labels = {"TopDown", "TopHat"}; boolean[] values = {m_Down, m_TopHat}; gd.addCheckboxGroup(1, 2, labels, values); gd.addMessage("Incorrect values will be replaced by defaults.\nLabels are drawn in the foreground color.\nPress Esc to stop processing."); return getUserParams(gd); }// end of 'GUI' method
public void rename(final ProjectThing thing) { final Object ob = thing.getObject(); final String old_title; if (null == ob) old_title = thing.getType(); else if (ob instanceof DBObject) old_title = ((DBObject)ob).getTitle(); else old_title = ob.toString(); GenericDialog gd = ControlWindow.makeGenericDialog("New name"); gd.addMessage("Old name: " + old_title); gd.addStringField("New name: ", old_title, 40); gd.showDialog(); if (gd.wasCanceled()) return; String title = gd.getNextString(); if (null == title) { Utils.log("WARNING: avoided setting the title to null for " + thing); return; } title = title.replace('"', '\'').trim(); // avoid XML problems - could also replace by double '', then replace again by " when reading. project.getRootLayerSet().addUndoStep(new RenameThingStep(thing)); if (title.length() == 0) { // Set the title to the template type thing.setTitle(thing.getTemplate().getType()); return; } thing.setTitle(title); this.updateUILater(); project.getRootLayerSet().addUndoStep(new RenameThingStep(thing)); }
int showDialog(String[] versions) { GenericDialog gd = new GenericDialog("ImageJ Updater 2"); gd.addChoice("Upgrade To:", versions, versions[0]); String msg = "You are currently running v"+ImageJ.VERSION+ImageJ.BUILD+".\n"+ " \n"+ "If you click \"OK\", ImageJ will quit\n"+ "and you will be running the upgraded\n"+ "version after you restart ImageJ.\n"; gd.addMessage(msg); gd.showDialog(); if (gd.wasCanceled()) return -1; else return gd.getNextChoiceIndex(); }
@Override public void keyPressed(final KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_F1) { final GenericDialog gd = new GenericDialog("Help :: image filters"); gd.addMessage( "In the table 'Available Filters':\n" + " - double-click a filter to add it to the table of 'Chosen Filters'\n \n" + "In the table 'Chosen Filters':\n" + " - double-click a filter to remove it.\n" + " - PAGE UP/DOWN keys move the filter up/down in the list.\n" + " - 'Delete' key removes the selected filter.\n \n" + "In the table of parameter names and values:\n" + " - double-click a value to edit it. Then push enter to set the new value.\n \n" + "What you need to know:\n" + " - filters are set and applied in order, so order matters.\n" + " - filters with parameters for which you entered a value of zero\nwill result in a warning message.\n" + " - when applying the filters, if you choose 'Selected images', these are the images\nthat were selected when the filter editor was opened.\n" + " - when applying the filters, if you want to filter for a regular expression pattern\nin the image name, use the 'All images in layer range...' option,\nwhere a range of one single layer is also possible." ); gd.hideCancelButton(); gd.setModal(false); gd.showDialog(); } } };
private boolean GUI() { GenericDialog gd = new GenericDialog("Lipschitz filter v"+Lipschitz_Version); gd.addNumericField("Slope", m_Slope, 2); String[] labels = {"TopDown", "TopHat"}; boolean[] values = {m_Down, m_TopHat}; gd.addCheckboxGroup(1, 2, labels, values); gd.addMessage("Incorrect values will be replaced by defaults.\nLabels are drawn in the foreground color.\nPress Esc to stop processing."); return getUserParams(gd); }// end of 'GUI' method
public static boolean downloadJar(String url) { String name = url.substring(url.lastIndexOf("/")+1); boolean ok = false; String msg = name+" was not found in the plugins\nfolder or it is outdated. Click \"OK\" to download\nit from the ImageJ website."; GenericDialog gd = new GenericDialog("Download "+name+"?"); gd.addMessage(msg); gd.showDialog(); if (!gd.wasCanceled()) { ok = (new PluginInstaller()).install(IJ.URL+url); if (!ok) IJ.error("Unable to download "+name+" from "+IJ.URL+url); } return ok; }
private synchronized boolean promptForSave(final String tableTitle) { final GenericDialog gd = new GenericDialog("Unsaved Data"); gd.addMessage("Save measurements in " + tableTitle + "?", new Font("SansSerif", Font.BOLD, 12)); gd.addMessage("Data will be discarded if you dismiss this prompt!", new Font("SansSerif", Font.PLAIN, 12), EnhancedGenericDialog.getDisabledComponentColor()); gd.setCancelLabel("No. Discard measurements"); gd.setOKLabel("Yes. Save to..."); gd.showDialog(); if (gd.wasOKed() && (new MeasurementsWriter()).save("")) { setUnsavedMeasurements(false); } return false; }
@Override protected boolean setUpDefaultValues( final int[] rangeMin, final int[] rangeMax ) { if ( !findRange( spimData, viewIdsToProcess, rangeMin, rangeMax ) ) return false; this.min = rangeMin.clone(); this.max = rangeMax.clone(); if ( defaultMin == null ) defaultMin = min.clone(); if ( defaultMax == null ) defaultMax = max.clone(); final GenericDialog gd = new GenericDialog( getDescription() ); gd.addChoice( "Reorientation", reorientationChoice, reorientationChoice[ defaultReorientate ] ); // ask which detections to use gd.addMessage( "" ); gd.addMessage( "Note: The bounding box is estimated based on detections in the image, choose which ones to use.", new Font( Font.SANS_SERIF, Font.BOLD, 13 ) ); // TODO Auto-generated method stub return false; }
int showDialog(String[] versions) { GenericDialog gd = new GenericDialog("ImageJ Updater 2"); gd.addChoice("Upgrade To:", versions, versions[0]); String msg = "You are currently running v"+ImageJ.VERSION+ImageJ.BUILD+".\n"+ " \n"+ "If you click \"OK\", ImageJ will quit\n"+ "and you will be running the upgraded\n"+ "version after you restart ImageJ.\n"; gd.addMessage(msg); gd.showDialog(); if (gd.wasCanceled()) return -1; else return gd.getNextChoiceIndex(); }
void getMacro(String macro) { String options = Macro.getOptions(); if (options!=null && options.startsWith("v=")) Macro.setOptions("code="+options); gd = new GenericDialog("Expression Evaluator"); gd.addStringField("Code:", macro, 42); gd.setInsets(0,40,0); gd.addMessage("v=pixel value, x,y&z=pixel coordinates, w=image width,\nh=image height, a=angle, d=distance from center\n"); gd.setInsets(5,40,0); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.addHelp(IJ.URL+"/docs/menus/process.html#math-macro"); gd.showDialog(); }