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

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

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

Simple border painter. This painter might be used instead of LineBorder in any component that supports painters.

Author:
Mikle Garin
See Also:
AbstractPainter, Painter

Field Summary
protected  java.awt.Color color
          Border color.
protected  int round
          Border round.
protected  java.awt.Stroke stroke
          Border stroke.
protected  int width
          Border width.
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
BorderPainter()
          Constructs default border painter.
BorderPainter(java.awt.Color color)
          Constructs border painter with a specified color.
BorderPainter(int width)
          Constructs border painter with a specified width.
BorderPainter(int width, java.awt.Color color)
          Constructs border painter with a specified width and color.
 
Method Summary
protected  java.awt.geom.RectangularShape getBorderShape(java.awt.Rectangle bounds)
          Returns border shape for the specified limiting bounds.
 java.awt.Color getColor()
          Returns border color.
 java.awt.Insets getMargin(E c)
          Returns margin required for visual data provided by this painter.
 java.awt.Dimension getPreferredSize(E c)
          Returns preferred size required for proper painting of visual data provided by this painter.
 int getRound()
          Returns border round.
 java.awt.Stroke getStroke()
          Returns border stroke.
 int getWidth()
          Returns border width.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E c)
          Paints visual data onto the component graphics.
 void setColor(java.awt.Color color)
          Sets border color.
 void setRound(int round)
          Sets border round.
 void setStroke(java.awt.Stroke stroke)
          Sets border stroke.
 void setWidth(int width)
          Sets border width.
protected  void updateStroke()
          Updates border stroke depending on painter settings.
 
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

width

protected int width
Border width.


round

protected int round
Border round.


color

protected java.awt.Color color
Border color.


stroke

protected java.awt.Stroke stroke
Border stroke.

Constructor Detail

BorderPainter

public BorderPainter()
Constructs default border painter.


BorderPainter

public BorderPainter(int width)
Constructs border painter with a specified width.

Parameters:
width - border width

BorderPainter

public BorderPainter(java.awt.Color color)
Constructs border painter with a specified color.

Parameters:
color - border color

BorderPainter

public BorderPainter(int width,
                     java.awt.Color color)
Constructs border painter with a specified width and color.

Parameters:
width - border width
color - border color
Method Detail

getWidth

public int getWidth()
Returns border width.

Returns:
border width

setWidth

public void setWidth(int width)
Sets border width. This will also force stroke to update and overwrite old stroke value.

Parameters:
width - new border width

getRound

public int getRound()
Returns border round.

Returns:
border round

setRound

public void setRound(int round)
Sets border round. This will also force stroke to update and overwrite old stroke value.

Parameters:
round - new border round

getColor

public java.awt.Color getColor()
Returns border color.

Returns:
border color

setColor

public void setColor(java.awt.Color color)
Sets border color.

Parameters:
color - new border color

getStroke

public java.awt.Stroke getStroke()
Returns border stroke.

Returns:
border stroke

setStroke

public void setStroke(java.awt.Stroke stroke)
Sets border stroke. Be aware that this value might be overwritten when you modify other painter settings.

Parameters:
stroke - new border stroke
See Also:
setWidth(int), setRound(int)

updateStroke

protected void updateStroke()
Updates border stroke depending on painter settings.


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.

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

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

getBorderShape

protected java.awt.geom.RectangularShape getBorderShape(java.awt.Rectangle bounds)
Returns border shape for the specified limiting bounds.

Parameters:
bounds - limiting bounds
Returns:
border shape for the specified limiting bounds