Argument not passed to PluginFilter

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

Argument not passed to PluginFilter

Iain Marcuson
I am attempting to call a PluginFilter from a Plugin.

I call the PluginFilter with
outfile = tf_back_sub_filename.getText();
IJ.showMessage(outfile);
IJ.run("Gradient Subtract Auto", outfile);

The showMessage() verifies that outfile is correct and not empty or null.

The setup function of the PluginFilter is:

public int setup(String arg, ImagePlus imp) {
        this.imp = imp;
        back_filename = arg;
        IJ.showMessage("back_filename is \"" + back_filename + "\"\narg is \""+arg+"\"");
        return DOES_32;
}

However, the showMessage indicates that arg and back_filename are both empty.  

Is there something I am missing?

Thank you,

Iain.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Argument not passed to PluginFilter

Salim Kanoun
You have to get the argument with this command

Macro.getOptions()

As explained here :
http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:retrieving_the_optional_args_when_a_plugin_is_called_from_a_macro


2017-08-04 15:23 GMT+02:00 Iain Marcuson <[hidden email]
>:

> I am attempting to call a PluginFilter from a Plugin.
>
> I call the PluginFilter with
> outfile = tf_back_sub_filename.getText();
> IJ.showMessage(outfile);
> IJ.run("Gradient Subtract Auto", outfile);
>
> The showMessage() verifies that outfile is correct and not empty or null.
>
> The setup function of the PluginFilter is:
>
> public int setup(String arg, ImagePlus imp) {
>         this.imp = imp;
>         back_filename = arg;
>         IJ.showMessage("back_filename is \"" + back_filename + "\"\narg is
> \""+arg+"\"");
>         return DOES_32;
> }
>
> However, the showMessage indicates that arg and back_filename are both
> empty.
>
> Is there something I am missing?
>
> Thank you,
>
> Iain.
>
> --
> 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: Argument not passed to PluginFilter

Michael Schmid
Hi Iain,

another way of retrieving an argument from a macro or 'IJ.run' call
would be a generic dialog; also IJ.getString(String prompt, String
defaultString) is one:

E.g. in the PlugInFilter you could have
   name = IJ.getString("File Name", "");

and you could call the PlugInFilter by
   IJ.run("My PlugInFilter Name", "file=myDatafile.dat");

[in a macro, omit the 'IJ.']

The keyword in the list of arguments is the first word of the prompt,
converted to lower case. Put square brackets around the argument after
the '=' if it can contain whitespace.

You can also use a file open dialog in the PlugInFilter and supply the
full path in the argument String.

In both cases, if you run the plugin manually, the macro recorder will
help you to form the correct call for a macro or IJ.run command.
(I wrote this without trying it, so if it does not work, use the command
recorder).

By the way, the 'arg' of public int setup(String arg, ImagePlus imp) can
be specified only if you pack a PligIn or PlugInFilter into a .jar file;
the plugins.config file in the .jar can specify to have more than one
menu command for the PlugIn, with different (fixed) values of 'arg'.
based on the 'arg' value, the PlugIn then knows what function to
perform. [1]


Michael

[1] https://imagej.nih.gov/ij/plugins/jar-demo.html
     https://imagej.net/Developing_Plugins_for_ImageJ_1.x
________________________________________________________________
On 04/08/2017 16:19, Salim Kanoun wrote:

> You have to get the argument with this command
>
> Macro.getOptions()
>
> As explained here :
> http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:retrieving_the_optional_args_when_a_plugin_is_called_from_a_macro
>
>
> 2017-08-04 15:23 GMT+02:00 Iain Marcuson <[hidden email]
>> :
>
>> I am attempting to call a PluginFilter from a Plugin.
>>
>> I call the PluginFilter with
>> outfile = tf_back_sub_filename.getText();
>> IJ.showMessage(outfile);
>> IJ.run("Gradient Subtract Auto", outfile);
>>
>> The showMessage() verifies that outfile is correct and not empty or null.
>>
>> The setup function of the PluginFilter is:
>>
>> public int setup(String arg, ImagePlus imp) {
>>          this.imp = imp;
>>          back_filename = arg;
>>          IJ.showMessage("back_filename is \"" + back_filename + "\"\narg is
>> \""+arg+"\"");
>>          return DOES_32;
>> }
>>
>> However, the showMessage indicates that arg and back_filename are both
>> empty.
>>
>> Is there something I am missing?
>>
>> Thank you,
>>
>> Iain.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> 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: Argument not passed to PluginFilter

Iain Marcuson
Thanks.  The tutorial I read at http://www.gm.fh-koeln.de/~konen/WPF-BV/tutorial-ImageJ_V1.71.pdf left a lot of that stuff out.

Iain.

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Michael Schmid
> Sent: Friday, August 04, 2017 12:20 PM
> To: [hidden email]
> Subject: Re: Argument not passed to PluginFilter
>
> Hi Iain,
>
> another way of retrieving an argument from a macro or 'IJ.run' call would be
> a generic dialog; also IJ.getString(String prompt, String
> defaultString) is one:
>
> E.g. in the PlugInFilter you could have
>    name = IJ.getString("File Name", "");
>
> and you could call the PlugInFilter by
>    IJ.run("My PlugInFilter Name", "file=myDatafile.dat");
>
> [in a macro, omit the 'IJ.']
>
> The keyword in the list of arguments is the first word of the prompt,
> converted to lower case. Put square brackets around the argument after the
> '=' if it can contain whitespace.
>
> You can also use a file open dialog in the PlugInFilter and supply the full path
> in the argument String.
>
> In both cases, if you run the plugin manually, the macro recorder will help
> you to form the correct call for a macro or IJ.run command.
> (I wrote this without trying it, so if it does not work, use the command
> recorder).
>
> By the way, the 'arg' of public int setup(String arg, ImagePlus imp) can be
> specified only if you pack a PligIn or PlugInFilter into a .jar file; the
> plugins.config file in the .jar can specify to have more than one menu
> command for the PlugIn, with different (fixed) values of 'arg'.
> based on the 'arg' value, the PlugIn then knows what function to perform. [1]
>
>
> Michael
>
> [1] https://imagej.nih.gov/ij/plugins/jar-demo.html
>      https://imagej.net/Developing_Plugins_for_ImageJ_1.x
> __________________________________________________________
> ______
> On 04/08/2017 16:19, Salim Kanoun wrote:
> > You have to get the argument with this command
> >
> > Macro.getOptions()
> >
> > As explained here :
> >
> http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:retrieving_the_op
> > tional_args_when_a_plugin_is_called_from_a_macro
> >
> >
> > 2017-08-04 15:23 GMT+02:00 Iain Marcuson
> > <[hidden email]
> >> :
> >
> >> I am attempting to call a PluginFilter from a Plugin.
> >>
> >> I call the PluginFilter with
> >> outfile = tf_back_sub_filename.getText(); IJ.showMessage(outfile);
> >> IJ.run("Gradient Subtract Auto", outfile);
> >>
> >> The showMessage() verifies that outfile is correct and not empty or null.
> >>
> >> The setup function of the PluginFilter is:
> >>
> >> public int setup(String arg, ImagePlus imp) {
> >>          this.imp = imp;
> >>          back_filename = arg;
> >>          IJ.showMessage("back_filename is \"" + back_filename +
> >> "\"\narg is \""+arg+"\"");
> >>          return DOES_32;
> >> }
> >>
> >> However, the showMessage indicates that arg and back_filename are
> >> both empty.
> >>
> >> Is there something I am missing?
> >>
> >> Thank you,
> >>
> >> Iain.
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html