Quaqua 7.4.2 2011-07-05

ch.randelshofer.quaqua
Class QuaquaButtonUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ButtonUI
          extended by javax.swing.plaf.basic.BasicButtonUI
              extended by ch.randelshofer.quaqua.QuaquaButtonUI
All Implemented Interfaces:
VisuallyLayoutable
Direct Known Subclasses:
QuaquaToggleButtonUI

public class QuaquaButtonUI
extends javax.swing.plaf.basic.BasicButtonUI
implements VisuallyLayoutable

QuaquaButtonUI.

Version:
$Id: QuaquaButtonUI.java 396 2011-07-05 19:32:05Z wrandelshofer $
Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class javax.swing.plaf.basic.BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset
 
Fields inherited from interface ch.randelshofer.quaqua.VisuallyLayoutable
CLIP_BOUNDS, COMPONENT_BOUNDS, TEXT_BOUNDS
 
Constructor Summary
QuaquaButtonUI()
           
 
Method Summary
protected  javax.swing.plaf.basic.BasicButtonListener createButtonListener(javax.swing.AbstractButton b)
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
          Push Button.
 int getBaseline(javax.swing.JComponent c, int width, int height)
          Returns the baseline for the specified component, or -1 if the baseline can not be determined.
 java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
           
 java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
           
static java.awt.Dimension getPreferredSize(javax.swing.AbstractButton b)
           
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
           
protected  java.lang.String getPropertyPrefix()
          This method is here, to let QuaquaButtonListener access this property.
 java.awt.Rectangle getVisualBounds(javax.swing.JComponent c, int type, int width, int height)
          Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.
protected  void installDefaults(javax.swing.AbstractButton b)
           
protected  java.lang.String layoutCL(javax.swing.AbstractButton c, java.awt.FontMetrics fontMetrics, java.lang.String text, javax.swing.Icon icon, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR)
          Forwards the call to SwingUtilities.layoutCompoundLabel().
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
           
protected  void paintIcon(java.awt.Graphics g, javax.swing.JComponent c, java.awt.Rectangle iconRect)
           
protected  void paintText(java.awt.Graphics g, javax.swing.AbstractButton b, java.awt.Rectangle textRect, java.lang.String text)
          Method which renders the text of the current button.
protected  void paintText(java.awt.Graphics g, javax.swing.JComponent c, java.awt.Rectangle textRect, java.lang.String text)
          As of Java 2 platform v 1.4 this method should not be used or overriden.
 
Methods inherited from class javax.swing.plaf.basic.BasicButtonUI
clearTextShiftOffset, getBaselineResizeBehavior, getDefaultTextIconGap, getTextShiftOffset, installKeyboardActions, installListeners, installUI, paintButtonPressed, paintFocus, setTextShiftOffset, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuaquaButtonUI

public QuaquaButtonUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
Push Button. Preferred spacing between buttons and other components. / private final static Insets pushRegularSpacing = new Insets(12,12,12,12); private final static Insets pushSmallSpacing = new Insets(10,10,10,10); private final static Insets pushMiniSpacing = new Insets(8,8,8,8); /** Metal Button. Preferred spacing between buttons and other components. / private final static Insets metalRegularSpacing = new Insets(12,12,12,12); private final static Insets metalSmallSpacing = new Insets(8,8,8,8); /** Bevel Button. Preferred spacing between buttons and other components. Large Spacing is used, if the bevel button contains an icon that is 24 x 24 pixels or larger. / private final static Insets bevelLargeSpacing = new Insets(8,8,8,8); private final static Insets bevelRegularSpacing = new Insets(0,0,0,0); /** Square Button. Preferred spacing between buttons and other components. / private final static Insets squareSpacing = new Insets(0,0,0,0); /** Icon Button (buttons without border and an icon, and, optionally, text) Preferred spacing between buttons and other components. Large Spacing is used, if the icon button contains an icon that is 24 x 24 pixels or larger. / private final static Insets iconLargeSpacing = new Insets(8,8,8,8); private final static Insets iconRegularSpacing = new Insets(0,0,0,0); /** Round Button and Help Button. / private final static Insets roundSpacing = new Insets(12,12,12,12);


installDefaults

protected void installDefaults(javax.swing.AbstractButton b)
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicButtonUI

createButtonListener

protected javax.swing.plaf.basic.BasicButtonListener createButtonListener(javax.swing.AbstractButton b)
Overrides:
createButtonListener in class javax.swing.plaf.basic.BasicButtonUI

paint

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

paintText

protected void paintText(java.awt.Graphics g,
                         javax.swing.JComponent c,
                         java.awt.Rectangle textRect,
                         java.lang.String text)
As of Java 2 platform v 1.4 this method should not be used or overriden. Use the paintText method which takes the AbstractButton argument.

Overrides:
paintText in class javax.swing.plaf.basic.BasicButtonUI

paintText

protected void paintText(java.awt.Graphics g,
                         javax.swing.AbstractButton b,
                         java.awt.Rectangle textRect,
                         java.lang.String text)
Method which renders the text of the current button.

Overrides:
paintText in class javax.swing.plaf.basic.BasicButtonUI
Parameters:
g - Graphics context
b - Current button to render
textRect - Bounding rectangle to render the text.
text - String to render
Since:
1.4

paintIcon

protected void paintIcon(java.awt.Graphics g,
                         javax.swing.JComponent c,
                         java.awt.Rectangle iconRect)
Overrides:
paintIcon in class javax.swing.plaf.basic.BasicButtonUI

getPropertyPrefix

protected java.lang.String getPropertyPrefix()
This method is here, to let QuaquaButtonListener access this property.

Overrides:
getPropertyPrefix in class javax.swing.plaf.basic.BasicButtonUI

getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
Overrides:
getMinimumSize in class javax.swing.plaf.basic.BasicButtonUI

getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
Overrides:
getMaximumSize in class javax.swing.plaf.basic.BasicButtonUI

getPreferredSize

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

getPreferredSize

public static java.awt.Dimension getPreferredSize(javax.swing.AbstractButton b)

layoutCL

protected java.lang.String layoutCL(javax.swing.AbstractButton c,
                                    java.awt.FontMetrics fontMetrics,
                                    java.lang.String text,
                                    javax.swing.Icon icon,
                                    java.awt.Rectangle viewR,
                                    java.awt.Rectangle iconR,
                                    java.awt.Rectangle textR)
Forwards the call to SwingUtilities.layoutCompoundLabel(). This method is here so that a subclass could do Label specific layout and to shorten the method name a little.

See Also:
SwingUtilities.layoutCompoundLabel(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, int, int, int, int, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle, int)

getBaseline

public int getBaseline(javax.swing.JComponent c,
                       int width,
                       int height)
Description copied from interface: VisuallyLayoutable
Returns the baseline for the specified component, or -1 if the baseline can not be determined. The baseline is measured from the top of the component.

Specified by:
getBaseline in interface VisuallyLayoutable
Overrides:
getBaseline in class javax.swing.plaf.basic.BasicButtonUI
Parameters:
c - JComponent to calculate baseline for
width - Width of the component to determine baseline for.
height - Height of the component to determine baseline for.
Returns:
baseline for the specified component

getVisualBounds

public java.awt.Rectangle getVisualBounds(javax.swing.JComponent c,
                                          int type,
                                          int width,
                                          int height)
Description copied from interface: VisuallyLayoutable
Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.

Specified by:
getVisualBounds in interface VisuallyLayoutable
Parameters:
c - JComponent to calculate visual margin for
type - The type of the visual margin.
width - Width of the component
height - Height of the component
Returns:
The visual bounds in component coordinates.

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.