Login  Register

Re: set default parameters in dialog Plugin and get used parameters

Posted by Emanuele Martini on Jun 28, 2014; 4:00pm
URL: http://imagej.273.s1.nabble.com/set-default-parameters-in-dialog-Plugin-and-get-used-parameters-tp5008470p5008484.html

----------------------------------
Show the dialog in the script and then call the plugin. Here is a JavaScript example that calls the MaximumFinder plugin:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  types = ["Single Points", "Maxima Within Tolerance", "Segmented Particles",
     "Point Selection", "List", "Count"];
  output = 0;
  noise = 150;
  gd = new GenericDialog("Find Maxima");
  gd.addChoice("Type:", types, output);
  gd.addNumericField("Tolerance:", noise, 0);
  gd.showDialog();
  output = gd.getNextChoiceIndex();
  noise = gd.getNextNumber();
  if (!gd.wasCanceled()) {
     mf = new MaximumFinder();
     ip = mf.findMaxima(imp.getProcessor(), noise, 0, output, false, false);
     if (ip!=null)
        new ImagePlus("Points", ip).show();
  };

-wayne
-----------------------------------------------------------


Thank you, but i'm searching for a solution that permits the user to use the preview button.
So i want only to put some default option in the original dialog box of the plugin.
Ideally, I would like a solution like that :
IJ.run ("find maxima","noise=150, output=[single points]") that only open the dialog box with these default parameters, then wait for the user adjustment with preview button and after the user click OK i would like to store the parametr really used by the user.
Maybe, the only solution is to create a "fake" dialog box with preview button ( and in that case i really appreciate you if you could post here an example of a simple plugin with a dialog box with preview button) but I really hope that there is a more simpler solution.
Thanking you for your attention,
have a nice weekend
Emanuele

Image Analyst @Ifom-IEO research campus -MI-