Package org.jdesktop.swingx.painter
Class TextPainter
- java.lang.Object
-
- org.jdesktop.beans.AbstractBean
-
- org.jdesktop.swingx.painter.AbstractPainter<T>
-
- org.jdesktop.swingx.painter.AbstractLayoutPainter<T>
-
- org.jdesktop.swingx.painter.AbstractAreaPainter<java.lang.Object>
-
- org.jdesktop.swingx.painter.TextPainter
-
- All Implemented Interfaces:
Painter<java.lang.Object>
@JavaBean public class TextPainter extends AbstractAreaPainter<java.lang.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
Constructors Constructor Description TextPainter()
Creates a new instance of TextPainterTextPainter(java.lang.String text)
Create a new TextPainter which will paint the specified textTextPainter(java.lang.String text, java.awt.Font font)
Create a new TextPainter which will paint the specified text with the specified font.TextPainter(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
Create a new TextPainter which will paint the specified text with the specified font and paint.TextPainter(java.lang.String text, java.awt.Paint paint)
Create a new TextPainter which will paint the specified text with the specified paint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.awt.Font
calculateFont(java.lang.Object component)
private java.lang.String
calculateText(java.lang.Object component)
protected void
doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height)
Subclasses must implement this method and perform custom painting operations here.java.awt.Font
getFont()
gets the font (and font size and style) to be used when drawing the textjava.lang.String
getText()
gets the text currently used to drawprotected java.awt.Shape
provideShape(java.awt.Graphics2D g2, java.lang.Object comp, int width, int height)
Returns the outline shape of this painter.void
setFont(java.awt.Font f)
Set the font (and font size and style) to be used when drawing the textvoid
setText(java.lang.String text)
Sets the text to draw-
Methods inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
calculateSnappedPaint, 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, isCacheCleared, isDirty, isInPaintContext, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInPaintContext, 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
-
-
-
-
Constructor Detail
-
TextPainter
public TextPainter()
Creates a new instance of TextPainter
-
TextPainter
public TextPainter(java.lang.String text)
Create a new TextPainter which will paint the specified text- Parameters:
text
- the text to paint
-
TextPainter
public TextPainter(java.lang.String text, java.awt.Font font)
Create a new TextPainter which will paint the specified text with the specified font.- Parameters:
text
- the text to paintfont
- the font to paint the text with
-
TextPainter
public TextPainter(java.lang.String text, java.awt.Paint paint)
Create a new TextPainter which will paint the specified text with the specified paint.- Parameters:
text
- the text to paintpaint
- the paint to paint with
-
TextPainter
public TextPainter(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
Create a new TextPainter which will paint the specified text with the specified font and paint.- Parameters:
text
- the text to paintfont
- the font to paint the text withpaint
- the paint to paint with
-
-
Method Detail
-
setFont
public void setFont(java.awt.Font f)
Set the font (and font size and style) to be used when drawing the text- Parameters:
f
- the new font
-
getFont
public java.awt.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(java.lang.String text)
Sets the text to draw- Parameters:
text
- the text to draw
-
getText
public java.lang.String getText()
gets the text currently used to draw- Returns:
- the text to be drawn
-
doPaint
protected void doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height)
Subclasses must implement this method and perform custom painting operations here.- Specified by:
doPaint
in classAbstractPainter<java.lang.Object>
- Parameters:
g
- The Graphics2D object in which to paint
-
calculateText
private java.lang.String calculateText(java.lang.Object component)
-
calculateFont
private java.awt.Font calculateFont(java.lang.Object component)
-
provideShape
protected java.awt.Shape provideShape(java.awt.Graphics2D g2, java.lang.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 classAbstractAreaPainter<java.lang.Object>
- Parameters:
g2
- graphicscomp
- The Object this painter will be painted on.width
- the width to paintheight
- the height to paint- Returns:
- the outline shape of this painter
-
-