Posted by
Jan Eglinger on
URL: http://imagej.273.s1.nabble.com/Macro-Recorder-misses-options-in-run-cmd-options-tp5024404p5024405.html
Dear Hidenao Yamada,
in my experience, the use of IJ.run() can trigger "premature" recording
of commands. If you use IJ.run() before your option string is populated
(which happens in gd.getNextString), you'll miss these options in the
recorded command.
The same is true for plugins that have a preview and use IJ.run() in
their preview methods.
According to these lines in Options.java:
https://github.com/imagej/imagej1/blob/2bf338ae80e6ccfc250994beb4e7e3511833bd51/ij/plugin/Options.java#L56-L70you should be able to set the "Division-by-zero" value like this to work
around the issue:
FloatBlitter.divideByZeroValue = 0.0;
Hope that helps,
Jan
On 22.01.21 00:44, Hidenao Yamada wrote:
> Dear all,
>
> The following PlugIn does not be recorded correctly on Macro Recorder. It missed options in run(command, options).
> However the options can be recorded if IJ.run("Misc...", "divide=0.0") is placed after gd.getNext**() in the java-code.
> Is this bug ?
>
> Best
> Hidenao Yamada
>
> Java code
> -------------------------------------------------------------
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
> public class NoRecord_Plugin implements PlugIn {
> public void run(String arg) {
> String str="";
> GenericDialog gd = new GenericDialog("Test");
> gd.addStringField("Input: ", str, 10);
> gd.showDialog();
> if (gd.wasCanceled()) return;
> IJ.run("Misc...", "divide=0.0");
> str = gd.getNextString();
> //IJ.run("Misc...", "divide=0.0");
> IJ.showMessage("Is the options recorded in Recorder ?");
> }
> }
> -------------------------------------------------------------
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html