org.jdesktop.swingx.painter
Class TextPainter

java.lang.Object
  extended by org.jdesktop.beans.AbstractBean
      extended by org.jdesktop.swingx.painter.AbstractPainter<T>
          extended by org.jdesktop.swingx.painter.AbstractLayoutPainter<T>
              extended by org.jdesktop.swingx.painter.AbstractAreaPainter<Object>
                  extended by org.jdesktop.swingx.painter.TextPainter
All Implemented Interfaces:
Painter<Object>

public class TextPainter
extends AbstractAreaPainter<Object>

A painter which draws text. If the font, text, and paint are not provided they will be obtained from the object being painted if it is a Swing text component.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
AbstractAreaPainter.Style
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignment
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractPainter
AbstractPainter.Interpolation
 
Constructor Summary
TextPainter()
          Creates a new instance of TextPainter
TextPainter(String text)
          Create a new TextPainter which will paint the specified text
TextPainter(String text, Font font)
          Create a new TextPainter which will paint the specified text with the specified font.
TextPainter(String text, Font font, Paint paint)
          Create a new TextPainter which will paint the specified text with the specified font and paint.
TextPainter(String text, Paint paint)
          Create a new TextPainter which will paint the specified text with the specified paint.
 
Method Summary
protected  void doPaint(Graphics2D g, Object component, int width, int height)
          Subclasses must implement this method and perform custom painting operations here.
 Font getFont()
          gets the font (and font size and style) to be used when drawing the text
 String getText()
          gets the text currently used to draw
protected  Shape provideShape(Graphics2D g2, Object comp, int width, int height)
          Returns the outline shape of this painter.
 void setFont(Font f)
          Set the font (and font size and style) to be used when drawing the text
 void setText(String text)
          Sets the text to draw
 
Methods inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyle
 
Methods inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignment
 
Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate
 
Methods inherited from class org.jdesktop.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextPainter

public TextPainter()
Creates a new instance of TextPainter


TextPainter

public TextPainter(String text)
Create a new TextPainter which will paint the specified text

Parameters:
text - the text to paint

TextPainter

public TextPainter(String text,
                   Font font)
Create a new TextPainter which will paint the specified text with the specified font.

Parameters:
text - the text to paint
font - the font to paint the text with

TextPainter

public TextPainter(String text,
                   Paint paint)
Create a new TextPainter which will paint the specified text with the specified paint.

Parameters:
text - the text to paint
paint - the paint to paint with

TextPainter

public TextPainter(String text,
                   Font font,
                   Paint paint)
Create a new TextPainter which will paint the specified text with the specified font and paint.

Parameters:
text - the text to paint
font - the font to paint the text with
paint - the paint to paint with
Method Detail

setFont

public void setFont(Font f)
Set the font (and font size and style) to be used when drawing the text

Parameters:
f - the new font

getFont

public Font getFont()
gets the font (and font size and style) to be used when drawing the text

Returns:
the current font

setText

public void setText(String text)
Sets the text to draw

Parameters:
text - the text to draw

getText

public String getText()
gets the text currently used to draw

Returns:
the text to be drawn

doPaint

protected void doPaint(Graphics2D g,
                       Object component,
                       int width,
                       int height)
Subclasses must implement this method and perform custom painting operations here.

Specified by:
doPaint in class AbstractPainter<Object>
Parameters:
g - The Graphics2D object in which to paint

provideShape

protected Shape provideShape(Graphics2D g2,
                             Object comp,
                             int width,
                             int height)
Returns the outline shape of this painter. Subclasses must implement this method. This shape will be used for filling, stroking, and clipping.

Specified by:
provideShape in class AbstractAreaPainter<Object>
Parameters:
g2 - graphics
comp - The Object this painter will be painted on.
width - the width to paint
height - the height to paint
Returns:
the outline shape of this painter