com.alee.managers.style.skin.ninepatch
Class NPLabelPainter<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>
          extended by com.alee.managers.style.skin.ninepatch.NPLabelPainter<E>
All Implemented Interfaces:
Painter<E>, SpecificPainter, LabelPainter<E>

public class NPLabelPainter<E extends javax.swing.JLabel>
extends WebLabelPainter<E>

Base 9-patch painter for JLabel component.

Author:
Mikle Garin

Field Summary
protected  NinePatchIcon backgroundIcon
          Used 9-patch icons.
protected  boolean focused
           
protected  NinePatchIcon focusedBackgroundIcon
           
protected  FocusTracker focusTracker
          Runtime variables.
protected  boolean paintFocus
           
protected  boolean undecorated
          Style settings.
 
Fields inherited from class com.alee.managers.style.skin.web.WebLabelPainter
backgroundPainter, drawShade, paintIconR, paintTextR, shadeColor, transparency
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
NPLabelPainter()
          Constructs default 9-patch label painter.
NPLabelPainter(NinePatchIcon backgroundIcon)
          Constructs 9-patch label painter using the specified background icon.
NPLabelPainter(NinePatchIcon backgroundIcon, NinePatchIcon focusedBackgroundIcon)
          Constructs 9-patch label painter using the specified background icons.
 
Method Summary
 NinePatchIcon getBackgroundIcon()
          Returns background 9-patch icon.
protected  NinePatchIcon getCurrentBackgroundIcon()
          Returns background 9-patch icon that should be painted right now.
 NinePatchIcon getFocusedBackgroundIcon()
          Returns focused background 9-patch icon.
 java.awt.Insets getMargin(E label)
          Returns margin required for visual data provided by this painter.
 void install(E c)
          Called when painter is intalled into some component.
 boolean isPaintFocus()
          Returns whether focus should be painted or not.
 boolean isUndecorated()
          Returns whether decoration should be painted or not.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c)
          Paints visual data onto the component graphics.
 void setBackgroundIcon(NinePatchIcon icon)
          Sets background 9-patch icon.
 void setFocusedBackgroundIcon(NinePatchIcon icon)
          Sets focused background 9-patch icon.
 void setPaintFocus(boolean paint)
          Sets whether focus should be painted or not.
 void setUndecorated(boolean undecorated)
          Sets whether decoration should be painted or not.
 void uninstall(E c)
          Called when painter is intalled into some component.
 
Methods inherited from class com.alee.managers.style.skin.web.WebLabelPainter
getBackgroundPainter, getPreferredSize, getShadeColor, getTransparency, isDrawShade, isOpaque, layout, layoutCL, paintDisabledText, paintEnabledText, paintShadowText, setBackgroundPainter, setDrawShade, setShadeColor, setTransparency
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, 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
 
Methods inherited from interface com.alee.extended.painter.Painter
addPainterListener, removePainterListener
 

Field Detail

undecorated

protected boolean undecorated
Style settings.


paintFocus

protected boolean paintFocus

backgroundIcon

protected NinePatchIcon backgroundIcon
Used 9-patch icons.


focusedBackgroundIcon

protected NinePatchIcon focusedBackgroundIcon

focusTracker

protected FocusTracker focusTracker
Runtime variables.


focused

protected boolean focused
Constructor Detail

NPLabelPainter

public NPLabelPainter()
Constructs default 9-patch label painter. todo Initialize default settings in this constructor?


NPLabelPainter

public NPLabelPainter(NinePatchIcon backgroundIcon)
Constructs 9-patch label painter using the specified background icon.

Parameters:
backgroundIcon - background 9-patch icon

NPLabelPainter

public NPLabelPainter(NinePatchIcon backgroundIcon,
                      NinePatchIcon focusedBackgroundIcon)
Constructs 9-patch label painter using the specified background icons.

Parameters:
backgroundIcon - background 9-patch icon
focusedBackgroundIcon - focused background 9-patch icon
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.JLabel>
Overrides:
install in class AbstractPainter<E extends javax.swing.JLabel>
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.JLabel>
Overrides:
uninstall in class AbstractPainter<E extends javax.swing.JLabel>
Parameters:
c - component to process

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

getBackgroundIcon

public NinePatchIcon getBackgroundIcon()
Returns background 9-patch icon.

Returns:
background 9-patch icon

setBackgroundIcon

public void setBackgroundIcon(NinePatchIcon icon)
Sets background 9-patch icon.

Parameters:
icon - background 9-patch icon

getFocusedBackgroundIcon

public NinePatchIcon getFocusedBackgroundIcon()
Returns focused background 9-patch icon.

Returns:
focused background 9-patch icon

setFocusedBackgroundIcon

public void setFocusedBackgroundIcon(NinePatchIcon icon)
Sets focused background 9-patch icon.

Parameters:
icon - focused background 9-patch icon

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 WebLabelPainter<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 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.JLabel>
Overrides:
paint in class WebLabelPainter<E extends javax.swing.JLabel>
Parameters:
g2d - component graphics
bounds - bounds for painter visual data
c - component to process

getCurrentBackgroundIcon

protected NinePatchIcon getCurrentBackgroundIcon()
Returns background 9-patch icon that should be painted right now.

Returns:
background 9-patch icon that should be painted right now