Login  Register

A tool with icon from a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

A tool with icon from a plugin

Yuekan Jiao-2
29 posts
Hello every one,

I am writing a plugin that uses mouse listening. One thing I want to
do is create a tool onto the toolbar - the plugin responds to the
mouse actions (clicking, dragging etc.) on an image when the created
tool is selected, and does not when other tools (area selection,
drawing etc.) are selected. I am able to do this by using the
commented-out sentences in the mouse_listener plugin

int tool = Toolbar.getInstance().addTool("Test Tool");
Toolbar.getInstance().setTool(tool);

and checking if the selected tool is the tool created ("Test Tool").

My question is how I can put an icon (just 1-2 letters) on the tool
created. A icon can be created with a tool macro but running the macro
pushes the default ImageJ macro tools aside.

Thank you.


Yuekan Jiao, PhD
Victoria, BC
[hidden email]
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: A tool with icon from a plugin

dscho
1631 posts
Hi,

On Sat, 26 Nov 2011, Yuekan Jiao wrote:

> I am writing a plugin that uses mouse listening. One thing I want to
> do is create a tool onto the toolbar - the plugin responds to the
> mouse actions (clicking, dragging etc.) on an image when the created
> tool is selected, and does not when other tools (area selection,
> drawing etc.) are selected. I am able to do this by using the
> commented-out sentences in the mouse_listener plugin
>
> int tool = Toolbar.getInstance().addTool("Test Tool");
> Toolbar.getInstance().setTool(tool);
>
> and checking if the selected tool is the tool created ("Test Tool").

There is more to it than testing whether the tool is selected or not. You
might be interested in Fiji's AbstractTool framework which takes all the
pain away from making a tool using Java.

You can check it out by starting Fiji's Script Editor and then selecting
"Bare Tool" from the Templates>Java menu. Run>Run will ask you to save the
file and start the tool plugin.

> My question is how I can put an icon (just 1-2 letters) on the tool
> created. A icon can be created with a tool macro but running the macro
> pushes the default ImageJ macro tools aside.

With the AbstractTool framework, you can easily override the tool icon by
implementing the getToolIcon() method.

To generate an icon, either you learn how to write that string, or you
make a 16x16 pixel image and call Fiji's Plugins>Examples>Image To Tool
Icon which will output that icon string to the Log window.

Ciao,
Johannes