Class TextPainter
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 AbstractAreaPainter
AbstractAreaPainter.StyleNested classes/interfaces inherited from class AbstractLayoutPainter
AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignmentNested classes/interfaces inherited from class AbstractPainter
AbstractPainter.Interpolation -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of TextPainterTextPainter(String text) Create a new TextPainter which will paint the specified textTextPainter(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
Modifier and TypeMethodDescriptionprivate FontcalculateFont(Object component) private StringcalculateText(Object component) protected voiddoPaint(Graphics2D g, Object component, int width, int height) Subclasses must implement this method and perform custom painting operations here.getFont()gets the font (and font size and style) to be used when drawing the textgetText()gets the text currently used to drawprotected ShapeprovideShape(Graphics2D g2, Object comp, int width, int height) Returns the outline shape of this painter.voidSet the font (and font size and style) to be used when drawing the textvoidSets the text to drawMethods inherited from class AbstractAreaPainter
calculateSnappedPaint, getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyleMethods inherited from class AbstractLayoutPainter
calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignmentMethods inherited from class AbstractPainter
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isCacheCleared, isDirty, isInPaintContext, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInPaintContext, setInterpolation, setVisible, shouldUseCache, validateMethods inherited from class AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Field Details
-
text
-
font
-
-
Constructor Details
-
TextPainter
public TextPainter()Creates a new instance of TextPainter -
TextPainter
Create a new TextPainter which will paint the specified text- Parameters:
text- the text to paint
-
TextPainter
-
TextPainter
-
TextPainter
-
-
Method Details
-
setFont
Set the font (and font size and style) to be used when drawing the text- Parameters:
f- the new font
-
getFont
gets the font (and font size and style) to be used when drawing the text- Returns:
- the current font
-
setText
-
getText
-
doPaint
Subclasses must implement this method and perform custom painting operations here.- Specified by:
doPaintin classAbstractPainter<Object>- Parameters:
g- The Graphics2D object in which to paintcomponent-width-height-
-
calculateText
-
calculateFont
-
provideShape
Returns the outline shape of this painter. Subclasses must implement this method. This shape will be used for filling, stroking, and clipping.- Specified by:
provideShapein classAbstractAreaPainter<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
-