com.alee.extended.painter
Class NinePatchIconPainter<E extends javax.swing.JComponent>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.extended.painter.NinePatchIconPainter<E>
Type Parameters:
E - component type
All Implemented Interfaces:
Painter<E>
Direct Known Subclasses:
InnerShadePainter

public class NinePatchIconPainter<E extends javax.swing.JComponent>
extends AbstractPainter<E>

Custom painter for 9-patch icon.

Author:
Mikle Garin
See Also:
NinePatchIcon, NinePatchStatePainter, AbstractPainter, Painter

Field Summary
protected  NinePatchIcon icon
          9-patch icon to paint.
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
NinePatchIconPainter()
          Constructs new 9-patch icon painter.
NinePatchIconPainter(java.awt.image.BufferedImage bufferedImage)
          Constructs new 9-patch icon painter.
NinePatchIconPainter(java.awt.Image image)
          Constructs new 9-patch icon painter.
NinePatchIconPainter(javax.swing.ImageIcon imageIcon)
          Constructs new 9-patch icon painter.
NinePatchIconPainter(NinePatchIcon icon)
          Constructs new 9-patch icon painter.
NinePatchIconPainter(java.lang.String iconSrc)
          Constructs new 9-patch icon painter.
NinePatchIconPainter(java.net.URL url)
          Constructs new 9-patch icon painter.
 
Method Summary
 java.awt.Insets getMargin(E c)
          Returns margin required for visual data provided by this painter.
 NinePatchIcon getNinePatchIcon()
          Returns painted 9-patch icon.
 java.awt.Dimension getPreferredSize(E c)
          Returns preferred size required for proper painting of visual data provided by this painter.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c)
          Paints visual data onto the component graphics.
 void setNinePatchIcon(NinePatchIcon icon)
          Sets painted 9-patch icon.
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, install, isOpaque, 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
 

Field Detail

icon

protected NinePatchIcon icon
9-patch icon to paint.

Constructor Detail

NinePatchIconPainter

public NinePatchIconPainter()
Constructs new 9-patch icon painter.


NinePatchIconPainter

public NinePatchIconPainter(java.net.URL url)
Constructs new 9-patch icon painter.

Parameters:
url - 9-patch image URL

NinePatchIconPainter

public NinePatchIconPainter(java.lang.String iconSrc)
Constructs new 9-patch icon painter.

Parameters:
iconSrc - 9-patch image source

NinePatchIconPainter

public NinePatchIconPainter(javax.swing.ImageIcon imageIcon)
Constructs new 9-patch icon painter.

Parameters:
imageIcon - 9-patch image

NinePatchIconPainter

public NinePatchIconPainter(java.awt.Image image)
Constructs new 9-patch icon painter.

Parameters:
image - 9-patch image

NinePatchIconPainter

public NinePatchIconPainter(java.awt.image.BufferedImage bufferedImage)
Constructs new 9-patch icon painter.

Parameters:
bufferedImage - 9-patch image

NinePatchIconPainter

public NinePatchIconPainter(NinePatchIcon icon)
Constructs new 9-patch icon painter.

Parameters:
icon - 9-patch icon
Method Detail

getNinePatchIcon

public NinePatchIcon getNinePatchIcon()
Returns painted 9-patch icon.

Returns:
painted 9-patch icon

setNinePatchIcon

public void setNinePatchIcon(NinePatchIcon icon)
Sets painted 9-patch icon.

Parameters:
icon - painted 9-patch icon

getPreferredSize

public java.awt.Dimension getPreferredSize(E c)
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.JComponent>
Overrides:
getPreferredSize in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process
Returns:
preferred size required for proper painting of visual data provided by this painter

getMargin

public java.awt.Insets getMargin(E c)
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:
c - 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.

Parameters:
g2d - component graphics
bounds - bounds for painter visual data
c - component to process