Modifier and Type | Method and Description |
---|---|
void |
appendText(String text)
Adds additional text to the end of the current text.
|
void |
appendText(String text,
Color color)
Adds a colored substring to the end of the current text.
|
void |
appendText(String text,
Color color,
int indent)
Adds a colored substring to the end of the current text.
|
void |
appendText(String text,
int indent)
Adds additional text to the end of the current text.
|
void |
dispose()
Cleans up the underlying OpenGL resources of this
LazyFont.DrawableString . |
void |
draw(float x,
float y)
Renders the text area at the specified coordinates.
|
void |
draw(Vector2f location)
Renders the text area at the specified coordinates.
|
void |
drawAtAngle(float x,
float y,
float angle)
Renders the text area at the specified coordinates with the specified angle.
|
void |
drawAtAngle(Vector2f location,
float angle)
Renders the text area at the specified coordinates with the specified angle.
|
Color |
getColor()
Returns the current color text will be drawn as.
|
LazyFont |
getFont()
Returns a reference to the
LazyFont used to create this LazyFont.DrawableString . |
float |
getFontSize()
Returns the font size text will be drawn at.
|
float |
getHeight()
Returns the height of the rendered text area.
|
float |
getMaxHeight()
Returns the maximum height of the area that this text will be rendered within.
|
float |
getMaxWidth()
Returns the maximum width of the area that this text will be rendered within.
|
String |
getText()
Returns the raw text of this
LazyFont.DrawableString , before any word-wrapping is applied. |
float |
getWidth()
Returns the width of the rendered text area.
|
boolean |
isDisposed()
Whether this object's underlying OpenGL resources have been cleaned up - attempting to render after disposal
will cause a
RuntimeException ! |
void |
setColor(Color color)
Sets the color text will be drawn as.
|
void |
setFontSize(float fontSize)
Changes the font size that this text will be rendered at.
|
void |
setMaxHeight(float maxHeight)
Changes the maximum height of the area that this text will be rendered within.
|
void |
setMaxWidth(float maxWidth)
Changes the maximum width of the area that this text will be rendered within.
|
void |
setText(String text)
Replaces all text in the
LazyFont.DrawableString with the entered String . |
public LazyFont getFont()
LazyFont
used to create this LazyFont.DrawableString
.LazyFont.DrawableString
.public float getWidth()
getMaxWidth()
-
this only considers the area used by the text.public float getHeight()
getMaxHeight()
-
this only considers the area used by the text.public float getFontSize()
LazyFont.DrawableString
.public void setFontSize(float fontSize)
Changing the font size will necessitate a full rebuild of the LazyFont.DrawableString
the next time you
attempt to draw or measure the text.
fontSize
- The new font size to render at.public float getMaxWidth()
public void setMaxWidth(float maxWidth)
Changing the text area constraints will necessitate a full rebuild of the LazyFont.DrawableString
the next
time you attempt to draw or measure the text.
maxWidth
- The nex maximum width of the text area. Text will be wrapped at the last word that fit
within this area.public float getMaxHeight()
public void setMaxHeight(float maxHeight)
Changing the text area constraints will necessitate a full rebuild of the LazyFont.DrawableString
the next
time you attempt to draw or measure the text.
maxHeight
- The nex maximum height of the text area. Further text will be discarded once this limit is
reached.public Color getColor()
public void setColor(Color color)
Unlike most setX() methods in this class, calling this will not trigger a rebuild of the entire LazyFont.DrawableString
.
color
- The color to draw the text as.public String getText()
LazyFont.DrawableString
, before any word-wrapping is applied.
Performance note: due to the underlying text being stored in a StringBuilder
, a new String
will be built every time this method is called.LazyFont.DrawableString
(without word-wrapping applied).to calculate the text after wrapping is applied.
public void setText(String text)
LazyFont.DrawableString
with the entered String
.
Changing a LazyFont.DrawableString
's text will necessitate a full rebuild of its contents the next time you
attempt to draw or measure the text.
text
- The String
to set this LazyFont.DrawableString
's contents to.public void appendText(String text)
Changing a LazyFont.DrawableString
's text will necessitate a full rebuild of its contents the next time you
attempt to draw or measure the text.
text
- The text to add to the LazyFont.DrawableString
.public void appendText(String text, Color color)
getColor()
.
Changing a LazyFont.DrawableString
's text will necessitate a full rebuild of its contents the next time you
attempt to draw or measure the text.
text
- The text to add to the LazyFont.DrawableString
.color
- The color this text should appear as.public void appendText(String text, int indent)
Changing a LazyFont.DrawableString
's text will necessitate a full rebuild of its contents the next time you
attempt to draw or measure the text.
text
- The text to add to the LazyFont.DrawableString
.indent
- All lines will be prepended with this number of blank spaces.public void appendText(String text, Color color, int indent)
getColor()
.
Changing a LazyFont.DrawableString
's text will necessitate a full rebuild of its contents the next time you
attempt to draw or measure the text.
text
- The text to add to the LazyFont.DrawableString
.indent
- All lines will be prepended with this number of blank spaces.color
- The color this text should appear as.public void draw(float x, float y)
You can render the same block of text in multiple places. The OpenGL commands are cached in a display list, so performance should not be an issue (provided the underlying data isn't changed, necessitating a rebuild).
x
- The X coordinate to draw at.y
- The Y coordinate to draw at.public void draw(Vector2f location)
You can render the same block of text in multiple places. The OpenGL commands are cached in a display list, so performance should not be an issue (provided the underlying data isn't changed, necessitating a rebuild).
location
- The coordinates to draw at.public void drawAtAngle(float x, float y, float angle)
You can render the same block of text in multiple places. The OpenGL commands are cached in a display list, so performance should not be an issue (provided the underlying data isn't changed, necessitating a rebuild).
x
- The X coordinate to draw at.y
- The Y coordinate to draw at.angle
- The angle to draw at.public void drawAtAngle(Vector2f location, float angle)
You can render the same block of text in multiple places. The OpenGL commands are cached in a display list, so performance should not be an issue (provided the underlying data isn't changed, necessitating a rebuild).
location
- The coordinates to draw at.angle
- The angle to draw at.public boolean isDisposed()
RuntimeException
!true
if dispose()
has been called; false
otherwise.public void dispose()
LazyFont.DrawableString
. Calling any draw() method after
this will cause a RuntimeException
.
Calling this method is optional, and rarely required. However, there are a limited number of display lists
available, so if you are creating many thousands of LazyFont.DrawableString
s, you will need to call this when
done with each to prevent the pool from being exhausted before the garbage collector can get around to
cleaning them up for you.