Modifier and Type | Method and Description |
---|---|
LazyFont.DrawableString |
append(String text)
Adds additional text to the end of the current text.
|
LazyFont.DrawableString |
append(String text,
Color color)
Adds a colored substring to the end of the current text.
|
LazyFont.DrawableString |
appendIndented(String text,
Color color,
int indent)
Adds a colored substring to the end of the current text, with indentation.
|
LazyFont.DrawableString |
appendIndented(String text,
int indent)
Adds additional text to the end of the current text, with indentation.
|
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.
|
LazyFont.TextAlignment |
getAlignment()
Returns which side of the text area the text will be aligned with.
|
LazyFont.TextAnchor |
getAnchor()
Returns the current anchor (origin when drawing) for this
LazyFont.DrawableString . |
Color |
getBaseColor()
Returns the default color of drawn text.
|
int |
getBlendDest()
Returns the blend destination factor used by
glBlendFunc()
when rendering this block of text.
|
int |
getBlendSrc()
Returns the blend source factor used by
glBlendFunc()
when rendering this block of text.
|
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.
|
boolean |
getRenderDebugBounds()
Returns whether bounds drawing is enabled.
|
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 ! |
boolean |
isRebuildNeeded()
Returns whether a method has been performed since the last draw call that will trigger a rebuild.
|
void |
setAlignment(LazyFont.TextAlignment alignment)
Sets which side of the text area the text will be aligned with.
|
void |
setAnchor(LazyFont.TextAnchor anchor)
Sets the anchor (origin when drawing) for this
LazyFont.DrawableString . |
void |
setBaseColor(Color color)
Sets the default color of drawn text.
|
void |
setBlendDest(int blendDest)
Sets the blend destination factor used by
glBlendFunc()
when rendering this block of text.
|
void |
setBlendSrc(int blendSrc)
Sets the blend source factor used by
glBlendFunc()
when rendering this block of text.
|
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 |
setRenderDebugBounds(boolean renderDebugBounds)
Sets whether bounds drawing is enabled.
|
void |
setText(String text)
Replaces all text in the
LazyFont.DrawableString with the entered String . |
void |
triggerRebuildIfNeeded()
Triggers a rebuild of the native GPU buffers if needed.
|
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 LazyFont.TextAnchor getAnchor()
LazyFont.DrawableString
.LazyFont.DrawableString
.LazyFont.TextAnchor
public void setAnchor(LazyFont.TextAnchor anchor)
LazyFont.DrawableString
.anchor
- The new anchor (origin of drawing) for this LazyFont.DrawableString
.LazyFont.TextAnchor
public LazyFont.TextAlignment getAlignment()
LazyFont.TextAlignment
public void setAlignment(LazyFont.TextAlignment alignment)
alignment
- Which side of the text area to align text to.LazyFont.TextAlignment
public Color getBaseColor()
append(String, Color)
.public void setBaseColor(Color color)
color
- The color text will be drawn as if not overridden in append(String, Color)
.public int getBlendDest()
GL11.GL_ONE_MINUS_SRC_ALPHA
.public void setBlendDest(int blendDest)
blendDest
- The blend destination factor to use when drawing text.public int getBlendSrc()
GL11.GL_ONE
.public void setBlendSrc(int blendSrc)
blendSrc
- The blend source factor to use when drawing text.public boolean getRenderDebugBounds()
true
if bounds rendering is enabled, false
otherwise.public void setRenderDebugBounds(boolean renderDebugBounds)
renderDebugBounds
- Whether to enable bounds drawing.public boolean isRebuildNeeded()
false
otherwise.public void triggerRebuildIfNeeded()
getWidth()
or getHeight()
between GL11.glBegin(int)
and GL11.glEnd()
on a
LazyFont.DrawableString
that needs to be rebuilt, as those methods trigger a rebuild which will fail if called
inside those two methods. Calling triggerRebuildIfNeeded()
before GL11.glBegin(int)
will
solve this problem.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 LazyFont.DrawableString append(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
.LazyFont.DrawableString
, for easier chaining of append calls.public LazyFont.DrawableString append(String text, Color color)
getBaseColor()
.
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 substring of text should appear as. Existing text, as well as following append
calls, will use their own color.LazyFont.DrawableString
, for easier chaining of append calls.public LazyFont.DrawableString appendIndented(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.LazyFont.DrawableString
, for easier chaining of append calls.public LazyFont.DrawableString appendIndented(String text, Color color, int indent)
getBaseColor()
.
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 substring of text should appear as. Existing text, as well as following append
calls, will use their own color.LazyFont.DrawableString
, for easier chaining of append calls.public void draw(float x, float y)
You can render the same block of text in multiple places. The OpenGL data is stored in a buffer on your GPU, so performance should not be an issue (provided the underlying data hasn'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 data is stored in a buffer on your GPU, so performance should not be an issue (provided the underlying data hasn'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 data is stored in a buffer on your GPU, so performance should not be an issue (provided the underlying data hasn'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, in degrees.public void drawAtAngle(Vector2f location, float angle)
You can render the same block of text in multiple places. The OpenGL data is stored in a buffer on your GPU, so performance should not be an issue (provided the underlying data hasn't changed, necessitating a rebuild).
location
- The coordinates to draw at.angle
- The angle to draw at, in degrees.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. However, there are a limited number of buffers 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.