Login  Register

Re: Listening on commands

Posted by ctrueden on Nov 17, 2014; 4:55pm
URL: http://imagej.273.s1.nabble.com/Listening-on-commands-tp5010468p5010489.html

Hi Filip,

> I wonder if it's possible to access both the currently performed
> command and its parameters.

In ImageJ2 you can subscribe to ModuleExecutedEvent [1] and/or other
ModuleExecutionEvent [2] subclasses of interest. There is an events
tutorial which is relevant [3].

But for ImageJ1 commands you'll have to use a different approach such as
what Jerome suggested.

Regards,
Curtis

[1]
http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutedEvent.html
[2]
http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutionEvent.html
[3]
https://github.com/imagej/imagej-tutorials/blob/master/listen-to-events/src/main/java/ListenToEvents.java

On Mon, Nov 17, 2014 at 2:14 AM, Filip Sedlák <[hidden email]> wrote:

> Thanks Jerome, I'll try it.
>
> Filip
>
>
> Dne 16.11.2014 v 23:38 Jerome Mutterer napsal(a):
> > Dear Filip,
> > IJ 1.47o4 introduced a new Recorder constructor: new Recorder(boolean
> > visible).
> > So you can silently create a a Recorder with:
> > Recorder r = new Recorder(false);
> > and at any time, retrieve the recorded macro:
> > String recordedMacro = r.getText();
> > that will contain both commands and parameters.
> > Sincerely,
> >
> > Jerome.
> >
> >
> >
> > On 16 November 2014 21:28, Filip Sedlak <[hidden email]> wrote:
> >
> >> Hi,
> >> I wonder if it's possible to access both the currently performed command
> >> and its parameters. Something similar what Plugins > Macro > Record does
> >> but from a plugin.
> >>
> >> I'd like to do an analysis of the user's actions and I need to get the
> >> performed operations without asking the user to e. g. copy-paste the
> >> recorder output to an external app.
> >>
> >> Using Executer.addCommandListener gives me only the command name and not
> >> its parameters. I started playing with ij.plugin.frame.Recorder, trying
> to
> >> patch it to support attaching listeners. The listeners would be notified
> >> with similar information like what is added to the text area.
> >>
> >> Can you see a simpler way to achieve this? Most importantly, it would be
> >> great if I could avoid running a patched version of the application.
> >>
> >> Thanks,
> >> Filip
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> >
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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