Refine search
private boolean showDialog() { gd = new GenericDialog("Startup Macro"); String text = "Macro code contained in this text area\nexecutes when ImageJ starts up."; Font font = new Font("SansSerif", Font.PLAIN, 14); gd.setInsets(5,15,0); gd.addMessage(text, font); gd.setInsets(5, 10, 0); gd.addTextAreas(macro, null, 12, 50); gd.addChoice("Add code:", code, code[0]); Vector choices = gd.getChoices(); if (choices!=null) { Choice choice = (Choice)choices.elementAt(0); choice.addItemListener(this); } gd.showDialog(); macro = gd.getNextText(); return !gd.wasCanceled(); }
public boolean showDialogAskBaseline() { GenericDialog gd = new GenericDialog("Bleach Correction"); gd.addNumericField("Background Intensity", baselineInt, 1) ; gd.showDialog(); if (gd.wasCanceled()) return false; baselineInt = gd.getNextNumber(); return true; }
public double showDialog(double angle) { GenericDialog gd = new GenericDialog("Rotate Selection"); int decimalPlaces = 0; if ((int)angle!=angle) decimalPlaces = 2; if (Macro.getOptions()!=null) rotateAroundImageCenter = false; gd.addNumericField("Angle:", angle, decimalPlaces, 3, "degrees"); gd.addCheckbox("Rotate around image center", rotateAroundImageCenter); gd.setInsets(5, 0, 0); gd.addMessage("Enter negative angle to \nrotate counter-clockwise", null, Color.darkGray); gd.showDialog(); if (gd.wasCanceled()) return Double.NaN; rotateAroundImageCenter = gd.getNextBoolean(); return gd.getNextNumber(); }
void showAngleDialog() { GenericDialog gd = new GenericDialog("Angle Tool"); gd.addCheckbox("Measure reflex angle", Prefs.reflexAngle); gd.showDialog(); if (!gd.wasCanceled()) Prefs.reflexAngle = gd.getNextBoolean(); }
/** 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(); }
/** Displays a color selection dialog and returns the color selected by the user. */ public Color getColor() { GenericDialog gd = frame!=null?new GenericDialog(title, frame):new GenericDialog(title); gd.addSlider("Red:", 0, 255, red); gd.addSlider("Green:", 0, 255, green); gd.addSlider("Blue:", 0, 255, blue); panel = new ColorPanel(initialColor); gd.addPanel(panel, GridBagConstraints.CENTER, new Insets(10, 0, 0, 0)); colors = gd.getNumericFields(); for (int i=0; i<colors.size(); i++) ((TextField)colors.elementAt(i)).addTextListener(this); sliders = gd.getSliders(); for (int i=0; i<sliders.size(); i++) ((Scrollbar)sliders.elementAt(i)).addAdjustmentListener(this); gd.showDialog(); if (gd.wasCanceled()) return null; int red = (int)gd.getNextNumber(); int green = (int)gd.getNextNumber(); int blue = (int)gd.getNextNumber(); return new Color(red, green, blue); }
@Override public boolean dialogItemChanged(final GenericDialog arg, final AWTEvent event) { useOnlySelectedPaths = gd.getNextRadioButton().contains("only"); restrictByRoi = gd.getNextRadioButton().contains("only"); restrictBySWCType = gd.getNextRadioButton().contains("only"); final String analysisChoice = gd.getNextRadioButton(); summarizeSkeleton = analysisChoice.contains("summary"); callAnalyzeSkeleton = analysisChoice.contains("Analyze Skeleton"); if (restrictBySWCType) { selectedSwcTypes.clear(); for (final int type : Path.getSWCtypes()) { if (gd.getNextBoolean()) selectedSwcTypes.add(type); } } final Vector<?> cbxs = gd.getCheckboxes(); for (int i = 0; i < cbxs.size(); i++) ((Checkbox) cbxs.get(i)).setEnabled(restrictBySWCType); return true; }
public static int addChoice(GenericDialog g, String title, Vector v, String defaultValue) { String[] list = new String[v.size()]; boolean hasDefault = false; for (int i = 0; i < list.length; i++) { list[i] = (String)v.get(i); if (list[i].equals(defaultValue)) hasDefault = true; } if (!hasDefault) { String[] newList = new String[list.length + 1]; System.arraycopy(list, 0, newList, 1, list.length); list = newList; list[0] = defaultValue; } g.addChoice(title, list, defaultValue); return list.length; }
synchronized private final int adjustResampling() { if (resample > 0) return resample; final GenericDialog gd = new GenericDialog("Resample"); final int default_resample = estimateResamplingFactor(); gd.addSlider("Resample: ", 1, Math.max(default_resample, 100), -1 != resample ? resample : default_resample); gd.showDialog(); if (gd.wasCanceled()) { resample = -1 != resample ? resample : default_resample; // current or default value return resample; } resample = ((java.awt.Scrollbar)gd.getSliders().get(0)).getValue(); return resample; }
@Override protected GenericDialog constructDialog() { GenericDialog gd = null; if (options.isHTTP()) { gd = new GenericDialog("Bio-Formats URL"); gd.addStringField("URL: ", "http://", 30); } else if (options.isOMERO()) { gd = new GenericDialog("OMERO Server Credentials"); gd.addStringField("Server: ", "", 80); gd.addStringField("Port: ", "4064", 80); gd.addStringField("Username: ", "", 80); gd.addStringField("Password: ", "", 80); gd.addStringField("Group: ", "default", 80); gd.addStringField("Image ID: ", "", 80); Vector v = gd.getStringFields(); ((TextField) v.get(3)).setEchoChar('*'); } return gd; }
@Override public void windowClosed(final WindowEvent e) { if (null != transp_adjuster) transp_adjuster.quit(); if (gd.wasCanceled()) { final float newTr = oldTr / 100f; ci.setTransparency(newTr); univ.fireContentChanged(c); return; } // apply to all instants of the content if (aBox.getState()) c.setTransparency(ci.getTransparency()); record(SET_TRANSPARENCY, Float.toString(((Scrollbar) gd.getSliders() .get(0)).getValue() / 100f)); } });
if (imp.getStackSize()>1) { IJ.error("This command requires a montage"); return; String options = Macro.getOptions(); if (options!=null) { options = options.replace("images_per_row=", "columns="); String montageHeight = (String)imp.getProperty("yMontage"); if (montageHeight!=null) rows = Integer.parseInt(montageHeight); GenericDialog gd = new GenericDialog("Stack Maker"); gd.addNumericField("Columns: ", columns, 0); gd.addNumericField("Rows: ", rows, 0); gd.addNumericField("Border width: ", border, 0); gd.showDialog(); if (gd.wasCanceled()) return; columns = (int)gd.getNextNumber(); rows = (int)gd.getNextNumber(); border = (int)gd.getNextNumber(); if (rows==0 || columns==0) return; ImageStack stack = makeStack(imp.getProcessor(), rows, columns, border); new ImagePlus("Stack", stack).show();
public void run( String args ) if ( IJ.versionLessThan( "1.37i" ) ) return; final ImagePlus imp = WindowManager.getCurrentImage(); if ( imp == null ) { System.err.println( "There are no images open" ); return; } final GenericDialog gd = new GenericDialog( "Test SIFT" ); gd.showDialog(); if ( gd.wasCanceled() ) return; SIFT.readFields( gd, p ); final ImageProcessor ip1 = imp.getProcessor().convertToFloat(); final ImageProcessor ip2 = imp.getProcessor().duplicate().convertToRGB(); drawSquare( ip2, new double[]{ f.location[ 0 ], f.location[ 1 ] }, p.fdSize * 4.0 * ( double )f.scale, ( double )f.orientation ); new ImagePlus( imp.getTitle() + " Features ", ip2 ).show();
public void run(String arg) { imp = WindowManager.getCurrentImage(); Roi roi = imp!=null?imp.getRoi():null; boolean selection = roi!=null && (roi.getType()==Roi.TRACED_ROI||roi.getType()==Roi.POLYGON); if (imp==null || (ID!=0&&imp.getID()!=ID) || !selection) startx = starty = 0; ID = imp!=null?imp.getID():0; double sliderMax = 255; int depth = imp!=null?imp.getBitDepth():0; if (depth==16 || depth==32) { sliderMax = imp.getProcessor().getMax(); if (depth==32) sliderMax+=0.0000000001; } showCheckbox = imp!=null && depth!=24 && WindowManager.getFrame("Threshold")==null && !imp.isThreshold(); GenericDialog gd = new GenericDialog("Wand Tool"); gd.addSlider("Tolerance: ", 0, sliderMax, tolerance); gd.addChoice("Mode:", modes, mode); if (showCheckbox) gd.addCheckbox("Enable Thresholding", false); gd.addCheckbox("Smooth if thresholded", Prefs.smoothWand); if (showCheckbox) { gd.setInsets(2,0,0); gd.addMessage("Thresholded objects are traced and \"Tolerance\"\nis ignored when thresholding is enabled."); } gd.addDialogListener(this); gd.showDialog(); }
@Override public void run(ImageProcessor ip) { GenericDialog gd = new GenericDialog("Despeckle"); gd.addNumericField("ratio color/space", 256.0 / (ip.getWidth() * ip.getHeight()), 3); gd.addNumericField("number of classes", 20, 0); gd.addNumericField("iterations (at most)", 50, 0); gd.showDialog(); if(gd.wasCanceled()) return; double ratio = gd.getNextNumber(); int n = (int)gd.getNextNumber(); int iter = (int)gd.getNextNumber(); KD kd = new KD(ip, ratio, n, iter); ImageProcessor result = kd.getResult(); new ImagePlus("KD Cartoon of " + image.getTitle(), result) .show(); }
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); }
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { ImageProcessor ip = imp.getProcessor(); ip.resetBinaryThreshold(); // remove any invisible threshold set by Make Binary or Convert to Mask thresholded = ip.getMinThreshold()!=ImageProcessor.NO_THRESHOLD; GenericDialog gd = new GenericDialog(command); int digits = (ip instanceof FloatProcessor)?2:0; String unit = (imp.getCalibration()!=null)?imp.getCalibration().getValueUnit():null; unit = (unit==null||unit.equals("Gray Value"))?":":" ("+unit+"):"; gd.addNumericField("Noise tolerance"+unit,tolerance, digits); gd.addChoice("Output type:", outputTypeNames, outputTypeNames[dialogOutputType]); gd.addCheckbox("Exclude edge maxima", excludeOnEdges); if (thresholded) gd.addCheckbox("Above lower threshold", useMinThreshold); gd.addCheckbox("Light background", lightBackground); gd.addPreviewCheckbox(pfr, "Preview point selection"); gd.addMessage(" "); //space for number of maxima messageArea = (Label)gd.getMessage(); gd.addDialogListener(this); checkboxes = gd.getCheckboxes(); previewing = true; gd.addHelp(IJ.URL+"/docs/menus/process.html#find-maxima"); gd.showDialog(); //input by the user (or macro) happens here if (gd.wasCanceled()) return DONE; previewing = false; if (!dialogItemChanged(gd, null)) //read parameters return DONE; IJ.register(this.getClass()); //protect static class variables (parameters) from garbage collection return flags; } // boolean showDialog
void interpolate() { Roi roi = imp.getRoi(); if (roi==null) {noRoi("Interpolate"); return;} if (roi.getType()==Roi.POINT) return; if (IJ.isMacro()&&Macro.getOptions()==null) Macro.setOptions("interval=1"); GenericDialog gd = new GenericDialog("Interpolate"); gd.addNumericField("Interval:", 1.0, 1, 4, "pixel"); gd.addCheckbox("Smooth", IJ.isMacro()?false:smooth); gd.addCheckbox("Adjust interval to match", IJ.isMacro()?false:adjust); gd.showDialog(); if (gd.wasCanceled()) return; double interval = gd.getNextNumber(); smooth = gd.getNextBoolean(); Undo.setup(Undo.ROI, imp); adjust = gd.getNextBoolean(); int sign = adjust ? -1 : 1; FloatPolygon poly = roi.getInterpolatedPolygon(sign*interval, smooth); int t = roi.getType(); if (t==Roi.POLYLINE && interval>=8.0) type = Roi.POLYLINE; ImageCanvas ic = imp.getCanvas(); imp.setRoi(p);
/** Ask the user for the parameters */ public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { calledAsPlugin = true;; String options = Macro.getOptions(); boolean oldMacro = false; nChannels = imp.getProcessor().getNChannels(); if (options!=null) { if (options.indexOf("radius=") >= 0) { // ensure compatibility with old macros oldMacro = true; // specifying "radius=", not "sigma= Macro.setOptions(options.replaceAll("radius=", "sigma=")); } } GenericDialog gd = new GenericDialog(command); sigma = Math.abs(sigma); gd.addNumericField("Sigma (Radius):", sigma, 2); if (imp.getCalibration()!=null && !imp.getCalibration().getUnits().equals("pixels")) { hasScale = true; gd.addCheckbox("Scaled Units ("+imp.getCalibration().getUnits()+")", sigmaScaled); } else sigmaScaled = false; gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); // input by the user (or macro) happens here if (gd.wasCanceled()) return DONE; if (oldMacro) sigma /= 2.5; // for old macros, "radius" was 2.5 sigma IJ.register(this.getClass()); // protect static class variables (parameters) from garbage collection return IJ.setupDialog(imp, flags); // ask whether to process all slices of stack (if a stack) }
private boolean showDialog(ImagePlus imp) { String options = Macro.getOptions(); if (options!=null) { if (!options.contains("compression=")) options = "compression=JPEG "+options; options = options.replace("compression=Uncompressed", "compression=None"); Macro.setOptions(options); } double fps = getFrameRate(imp); int decimalPlaces = (int) fps == fps?0:1; GenericDialog gd = new GenericDialog("Save as AVI..."); gd.addChoice("Compression:", COMPRESSION_STRINGS, COMPRESSION_STRINGS[compressionIndex]); gd.addNumericField("Frame Rate:", fps, decimalPlaces, 3, "fps"); gd.showDialog(); // user input (or reading from macro) happens here if (gd.wasCanceled()) // dialog cancelled? return false; compressionIndex = gd.getNextChoiceIndex(); fps = gd.getNextNumber(); if (fps<=0.5) fps = 0.5; imp.getCalibration().fps = fps; return true; }