Saving plugin parameter values

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

Saving plugin parameter values

Serafino
I saw that some plugins and filters , when reopened, will offer the user the last parameter values he inputted (ie the RankedFilter plugin), I am wondering whether this depends on the interface implemented (Plugin, PluginFilter, ExtendedPluginFilter).
Any link to a doc file will be appreciated ^^
Reply | Threaded
Open this post in threaded view
|

Re: Saving plugin parameter values

Stephan Saalfeld
Hi,

the easiest way to get that behavior is to store the paremeters in
static fields.  That way, all instances of the plugin share common
parameters until the class is reloaded (read, usually during the
lifetime of an ImageJ instance).  Doing so, it is a good idea to copy
these static fields into local fields of the plugin and access only the
local fields from the run method.  That effectively prevents bogus cross
talking of multiple instances of the plugin running in parallel.

Best,
Stephan




On Sat, 2011-02-05 at 01:12 -0800, Serafino wrote:
> I saw that some plugins and filters , when reopened, will offer the user the
> last parameter values he inputted (ie the RankedFilter plugin), I am
> wondering whether this depends on the interface implemented (Plugin,
> PluginFilter, ExtendedPluginFilter).
> Any link to a doc file will be appreciated ^^
Reply | Threaded
Open this post in threaded view
|

Re: Saving plugin parameter values

Serafino
Thank you Stephan,
I had not considered that it could depend on the plugin architecture of ImageJ
Reply | Threaded
Open this post in threaded view
|

Re: Saving plugin parameter values

dscho
In reply to this post by Stephan Saalfeld
Hi,

On Sat, 5 Feb 2011, Stephan Saalfeld wrote:

> the easiest way to get that behavior is to store the paremeters in
> static fields.  That way, all instances of the plugin share common
> parameters until the class is reloaded (read, usually during the
> lifetime of an ImageJ instance).  Doing so, it is a good idea to copy
> these static fields into local fields of the plugin and access only the
> local fields from the run method.  That effectively prevents bogus cross
> talking of multiple instances of the plugin running in parallel.

This is a good method, but there are two things to mention in addition:

- the class is reloaded upon Help>Refresh Menus (i.e. whenever you install
  a plugin, even without restarting ImageJ, all plugin classes are
  reloaded),

- you could persist the values even past a File>Quit by using ij.Prefs as
  described here:
  http://pacific.mpi-cbg.de/Tips_for_developers#How_to_store_settings_persistently

I would also think that the plugin architecture in ImageJ2 allows you to
have persistent settings even without the plugin programmer taking care of
it explicitly.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: Saving plugin parameter values

Serafino
Hi, thank you Johannes,
I found the Pref class doc, but I am not sure that having preferences persisting on physical memory will help with a simple plugin like mine.
By the way, thank you for pointing the existence of ImageJ2 to me!