|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.opengl.gui.text.TextFactory
com.threerings.opengl.gui.text.CharacterTextFactory
public class CharacterTextFactory
Formats text by rendering individual characters into a set of shared textures, then returning
Text instances that render groups of quads, one for each character.
| Nested Class Summary | |
|---|---|
protected class |
CharacterTextFactory.Glyph
A single glyph. |
protected class |
CharacterTextFactory.GlyphTexture
A shared texture. |
| Field Summary | |
|---|---|
protected Font |
_font
The font being rendered by this factory. |
protected HashIntMap<CharacterTextFactory.Glyph> |
_glyphs
Cached glyphs. |
protected Graphics2D |
_graphics
|
protected static HashMap<Tuple<Font,Boolean>,CharacterTextFactory> |
_instances
Shared instances. |
protected FontMetrics |
_metrics
The font metrics. |
protected BufferedImage |
_scratch
A scratchpad image and its graphics context. |
protected CharacterTextFactory.GlyphTexture |
_texture
The glyph texture currently being populated. |
protected static int |
TEXTURE_SIZE
The width/height of the glyph textures. |
| Fields inherited from interface com.threerings.opengl.gui.UIConstants |
|---|
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL |
| Constructor Summary | |
|---|---|
CharacterTextFactory(Font font,
boolean antialias)
Creates a character text factory with the supplied font. |
|
| Method Summary | |
|---|---|
protected TextureUnit[] |
addGlyphToTexture(Renderer renderer,
int width,
int height,
float[] tcoords)
Inserts the glyph image in the scratch pad into the current texture (creating a new texture if there is no current texture or the current texture doesn't have enough room), returns the texture unit data, and populates the supplied array with the texture coordinates. |
Text |
createText(String text,
Color4f color,
int effect,
int effectSize,
Color4f effectColor,
boolean useAdvance)
Creates a text instance using our the font configuration associated with this text factory and the foreground color, text effect and text effect color specified. |
protected IntTuple |
getBreakSpan(StringBuilder buf)
Searches for an appropriate break span: the last region of whitespace preceeded by a non-whitespace character. |
protected CharacterTextFactory.Glyph |
getGlyph(char c)
Returns the normal glyph for the given character. |
protected CharacterTextFactory.Glyph |
getGlyph(char c,
int effect,
int size)
Returns the glyph for the given character with the given effect and effect size. |
int |
getHeight()
Returns the height of our text. |
static CharacterTextFactory |
getInstance(Font font,
boolean antialias)
Returns a shared factory instance. |
void |
render(Renderer renderer,
String text,
int x,
int y,
Color4f color)
Renders a string directly, without creating a text object. |
Text[] |
wrapText(String text,
Color4f color,
int effect,
int effectSize,
Color4f effectColor,
int maxWidth)
Wraps a string into a set of text objects that do not exceed the specified width. |
| Methods inherited from class com.threerings.opengl.gui.text.TextFactory |
|---|
createText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Font _font
protected BufferedImage _scratch
protected Graphics2D _graphics
protected FontMetrics _metrics
protected HashIntMap<CharacterTextFactory.Glyph> _glyphs
protected CharacterTextFactory.GlyphTexture _texture
protected static HashMap<Tuple<Font,Boolean>,CharacterTextFactory> _instances
protected static final int TEXTURE_SIZE
| Constructor Detail |
|---|
public CharacterTextFactory(Font font,
boolean antialias)
| Method Detail |
|---|
public static CharacterTextFactory getInstance(Font font,
boolean antialias)
public void render(Renderer renderer,
String text,
int x,
int y,
Color4f color)
public int getHeight()
TextFactory
getHeight in class TextFactory
public Text createText(String text,
Color4f color,
int effect,
int effectSize,
Color4f effectColor,
boolean useAdvance)
TextFactory
createText in class TextFactoryuseAdvance - if true, the advance to the next insertion point will be included in the
bounds of the created text (this is needed by editable text displays).
public Text[] wrapText(String text,
Color4f color,
int effect,
int effectSize,
Color4f effectColor,
int maxWidth)
TextFactory
wrapText in class TextFactoryprotected CharacterTextFactory.Glyph getGlyph(char c)
protected CharacterTextFactory.Glyph getGlyph(char c,
int effect,
int size)
protected IntTuple getBreakSpan(StringBuilder buf)
null if no span
was found.
protected TextureUnit[] addGlyphToTexture(Renderer renderer,
int width,
int height,
float[] tcoords)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||