Module ij
Package ij.gui

Class Toolbar

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

    public class Toolbar
    extends java.awt.Canvas
    implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ItemListener, java.awt.event.ActionListener
    The ImageJ toolbar.
    See Also:
    Serialized Form
    • Nested Class Summary

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

        java.awt.Canvas.AccessibleAWTCanvas
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      Toolbar()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      void addMacroTool​(java.lang.String name, MacroInstaller macroInstaller)
      Used by the MacroInstaller class to add a macro tool to the toolbar.
      void addMacroTool​(java.lang.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​(java.lang.String toolTip)
      Adds a tool to the toolbar.
      static java.awt.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).
      java.awt.Color getColor()
      Deprecated.
      replaced by getForegroundColor()
      static java.awt.Color getForegroundColor()  
      static double getForegroundValue()  
      static Toolbar getInstance()
      Returns a reference to the ImageJ toolbar.
      java.awt.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()  
      java.awt.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​(java.lang.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 java.lang.String getToolName()
      Returns the name of the current tool.
      void init()  
      static boolean installStartupMacrosTools()  
      void installStartupTools()  
      void itemStateChanged​(java.awt.event.ItemEvent e)  
      void mouseClicked​(java.awt.event.MouseEvent e)  
      void mouseDragged​(java.awt.event.MouseEvent e)  
      void mouseEntered​(java.awt.event.MouseEvent e)  
      void mouseExited​(java.awt.event.MouseEvent e)  
      void mouseMoved​(java.awt.event.MouseEvent e)  
      void mousePressed​(java.awt.event.MouseEvent e)  
      void mouseReleased​(java.awt.event.MouseEvent e)  
      void paint​(java.awt.Graphics g)  
      static void removeMacroTools()  
      static void repaintTool​(int tool)  
      void restorePreviousTool()  
      static void restoreTools()  
      static void setBackgroundColor​(java.awt.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​(java.awt.Color c)
      Deprecated.
      replaced by setForegroundColor()
      static void setForegroundColor​(java.awt.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​(java.lang.String toolName, java.lang.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​(java.lang.String name)  
      static void showCode​(java.lang.String title, java.lang.String code)  
      void triggerPopupMenu​(int newTool, java.awt.event.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
    • Constructor Detail

      • Toolbar

        public Toolbar()
    • Method Detail

      • 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​(java.lang.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​(java.awt.Graphics g)
        Overrides:
        paint in class java.awt.Canvas
      • setTool

        public boolean setTool​(java.lang.String name)
      • getToolName

        public static java.lang.String getToolName()
        Returns the name of the current tool.
      • setTool

        public void setTool​(int tool)
      • getColor

        public java.awt.Color getColor()
        Deprecated.
        replaced by getForegroundColor()
      • setColor

        public void setColor​(java.awt.Color c)
        Deprecated.
        replaced by setForegroundColor()
      • getForegroundColor

        public static java.awt.Color getForegroundColor()
      • setForegroundColor

        public static void setForegroundColor​(java.awt.Color c)
      • getBackgroundColor

        public static java.awt.Color getBackgroundColor()
      • setBackgroundColor

        public static void setBackgroundColor​(java.awt.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,
                                     java.awt.event.MouseEvent e,
                                     boolean isRightClick,
                                     boolean isLongPress)
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • restorePreviousTool

        public void restorePreviousTool()
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • itemStateChanged

        public void itemStateChanged​(java.awt.event.ItemEvent e)
        Specified by:
        itemStateChanged in interface java.awt.event.ItemListener
      • restoreTools

        public static void restoreTools()
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Overrides:
        getPreferredSize in class java.awt.Component
      • getMinimumSize

        public java.awt.Dimension getMinimumSize()
        Overrides:
        getMinimumSize in class java.awt.Component
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • addTool

        public int addTool​(java.lang.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​(java.lang.String name,
                                 MacroInstaller macroInstaller,
                                 int id)
        Used by the MacroInstaller class to install a set of macro tools.
      • addMacroTool

        public void addMacroTool​(java.lang.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​(java.lang.String title,
                                    java.lang.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​(java.lang.String toolName,
                                   java.lang.String icon)
        Sets the icon of the specified macro or plugin tool.
        See: Help>Examples>Tool>Animated Icon Tool;