Login  Register

Re: moving Java plugins from highly interactive to "batch friendly"

Posted by Curtis Rueden-2 on Sep 09, 2019; 8:22pm
URL: http://imagej.273.s1.nabble.com/moving-Java-plugins-from-highly-interactive-to-batch-friendly-tp5022429p5022436.html

Hi Kenneth,

I would suggest to structure your plugins as SciJava Commands, with
the @Parameter annotation. Then you will not need UI code, at least for
"run-and-done" commands, and they will work headless, and record script
snippets using the Macro Recorder [1]. Check the imagej/tutorials
repository for examples [2].

Adapting more complex interactive commands is more complicated. If you have
a well-designed public API which exposes the processing separate from the
UI, you can call that API from any of ImageJ's supporting scripting
languages [3]. To call your API from ImageJ macro is trickier, but can be
done in a relatively general manner by:

A) Using the 'call' function if you have public static methods that accept
only string arguments; and/or:
B) Using the 'eval("js", script)' function passing JavaScript code.

Regards,
Curtis

[1] https://imagej.net/Recorder
[2]
https://github.com/imagej/tutorials/blob/27d059117b3bfd1c73d8300f3193db11f6aebb9d/maven-projects/simple-commands/src/main/java/GradientImage.java#L21-L45
[3] https://imagej.net/Scripting

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/

On Mon, Sep 9, 2019 at 1:58 PM Kenneth Sloan <[hidden email]>
wrote:

> I have (almost exclusively) implemented Java plugins for ImageJ which
> are highly interactive.  While I have tried to compartmentalize the
> user interaction (mostly through dialog boxes) from the actual
> computations, I haven't always been completely successful.
>
> I'm looking for "best practices" on writing Java plugins which require
> multiple parameters - and which are written to accept these parameters
> either
> from their invocation, or as responses from  user interacting with dialog
> boxes.
>
> The movivation, of course, is that now many of the things which I have
> written
> as "exploratory, interactive mini-applications" have entered the world of
> "production use".
> I'm "on deadine" now with processing that will take me 8 hours to do
> interactively.  I suspect
> it will take me MORE than 8 hours to modify the existing code to be
> script-driven, but...once
> I get past this deadline I'll be strongly motivated to do some serious
> re-writing.
>
> One or two really good examples would be wonderful.
>
> --
> Kenneth Sloan
> [hidden email]
> Vision is the art of seeing what is invisible to others.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html