I've written a plugin which calculates a value from an image. Someone now wants to use this plugin from within a macro.
I can configure the plugin from the macro by using Macro.getOptions() and parsing the string they pass in, but what I need now is a way to return a value (or preferably values) from the plugin and send it back to the calling macro so it can be used elsewhere in the macro. I'm sure there must be an easy way to do this, but I've not found it in the documentation. Can anyone enlighten me? Thanks Simon. |
On Wednesday 02 Jun 2010 11:12:35 you wrote:
> I can configure the plugin from the macro by using Macro.getOptions() and > parsing the string they pass in, but what I need now is a way to return a > value (or preferably values) from the plugin and send it back to the > calling macro so it can be used elsewhere in the macro. You should read the mailing list archives. I asked the same question not long ago and there are several ways to do this. I found this example to be enough to do what I needed: http://rsbweb.nih.gov/ij/plugins/imp-props.html G |
In reply to this post by simon andrews (BI)
Hi Simon,
one possibilty is a static method in your plugin that returns a value or string (possibly in dependence of a parameter that serves as key which value to return). You can use the call("myPlugin.staticmethod", "key")) macro function to get it. You can also write the values (if numeric) to the ResultsTable or (if a String or converted to a String) to the properties (info) of the image - the latter would have the advantage that it is multithreading- safe. Michael ________________________________________________________________ On 2 Jun 2010, at 11:39, simon andrews (BI) wrote: > I've written a plugin which calculates a value from an image. > Someone now wants to use this plugin from within a macro. > > I can configure the plugin from the macro by using Macro.getOptions > () and parsing the string they pass in, but what I need now is a > way to return a value (or preferably values) from the plugin and > send it back to the calling macro so it can be used elsewhere in > the macro. > > I'm sure there must be an easy way to do this, but I've not found > it in the documentation. > > Can anyone enlighten me? > > Thanks > > Simon. |
In reply to this post by simon andrews (BI)
Hi Simon,
you could exchange data with the macro via the "preferences" mechanism. Alternative, I use a technique that attaches "properties" to the window that the plugin operated on. You also add at static function to your plugin where it can return the result of a previous call (as used in my tifftags plugin) See: http://rsb.info.nih.gov/ij/macros/CallJavaDemo.txt http://rsb.info.nih.gov/ij/developer/api/ij/Prefs.html http://rsbweb.nih.gov/ij/plugins/imp-props.html http://rsbweb.nih.gov/ij/plugins/tiff-tags.html Mit freundlichen Grüßen / Best regards Joachim Wesner "simon andrews (BI)" <simon.andrews@BB An SRC.AC.UK> [hidden email] Gesendet von: Kopie ImageJ Interest Group Thema <[hidden email]. Passing information to a macro GOV> from a plugin 02.06.2010 11:39 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> I've written a plugin which calculates a value from an image. Someone now wants to use this plugin from within a macro. I can configure the plugin from the macro by using Macro.getOptions() and parsing the string they pass in, but what I need now is a way to return a value (or preferably values) from the plugin and send it back to the calling macro so it can be used elsewhere in the macro. I'm sure there must be an easy way to do this, but I've not found it in the documentation. Can anyone enlighten me? Thanks Simon. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Michael Schmid
> On 2 Jun 2010, at 11:39, simon andrews (BI) wrote:
> >> I've written a plugin which calculates a value from an image. >> Someone now wants to use this plugin from within a macro. >> >> I can configure the plugin from the macro by using Macro.getOptions >> () and parsing the string they pass in, but what I need now is a >> way to return a value (or preferably values) from the plugin and >> send it back to the calling macro so it can be used elsewhere in >> the macro. On 2 Jun 2010, at 11:23, Michael Schmid wrote: > You can also write the values (if numeric) to the ResultsTable or (if > a String or converted to a String) to the properties (info) of the > image - the latter would have the advantage that it is multithreading- > safe. Thanks - using the image properties to store and access the data worked out just fine. Simon. |
Free forum by Nabble | Edit this page |