Modifying the Macro Recorder

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

Modifying the Macro Recorder

JonKaplan
Hello,
I am attempting to alter the Macro Recorder so that another plugin can be notified when the Recorder adds to its text.
I tried to copy the source code and add an underscore (as outlined at http://rsbweb.nih.gov/ij/docs/menus/plugins.html "Internal Plugins"). The new Recorder_ plugin runs fine and looks identical but does not do any recording. I believe this stems from not knowing what calls the Recorder methods.
If anyone knows how I could use a modified Recorder it would be much appreciated.

Thanks,
Jon
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the Macro Recorder

dscho
Hi,

On Tue, 20 Jul 2010, JonKaplan wrote:

> I am attempting to alter the Macro Recorder so that another plugin can
> be notified when the Recorder adds to its text.
>
> I tried to copy the source code and add an underscore (as outlined at
> http://rsbweb.nih.gov/ij/docs/menus/plugins.html "Internal Plugins").
> The new Recorder_ plugin runs fine and looks identical but does not do
> any recording. I believe this stems from not knowing what calls the
> Recorder methods.

The problem is that your class will not be used, but the original one,
unless you put the .jar containing your class _in front of_ ij.jar in the
classpath.

But a much better way to do what you want to do is probably to register a
CommandListener:
http://rsb.info.nih.gov/ij/developer/api/ij/Executer.html#addCommandListener(ij.CommandListener)

This listener will be notified whenever an action occurred.

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

Re: Modifying the Macro Recorder

dscho
Hi,

please reply-to-all when responding to me. If you reply to me privately
(and I then reply to you privately by mistake, too), then basically I
spend my time exclusively for you. All the while others might have been
interested in the discussion and could have learnt from it.

> On Tue, 27 Jul 2010, Jon Kaplan wrote:

> The command listener is pretty much what I was looking for. The problem
> though is my intention is to create a plug in to keep track of an
> image's history. After toying with the CommandListener I realized it
> does not have the same access to plugins as the Recorder. I hadn't
> realized that the GenericDialog class has built in commands to send
> options to the Recorder. This problem causes the CommandListener to be
> notified immediately so calling Recorder.getCommandOptions() always
> seems to return null.
>
> I guess ideally I would have a listener on the Recorder's text area, but I
> don't know a good way of getting around that to get command options.

This is a fragile setup, since the recorder can get closed and reopened
(in which case it is _another_ recorder).

A better way might be to go with ImageJA (included in Fiji), which has a
CommandListenerPlus, providing you with more detailed information.

Ciao,
Johannes