com.alee.laf.button
Class WebButtonUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ButtonUI
          extended by javax.swing.plaf.basic.BasicButtonUI
              extended by com.alee.laf.button.WebButtonUI
All Implemented Interfaces:
ShapeProvider, BorderMethods, SwingMethods, javax.swing.SwingConstants
Direct Known Subclasses:
WebSplitButtonUI, WebToggleButtonUI

public class WebButtonUI
extends javax.swing.plaf.basic.BasicButtonUI
implements ShapeProvider, javax.swing.SwingConstants, BorderMethods

Author:
Mikle Garin

Field Summary
protected  javax.swing.event.AncestorListener ancestorListener
           
protected  boolean animate
           
protected  WebTimer animator
           
protected  java.awt.Color bottomBgColor
           
protected  java.awt.Color bottomSelectedBgColor
           
protected  javax.swing.AbstractButton button
           
protected  boolean drawBottom
           
protected  boolean drawBottomLine
           
protected  boolean drawFocus
           
protected  boolean drawLeft
           
protected  boolean drawLeftLine
           
protected  boolean drawRight
           
protected  boolean drawRightLine
           
protected  boolean drawShade
           
protected  boolean drawTop
           
protected  boolean drawTopLine
           
protected  java.awt.Color innerShadeColor
           
protected  int innerShadeWidth
           
protected  int leftRightSpacing
           
protected  java.awt.Insets margin
           
protected  java.awt.event.MouseAdapter mouseAdapter
           
protected  java.awt.Point mousePoint
           
protected  boolean moveIconOnPress
           
protected  boolean oldBorderPainted
           
protected  boolean oldContentAreaFilled
           
protected  boolean oldFocusable
           
protected  boolean oldFocusPainted
           
protected  Painter painter
           
protected  java.beans.PropertyChangeListener propertyChangeListener
           
protected  boolean rollover
           
protected  boolean rolloverDarkBorderOnly
           
protected  boolean rolloverDecoratedOnly
           
protected  boolean rolloverShadeOnly
           
protected  boolean rolloverShine
           
protected  int round
           
protected  java.awt.Color selectedForeground
           
protected  java.awt.Color shadeColor
           
protected  boolean shadeToggleIcon
           
protected  float shadeToggleIconTransparency
           
protected  int shadeWidth
           
protected  java.awt.Color shineColor
           
protected  boolean showDisabledShade
           
protected  java.awt.Color topBgColor
          todo 1.
protected  java.awt.Color topSelectedBgColor
           
protected  float transparency
           
protected  java.awt.Color transparentShineColor
           
protected  boolean undecorated
           
 
Fields inherited from class javax.swing.plaf.basic.BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset
 
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
WebButtonUI()
           
 
Method Summary
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
protected  java.awt.Insets getBorderInsets()
          Returns component border insets used for WebLaF border.
 java.awt.Color getBottomBgColor()
           
 java.awt.Color getBottomSelectedBgColor()
           
protected  java.awt.Shape getButtonShape(javax.swing.AbstractButton button, boolean border)
           
 java.awt.Color getInnerShadeColor()
           
 int getInnerShadeWidth()
           
 int getLeftRightSpacing()
           
 java.awt.Insets getMargin()
           
 Painter getPainter()
           
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
           
 int getRound()
           
 java.awt.Color getSelectedForeground()
           
 java.awt.Color getShadeColor()
           
 float getShadeToggleIconTransparency()
           
 int getShadeWidth()
           
 java.awt.Color getShineColor()
           
 java.awt.Color getTopBgColor()
           
 java.awt.Color getTopSelectedBgColor()
           
 void installUI(javax.swing.JComponent c)
           
protected  boolean isAfterEnabledButton(javax.swing.AbstractButton button)
          Returns whether this button placed after another enabled button inside a WebButtonGroup container or not.
 boolean isAnimate()
           
protected  boolean isBeforeEnabledButton(javax.swing.AbstractButton button)
          Returns whether this button placed before another enabled button inside a WebButtonGroup container or not.
 boolean isDrawBottom()
           
 boolean isDrawBottomLine()
           
 boolean isDrawFocus()
           
 boolean isDrawLeft()
           
 boolean isDrawLeftLine()
           
 boolean isDrawRight()
           
 boolean isDrawRightLine()
           
 boolean isDrawShade()
           
 boolean isDrawTop()
           
 boolean isDrawTopLine()
           
protected  boolean isInButtonGroup(javax.swing.AbstractButton button)
          Returns whether this button is inside WebButtonGroup or not.
 boolean isMoveIconOnPress()
           
 boolean isRollover()
           
 boolean isRolloverDarkBorderOnly()
           
 boolean isRolloverDecoratedOnly()
           
 boolean isRolloverShadeOnly()
           
 boolean isRolloverShine()
           
 boolean isShadeToggleIcon()
           
 boolean isShowDisabledShade()
           
 boolean isUndecorated()
           
 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.JComponent c, java.awt.Rectangle textRect, java.lang.String text)
           
 java.awt.Shape provideShape()
          Returns component shape.
 void setAnimate(boolean animate)
           
 void setBottomBgColor(java.awt.Color bottomBgColor)
           
 void setBottomSelectedBgColor(java.awt.Color bottomSelectedBgColor)
           
 void setDrawBottom(boolean drawBottom)
           
 void setDrawBottomLine(boolean drawBottomLine)
           
 void setDrawFocus(boolean drawFocus)
           
 void setDrawLeft(boolean drawLeft)
           
 void setDrawLeftLine(boolean drawLeftLine)
           
 void setDrawLines(boolean top, boolean left, boolean bottom, boolean right)
           
 void setDrawRight(boolean drawRight)
           
 void setDrawRightLine(boolean drawRightLine)
           
 void setDrawShade(boolean drawShade)
           
 void setDrawSides(boolean top, boolean left, boolean bottom, boolean right)
           
 void setDrawTop(boolean drawTop)
           
 void setDrawTopLine(boolean drawTopLine)
           
 void setInnerShadeColor(java.awt.Color innerShadeColor)
           
 void setInnerShadeWidth(int innerShadeWidth)
           
 void setLeftRightSpacing(int leftRightSpacing)
           
 void setMargin(java.awt.Insets margin)
           
 void setMoveIconOnPress(boolean moveIconOnPress)
           
 void setPainter(Painter painter)
           
 void setRolloverDarkBorderOnly(boolean rolloverDarkBorderOnly)
           
 void setRolloverDecoratedOnly(boolean rolloverDecoratedOnly)
           
 void setRolloverShadeOnly(boolean rolloverShadeOnly)
           
 void setRolloverShine(boolean rolloverShine)
           
 void setRound(int round)
           
 void setSelectedForeground(java.awt.Color selectedForeground)
           
 void setShadeColor(java.awt.Color shadeColor)
           
 void setShadeToggleIcon(boolean shadeToggleIcon)
           
 void setShadeToggleIconTransparency(float shadeToggleIconTransparency)
           
 void setShadeWidth(int shadeWidth)
           
 void setShineColor(java.awt.Color shineColor)
           
 void setShowDisabledShade(boolean showDisabledShade)
           
 void setTopBgColor(java.awt.Color topBgColor)
           
 void setTopSelectedBgColor(java.awt.Color topSelectedBgColor)
           
 void setUndecorated(boolean undecorated)
           
 void uninstallUI(javax.swing.JComponent c)
           
 void updateBorder()
          Updates custom WebLaF border.
 
Methods inherited from class javax.swing.plaf.basic.BasicButtonUI
clearTextShiftOffset, createButtonListener, getBaseline, getBaselineResizeBehavior, getDefaultTextIconGap, getMaximumSize, getMinimumSize, getPropertyPrefix, getTextShiftOffset, installDefaults, installKeyboardActions, installListeners, paintButtonPressed, paintFocus, paintText, setTextShiftOffset, uninstallDefaults, uninstallKeyboardActions, uninstallListeners
 
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
 

Field Detail

topBgColor

protected java.awt.Color topBgColor
todo 1. Properly check situations when button sides are painted within multi-row/column WebButtonGroup todo 2. Properly paint side-borders when grouped buttons are rollover decorated only


bottomBgColor

protected java.awt.Color bottomBgColor

topSelectedBgColor

protected java.awt.Color topSelectedBgColor

bottomSelectedBgColor

protected java.awt.Color bottomSelectedBgColor

selectedForeground

protected java.awt.Color selectedForeground

rolloverShine

protected boolean rolloverShine

shineColor

protected java.awt.Color shineColor

rolloverDarkBorderOnly

protected boolean rolloverDarkBorderOnly

round

protected int round

drawShade

protected boolean drawShade

rolloverShadeOnly

protected boolean rolloverShadeOnly

showDisabledShade

protected boolean showDisabledShade

shadeWidth

protected int shadeWidth

margin

protected java.awt.Insets margin

shadeColor

protected java.awt.Color shadeColor

innerShadeWidth

protected int innerShadeWidth

innerShadeColor

protected java.awt.Color innerShadeColor

leftRightSpacing

protected int leftRightSpacing

shadeToggleIcon

protected boolean shadeToggleIcon

shadeToggleIconTransparency

protected float shadeToggleIconTransparency

drawFocus

protected boolean drawFocus

rolloverDecoratedOnly

protected boolean rolloverDecoratedOnly

animate

protected boolean animate

undecorated

protected boolean undecorated

painter

protected Painter painter

moveIconOnPress

protected boolean moveIconOnPress

drawTop

protected boolean drawTop

drawLeft

protected boolean drawLeft

drawBottom

protected boolean drawBottom

drawRight

protected boolean drawRight

drawTopLine

protected boolean drawTopLine

drawLeftLine

protected boolean drawLeftLine

drawBottomLine

protected boolean drawBottomLine

drawRightLine

protected boolean drawRightLine

transparentShineColor

protected java.awt.Color transparentShineColor

rollover

protected boolean rollover

transparency

protected float transparency

mousePoint

protected java.awt.Point mousePoint

animator

protected WebTimer animator

button

protected javax.swing.AbstractButton button

oldFocusPainted

protected boolean oldFocusPainted

oldContentAreaFilled

protected boolean oldContentAreaFilled

oldBorderPainted

protected boolean oldBorderPainted

oldFocusable

protected boolean oldFocusable

mouseAdapter

protected java.awt.event.MouseAdapter mouseAdapter

ancestorListener

protected javax.swing.event.AncestorListener ancestorListener

propertyChangeListener

protected java.beans.PropertyChangeListener propertyChangeListener
Constructor Detail

WebButtonUI

public WebButtonUI()
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.basic.BasicButtonUI

uninstallUI

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

provideShape

public java.awt.Shape provideShape()
Description copied from interface: ShapeProvider
Returns component shape.

Specified by:
provideShape in interface ShapeProvider
Returns:
component shape

getTopBgColor

public java.awt.Color getTopBgColor()

setTopBgColor

public void setTopBgColor(java.awt.Color topBgColor)

getBottomBgColor

public java.awt.Color getBottomBgColor()

setBottomBgColor

public void setBottomBgColor(java.awt.Color bottomBgColor)

getTopSelectedBgColor

public java.awt.Color getTopSelectedBgColor()

setTopSelectedBgColor

public void setTopSelectedBgColor(java.awt.Color topSelectedBgColor)

getBottomSelectedBgColor

public java.awt.Color getBottomSelectedBgColor()

setBottomSelectedBgColor

public void setBottomSelectedBgColor(java.awt.Color bottomSelectedBgColor)

getSelectedForeground

public java.awt.Color getSelectedForeground()

setSelectedForeground

public void setSelectedForeground(java.awt.Color selectedForeground)

isRolloverDarkBorderOnly

public boolean isRolloverDarkBorderOnly()

setRolloverDarkBorderOnly

public void setRolloverDarkBorderOnly(boolean rolloverDarkBorderOnly)

isRolloverShine

public boolean isRolloverShine()

setRolloverShine

public void setRolloverShine(boolean rolloverShine)

getShineColor

public java.awt.Color getShineColor()

setShineColor

public void setShineColor(java.awt.Color shineColor)

updateBorder

public void updateBorder()
Updates custom WebLaF border.

Specified by:
updateBorder in interface BorderMethods

getBorderInsets

protected java.awt.Insets getBorderInsets()
Returns component border insets used for WebLaF border.

Returns:
component border insets

isDrawShade

public boolean isDrawShade()

setDrawShade

public void setDrawShade(boolean drawShade)

isRolloverShadeOnly

public boolean isRolloverShadeOnly()

setRolloverShadeOnly

public void setRolloverShadeOnly(boolean rolloverShadeOnly)

isShowDisabledShade

public boolean isShowDisabledShade()

setShowDisabledShade

public void setShowDisabledShade(boolean showDisabledShade)

getShadeWidth

public int getShadeWidth()

setShadeWidth

public void setShadeWidth(int shadeWidth)

getMargin

public java.awt.Insets getMargin()

setMargin

public void setMargin(java.awt.Insets margin)

getShadeColor

public java.awt.Color getShadeColor()

setShadeColor

public void setShadeColor(java.awt.Color shadeColor)

getInnerShadeWidth

public int getInnerShadeWidth()

setInnerShadeWidth

public void setInnerShadeWidth(int innerShadeWidth)

getInnerShadeColor

public java.awt.Color getInnerShadeColor()

setInnerShadeColor

public void setInnerShadeColor(java.awt.Color innerShadeColor)

getLeftRightSpacing

public int getLeftRightSpacing()

setLeftRightSpacing

public void setLeftRightSpacing(int leftRightSpacing)

getRound

public int getRound()

setRound

public void setRound(int round)

isShadeToggleIcon

public boolean isShadeToggleIcon()

setShadeToggleIcon

public void setShadeToggleIcon(boolean shadeToggleIcon)

getShadeToggleIconTransparency

public float getShadeToggleIconTransparency()

setShadeToggleIconTransparency

public void setShadeToggleIconTransparency(float shadeToggleIconTransparency)

isUndecorated

public boolean isUndecorated()

setUndecorated

public void setUndecorated(boolean undecorated)

getPainter

public Painter getPainter()

setPainter

public void setPainter(Painter painter)

isMoveIconOnPress

public boolean isMoveIconOnPress()

setMoveIconOnPress

public void setMoveIconOnPress(boolean moveIconOnPress)

isRolloverDecoratedOnly

public boolean isRolloverDecoratedOnly()

setRolloverDecoratedOnly

public void setRolloverDecoratedOnly(boolean rolloverDecoratedOnly)

isAnimate

public boolean isAnimate()

setAnimate

public void setAnimate(boolean animate)

isDrawFocus

public boolean isDrawFocus()

setDrawFocus

public void setDrawFocus(boolean drawFocus)

isDrawBottom

public boolean isDrawBottom()

setDrawBottom

public void setDrawBottom(boolean drawBottom)

isDrawLeft

public boolean isDrawLeft()

setDrawLeft

public void setDrawLeft(boolean drawLeft)

isDrawRight

public boolean isDrawRight()

setDrawRight

public void setDrawRight(boolean drawRight)

isDrawTop

public boolean isDrawTop()

setDrawTop

public void setDrawTop(boolean drawTop)

setDrawSides

public void setDrawSides(boolean top,
                         boolean left,
                         boolean bottom,
                         boolean right)

isDrawTopLine

public boolean isDrawTopLine()

setDrawTopLine

public void setDrawTopLine(boolean drawTopLine)

isDrawLeftLine

public boolean isDrawLeftLine()

setDrawLeftLine

public void setDrawLeftLine(boolean drawLeftLine)

isDrawBottomLine

public boolean isDrawBottomLine()

setDrawBottomLine

public void setDrawBottomLine(boolean drawBottomLine)

isDrawRightLine

public boolean isDrawRightLine()

setDrawRightLine

public void setDrawRightLine(boolean drawRightLine)

setDrawLines

public void setDrawLines(boolean top,
                         boolean left,
                         boolean bottom,
                         boolean right)

isRollover

public boolean isRollover()

paint

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

isAfterEnabledButton

protected boolean isAfterEnabledButton(javax.swing.AbstractButton button)
Returns whether this button placed after another enabled button inside a WebButtonGroup container or not. This check is required to paint button sides with proper colors.

Parameters:
button - this button
Returns:
true if this button placed after another enabled button inside a WebButtonGroup container, false otherwise

isBeforeEnabledButton

protected boolean isBeforeEnabledButton(javax.swing.AbstractButton button)
Returns whether this button placed before another enabled button inside a WebButtonGroup container or not. This check is required to paint button sides with proper colors.

Parameters:
button - this button
Returns:
true if this button placed before another enabled button inside a WebButtonGroup container, false otherwise

isInButtonGroup

protected boolean isInButtonGroup(javax.swing.AbstractButton button)
Returns whether this button is inside WebButtonGroup or not.

Parameters:
button - this button
Returns:
true if this button is inside WebButtonGroup, false otherwise

paintText

protected void paintText(java.awt.Graphics g,
                         javax.swing.JComponent c,
                         java.awt.Rectangle textRect,
                         java.lang.String text)
Overrides:
paintText in class javax.swing.plaf.basic.BasicButtonUI

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

getButtonShape

protected java.awt.Shape getButtonShape(javax.swing.AbstractButton button,
                                        boolean border)

getPreferredSize

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