org.pushingpixels.flamingo.internal.ui.common
Class BasicCommandButtonUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ButtonUI
          extended by org.pushingpixels.flamingo.internal.ui.common.CommandButtonUI
              extended by org.pushingpixels.flamingo.internal.ui.common.BasicCommandButtonUI
Direct Known Subclasses:
BasicCommandMenuButtonUI, BasicCommandToggleButtonUI, BasicRibbonApplicationMenuButtonUI

public class BasicCommandButtonUI
extends CommandButtonUI

Basic UI for command button JCommandButton.


Field Summary
protected  BasicCommandButtonListener basicPopupButtonListener
          Tracks user interaction with the command button (including keyboard and mouse).
protected  javax.swing.CellRendererPane buttonRendererPane
          Used to provide a LAF-consistent appearance under core LAFs.
protected  AbstractCommandButton commandButton
          The associated command button.
protected  java.awt.event.ActionListener disposePopupsActionListener
          This listener disposes all popup panels when button's action is activated.
static java.lang.String DONT_DISPOSE_POPUPS
          Client property to mark the command button to not dispose the popups on activation.
static java.lang.String EMULATE_SQUARE_BUTTON
          Client property to mark the command button to have square corners.
protected  boolean isUnderMouse
          Indication whether the mouse pointer is over the associated command button.
protected  CommandButtonLayoutManager.CommandButtonLayoutInfo layoutInfo
          Layout information.
protected  CommandButtonLayoutManager layoutManager
           
protected  ResizableIcon popupActionIcon
          The "expand" action icon.
protected  PopupActionListener popupActionListener
          Action listener on the popup area.
protected  java.beans.PropertyChangeListener propertyChangeListener
          Property change listener.
protected  javax.swing.AbstractButton rendererButton
          Used to provide a LAF-consistent appearance under core LAFs.
protected  javax.swing.JSeparator rendererSeparator
          Used to paint the separator between the action and popup areas.
 
Constructor Summary
BasicCommandButtonUI()
          Creates a new UI delegate.
 
Method Summary
protected  void configureRenderer()
           
protected  BasicCommandButtonListener createButtonListener(AbstractCommandButton b)
          Creates the button listener for the specified command button.
protected  ResizableIcon createPopupActionIcon()
          Creates the icon for the popup area.
protected  PopupActionListener createPopupActionListener()
          Creates the popup action listener for this command button.
protected  javax.swing.AbstractButton createRendererButton()
          Creates the renderer button.
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
protected  java.awt.Color getForegroundColor(boolean isTextPaintedEnabled)
           
protected  javax.swing.Icon getIconToPaint()
          Returns the current icon.
 java.awt.Point getKeyTipAnchorCenterPoint()
           
protected  int getLayoutGap()
          Returns the layout gap for the visuals of the associated command button.
 CommandButtonLayoutManager.CommandButtonLayoutInfo getLayoutInfo()
          Returns the layout information for the associated button.
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
           
protected  void installComponents()
          Installs subcomponents on the associated command button.
protected  void installDefaults()
          Installs defaults on the associated command button.
protected  void installKeyboardActions()
          Installs the keyboard actions on the associated command button.
protected  void installListeners()
          Installs listeners on the associated command button.
 void installUI(javax.swing.JComponent c)
           
protected  boolean isPaintingBackground()
          Returns indication whether the button background is painted.
protected  boolean isPaintingSeparators()
          Returns indication whether the action-popup areas separator is painted.
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
           
protected  void paintButtonBackground(java.awt.Graphics graphics, java.awt.Rectangle toFill)
          Paints command button background.
protected  void paintButtonBackground(java.awt.Graphics graphics, java.awt.Rectangle toFill, javax.swing.ButtonModel... modelToUse)
          Paints the background of the command button.
protected  void paintButtonHorizontalSeparator(java.awt.Graphics graphics, java.awt.Rectangle separatorArea)
          Paints command button horizontal separator.
protected  void paintButtonIcon(java.awt.Graphics g, java.awt.Rectangle iconRect)
          Paints the button icon.
protected  void paintButtonVerticalSeparator(java.awt.Graphics graphics, java.awt.Rectangle separatorArea)
          Paints command button vertical separator.
protected  void paintPopupActionIcon(java.awt.Graphics g, java.awt.Rectangle popupActionRect)
          Paints the icon of the popup area.
protected  void processPopupAction()
           
protected  void syncDisabledIcon()
           
protected  void syncIconDimension()
           
protected  boolean toUseDisabledIcon()
           
protected  void unconfigureRenderer()
           
protected  void uninstallComponents()
          Uninstalls subcomponents from the associated command button.
protected  void uninstallDefaults()
          Uninstalls defaults from the associated command button.
protected  void uninstallKeyboardActions()
          Uninstalls the keyboard actions from the associated command button.
protected  void uninstallListeners()
          Uninstalls listeners from the associated command button.
 void uninstallUI(javax.swing.JComponent c)
           
 void update(java.awt.Graphics g, javax.swing.JComponent c)
           
protected  void updateBorder()
           
protected  void updateCustomDimension()
          Updates the custom dimension.
protected  void updatePopupActionIcon()
          Updates the popup action icon.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandButton

protected AbstractCommandButton commandButton
The associated command button.


isUnderMouse

protected boolean isUnderMouse
Indication whether the mouse pointer is over the associated command button.


propertyChangeListener

protected java.beans.PropertyChangeListener propertyChangeListener
Property change listener.


basicPopupButtonListener

protected BasicCommandButtonListener basicPopupButtonListener
Tracks user interaction with the command button (including keyboard and mouse).


layoutInfo

protected CommandButtonLayoutManager.CommandButtonLayoutInfo layoutInfo
Layout information.


EMULATE_SQUARE_BUTTON

public static final java.lang.String EMULATE_SQUARE_BUTTON
Client property to mark the command button to have square corners. This client property is for internal use only.

See Also:
Constant Field Values

DONT_DISPOSE_POPUPS

public static final java.lang.String DONT_DISPOSE_POPUPS
Client property to mark the command button to not dispose the popups on activation.

See Also:
disposePopupsActionListener, Constant Field Values

disposePopupsActionListener

protected java.awt.event.ActionListener disposePopupsActionListener
This listener disposes all popup panels when button's action is activated. An example of scenario would be a command button in the popup panel of an in-ribbon gallery. When this command button is activated, the associated popup panel is dismissed.

See Also:
DONT_DISPOSE_POPUPS

popupActionListener

protected PopupActionListener popupActionListener
Action listener on the popup area.


popupActionIcon

protected ResizableIcon popupActionIcon
The "expand" action icon.


layoutManager

protected CommandButtonLayoutManager layoutManager

buttonRendererPane

protected javax.swing.CellRendererPane buttonRendererPane
Used to provide a LAF-consistent appearance under core LAFs.


rendererButton

protected javax.swing.AbstractButton rendererButton
Used to provide a LAF-consistent appearance under core LAFs.


rendererSeparator

protected javax.swing.JSeparator rendererSeparator
Used to paint the separator between the action and popup areas.

Constructor Detail

BasicCommandButtonUI

public BasicCommandButtonUI()
Creates a new UI delegate.

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()
Installs defaults on the associated command button.


configureRenderer

protected void configureRenderer()

updateBorder

protected void updateBorder()

createRendererButton

protected javax.swing.AbstractButton createRendererButton()
Creates the renderer button.

Returns:
The renderer button.

installComponents

protected void installComponents()
Installs subcomponents on the associated command button.


installListeners

protected void installListeners()
Installs listeners on the associated command button.


createPopupActionIcon

protected ResizableIcon createPopupActionIcon()
Creates the icon for the popup area.

Returns:
The icon for the popup area.

createButtonListener

protected BasicCommandButtonListener createButtonListener(AbstractCommandButton b)
Creates the button listener for the specified command button.

Parameters:
b - Command button.
Returns:
The button listener for the specified command button.

installKeyboardActions

protected void installKeyboardActions()
Installs the keyboard actions on the associated command button.


uninstallDefaults

protected void uninstallDefaults()
Uninstalls defaults from the associated command button.


unconfigureRenderer

protected void unconfigureRenderer()

uninstallComponents

protected void uninstallComponents()
Uninstalls subcomponents from the associated command button.


uninstallListeners

protected void uninstallListeners()
Uninstalls listeners from the associated command button.


uninstallKeyboardActions

protected void uninstallKeyboardActions()
Uninstalls the keyboard actions from the associated command button.


update

public void update(java.awt.Graphics g,
                   javax.swing.JComponent c)
Overrides:
update in class javax.swing.plaf.ComponentUI

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Overrides:
paint in class javax.swing.plaf.ComponentUI

getForegroundColor

protected java.awt.Color getForegroundColor(boolean isTextPaintedEnabled)

paintPopupActionIcon

protected void paintPopupActionIcon(java.awt.Graphics g,
                                    java.awt.Rectangle popupActionRect)
Paints the icon of the popup area.

Parameters:
g - Graphics context.
popupActionRect -

getIconToPaint

protected javax.swing.Icon getIconToPaint()
Returns the current icon.

Returns:
Current icon.

toUseDisabledIcon

protected boolean toUseDisabledIcon()

paintButtonVerticalSeparator

protected void paintButtonVerticalSeparator(java.awt.Graphics graphics,
                                            java.awt.Rectangle separatorArea)
Paints command button vertical separator.

Parameters:
graphics - Graphics context.
separatorArea - Separator area.

paintButtonHorizontalSeparator

protected void paintButtonHorizontalSeparator(java.awt.Graphics graphics,
                                              java.awt.Rectangle separatorArea)
Paints command button horizontal separator.

Parameters:
graphics - Graphics context.
separatorArea - Separator area.

paintButtonBackground

protected void paintButtonBackground(java.awt.Graphics graphics,
                                     java.awt.Rectangle toFill)
Paints command button background.

Parameters:
graphics - Graphics context.
toFill - Rectangle for the background.

paintButtonBackground

protected void paintButtonBackground(java.awt.Graphics graphics,
                                     java.awt.Rectangle toFill,
                                     javax.swing.ButtonModel... modelToUse)
Paints the background of the command button.

Parameters:
graphics - Graphics context.
toFill - Rectangle to fill.
modelToUse - Button models to use for computing the background fill.

updateCustomDimension

protected void updateCustomDimension()
Updates the custom dimension.


updatePopupActionIcon

protected void updatePopupActionIcon()
Updates the popup action icon.


paintButtonIcon

protected void paintButtonIcon(java.awt.Graphics g,
                               java.awt.Rectangle iconRect)
Paints the button icon.

Parameters:
g - Graphics context.
iconRect - Icon rectangle.

getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
Overrides:
getPreferredSize in class javax.swing.plaf.ComponentUI

getLayoutInfo

public CommandButtonLayoutManager.CommandButtonLayoutInfo getLayoutInfo()
Description copied from class: CommandButtonUI
Returns the layout information for the associated button.

Specified by:
getLayoutInfo in class CommandButtonUI
Returns:
Layout information for the associated button.

getLayoutGap

protected int getLayoutGap()
Returns the layout gap for the visuals of the associated command button.

Returns:
The layout gap for the visuals of the associated command button.

isPaintingSeparators

protected boolean isPaintingSeparators()
Returns indication whether the action-popup areas separator is painted.

Returns:
true if the action-popup areas separator is painted.

isPaintingBackground

protected boolean isPaintingBackground()
Returns indication whether the button background is painted.

Returns:
true if the button background is painted.

createPopupActionListener

protected PopupActionListener createPopupActionListener()
Creates the popup action listener for this command button.

Returns:
Popup action listener for this command button.

processPopupAction

protected void processPopupAction()

syncDisabledIcon

protected void syncDisabledIcon()

syncIconDimension

protected void syncIconDimension()

getKeyTipAnchorCenterPoint

public java.awt.Point getKeyTipAnchorCenterPoint()
Specified by:
getKeyTipAnchorCenterPoint in class CommandButtonUI