Module ij
Package ij.gui

# Class Toolbar

java.lang.Object
java.awt.Component
java.awt.Canvas
ij.gui.Toolbar

All Implemented Interfaces:
  `ActionListener`, `ItemListener`, `MouseListener`, `MouseMotionListener`, `ImageObserver`, `MenuContainer`, `Serializable`, `EventListener`, `Accessible`

public class Toolbar extends Canvas implements MouseListener, MouseMotionListener, ItemListener, ActionListener
The ImageJ toolbar.

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class java.awt.Canvas

`Canvas.AccessibleAWTCanvas`

## Nested classes/interfaces inherited from class java.awt.Component

`Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ANGLE`
`static final int`
`BRUSH_ROI`
`static final String[]`
`builtInTools`
`static final String`
`CORNER_DIAMETER`
`static final int`
`CROSSHAIR`
`static final int`
`CUSTOM1`
`static final int`
`CUSTOM2`
`static final int`
`CUSTOM3`
`static final int`
`CUSTOM4`
`static final int`
`CUSTOM5`
`static final int`
`CUSTOM6`
`static final int`
`CUSTOM7`
`static final int`
`DOUBLE_CLICK_THRESHOLD`
`static final int`
`DROPPER`
`static final int`
`ELLIPSE_ROI`
`static final int`
`FREELINE`
`static final int`
`FREEROI`
`static final int`
`HAND`
`static final int`
`LINE`
`static final int`
`MAGNIFIER`
`static final int`
`OVAL`
`static final int`
`OVAL_ROI`
`static final int`
`POINT`
`static final int`
`POLYGON`
`static final int`
`POLYLINE`
`static final int`
`RECT_ROI`
`static final int`
`RECTANGLE`
`static final int`
`ROTATED_RECT_ROI`
`static final int`
`ROUNDED_RECT_ROI`
`static final int`
`SPARE1`
Obsolete public constants
`static final int`
`SPARE2`
Obsolete public constants
`static final int`
`SPARE3`
Obsolete public constants
`static final int`
`SPARE4`
Obsolete public constants
`static final int`
`SPARE5`
Obsolete public constants
`static final int`
`SPARE6`
Obsolete public constants
`static final int`
`SPARE7`
Obsolete public constants
`static final int`
`SPARE8`
Obsolete public constants
`static final int`
`SPARE9`
Obsolete public constants
`static final int`
`TEXT`
`static String`
`TOOL_KEY`
`static final int`
`UNUSED`
`static final int`
`WAND`

### Fields inherited from class java.awt.Component

`accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

### Fields inherited from interface java.awt.image.ImageObserver

`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

## Constructor Summary

Constructors
Constructor
Description
`Toolbar()`

## Method Summary

Modifier and Type
Method
Description
`void`
`actionPerformed(ActionEvent e)`
`void`
`addMacroTool(String name, MacroInstaller macroInstaller)`
Used by the MacroInstaller class to add a macro tool to the toolbar.
`void`
`addMacroTool(String name, MacroInstaller macroInstaller, int id)`
Used by the MacroInstaller class to install a set of macro tools.
`static void`
`addPlugInTool(PlugInTool tool)`
Adds a plugin tool to the first available toolbar slot, or to the last slot if the toolbar is full.
`int`
`addTool(String toolTip)`
Adds a tool to the toolbar.
`static Color`
`getBackgroundColor()`
`static double`
`getBackgroundValue()`
`static int`
`getBrushSize()`
Returns the size of the selection brush tool, or 0 if the brush tool is not enabled.
`static int`
`getButtonSize()`
Returns the button width (button spacing).
`Color`
`getColor()`
Deprecated.
replaced by getForegroundColor()
`static Color`
`getForegroundColor()`
`static double`
`getForegroundValue()`
`static Toolbar`
`getInstance()`
Returns a reference to the ImageJ toolbar.
`Dimension`
`getMinimumSize()`
`static boolean`
`getMultiPointMode()`
Returns 'true' if the multi-point tool is enabled.
`int`
`getNumTools()`
`static int`
`getOvalToolType()`
Returns the oval tool type (OVAL_ROI, ELLIPSE_ROI or BRUSH_ROI).
`static PlugInTool`
`getPlugInTool()`
`Dimension`
`getPreferredSize()`
`static int`
`getRectToolType()`
Returns the rectangle tool type (RECT_ROI, ROUNDED_RECT_ROI or ROTATED_RECT_ROI).
`static int`
`getRoundRectArcSize()`
Returns the rounded rectangle arc size, or 0 if the rounded rectangle tool is not enabled.
`static int`
`getToolId()`
Returns the ID of the current tool (Toolbar.RECTANGLE, Toolbar.OVAL, etc.).
`int`
`getToolId(String name)`
Returns the ID of the tool whose name (the description displayed in the status bar) starts with the specified string, or -1 if the tool is not found.
`static String`
`getToolName()`
Returns the name of the current tool.
`void`
`init()`
`static boolean`
`installStartupMacrosTools()`
`void`
`installStartupTools()`
`void`
`itemStateChanged(ItemEvent e)`
`void`
`mouseClicked(MouseEvent e)`
`void`
`mouseDragged(MouseEvent e)`
`void`
`mouseEntered(MouseEvent e)`
`void`
`mouseExited(MouseEvent e)`
`void`
`mouseMoved(MouseEvent e)`
`void`
`mousePressed(MouseEvent e)`
`void`
`mouseReleased(MouseEvent e)`
`void`
`paint(Graphics g)`
`static void`
`removeMacroTools()`
`static void`
`repaintTool(int tool)`
`void`
`restorePreviousTool()`
`static void`
`restoreTools()`
`static void`
`setBackgroundColor(Color c)`
`static void`
`setBackgroundValue(double value)`
Sets the background color to grayscale, where value is between 0 (black) and 255 (white).
`static void`
`setBrushSize(int size)`
Set the size of the selection brush tool, in pixels.
`void`
`setColor(Color c)`
Deprecated.
replaced by setForegroundColor()
`static void`
`setForegroundColor(Color c)`
`static void`
`setForegroundValue(double value)`
Sets the foreground color to grayscale, where value is between 0 (black) and 255 (white).
`static void`
`setIcon(String toolName, String icon)`
Sets the icon of the specified macro or plugin tool.
See: Help>Examples>Tool>Animated Icon Tool;
`static void`
`setLongClickDelay(int delay)`
Sets the tool menu long click delay in milliseconds (default is 600).
`static void`
`setRoundRectArcSize(int size)`
Sets the rounded rectangle corner diameter (pixels).
`void`
`setTool(int tool)`
`boolean`
`setTool(String name)`
`static void`
`showCode(String title, String code)`
`void`
`triggerPopupMenu(int newTool, MouseEvent e, boolean isRightClick, boolean isLongPress)`

### Methods inherited from class java.awt.Canvas

`addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update`

### Methods inherited from class java.awt.Component

`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### RECTANGLE

public static final int RECTANGLE

See Also:
  - Constant Field Values

### OVAL

public static final int OVAL

See Also:
  - Constant Field Values

### POLYGON

public static final int POLYGON

See Also:
  - Constant Field Values

### FREEROI

public static final int FREEROI

See Also:
  - Constant Field Values

### LINE

public static final int LINE

See Also:
  - Constant Field Values

### POLYLINE

public static final int POLYLINE

See Also:
  - Constant Field Values

### FREELINE

public static final int FREELINE

See Also:
  - Constant Field Values

### POINT

public static final int POINT

See Also:
  - Constant Field Values

### CROSSHAIR

public static final int CROSSHAIR

See Also:
  - Constant Field Values

### WAND

public static final int WAND

See Also:
  - Constant Field Values

### TEXT

public static final int TEXT

See Also:
  - Constant Field Values

### UNUSED

public static final int UNUSED

See Also:
  - Constant Field Values

### MAGNIFIER

public static final int MAGNIFIER

See Also:
  - Constant Field Values

### HAND

public static final int HAND

See Also:
  - Constant Field Values

### DROPPER

public static final int DROPPER

See Also:
  - Constant Field Values

### ANGLE

public static final int ANGLE

See Also:
  - Constant Field Values

### CUSTOM1

public static final int CUSTOM1

See Also:
  - Constant Field Values

### CUSTOM2

public static final int CUSTOM2

See Also:
  - Constant Field Values

### CUSTOM3

public static final int CUSTOM3

See Also:
  - Constant Field Values

### CUSTOM4

public static final int CUSTOM4

See Also:
  - Constant Field Values

### CUSTOM5

public static final int CUSTOM5

See Also:
  - Constant Field Values

### CUSTOM6

public static final int CUSTOM6

See Also:
  - Constant Field Values

### CUSTOM7

public static final int CUSTOM7

See Also:
  - Constant Field Values

### DOUBLE_CLICK_THRESHOLD

public static final int DOUBLE_CLICK_THRESHOLD

See Also:
  - Constant Field Values

### RECT_ROI

public static final int RECT_ROI

See Also:
  - Constant Field Values

### ROUNDED_RECT_ROI

public static final int ROUNDED_RECT_ROI

See Also:
  - Constant Field Values

### ROTATED_RECT_ROI

public static final int ROTATED_RECT_ROI

See Also:
  - Constant Field Values

### OVAL_ROI

public static final int OVAL_ROI

See Also:
  - Constant Field Values

### ELLIPSE_ROI

public static final int ELLIPSE_ROI

See Also:
  - Constant Field Values

### BRUSH_ROI

public static final int BRUSH_ROI

See Also:
  - Constant Field Values

### builtInTools

public static final String[] builtInTools

### CORNER_DIAMETER

public static final String CORNER_DIAMETER

See Also:
  - Constant Field Values

### TOOL_KEY

public static String TOOL_KEY

### SPARE1

public static final int SPARE1
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE2

public static final int SPARE2
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE3

public static final int SPARE3
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE4

public static final int SPARE4
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE5

public static final int SPARE5
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE6

public static final int SPARE6
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE7

public static final int SPARE7
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE8

public static final int SPARE8
Obsolete public constants

See Also:
  - Constant Field Values

### SPARE9

public static final int SPARE9
Obsolete public constants

See Also:
  - Constant Field Values

## Constructor Details

### Toolbar

public Toolbar()

## Method Details

### init

public void init()

### getToolId

public static int getToolId()
Returns the ID of the current tool (Toolbar.RECTANGLE, Toolbar.OVAL, etc.).

### getToolId

public int getToolId(String name)
Returns the ID of the tool whose name (the description displayed in the status bar) starts with the specified string, or -1 if the tool is not found.

### getInstance

public static Toolbar getInstance()
Returns a reference to the ImageJ toolbar.

### paint

public void paint(Graphics g)

Overrides:
  `paint` in class `Canvas`

### setTool

public boolean setTool(String name)

### getToolName

public static String getToolName()
Returns the name of the current tool.

### setTool

public void setTool(int tool)

### getColor

public Color getColor()
Deprecated.
replaced by getForegroundColor()

### setColor

public void setColor(Color c)
Deprecated.
replaced by setForegroundColor()

### getForegroundColor

public static Color getForegroundColor()

### setForegroundColor

public static void setForegroundColor(Color c)

### getBackgroundColor

public static Color getBackgroundColor()

### setBackgroundColor

public static void setBackgroundColor(Color c)

### getForegroundValue

public static double getForegroundValue()

### setForegroundValue

public static void setForegroundValue(double value)
Sets the foreground color to grayscale, where value is between 0 (black) and 255 (white).

### getBackgroundValue

public static double getBackgroundValue()

### setBackgroundValue

public static void setBackgroundValue(double value)
Sets the background color to grayscale, where value is between 0 (black) and 255 (white).

### getBrushSize

public static int getBrushSize()
Returns the size of the selection brush tool, or 0 if the brush tool is not enabled.

### setBrushSize

public static void setBrushSize(int size)
Set the size of the selection brush tool, in pixels.

### getRoundRectArcSize

public static int getRoundRectArcSize()
Returns the rounded rectangle arc size, or 0 if the rounded rectangle tool is not enabled.

### setRoundRectArcSize

public static void setRoundRectArcSize(int size)
Sets the rounded rectangle corner diameter (pixels).

### getMultiPointMode

public static boolean getMultiPointMode()
Returns 'true' if the multi-point tool is enabled.

### getRectToolType

public static int getRectToolType()
Returns the rectangle tool type (RECT_ROI, ROUNDED_RECT_ROI or ROTATED_RECT_ROI).

### getOvalToolType

public static int getOvalToolType()
Returns the oval tool type (OVAL_ROI, ELLIPSE_ROI or BRUSH_ROI).

### getButtonSize

public static int getButtonSize()
Returns the button width (button spacing).

### repaintTool

public static void repaintTool(int tool)

### triggerPopupMenu

public void triggerPopupMenu(int newTool, MouseEvent e, boolean isRightClick, boolean isLongPress)

### mousePressed

public void mousePressed(MouseEvent e)

Specified by:
  `mousePressed` in interface `MouseListener`

### mouseReleased

public void mouseReleased(MouseEvent e)

Specified by:
  `mouseReleased` in interface `MouseListener`

### restorePreviousTool

public void restorePreviousTool()

### mouseExited

public void mouseExited(MouseEvent e)

Specified by:
  `mouseExited` in interface `MouseListener`

### mouseClicked

public void mouseClicked(MouseEvent e)

Specified by:
  `mouseClicked` in interface `MouseListener`

### mouseEntered

public void mouseEntered(MouseEvent e)

Specified by:
  `mouseEntered` in interface `MouseListener`

### mouseDragged

public void mouseDragged(MouseEvent e)

Specified by:
  `mouseDragged` in interface `MouseMotionListener`

### itemStateChanged

public void itemStateChanged(ItemEvent e)

Specified by:
  `itemStateChanged` in interface `ItemListener`

### restoreTools

public static void restoreTools()

### actionPerformed

public void actionPerformed(ActionEvent e)

Specified by:
  `actionPerformed` in interface `ActionListener`

### getPreferredSize

public Dimension getPreferredSize()

Overrides:
  `getPreferredSize` in class `Component`

### getMinimumSize

public Dimension getMinimumSize()

Overrides:
  `getMinimumSize` in class `Component`

### mouseMoved

public void mouseMoved(MouseEvent e)

Specified by:
  `mouseMoved` in interface `MouseMotionListener`

### addTool

public int addTool(String toolTip)
Adds a tool to the toolbar. The 'toolTip' string is displayed in the status bar when the mouse is over the tool icon. The 'toolTip' string may include icon (http://imagej.nih.gov/ij/developer/macro/macros.html#tools). Returns the tool ID, or -1 if all tool slots are in use.

### addMacroTool

public void addMacroTool(String name, MacroInstaller macroInstaller, int id)
Used by the MacroInstaller class to install a set of macro tools.

### addMacroTool

public void addMacroTool(String name, MacroInstaller macroInstaller)
Used by the MacroInstaller class to add a macro tool to the toolbar.

### removeMacroTools

public static void removeMacroTools()

### addPlugInTool

public static void addPlugInTool(PlugInTool tool)
Adds a plugin tool to the first available toolbar slot, or to the last slot if the toolbar is full.

### getPlugInTool

public static PlugInTool getPlugInTool()

### installStartupTools

public void installStartupTools()

### showCode

public static void showCode(String title, String code)

### installStartupMacrosTools

public static boolean installStartupMacrosTools()

### getNumTools

public int getNumTools()

### setLongClickDelay

public static void setLongClickDelay(int delay)
Sets the tool menu long click delay in milliseconds (default is 600). Set to 0 to disable long click triggering.

### setIcon

public static void setIcon(String toolName, String icon)
Sets the icon of the specified macro or plugin tool.
See: Help>Examples>Tool>Animated Icon Tool;