com.alee.managers.style.skin.web
Class WebDecorationPainter<E extends javax.swing.JComponent>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.managers.style.skin.web.WebDecorationPainter<E>
All Implemented Interfaces:
Painter<E>, PartialDecoration, PainterShapeProvider<E>
Direct Known Subclasses:
WebPanelPainter

public class WebDecorationPainter<E extends javax.swing.JComponent>
extends AbstractPainter<E>
implements PainterShapeProvider<E>, PartialDecoration

Web-style background painter for any component. Commonly used as a base class for various Swing components like JPanel, JButton and others.

Author:
Mikle Garin

Field Summary
protected  boolean actualPaintLeft
           
protected  boolean actualPaintRight
           
protected static java.lang.String BACKGROUND_SHAPE
           
protected static java.lang.String BORDER_SHAPE
          Shape cache keys.
protected  java.awt.Color borderColor
           
protected  java.awt.Stroke borderStroke
           
protected  java.awt.Color disabledBorderColor
           
protected  boolean focused
           
protected  FocusTracker focusTracker
          Runtime variables.
protected  int h
           
protected  boolean ltr
          Painting variables.
protected  boolean paintBackground
           
protected  boolean paintBottom
           
protected  boolean paintBottomLine
           
protected  boolean paintFocus
           
protected  boolean paintLeft
           
protected  boolean paintLeftLine
           
protected  boolean paintRight
           
protected  boolean paintRightLine
           
protected  boolean paintTop
           
protected  boolean paintTopLine
           
protected  int round
           
protected  float shadeTransparency
           
protected  int shadeWidth
           
protected  boolean undecorated
          Style settings.
protected  int w
           
protected  boolean webColoredBackground
           
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
WebDecorationPainter()
           
 
Method Summary
protected  java.awt.Shape createShape(E c, boolean background)
          Returns decoration border shape.
 java.awt.Color getBorderColor()
          Returns decoration border color.
 java.awt.Stroke getBorderStroke()
          Returns decoration border stroke.
protected  java.lang.Object[] getCachedShapeSettings(E c)
          Returns an array of shape settings cached along with the shape.
 java.awt.Color getDisabledBorderColor()
          Returns decoration disabled border color.
 java.awt.Insets getMargin(E scrollbar)
          Returns margin required for visual data provided by this painter.
 int getRound()
          Returns decoration corners rounding.
 float getShadeTransparency()
          Returns decoration shade transparency.
 int getShadeWidth()
          Returns decoration shade width.
protected  java.awt.Shape getShape(E c, boolean background)
          Returns decoration border shape.
 void install(E c)
          Called when painter is intalled into some component.
 java.lang.Boolean isOpaque(E c)
          Returns whether visual data provided by this painter is opaque or not.
 boolean isPaintBackground()
          Returns whether should paint decoration background or not.
 boolean isPaintBottom()
          Returns whether should paint bottom side or not.
 boolean isPaintBottomLine()
          Returns whether should paint bottom side line or not.
 boolean isPaintFocus()
          Returns whether focus should be painted or not.
 boolean isPaintLeft()
          Returns whether should paint left side or not.
 boolean isPaintLeftLine()
          Returns whether should paint left side line or not.
 boolean isPaintRight()
          Returns whether should paint right side or not.
 boolean isPaintRightLine()
          Returns whether should paint right side line or not.
 boolean isPaintTop()
          Returns whether should paint top side or not.
 boolean isPaintTopLine()
          Returns whether should paint top side line or not.
 boolean isUndecorated()
          Returns whether decoration should be painted or not.
 boolean isWebColoredBackground()
          Sets whether should paint web-styled background or not.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c)
          Paints visual data onto the component graphics.
protected  void paintBackground(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c, java.awt.Shape backgroundShape)
          Paints decoration background.
protected  void paintBorder(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c, java.awt.Shape borderShape)
          Paints decoration border.
protected  void paintShade(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c, java.awt.Shape borderShape)
          Paints outer decoration shade.
 java.awt.Shape provideShape(E component, java.awt.Rectangle bounds)
          Returns painted component shape.
 void setBorderColor(java.awt.Color color)
          Sets decoration border color.
 void setBorderStroke(java.awt.Stroke stroke)
          Sets decoration border stroke.
 void setDisabledBorderColor(java.awt.Color color)
          Sets decoration disabled border color.
 void setPaintBackground(boolean paint)
          Sets whether should paint decoration background or not.
 void setPaintBottom(boolean bottom)
          Sets whether should paint bottom side or not.
 void setPaintBottomLine(boolean bottom)
          Sets whether should paint bottom side line or not.
 void setPaintFocus(boolean paint)
          Sets whether focus should be painted or not.
 void setPaintLeft(boolean left)
          Sets whether should paint left side or not.
 void setPaintLeftLine(boolean left)
          Sets whether should paint left side line or not.
 void setPaintRight(boolean right)
          Sets whether should paint right side or not.
 void setPaintRightLine(boolean right)
          Sets whether should paint right side line or not.
 void setPaintSideLines(boolean top, boolean left, boolean bottom, boolean right)
          Sets whether should paint specific side lines or not.
 void setPaintSides(boolean top, boolean left, boolean bottom, boolean right)
          Sets whether should paint specific sides or not.
 void setPaintTop(boolean top)
          Sets whether should paint top side or not.
 void setPaintTopLine(boolean top)
          Sets whether should paint top side line or not.
 void setRound(int round)
          Sets decoration corners rounding.
 void setShadeTransparency(float transparency)
          Sets decoration shade transparency.
 void setShadeWidth(int width)
          Sets decoration shade width.
 void setUndecorated(boolean undecorated)
          Sets whether decoration should be painted or not.
 void setWebColoredBackground(boolean webColored)
          Sets whether should paint web-styled background or not.
 void uninstall(E c)
          Called when painter is intalled into some component.
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, getPreferredSize, p, removePainterListener, repaint, repaint, repaint, revalidate, setMargin, setMargin, setMargin, setOpaque, setPreferredSize, updateAll, updateOpacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BORDER_SHAPE

protected static final java.lang.String BORDER_SHAPE
Shape cache keys.

See Also:
Constant Field Values

BACKGROUND_SHAPE

protected static final java.lang.String BACKGROUND_SHAPE
See Also:
Constant Field Values

undecorated

protected boolean undecorated
Style settings.


paintFocus

protected boolean paintFocus

round

protected int round

shadeWidth

protected int shadeWidth

shadeTransparency

protected float shadeTransparency

borderStroke

protected java.awt.Stroke borderStroke

borderColor

protected java.awt.Color borderColor

disabledBorderColor

protected java.awt.Color disabledBorderColor

paintBackground

protected boolean paintBackground

webColoredBackground

protected boolean webColoredBackground

paintTop

protected boolean paintTop

paintLeft

protected boolean paintLeft

paintBottom

protected boolean paintBottom

paintRight

protected boolean paintRight

paintTopLine

protected boolean paintTopLine

paintLeftLine

protected boolean paintLeftLine

paintBottomLine

protected boolean paintBottomLine

paintRightLine

protected boolean paintRightLine

focusTracker

protected FocusTracker focusTracker
Runtime variables.


focused

protected boolean focused

ltr

protected boolean ltr
Painting variables.


actualPaintLeft

protected boolean actualPaintLeft

actualPaintRight

protected boolean actualPaintRight

w

protected int w

h

protected int h
Constructor Detail

WebDecorationPainter

public WebDecorationPainter()
Method Detail

install

public void install(E c)
Called when painter is intalled into some component. You might want to use this method to add custom component listeners or modify component settings.

Specified by:
install in interface Painter<E extends javax.swing.JComponent>
Overrides:
install in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process

uninstall

public void uninstall(E c)
Called when painter is intalled into some component. You might want to use this method to add custom component listeners or modify component settings.

Specified by:
uninstall in interface Painter<E extends javax.swing.JComponent>
Overrides:
uninstall in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process

provideShape

public java.awt.Shape provideShape(E component,
                                   java.awt.Rectangle bounds)
Returns painted component shape.

Specified by:
provideShape in interface PainterShapeProvider<E extends javax.swing.JComponent>
Parameters:
component - component to process
bounds - bounds for painter visual data
Returns:
painted component shape

isUndecorated

public boolean isUndecorated()
Returns whether decoration should be painted or not.

Returns:
true if decoration should be painted, false otherwise

setUndecorated

public void setUndecorated(boolean undecorated)
Sets whether decoration should be painted or not.

Parameters:
undecorated - whether decoration should be painted or not

isPaintFocus

public boolean isPaintFocus()
Returns whether focus should be painted or not.

Returns:
true if focus should be painted, false otherwise

setPaintFocus

public void setPaintFocus(boolean paint)
Sets whether focus should be painted or not.

Parameters:
paint - whether focus should be painted or not

getRound

public int getRound()
Returns decoration corners rounding.

Returns:
decoration corners rounding

setRound

public void setRound(int round)
Sets decoration corners rounding.

Parameters:
round - decoration corners rounding

getShadeWidth

public int getShadeWidth()
Returns decoration shade width.

Returns:
decoration shade width

setShadeWidth

public void setShadeWidth(int width)
Sets decoration shade width.

Parameters:
width - decoration shade width

getShadeTransparency

public float getShadeTransparency()
Returns decoration shade transparency.

Returns:
decoration shade transparency

setShadeTransparency

public void setShadeTransparency(float transparency)
Sets decoration shade transparency.

Parameters:
transparency - new decoration shade transparency

getBorderStroke

public java.awt.Stroke getBorderStroke()
Returns decoration border stroke.

Returns:
decoration border stroke

setBorderStroke

public void setBorderStroke(java.awt.Stroke stroke)
Sets decoration border stroke.

Parameters:
stroke - decoration border stroke

getBorderColor

public java.awt.Color getBorderColor()
Returns decoration border color.

Returns:
decoration border color

setBorderColor

public void setBorderColor(java.awt.Color color)
Sets decoration border color.

Parameters:
color - decoration border color

getDisabledBorderColor

public java.awt.Color getDisabledBorderColor()
Returns decoration disabled border color.

Returns:
decoration disabled border color

setDisabledBorderColor

public void setDisabledBorderColor(java.awt.Color color)
Sets decoration disabled border color.

Parameters:
color - decoration disabled border color

isPaintBackground

public boolean isPaintBackground()
Returns whether should paint decoration background or not.

Returns:
true if should paint decoration background, false otherwise

setPaintBackground

public void setPaintBackground(boolean paint)
Sets whether should paint decoration background or not.

Parameters:
paint - whether should paint decoration background or not

isWebColoredBackground

public boolean isWebColoredBackground()
Sets whether should paint web-styled background or not.

Returns:
true if should paint web-styled background, false otherwise

setWebColoredBackground

public void setWebColoredBackground(boolean webColored)
Sets whether should paint web-styled background or not.

Parameters:
webColored - whether should paint web-styled background or not

isPaintTop

public boolean isPaintTop()
Returns whether should paint top side or not.

Returns:
true if should paint top side, false otherwise

setPaintTop

public void setPaintTop(boolean top)
Sets whether should paint top side or not.

Specified by:
setPaintTop in interface PartialDecoration
Parameters:
top - whether should paint top side or not

isPaintLeft

public boolean isPaintLeft()
Returns whether should paint left side or not.

Returns:
true if should paint left side, false otherwise

setPaintLeft

public void setPaintLeft(boolean left)
Sets whether should paint left side or not.

Specified by:
setPaintLeft in interface PartialDecoration
Parameters:
left - whether should paint left side or not

isPaintBottom

public boolean isPaintBottom()
Returns whether should paint bottom side or not.

Returns:
true if should paint bottom side, false otherwise

setPaintBottom

public void setPaintBottom(boolean bottom)
Sets whether should paint bottom side or not.

Specified by:
setPaintBottom in interface PartialDecoration
Parameters:
bottom - whether should paint bottom side or not

isPaintRight

public boolean isPaintRight()
Returns whether should paint right side or not.

Returns:
true if should paint right side, false otherwise

setPaintRight

public void setPaintRight(boolean right)
Sets whether should paint right side or not.

Specified by:
setPaintRight in interface PartialDecoration
Parameters:
right - whether should paint right side or not

setPaintSides

public void setPaintSides(boolean top,
                          boolean left,
                          boolean bottom,
                          boolean right)
Sets whether should paint specific sides or not.

Specified by:
setPaintSides in interface PartialDecoration
Parameters:
top - whether should paint top side or not
left - whether should paint left side or not
bottom - whether should paint bottom side or not
right - whether should paint right side or not

isPaintTopLine

public boolean isPaintTopLine()
Returns whether should paint top side line or not.

Returns:
true if should paint top side line, false otherwise

setPaintTopLine

public void setPaintTopLine(boolean top)
Sets whether should paint top side line or not.

Specified by:
setPaintTopLine in interface PartialDecoration
Parameters:
top - whether should paint top side line or not

isPaintLeftLine

public boolean isPaintLeftLine()
Returns whether should paint left side line or not.

Returns:
true if should paint left side line, false otherwise

setPaintLeftLine

public void setPaintLeftLine(boolean left)
Sets whether should paint left side line or not.

Specified by:
setPaintLeftLine in interface PartialDecoration
Parameters:
left - whether should paint left side line or not

isPaintBottomLine

public boolean isPaintBottomLine()
Returns whether should paint bottom side line or not.

Returns:
true if should paint bottom side line, false otherwise

setPaintBottomLine

public void setPaintBottomLine(boolean bottom)
Sets whether should paint bottom side line or not.

Specified by:
setPaintBottomLine in interface PartialDecoration
Parameters:
bottom - whether should paint bottom side line or not

isPaintRightLine

public boolean isPaintRightLine()
Returns whether should paint right side line or not.

Returns:
true if should paint right side line, false otherwise

setPaintRightLine

public void setPaintRightLine(boolean right)
Sets whether should paint right side line or not.

Specified by:
setPaintRightLine in interface PartialDecoration
Parameters:
right - whether should paint right side line or not

setPaintSideLines

public void setPaintSideLines(boolean top,
                              boolean left,
                              boolean bottom,
                              boolean right)
Sets whether should paint specific side lines or not.

Specified by:
setPaintSideLines in interface PartialDecoration
Parameters:
top - whether should paint top side line or not
left - whether should paint left side line or not
bottom - whether should paint bottom side line or not
right - whether should paint right side line or not

isOpaque

public java.lang.Boolean isOpaque(E c)
Returns whether visual data provided by this painter is opaque or not. Returned value might affect component opacity depending on painter support inside that component UI. Simply return null if you don't want to change default component opacity.

Specified by:
isOpaque in interface Painter<E extends javax.swing.JComponent>
Overrides:
isOpaque in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process
Returns:
true if visual data provided by this painter is opaque, false otherwise

getMargin

public java.awt.Insets getMargin(E scrollbar)
Returns margin required for visual data provided by this painter. This margin is usually added to component's margin when the final component border is calculated. You may pass null instead of zero margin - it will simply be ignored in that case.

Specified by:
getMargin in interface Painter<E extends javax.swing.JComponent>
Overrides:
getMargin in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
scrollbar - component to process
Returns:
margin required for visual data provided by this painter or null for zero margin

paint

public void paint(java.awt.Graphics2D g2d,
                  java.awt.Rectangle bounds,
                  E c)
Paints visual data onto the component graphics. Provided graphics and component are taken directly from component UI paint method. Provided bounds are usually fake (zero location, component size) but in some cases it might be specified by componentUI.

Specified by:
paint in interface Painter<E extends javax.swing.JComponent>
Parameters:
g2d - component graphics
bounds - bounds for painter visual data
c - component to process

paintShade

protected void paintShade(java.awt.Graphics2D g2d,
                          java.awt.Rectangle bounds,
                          E c,
                          java.awt.Shape borderShape)
Paints outer decoration shade.

Parameters:
g2d - graphics context
bounds - painting bounds
c - painted component
borderShape - component border shape

paintBackground

protected void paintBackground(java.awt.Graphics2D g2d,
                               java.awt.Rectangle bounds,
                               E c,
                               java.awt.Shape backgroundShape)
Paints decoration background.

Parameters:
g2d - graphics context
bounds - painting bounds
c - painted component
backgroundShape - component background shape

paintBorder

protected void paintBorder(java.awt.Graphics2D g2d,
                           java.awt.Rectangle bounds,
                           E c,
                           java.awt.Shape borderShape)
Paints decoration border.

Parameters:
g2d - graphics context
bounds - painting bounds
c - painted component
borderShape - component border shape

getShape

protected java.awt.Shape getShape(E c,
                                  boolean background)
Returns decoration border shape.

Parameters:
c - painted component
background - whether should return background shape or not
Returns:
decoration border shape

getCachedShapeSettings

protected java.lang.Object[] getCachedShapeSettings(E c)
Returns an array of shape settings cached along with the shape.

Parameters:
c - painted component
Returns:
an array of shape settings cached along with the shape

createShape

protected java.awt.Shape createShape(E c,
                                     boolean background)
Returns decoration border shape.

Parameters:
c - painted component
background - whether should return background shape or not
Returns:
decoration border shape