JHotDraw 7.4.1

org.jhotdraw.gui.plaf.palette
Class PaletteToolBarUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ToolBarUI
          extended by org.jhotdraw.gui.plaf.palette.PaletteToolBarUI
All Implemented Interfaces:
javax.swing.SwingConstants

public class PaletteToolBarUI
extends javax.swing.plaf.ToolBarUI
implements javax.swing.SwingConstants

ToolBarUI for palette components.

This UI differs from BasicToolBarUI, in that the component holding the toolbar is supposed to use BoxLayout instead of BorderLayout. This allows to have multiple toolbars in the same component. The toolbars can be reorderd in the component, but they are not allowed to float in their own floating window.

The JToolBar starts dragging only, if the drag starts over the insets of its border.

Author:
Werner Randelshofer  @version $Id: PaletteToolBarUI.java 527 2009-06-07 14:28:19Z rawcoder $

Nested Class Summary
 class PaletteToolBarUI.DockingListener
          This class should be treated as a "protected" inner class.
protected  class PaletteToolBarUI.DragWindow
           
protected  class PaletteToolBarUI.FrameListener
           
protected  class PaletteToolBarUI.PropertyListener
           
protected  class PaletteToolBarUI.ToolBarContListener
           
protected  class PaletteToolBarUI.ToolBarFocusListener
           
 
Field Summary
protected  java.lang.Integer constraintBeforeFloating
           
protected  java.awt.Color dockingBorderColor
           
protected  java.awt.Color dockingColor
           
protected  javax.swing.event.MouseInputListener dockingListener
           
protected  javax.swing.KeyStroke downKey
          Deprecated. As of Java 2 platform v1.3.
protected  PaletteToolBarUI.DragWindow dragWindow
           
protected  java.awt.Color floatingBorderColor
           
protected  java.awt.Color floatingColor
           
protected  int focusedCompIndex
           
protected  javax.swing.KeyStroke leftKey
          Deprecated. As of Java 2 platform v1.3.
protected  java.beans.PropertyChangeListener propertyListener
           
protected  javax.swing.KeyStroke rightKey
          Deprecated. As of Java 2 platform v1.3.
protected  javax.swing.JToolBar toolBar
           
static java.lang.String TOOLBAR_ICON_PROPERTY
           
static java.lang.String TOOLBAR_INSETS_OVERRIDE_PROPERTY
           
static java.lang.String TOOLBAR_TEXT_ICON_GAP_PROPERTY
           
protected  java.awt.event.ContainerListener toolBarContListener
           
protected  java.awt.event.FocusListener toolBarFocusListener
           
protected  javax.swing.KeyStroke upKey
          Deprecated. As of Java 2 platform v1.3.
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
PaletteToolBarUI()
           
 
Method Summary
 boolean canDock(java.awt.Component c, java.awt.Point p)
           
protected  javax.swing.event.MouseInputListener createDockingListener()
           
protected  PaletteToolBarUI.DragWindow createDragWindow(javax.swing.JToolBar toolbar)
           
protected  javax.swing.JFrame createFloatingFrame(javax.swing.JToolBar toolbar)
          No longer used, use PaletteToolBarUI.createFloatingWindow(JToolBar)
protected  javax.swing.RootPaneContainer createFloatingWindow(javax.swing.JToolBar toolbar)
          Creates a window which contains the toolbar after it has been dragged out from its container
protected  java.awt.event.WindowListener createFrameListener()
           
protected  javax.swing.border.Border createNonRolloverBorder()
          Creates the non rollover border for toolbar components.
protected  java.beans.PropertyChangeListener createPropertyListener()
           
protected  javax.swing.border.Border createRolloverBorder()
          Creates a rollover border for toolbar components.
protected  java.awt.event.ContainerListener createToolBarContListener()
           
protected  java.awt.event.FocusListener createToolBarFocusListener()
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
protected  void dragTo(java.awt.Point position, java.awt.Point origin)
           
protected  void floatAt(java.awt.Point position, java.awt.Point origin)
           
 java.awt.Color getDockingColor()
          Gets the color displayed when over a docking area
 java.awt.Color getFloatingColor()
          Gets the color displayed when over a floating area
protected  void installComponents()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  void installListeners()
           
protected  void installNonRolloverBorders(javax.swing.JComponent c)
          Installs non-rollover borders on all the child components of the JComponent.
protected  void installNormalBorders(javax.swing.JComponent c)
          Installs normal borders on all the child components of the JComponent.
protected  void installRolloverBorders(javax.swing.JComponent c)
          Installs rollover borders on all the child components of the JComponent.
 void installUI(javax.swing.JComponent c)
           
 boolean isFloating()
           
 boolean isRolloverBorders()
          Returns a flag to determine whether rollover button borders are enabled.
protected  void navigateFocusedComp(int direction)
           
protected  void paintDragWindow(java.awt.Graphics g)
          Paints the contents of the window used for dragging.
protected  void setBorderToNonRollover(java.awt.Component c)
          Sets the border of the component to have a non-rollover border which was created by createNonRolloverBorder.
protected  void setBorderToNormal(java.awt.Component c)
          Sets the border of the component to have a normal border.
protected  void setBorderToRollover(java.awt.Component c)
          Sets the border of the component to have a rollover border which was created by createRolloverBorder.
 void setDockingColor(java.awt.Color c)
          Sets the color displayed when over a docking area
 void setFloating(boolean b, java.awt.Point p)
           
 void setFloatingColor(java.awt.Color c)
          Sets the color displayed when over a floating area
 void setFloatingLocation(int x, int y)
           
 void setOrientation(int orientation)
           
 void setRolloverBorders(boolean rollover)
          Sets the flag for enabling rollover borders on the toolbar and it will also install the apropriate border depending on the state of the flag.
protected  void uninstallComponents()
           
protected  void uninstallDefaults()
           
protected  void uninstallKeyboardActions()
           
protected  void uninstallListeners()
           
 void uninstallUI(javax.swing.JComponent c)
           
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, paint, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toolBar

protected javax.swing.JToolBar toolBar

dragWindow

protected PaletteToolBarUI.DragWindow dragWindow

focusedCompIndex

protected int focusedCompIndex

dockingColor

protected java.awt.Color dockingColor

floatingColor

protected java.awt.Color floatingColor

dockingBorderColor

protected java.awt.Color dockingBorderColor

floatingBorderColor

protected java.awt.Color floatingBorderColor

dockingListener

protected javax.swing.event.MouseInputListener dockingListener

propertyListener

protected java.beans.PropertyChangeListener propertyListener

toolBarContListener

protected java.awt.event.ContainerListener toolBarContListener

toolBarFocusListener

protected java.awt.event.FocusListener toolBarFocusListener

constraintBeforeFloating

protected java.lang.Integer constraintBeforeFloating

TOOLBAR_ICON_PROPERTY

public static final java.lang.String TOOLBAR_ICON_PROPERTY
See Also:
Constant Field Values

TOOLBAR_TEXT_ICON_GAP_PROPERTY

public static final java.lang.String TOOLBAR_TEXT_ICON_GAP_PROPERTY
See Also:
Constant Field Values

TOOLBAR_INSETS_OVERRIDE_PROPERTY

public static final java.lang.String TOOLBAR_INSETS_OVERRIDE_PROPERTY
See Also:
Constant Field Values

upKey

@Deprecated
protected javax.swing.KeyStroke upKey
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.


downKey

@Deprecated
protected javax.swing.KeyStroke downKey
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.


leftKey

@Deprecated
protected javax.swing.KeyStroke leftKey
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.


rightKey

@Deprecated
protected javax.swing.KeyStroke rightKey
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.

Constructor Detail

PaletteToolBarUI

public PaletteToolBarUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)

installUI

public void installUI(javax.swing.JComponent c)
Overrides:
installUI in class javax.swing.plaf.ComponentUI

uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Overrides:
uninstallUI in class javax.swing.plaf.ComponentUI

installDefaults

protected void installDefaults()

uninstallDefaults

protected void uninstallDefaults()

installComponents

protected void installComponents()

uninstallComponents

protected void uninstallComponents()

installListeners

protected void installListeners()

uninstallListeners

protected void uninstallListeners()

installKeyboardActions

protected void installKeyboardActions()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

navigateFocusedComp

protected void navigateFocusedComp(int direction)

createRolloverBorder

protected javax.swing.border.Border createRolloverBorder()
Creates a rollover border for toolbar components. The rollover border will be installed if rollover borders are enabled.

Override this method to provide an alternate rollover border.

Since:
1.4

createNonRolloverBorder

protected javax.swing.border.Border createNonRolloverBorder()
Creates the non rollover border for toolbar components. This border will be installed as the border for components added to the toolbar if rollover borders are not enabled.

Override this method to provide an alternate rollover border.

Since:
1.4

createFloatingFrame

protected javax.swing.JFrame createFloatingFrame(javax.swing.JToolBar toolbar)
No longer used, use PaletteToolBarUI.createFloatingWindow(JToolBar)

See Also:
createFloatingWindow(javax.swing.JToolBar)

createFloatingWindow

protected javax.swing.RootPaneContainer createFloatingWindow(javax.swing.JToolBar toolbar)
Creates a window which contains the toolbar after it has been dragged out from its container

Returns:
a RootPaneContainer object, containing the toolbar.

createDragWindow

protected PaletteToolBarUI.DragWindow createDragWindow(javax.swing.JToolBar toolbar)

isRolloverBorders

public boolean isRolloverBorders()
Returns a flag to determine whether rollover button borders are enabled.

Returns:
true if rollover borders are enabled; false otherwise
Since:
1.4
See Also:
setRolloverBorders(boolean)

setRolloverBorders

public void setRolloverBorders(boolean rollover)
Sets the flag for enabling rollover borders on the toolbar and it will also install the apropriate border depending on the state of the flag.

Parameters:
rollover - if true, rollover borders are installed. Otherwise non-rollover borders are installed
Since:
1.4
See Also:
isRolloverBorders()

installRolloverBorders

protected void installRolloverBorders(javax.swing.JComponent c)
Installs rollover borders on all the child components of the JComponent.

This is a convenience method to call setBorderToRollover for each child component.

Parameters:
c - container which holds the child components (usally a JToolBar)
Since:
1.4
See Also:
setBorderToRollover(java.awt.Component)

installNonRolloverBorders

protected void installNonRolloverBorders(javax.swing.JComponent c)
Installs non-rollover borders on all the child components of the JComponent. A non-rollover border is the border that is installed on the child component while it is in the toolbar.

This is a convenience method to call setBorderToNonRollover for each child component.

Parameters:
c - container which holds the child components (usally a JToolBar)
Since:
1.4
See Also:
setBorderToNonRollover(java.awt.Component)

installNormalBorders

protected void installNormalBorders(javax.swing.JComponent c)
Installs normal borders on all the child components of the JComponent. A normal border is the original border that was installed on the child component before it was added to the toolbar.

This is a convenience method to call setBorderNormal for each child component.

Parameters:
c - container which holds the child components (usally a JToolBar)
Since:
1.4
See Also:
setBorderToNonRollover(java.awt.Component)

setBorderToRollover

protected void setBorderToRollover(java.awt.Component c)
Sets the border of the component to have a rollover border which was created by createRolloverBorder.

Parameters:
c - component which will have a rollover border installed
Since:
1.4
See Also:
createRolloverBorder()

setBorderToNonRollover

protected void setBorderToNonRollover(java.awt.Component c)
Sets the border of the component to have a non-rollover border which was created by createNonRolloverBorder.

Parameters:
c - component which will have a non-rollover border installed
Since:
1.4
See Also:
createNonRolloverBorder()

setBorderToNormal

protected void setBorderToNormal(java.awt.Component c)
Sets the border of the component to have a normal border. A normal border is the original border that was installed on the child component before it was added to the toolbar.

Parameters:
c - component which will have a normal border re-installed
Since:
1.4
See Also:
createNonRolloverBorder()

setFloatingLocation

public void setFloatingLocation(int x,
                                int y)

isFloating

public boolean isFloating()

setFloating

public void setFloating(boolean b,
                        java.awt.Point p)

setOrientation

public void setOrientation(int orientation)

getDockingColor

public java.awt.Color getDockingColor()
Gets the color displayed when over a docking area


setDockingColor

public void setDockingColor(java.awt.Color c)
Sets the color displayed when over a docking area


getFloatingColor

public java.awt.Color getFloatingColor()
Gets the color displayed when over a floating area


setFloatingColor

public void setFloatingColor(java.awt.Color c)
Sets the color displayed when over a floating area


canDock

public boolean canDock(java.awt.Component c,
                       java.awt.Point p)

dragTo

protected void dragTo(java.awt.Point position,
                      java.awt.Point origin)

floatAt

protected void floatAt(java.awt.Point position,
                       java.awt.Point origin)

createToolBarContListener

protected java.awt.event.ContainerListener createToolBarContListener()

createToolBarFocusListener

protected java.awt.event.FocusListener createToolBarFocusListener()

createPropertyListener

protected java.beans.PropertyChangeListener createPropertyListener()

createDockingListener

protected javax.swing.event.MouseInputListener createDockingListener()

createFrameListener

protected java.awt.event.WindowListener createFrameListener()

paintDragWindow

protected void paintDragWindow(java.awt.Graphics g)
Paints the contents of the window used for dragging.

Parameters:
g - Graphics to paint to.
Throws:
java.lang.NullPointerException - is g is null
Since:
1.5

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.