Re: return values to a plugin called from within another plugin

Posted by dscho on
URL: http://imagej.273.s1.nabble.com/return-values-to-a-plugin-called-from-within-another-plugin-tp3684561p3684563.html

Hi Susanna,

On Wed, 18 May 2011, Susanna Trollvad wrote:

> I have written a plugin(1) which can load a bunch of pictures the call
> another plugin/macro(2) which one by one does the same operation on the
> pictures and gets a bunch of values from them. I want a way to send the
> values obtained (2) to (1) and but all the values in one or more arrays.
>
> Can I write the plugin so that the run method returns the values or will
> that make ImageJ go crazy? What other ways is there to do it?

In general, this is not possible, because the run() method is defined not
to return anything.

Having said that, if you can change the code of both (2) and (1), you can
always work around the missing return value(s) by e.g. setting a property
of the current image (if both are plugins) or by communicating via the
call() method to execute static methods that then change a global variable
or some such.

> And also in the end I want to use the collected values in (1) to display
> a table were each row represents the values for one picture and each
> column one of the parameters measured by (2). Any ideas how I best do
> this?

I wrote some tips for ImageJ developers that you might find helpful:

http://pacific.mpi-cbg.de/wiki/index.php/Tips_for_developers#Show_a_results_table

Ciao,
Johannes