Hi,
sorry, as far as I can say, no way, at least as long as one would
want to write reasonable code. The 'Preview' checkbox is a special
one, it is always off when a dialog is opened.
The background thread for preview is initiated by a DialogItemChanged
event (more specifically, ItemStateChanged event), with the
previewCheckbox as a source, so even initializing the previewCheckbox
to the 'on' state would not trigger preview.
It is the PlugInFilterRunner running the 'Subtract Background'
command that registers as a DialogListener and thus receives
DialogItemChanged events. The PlugInFilterRunner provides the
background thread for preview. This may seem a bit cumbersome at
first glance, but it is a fairly clean solution that provides
compatibility with with plugins that do not provide preview and also
it enables plugin programmers to have preview with only a few
additional lines.
So the only workaround that I see would be very cumbersome: start the
PlugInFilterRunner with 'Subtract Background' in your plugin
(duplicate some code from IJ.java), have a second thread that waits
(in an endless loop) until the Dialog is there, step through its
components to get the previewCheckbox, create an appropriate
ItemStateChanged event, and call the PlugInFilterRunner's
DialogItemChanged method. I would not want to do this type of
programming.
Michael
________________________________________________________________
On 30 Mar 2010, at 20:08, Cspr wrote:
> Hello ImageJ users.
>
> I'm in the middle of creating a small plugin for ImageJ Fiji. One
> of the
> steps involved here is the use of the subtract background. When you
> start
> the Subtract Background routine none of the options are checked. I
> would
> like only the preview option to be checked here.
>
> The usual call IJ.run(image, "Subtract Background...", ""); starts the
> routine which is fine but i've yet to be able to decipher how I add
> arguements to the call i.e. how do I fill out the third parameter
> in the
> above call (currently the empty string) to set the Subtract Background
> window to appear with the preview option enabled? I have tried
> enabling the
> Macro recording (using imageJ 1.43) but unfortunately it doesnt
> provide any
> answers for the Preview option, unlike for instance the disable
> setting.
>
> Thank you.