Refine search
boolean getScale() { thresh = (int) Prefs.get("edtS1.thresh", 128); inverse = Prefs.get("edtS1.inverse", false); final GenericDialog gd = new GenericDialog("EDT...", IJ.getInstance()); gd.addNumericField("Threshold (1 to 255; value < thresh is background)", thresh, 0); gd.addCheckbox("Inverse case (background when value >= thresh)", inverse); gd.showDialog(); if (gd.wasCanceled()) return false; thresh = (int) gd.getNextNumber(); inverse = gd.getNextBoolean(); Prefs.set("edtS1.thresh", thresh); Prefs.set("edtS1.inverse", inverse); return true; } }
public static int numThreads() { return Math.max( 1, Prefs.getThreads() ); } }
private void resetOptions() { // Reset plugin parameters Prefs.set(PREFS_KEY, null); currentBooleanPrefs = UNSET_PREFS; Prefs.set(HASHMAP_KEY, null); hashMapString = ""; // Reset Sholl metrics and output options Prefs.set(METRICS_KEY, null); Prefs.set(METRICS_KEY + ".comment", null); Prefs.set(MASK_KEY, null); Prefs.set(MASK_KEY + ".type", null); setPlotOutput(DEFAULT_PLOT_OUTPUT); currentMetrics = UNSET_PREFS; commentString = null; maskBackground = UNSET_PREFS; maskType = UNSET_PREFS; // Reset Analyzer prefs Analyzer.setPrecision(3); Analyzer.setMeasurement(Measurements.SCIENTIFIC_NOTATION, false); // Reset other global IJ prefs Prefs.setThreads(Runtime.getRuntime().availableProcessors()); Prefs.set("options.ext", null); }
minSize=(int) Prefs.get("3D-OC_minSize.double", 10); maxSize=length; excludeOnEdges=Prefs.get("3D-OC_excludeOnEdges.boolean", true); showObj=Prefs.get("3D-OC_showObj.boolean", true); showSurf=Prefs.get("3D-OC_showSurf.boolean", true); showCentro=Prefs.get("3D-OC_showCentro.boolean", true); showCOM=Prefs.get("3D-OC_showCOM.boolean", true); showStat=Prefs.get("3D-OC_showStat.boolean", true); showSummary=Prefs.get("3D-OC_summary.boolean", true); showMaskedImg=Prefs.get("3D-OC-Options_showMaskedImg.boolean", true); closeImg=Prefs.get("3D-OC-Options_closeImg.boolean", false); redirectTo=Prefs.get("3D-OC-Options_redirectTo.string", "none"); redirect=!this.redirectTo.equals("none") && WindowManager.getImage(this.redirectTo)!=null; Prefs.set("3D-OC-Options_redirectTo.string", "none"); Prefs.set("3D-OC-Options_showMaskedImg.boolean", false); Prefs.set("3D-OC_minSize.double", minSize); Prefs.set("3D-OC_excludeOnEdges.boolean", excludeOnEdges); Prefs.set("3D-OC_showObj.boolean", showObj); Prefs.set("3D-OC_showSurf.boolean", showSurf); Prefs.set("3D-OC_showCentro.boolean", showCentro); Prefs.set("3D-OC_showCOM.boolean", showCOM); Prefs.set("3D-OC_showStat.boolean", showStat); Prefs.set("3D-OC_summary.boolean", showSummary); if (!redirect) Prefs.set("3D-OC-Options_redirectTo.string", "none");
public void run(String arg) { imp = IJ.getImage(); if (imp==null) { IJ.noImage(); return; if(imp.getStackSize()==1) { IJ.error("Z Project", "Stack required"); return; if (imp.getProcessor().isInvertedLut()) { if (!IJ.showMessageWithCancel("ZProjection", lutMessage)) return; gd.showDialog(); if (gd.wasCanceled()) return; if (!imp.lock()) return; // exit if in use long tstart = System.currentTimeMillis(); gd.setSmartRecording(true); int startSlice2 = startSlice; int stopSlice2 = stopSlice; gd.setSmartRecording(false); method = gd.getNextChoiceIndex(); Prefs.set(METHOD_KEY, method); if (isHyperstack) allTimeFrames = imp.getNFrames()>1&&imp.getNSlices()>1?gd.getNextBoolean():false;
void changeMemoryAllocation() { IJ.maxMemory(); // forces IJ to cache old limit int max = (int)(getMemorySetting()/1048576L); boolean unableToSet = max==0; if (max==0) max = (int)(maxMemory()/1048576L); String title = "Memory "+(IJ.is64Bit()?"(64-bit)":"(32-bit)"); GenericDialog gd = new GenericDialog(title); gd.addNumericField("Maximum memory:", max, 0, 5, "MB"); gd.addNumericField("Parallel threads:", Prefs.getThreads(), 0, 5, ""); gd.setInsets(12, 0, 0); gd.addCheckbox("Keep multiple undo buffers", Prefs.keepUndoBuffers); if (gd.wasCanceled()) return; int max2 = (int)gd.getNextNumber(); Prefs.setThreads((int)gd.getNextNumber()); Prefs.keepUndoBuffers = gd.getNextBoolean(); Prefs.noClickToGC = !gd.getNextBoolean(); if (gd.invalidNumber()) { IJ.showMessage("Memory", "The number entered was invalid."); return;
void showBrushDialog() { GenericDialog gd = new GenericDialog("Selection Brush"); gd.addCheckbox("Enable selection brush", ovalType==BRUSH_ROI); gd.addNumericField(" Size:", brushSize, 0, 4, "pixels"); gd.showDialog(); if (gd.wasCanceled()) return; if (gd.getNextBoolean()) ovalType = BRUSH_ROI; brushSize = (int)gd.getNextNumber(); if (brushSize<1) brushSize=1; repaintTool(OVAL); ImagePlus img = WindowManager.getCurrentImage(); Roi roi = img!=null?img.getRoi():null; if (roi!=null && roi.getType()==Roi.OVAL && ovalType==BRUSH_ROI) img.deleteRoi(); Prefs.set(BRUSH_SIZE, brushSize); }
final GenericDialog gd = new GenericDialog("Folder Watch Alignment Plugin Settings"); final Button button = new Button("Update Result"); final Panel panel = new Panel(new FlowLayout(FlowLayout.CENTER)); final double pollTime = Prefs.get(POLL_KEY, 30.0); final String regexField = Prefs.get(REGEX_KEY, "Tile.*(tif|tiff|png)$"); final String regexTestField = Prefs.get(REGEX_TEST_KEY, "Tile_r1-c1_Something Something.tif"); final boolean appendField = Prefs.get(APPEND_KEY, "true").equals("true"); Vector stringFields; gd.addNumericField("Section Thickness (pixels)", 1.0, 2); gd.addCheckbox("Append After the Last Section", appendField); gd.addNumericField("Poll Frequency (seconds)", pollTime, 2); doAppend = gd.getNextBoolean(); Prefs.set(POLL_KEY, ((double)delayMS)/1000); Prefs.set(REGEX_KEY, regexp); Prefs.set(REGEX_TEST_KEY, gd.getNextString()); if (doAppend) Prefs.set(APPEND_KEY, "true"); Prefs.set(APPEND_KEY, "false"); Prefs.savePreferences();
final int n_images = WindowManager.getImageCount(); for ( int i = 0; i < n_images; i++ ) image_names[ i + 1 ] = WindowManager.getImage( i + 1 ).getTitle(); final GenericDialog gd = new GenericDialog( "Image Expression Parser" ); expression = Prefs.get( prefix + "expression.val", "A^2" ); gd.addStringField( "Expression", expression, 20 ); final String tmp_choice = Prefs.get( prefix + "image.selection." + i, image_names[ i + 1 ] ); gd.addChoice( String.valueOf( letters[ i ] ), image_names, tmp_choice ); gd.showDialog(); expression = gd.getNextString(); Prefs.set( prefix + "expression.val", expression ); image_map = new HashMap< String, Img< T > >( 1 ); for ( int i = 0; i < n_images; i++ ) if ( !im.equals( "None" ) ) Prefs.set( prefix + "image.selection." + i, im ); image_map.put( String.valueOf( letters[ i ] ), ImagePlusAdapter.< T >wrap( WindowManager.getImage( im ) ) ); IJ.error( error_message );
@Override public void run(ImageProcessor ip) { // Can't get Prefs.getInt to work String iso = Prefs.get(ISO_VALUE_KEY, String.valueOf(DEFAULT_ISO_VALUE)); int isoValue = Integer.parseInt(iso); GenericDialog gd = new GenericDialog("Dilate"); gd.addNumericField("Iso value", isoValue, 0); gd.addHelp("http://imagej.net/3D_Binary_Filters"); gd.showDialog(); if(gd.wasCanceled()) { return; } isoValue = (int) gd.getNextNumber(); Prefs.set(ISO_VALUE_KEY, isoValue); dilate(image, isoValue, false).show(); }
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { isRGB = imp.getProcessor() instanceof ColorProcessor; calledAsPlugin = true; String options = Macro.getOptions(); doPresmooth = true; GenericDialog gd = new GenericDialog(command); gd.addNumericField("Rolling ball radius:", radius, 1, 6, "pixels"); gd.addCheckbox("Light background", lightBackground); if (isRGB) gd.addCheckbox("Separate colors", separateColors); gd.addCheckbox("Create background (don't subtract)", createBackground); previewing = false; if (gd.wasCanceled()) return DONE; IJ.register(this.getClass()); //protect static class variables (filter parameters) from garbage collection if ((imp.getProcessor() instanceof FloatProcessor) && !createBackground) staticUseParaboloid = useParaboloid; staticDoPresmooth = doPresmooth; Prefs.set("bs.background", lightBackground); return IJ.setupDialog(imp, flags); //ask whether to process all slices of stack (if a stack)
@Override public void run(ImageProcessor ip) { boolean useCalibration = Prefs.get(CALIBRATION_KEY, DEFAULT_CALIBRATION); GenericDialog gd = new GenericDialog("Gradient_"); gd.addCheckbox("Use calibration", useCalibration); gd.addHelp("http://imagej.net/3D_Binary_Filters"); gd.showDialog(); if(gd.wasCanceled()) { return; } useCalibration = gd.getNextBoolean(); Prefs.set(CALIBRATION_KEY, useCalibration); ImagePlus grad = calculateGrad(image, useCalibration); Rebin.rebin(grad, 256).show(); } }
private void runMacOSX() { long memory = maxMemory() >> 20; int threads = Prefs.getThreads(); final GenericDialog gd = new GenericDialog("Memory " + (IJ.is64Bit() ? "(64-bit)" : "(32-bit)")); gd.addNumericField("Maximum Memory:", memory, 0, 5, "MB"); gd.addNumericField("Parallel Threads for Stacks:", threads, 0, 5, ""); gd.showDialog(); if (gd.wasCanceled()) return; if (gd.invalidNumber()) { IJ.showMessage("Memory", "The number entered was invalid."); return; } memory = (long)gd.getNextNumber(); threads = (int)gd.getNextNumber(); Prefs.setThreads(threads); final int limit = 1700; if (!IJ.is64Bit() && memory > limit) { if (!IJ.showMessageWithCancel("Memory", "Note: setting the memory limit to a " + "value\ngreater than " + limit + "MB on a 32-bit system\n" + "may cause ImageJ to fail to start.")) return; } writeFileMacOSX(memory); }
quitting = true; boolean changes = false; int[] wList = WindowManager.getIDList(); if (wList!=null) { for (int i=0; i<wList.length; i++) { ImagePlus imp = WindowManager.getImage(wList[i]); if (imp!=null && imp.changes==true) { changes = true; Frame[] frames = WindowManager.getNonImageWindows(); if (frames!=null) { for (int i=0; i<frames.length; i++) { if (windowClosed && !changes && Menus.window.getItemCount()>Menus.WINDOW_MENU_ITEMS && !(IJ.macroRunning()&&WindowManager.getImageCount()==0)) { GenericDialog gd = new GenericDialog("ImageJ", this); gd.addMessage("Are you sure you want to quit ImageJ?"); gd.showDialog(); quitting = !gd.wasCanceled(); windowClosed = false; Prefs.savePreferences(); IJ.cleanup(); dispose(); if (exitWhenQuitting)
/** * Prompts the user to enter their LuraWave * license code in an ImageJ dialog window. */ public static String promptLicenseCode(String code, boolean first) { GenericDialog gd = new GenericDialog("LuraWave License Code"); if (!first) gd.addMessage("Invalid license code; try again."); gd.addStringField("LuraWave_License Code: ", code, 16); gd.showDialog(); if (gd.wasCanceled()) return null; code = gd.getNextString(); if (code != null) Prefs.set(LuraWaveServiceImpl.LICENSE_PROPERTY, code); return code; }
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) { double width2 = gd.getNextNumber(); double headSize2 = gd.getNextNumber(); String colorName2 = gd.getNextChoice(); int style2 = gd.getNextChoiceIndex(); boolean outline2 = gd.getNextBoolean(); if (colorName!=null && !colorName2.equals(colorName)) { Color color = Colors.decode(colorName2, null); Toolbar.setForegroundColor(color); Arrow.setDefaultOutline(outline2); Arrow.setDefaultDoubleHeaded(doubleHeaded2); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) return true; Roi roi = imp.getRoi(); if (roi==null) return true; if (roi instanceof Arrow) { arrow.setOutline(outline2); arrow.setDoubleHeaded(doubleHeaded2); imp.draw(); Prefs.set(Arrow.STYLE_KEY, style2); Prefs.set(Arrow.WIDTH_KEY, width2); Prefs.set(Arrow.SIZE_KEY, headSize2); Prefs.set(Arrow.OUTLINE_KEY, outline2); Prefs.set(Arrow.DOUBLE_HEADED_KEY, doubleHeaded2); return true;
pluginStates[idx++] = SimpleNeuriteTracer.verbose; final GenericDialog gd = new GenericDialog("SNT v" + SNT.VERSION + " Preferences"); final Font font = new Font("SansSerif", Font.BOLD, 12); gd.setInsets(0, 0, 0); gd.addMessage("Startup Options:", font); gd.setInsets(0, 0, 0); gd.addCheckboxGroup(startupOptions, 1, startupLabels, startupStates); currentBooleans &= ~pluginItems[i]; Prefs.set(BOOLEANS, currentBooleans); Prefs.savePreferences(); loadPluginPrefs();
void find(String s) { if (s==null) { GenericDialog gd = new GenericDialog("Find", this); gd.addStringField("Find: ", searchString, 20); String[] labels = {"Case Sensitive", "Whole Words"}; boolean[] states = {caseSensitive, wholeWords}; gd.addCheckboxGroup(1, 2, labels, states); gd.showDialog(); if (gd.wasCanceled()) caseSensitive = gd.getNextBoolean(); wholeWords = gd.getNextBoolean(); Prefs.set(CASE_SENSITIVE, caseSensitive); searchString = s2; if (index<0) {IJ.beep(); return;} ta.setSelectionStart(index); ta.setSelectionEnd(index+s.length());
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) { if (e!=null && e.toString().contains("Undo")) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) IJ.run("Undo"); return true; } width = (int)gd.getNextNumber(); if (gd.invalidNumber() || width<0) width = (int)Prefs.get(widthKey, 1); //transparency = (int)gd.getNextNumber(); //if (gd.invalidNumber() || transparency<0 || transparency>100) // transparency = 100; String colorName = gd.getNextChoice(); paintOnOverlay = gd.getNextBoolean(); Color color = Colors.decode(colorName, null); Toolbar.setForegroundColor(color); Prefs.set(widthKey, width); Prefs.set(OVERLAY_KEY, paintOnOverlay); return true; } }