[ImageJ-devel] Masking @Parameter from GUI harvesting ?

Curtis Rueden ctrueden at wisc.edu
Mon Aug 24 15:31:07 CDT 2015


Hi Adrian,

> 1) How does one prevent a @Parameter from showing up in the harvesting
> GUI dialog, in the manner of a '@Parameter LogService log'? (more
> below)

Parameters which are resolved before the input harvester dialog pops up
will not show up.

They get resolved by the various preprocessors in the preprocessing chain,
which is applied before the module is actually run. The InputHarvester --
which is what pops the dialog box -- is (IIRC) the final preprocessing step
before run happens.

We could add a way to mark parameters which are not desired to be shown in
the dialog box. What is your use case for a parameter you want to have in
the script, but never shown to the user in cases where it is still null?

> 2) A net.imagej.overlay.RectangleOverlay parameter, although properly
> populated, provoques an Exception after the execution of the command.
> (more details and stacktraces below)

As I mentioned in the other thread: try with Overlay instead? We could
certainly make it autofill parameters with specific Overlay subclasses
too—just need to confirm first that that is indeed your problem.

> 3) When a new preview is triggered, and that preview modifies numeric
> parameters, then the numeric values visible in the gui dialog are
> updated except for the NumericField on which input has triggered the
> call to preview().

It is a programming error for the preview() function to modify parameter
values. Use callbacks instead, which occur before preview() is called [1].

> 4) It would be nice if a parameter could have a label even if
> ItemVisibility is MESSAGE

Fixed [2].

Regards,
Curtis

[1]
https://github.com/scijava/scijava-common/blob/scijava-common-2.44.2/src/main/java/org/scijava/widget/DefaultWidgetModel.java#L167-L169

[2]
https://github.com/scijava/scijava-ui-swing/commit/84c30c045bf3327a424f499f1f2fe867b0d9375e


On Sun, Aug 23, 2015 at 6:44 AM, Adrian Daerr <
adrian.daerr at univ-paris-diderot.fr> wrote:

> Dear ImageJ developers,
>
> As I slowly learn more about IJ2 @Plugins, I have one question and three
> minor comments that I would like to submit to you.
>
> 1) How does one prevent a @Parameter from showing up in the harvesting
> GUI dialog, in the manner of a '@Parameter LogService log'? (more below)
>
> 2) A net.imagej.overlay.RectangleOverlay parameter, although properly
> populated, provoques an Exception after the execution of the command.
> (more details and stacktraces below)
>
> 3) When a new preview is triggered, and that preview modifies numeric
> parameters, then the numeric values visible in the gui dialog are
> updated except for the NumericField on which input has triggered the
> call to preview().
>
> 4) It would be nice if a parameter could have a label even if
> ItemVisibility is MESSAGE:
>   @Parameter(persist = false,
>              visibility = org.scijava.ItemVisibility.MESSAGE,
>              label = "Current foo value")
>     private double foo = 0;
> (currently, at least on my box, the label is not shown in this case)
> Obviously a workaround is to build a String with label+foo instead.
>
> cheers,
> Adrian
>
>
>
> ad 1)
> How to prevent a @Parameter from showing up in the harvesting GUI
> dialog? Some seem to be masked by default (ImagePlus, LogService), but
> I did not find the appropriate annotation to make the parameter roi in
> the following not show up, although it is already properly populated
> by the rectangular selection of the active image ? There is no
> meaningful thing I can do with the associated selector in the dialog.
>
>     @Parameter private ImagePlus imp;
>     @Parameter private RectangleOverlay roi;
>     @Parameter private double a;
>
>
> ad 2)
> A net.imagej.overlay.RectangleOverlay parameter
>
>   @Parameter private RectangleOverlay roi;
>
> is properly populated when the Command is invoqued on an active image
> containing a rectangular selection. However it provoques an Exception
> after the execution of the command, when either the
> DefaultPrefService, or the Recorder if a persist=false attribute is
> added, apparently tries to record a 'null' value for an option. The
> two stacktraces are
>
>   [ERROR] Module threw exception
>   java.lang.NullPointerException
>         at
> java.util.prefs.AbstractPreferences.put(AbstractPreferences.java:224)
>         at
> org.scijava.prefs.DefaultPrefService.put(DefaultPrefService.java:183)
>         at
> org.scijava.module.DefaultModuleService.save(DefaultModuleService.java:278)
>         at
> org.scijava.module.process.SaveInputsPreprocessor.saveValue(SaveInputsPreprocessor.java:74)
>         at
> org.scijava.module.process.SaveInputsPreprocessor.process(SaveInputsPreprocessor.java:65)
>         at
> org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
>         at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
>         at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
>         at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
>         at
> org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:662)
>
>   [ERROR] Module threw exception
>   java.lang.NullPointerException
>         at ij.plugin.frame.Recorder.addQuotes(Recorder.java:612)
>         at ij.plugin.frame.Recorder.recordOption(Recorder.java:362)
>         at net.imagej.legacy.IJ1Helper.recordOption(IJ1Helper.java:467)
>         at
> net.imagej.legacy.plugin.MacroRecorderPostprocessor.process(MacroRecorderPostprocessor.java:70)
>         at
> org.scijava.module.ModuleRunner.postProcess(ModuleRunner.java:116)
>         at org.scijava.module.ModuleRunner.run(ModuleRunner.java:176)
>         at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
>         at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
>         at
> org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:662)
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20150824/c21c3eb5/attachment.html>


More information about the ImageJ-devel mailing list