Macro Recorder misses options in run(cmd, options)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro Recorder misses options in run(cmd, options)

Hidenao IWAI
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
Reply | Threaded
Open this post in threaded view
|

Re: Macro Recorder misses options in run(cmd, options)

Jan Eglinger
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-L70

you 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
Reply | Threaded
Open this post in threaded view
|

Re: Macro Recorder misses options in run(cmd, options)

Hidenao IWAI
Hi Jan,

>you should be able to set the "Division-by-zero" value like this to work
around the issue:
>FloatBlitter.divideByZeroValue = 0.0;

This reply actually helps me. Thank you very much!!

Best regards
H. Yamada



送信元: "Jan Eglinger" <[hidden email]>
宛先:   [hidden email]
Cc:     "Hidenao Yamada" <[hidden email]>
日付:   2021/01/22 21:23
件名:   Re: Macro Recorder misses options in run(cmd, options)



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-L70


you 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