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[]cachedGlyphShapesprotected java.awt.font.GlyphVectorcachedGlyphVectorprotected floatcachedTextAscentprotected floatcachedTextHeightprotected floatcachedTextWidthprivate booleancacheValidprotected floatcapitalMAscentprivate java.awt.Colorcolorprivate java.awt.Fontfontprivate HeightModeheightModeprivate java.lang.Stringtext
-
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.FontcreateDefaultFont()Creates and returns a default font object.private voidensureCapitalMAscentComputed(java.awt.font.FontRenderContext frc)Ensures that the ascent of a capital M has been computed.protected voidensureValidCache(java.awt.Graphics2D g2)protected floatgetAdjustedAscent()Computes and answers the text ascent using the current height mode.protected floatgetAdjustedDescent()Computes and answers the text descent using the current height mode.java.awt.ColorgetColor()java.awt.FontgetFont()HeightModegetHeightMode()java.lang.StringgetText()protected voidinvalidateCache()Invalidates the cache.protected booleanisCacheValid()protected voidsetCacheValid(boolean b)voidsetColor(java.awt.Color color)voidsetFont(java.awt.Font newFont)Sets the renderer's font.voidsetHeightMode(HeightMode heightMode)voidsetText(java.lang.String newText)Sets the renderer's text.protected voidvalidateCache(java.awt.Graphics2D g2)Validates the cache, here: creates aGlyphVectorand 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 aGlyphVectorand 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.
-
-