Posted by
Michael Schmid on
Oct 16, 2009; 1:26pm
URL: http://imagej.273.s1.nabble.com/How-to-return-a-value-from-a-plugin-to-a-macro-tp3690723p3690727.html
Hi Bill, Gabe,
ok, a bit more specific:
For transferring parameters/data *to* a plugin, the usual way is via
GenericDialog (also recordable in a macro), as almost all built-in
ImageJ commands do.
Of course, you can also use static methods that set static variables
for this purpose.
For transferring data *from* a plugin, setting a static variable and
having a static method to return it is a reasonable choice
(especially if there are reasons for not using the Results Table).
Of course, static methods are not multithread-safe.
Example:
In your plugin, you have, e.g.:
public class My_Plugin extends ... {
static double myResult;
void run(ImageProcessor ip) {
...
myResult = ...;
}
static String getResult() {
return myResult.toString();
}
}
In the macro
myResult = parseFloat(call("My_Plugin.getResult"));
Michael
________________________________________________________________
>
> Michael Schmid wrote:
>>
>> Hi Gabe, there are several possibilities: - have a static method
>> of your plugin that returns a String. You can access it by the
>> call macro function - via the Results Table - by setting pixels in
>> an image created for this putpose (if you want to access an array)
>> - via a file Michael
>> ________________________________________________________________
>> On 16 Oct 2009, at 14:20, gabejackson wrote:
>>>
>>> I've been searching around for this a bit and can't find
>>> anything. How can i return a value from a plugin to a macro? I've
>>> got a lot of analysis plugins and would like to perform various
>>> things with the return values in a macro. thanks in advance Gabe