Login  Register

Re: Own icons in toolbar

Posted by dscho on Feb 18, 2014; 6:19pm
URL: http://imagej.273.s1.nabble.com/Own-icons-in-toolbar-tp5006564p5006566.html

Hi Jiří,

On Tue, 18 Feb 2014, Jiří Borovec wrote:

> may I ask if there is a simple way how to add new icons in IJ toolbar and
> associate an action to each of them. The idea behind is simple, just have
> an overlap segmentation and set of icons/numbers {0,20,40,60,80,100} in the
> toolbar. After each click the transparency of segmentation is changed. I
> went throw IJ api but I have not found anything suitable. Does anyone an
> advice?

There are three ways to do so:

1) use a macro (this used to be the old way, and for full
backwards-compatibility you might need to do it that way because some
users are stuck with older ImageJ 1.x versions due to some plugins no
longer working):

http://imagej.nih.gov/ij/developer/macro/macros.html#tools

2) implement a PlugInTool (added in 1.46d):

http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/ij/plugin/tool/PlugInTool.html

3) use Fiji's AbstractTool infrastructure (which inspired Wayne to add the
slightly more limited PlugInTool infrastructure):

http://jenkins.imagej.net/view/Fiji/job/Fiji-javadoc/javadoc/fiji/tool/AbstractTool.html

Unfortunately, I still did not find time to document this better, so the
source code may serve as a starting point:

https://github.com/fiji/fiji/blob/master/src-plugins/fiji-lib/src/main/java/fiji/tool/AbstractTool.java

The idea is that you define what your tool wants to override by
implementing one or more of the following interfaces (in addition to
extending AbstractTool):

MouseListener, MouseMotionListener, MouseWheelListener, KeyListener,
SliceListener, ToolWithOptions, ToolToggleListener.

Examples for the different methods:

1)

https://github.com/fiji/fiji/blob/master/src-plugins/VIB_/src/main/java/ROIBrush_.java#L17

2)

http://imagej.nih.gov/ij/plugins/download/Example_Tool.java

3)

https://github.com/fiji/fiji/blob/master/src-plugins/Script_Editor/src/main/resources/templates/Java/Bare_Tool.java

Ciao,
Dscho

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