com.alee.managers.style.skin.web
Class WebLabelPainter<E extends javax.swing.JLabel>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.managers.style.skin.web.WebLabelPainter<E>
All Implemented Interfaces:
Painter<E>, SpecificPainter, LabelPainter<E>
Direct Known Subclasses:
HotkeyTipPainter, NPLabelPainter, WebBreadcrumbLabelPainter, WebComboBoxElementPainter, WebHotkeyLabelPainter, WebVerticalLabelPainter

public class WebLabelPainter<E extends javax.swing.JLabel>
extends AbstractPainter<E>
implements LabelPainter<E>

Web-style painter for JLabel component. It is used as WebLabelUI default painter.

Author:
Mikle Garin

Field Summary
protected  Painter backgroundPainter
           
protected  boolean drawShade
          Style settings.
protected  java.awt.Rectangle paintIconR
          Runtime variables.
protected  java.awt.Rectangle paintTextR
           
protected  java.awt.Color shadeColor
           
protected  java.lang.Float transparency
           
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
WebLabelPainter()
          Constructs new WebLabelPainter with default settings.
WebLabelPainter(Painter backgroundPainter)
          Constructs new WebLabelPainter with the specified background painter.
 
Method Summary
 Painter getBackgroundPainter()
          Returns label background painter.
 java.awt.Insets getMargin(E label)
          Returns margin required for visual data provided by this painter.
 java.awt.Dimension getPreferredSize(E label)
          Returns preferred size required for proper painting of visual data provided by this painter.
 java.awt.Color getShadeColor()
          Returns text shade color.
 java.lang.Float getTransparency()
          Returns label transparency.
 boolean isDrawShade()
          Returns whether text shade is displayed or not.
 java.lang.Boolean isOpaque(E c)
          Returns whether visual data provided by this painter is opaque or not.
protected  java.lang.String layout(E label, java.awt.FontMetrics fm, int width, int height)
          Updates painted label layout and returns clipped or full label text.
protected  java.lang.String layoutCL(E label, java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR)
          Performs label layout and returns clipped or full label text.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E label)
          Paints visual data onto the component graphics.
protected  void paintDisabledText(E label, java.awt.Graphics2D g2d, java.lang.String text, int textX, int textY)
          Performs disabled text painting.
protected  void paintEnabledText(E label, java.awt.Graphics2D g2d, java.lang.String text, int textX, int textY)
          Performs enabled text painting.
protected  void paintShadowText(java.awt.Graphics2D g2d, java.lang.String text, int textX, int textY)
          Paints custom text shade.
 void setBackgroundPainter(Painter painter)
          Sets label background painter.
 void setDrawShade(boolean drawShade)
          Sets whether text shade should be displayed or not.
 void setShadeColor(java.awt.Color shadeColor)
          Sets text shade color.
 void setTransparency(java.lang.Float transparency)
          Sets label transparency.
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, install, p, removePainterListener, repaint, repaint, repaint, revalidate, setMargin, setMargin, setMargin, setOpaque, setPreferredSize, uninstall, updateAll, updateOpacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.extended.painter.Painter
addPainterListener, install, removePainterListener, uninstall
 

Field Detail

drawShade

protected boolean drawShade
Style settings.


shadeColor

protected java.awt.Color shadeColor

transparency

protected java.lang.Float transparency

backgroundPainter

protected Painter backgroundPainter

paintIconR

protected java.awt.Rectangle paintIconR
Runtime variables.


paintTextR

protected java.awt.Rectangle paintTextR
Constructor Detail

WebLabelPainter

public WebLabelPainter()
Constructs new WebLabelPainter with default settings.


WebLabelPainter

public WebLabelPainter(Painter backgroundPainter)
Constructs new WebLabelPainter with the specified background painter.

Parameters:
backgroundPainter - background painter
Method Detail

isDrawShade

public boolean isDrawShade()
Returns whether text shade is displayed or not.

Returns:
true if text shade is displayed, false otherwise

setDrawShade

public void setDrawShade(boolean drawShade)
Sets whether text shade should be displayed or not.

Specified by:
setDrawShade in interface LabelPainter<E extends javax.swing.JLabel>
Parameters:
drawShade - whether text shade should be displayed or not

getShadeColor

public java.awt.Color getShadeColor()
Returns text shade color.

Returns:
text shade color

setShadeColor

public void setShadeColor(java.awt.Color shadeColor)
Sets text shade color.

Parameters:
shadeColor - text shade color

getTransparency

public java.lang.Float getTransparency()
Returns label transparency.

Returns:
label transparency

setTransparency

public void setTransparency(java.lang.Float transparency)
Sets label transparency.

Parameters:
transparency - label transparency

getBackgroundPainter

public Painter getBackgroundPainter()
Returns label background painter.

Returns:
label background painter

setBackgroundPainter

public void setBackgroundPainter(Painter painter)
Sets label background painter.

Parameters:
painter - label background painter

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.JLabel>
Overrides:
isOpaque in class AbstractPainter<E extends javax.swing.JLabel>
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 label)
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.JLabel>
Overrides:
getMargin in class AbstractPainter<E extends javax.swing.JLabel>
Parameters:
label - 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 label)
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.JLabel>
Parameters:
g2d - component graphics
bounds - bounds for painter visual data
label - component to process

layout

protected java.lang.String layout(E label,
                                  java.awt.FontMetrics fm,
                                  int width,
                                  int height)
Updates painted label layout and returns clipped or full label text.

Parameters:
label - label to process
fm - label font metrics
width - label width
height - label height
Returns:
clipped or full label text

layoutCL

protected java.lang.String layoutCL(E label,
                                    java.awt.FontMetrics fm,
                                    java.lang.String text,
                                    javax.swing.Icon icon,
                                    java.awt.Rectangle viewR,
                                    java.awt.Rectangle iconR,
                                    java.awt.Rectangle textR)
Performs label layout and returns clipped or full label text.

Parameters:
label - label to process
fm - label font metrics
text - label text
icon - label icon
viewR - rectangle limited by label insets
iconR - icon rectangle dummy
textR - text rectangle dummy
Returns:
clipped or full label text

paintEnabledText

protected void paintEnabledText(E label,
                                java.awt.Graphics2D g2d,
                                java.lang.String text,
                                int textX,
                                int textY)
Performs enabled text painting.

Parameters:
label - label to process
g2d - graphics context
text - label text
textX - text X coordinate
textY - text Y coordinate

paintDisabledText

protected void paintDisabledText(E label,
                                 java.awt.Graphics2D g2d,
                                 java.lang.String text,
                                 int textX,
                                 int textY)
Performs disabled text painting.

Parameters:
label - label to process
g2d - graphics context
text - label text
textX - text X coordinate
textY - text Y coordinate

paintShadowText

protected void paintShadowText(java.awt.Graphics2D g2d,
                               java.lang.String text,
                               int textX,
                               int textY)
Paints custom text shade.

Parameters:
g2d - graphics context
text - text
textX - text X coordinate
textY - text Y coordinate

getPreferredSize

public java.awt.Dimension getPreferredSize(E label)
Returns preferred size required for proper painting of visual data provided by this painter. This should not take into account any sizes not related to this painter settings (for example text size on button).

Specified by:
getPreferredSize in interface Painter<E extends javax.swing.JLabel>
Overrides:
getPreferredSize in class AbstractPainter<E extends javax.swing.JLabel>
Parameters:
label - component to process
Returns:
preferred size required for proper painting of visual data provided by this painter