Posted by
Michael Schmid on
May 18, 2011; 12:13pm
URL: http://imagej.273.s1.nabble.com/return-values-to-a-plugin-called-from-within-another-plugin-tp3684561p3684562.html
Hi Susanna,
you could have a static Hashtable in plugin 2, and a public method to
access that Hashtable.
You can populate the Hashtable with e.g. ImagePlus, ImageProcessor or
Integer(ImageID) as a key and an object containing the array to pass
as value. Plugin 1 can then access the Hashtable and draw its
conclusions from the values obtained.
Alternatively, plugin 2 could also call to a static method of plugin
1 to tell it about the image and the values, and plugin 1 could then
store the values in a static Hashtable for later use.
Remember that the objects cannot be garbage collected as long as they
are in the Hashtable. So, remove an entry from there when you don't
need it any more, otherwise it will remain in memory.
Michael
________________________________________________________________
On 18 May 2011, at 12:28, 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?
>
> 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?
>
> //Susanna