Package com.jgoodies.animation.renderer
Class AbstractTextRenderer
- java.lang.Object
-
- com.jgoodies.animation.renderer.AbstractTextRenderer
-
- All Implemented Interfaces:
AnimationRenderer
- Direct Known Subclasses:
BasicTextRenderer
,GlyphRenderer
public abstract class AbstractTextRenderer extends java.lang.Object implements AnimationRenderer
An abstract superclass that helps implementing typographic animation renderers.- Version:
- $Revision: 1.8 $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Shape[]
cachedGlyphShapes
protected java.awt.font.GlyphVector
cachedGlyphVector
protected float
cachedTextAscent
protected float
cachedTextHeight
protected float
cachedTextWidth
private boolean
cacheValid
protected float
capitalMAscent
private java.awt.Color
color
private java.awt.Font
font
private HeightMode
heightMode
private java.lang.String
text
-
Constructor Summary
Constructors Constructor Description AbstractTextRenderer(java.lang.String text)
AbstractTextRenderer(java.lang.String text, java.awt.Font font)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.awt.Font
createDefaultFont()
Creates and returns a default font object.private void
ensureCapitalMAscentComputed(java.awt.font.FontRenderContext frc)
Ensures that the ascent of a capital M has been computed.protected void
ensureValidCache(java.awt.Graphics2D g2)
protected float
getAdjustedAscent()
Computes and answers the text ascent using the current height mode.protected float
getAdjustedDescent()
Computes and answers the text descent using the current height mode.java.awt.Color
getColor()
java.awt.Font
getFont()
HeightMode
getHeightMode()
java.lang.String
getText()
protected void
invalidateCache()
Invalidates the cache.protected boolean
isCacheValid()
protected void
setCacheValid(boolean b)
void
setColor(java.awt.Color color)
void
setFont(java.awt.Font newFont)
Sets the renderer's font.void
setHeightMode(HeightMode heightMode)
void
setText(java.lang.String newText)
Sets the renderer's text.protected void
validateCache(java.awt.Graphics2D g2)
Validates the cache, here: creates aGlyphVector
and computes and stores its size information.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jgoodies.animation.renderer.AnimationRenderer
render
-
-
-
-
Field Detail
-
text
private java.lang.String text
-
font
private java.awt.Font font
-
color
private java.awt.Color color
-
heightMode
private HeightMode heightMode
-
cachedGlyphVector
protected java.awt.font.GlyphVector cachedGlyphVector
-
cachedGlyphShapes
protected java.awt.Shape[] cachedGlyphShapes
-
cachedTextWidth
protected float cachedTextWidth
-
cachedTextAscent
protected float cachedTextAscent
-
cachedTextHeight
protected float cachedTextHeight
-
capitalMAscent
protected float capitalMAscent
-
cacheValid
private boolean cacheValid
-
-
Method Detail
-
createDefaultFont
private static java.awt.Font createDefaultFont()
Creates and returns a default font object.- Returns:
- a default font object
-
getColor
public java.awt.Color getColor()
-
getFont
public java.awt.Font getFont()
-
getText
public java.lang.String getText()
-
getHeightMode
public HeightMode getHeightMode()
-
setColor
public void setColor(java.awt.Color color)
-
setHeightMode
public void setHeightMode(HeightMode heightMode)
-
setFont
public void setFont(java.awt.Font newFont)
Sets the renderer's font.- Parameters:
newFont
- the font to be set
-
setText
public void setText(java.lang.String newText)
Sets the renderer's text.- Parameters:
newText
- the text to be set
-
getAdjustedAscent
protected float getAdjustedAscent()
Computes and answers the text ascent using the current height mode.- Returns:
- the ascent adjusted using the current height mode
- See Also:
getHeightMode()
-
getAdjustedDescent
protected float getAdjustedDescent()
Computes and answers the text descent using the current height mode.- Returns:
- the descent adjusted to the current height mode
- See Also:
getHeightMode()
-
isCacheValid
protected boolean isCacheValid()
-
setCacheValid
protected void setCacheValid(boolean b)
-
ensureValidCache
protected void ensureValidCache(java.awt.Graphics2D g2)
-
validateCache
protected void validateCache(java.awt.Graphics2D g2)
Validates the cache, here: creates aGlyphVector
and computes and stores its size information.- Parameters:
g2
- the Graphics object used to get the font render context
-
ensureCapitalMAscentComputed
private void ensureCapitalMAscentComputed(java.awt.font.FontRenderContext frc)
Ensures that the ascent of a capital M has been computed.- Parameters:
frc
- the font render context used to create the glyph vector
-
invalidateCache
protected void invalidateCache()
Invalidates the cache.
-
-