com.annahid.libs.artenus.graphics.sprites
TextSprite
Represents a text block. A text is a series of characters displayed on the screen using a
Font
. This class provides all controls relating to size, color and text manipulation to
manage the piece of text that is added to the scene.See Also:
public final class TextSprite extends SpriteEntity
Field Summary
Fields inherited from com.annahid.libs.artenus.graphics.sprites.SpriteEntity
Constructor Summary
Modifier and Type | Constructor and Description |
---|---|
public | TextSprite(Font font, int fontSize) Creates a TextSprite using the given font and font size. |
public | TextSprite(Font font, int fontSize, String initialText) Creates a TextSprite using the given font and font size. |
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | centerAt(Point2D p) Sets the position of the text sprite so that it is centered at the given point. |
public void | centerAt(float x, float y) Sets the position of the text sprite so that it is centered at the given point. |
public final Font | getFont() Gets the current font assigned to this TextSprite. |
public final String | getText() Gets the string representation of the text currently displayed for this TextSprite. |
public final boolean | isTextEmpty() Determines whether this TextSprite represents an empty text. |
public final void | render(RenderingContext ctx, int flags) Renders the visual content. |
public final void | setFont(Font font) Assigns a new font to this TextSprite. |
public void | setRTL(boolean isRtl) Sets the right-to-left state of this TextSprite. |
public final void | setText(String value) Sets the text on this TextSprite. |
Methods inherited from com.annahid.libs.artenus.graphics.sprites.SpriteEntity
advance
, getAlpha
, getAnimation
, getColorFilter
, getPosition
, getRotation
, getScale
, hasBehavior
, move
, onAttach
, onDetach
, rotate
, setAlpha
, setAnimation
, setColorFilter
, setColorFilter
, setPosition
, setPosition
, setRotation
, setScale
, setScale
Methods inherited from java.lang.Object
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Constructor Detail
TextSprite | ||||
---|---|---|---|---|
public TextSprite( Font font, int fontSize )Creates a TextSprite using the given font and font size. Parameters:
|
TextSprite | ||||||
---|---|---|---|---|---|---|
public TextSprite( Font font, int fontSize, String initialText )Creates a TextSprite using the given font and font size. The text initially displayed for the sprite is also specified. Parameters:
|
Method Detail
centerAt | ||
---|---|---|
public void centerAt( Point2D p ) Sets the position of the text sprite so that it is centered at the given point. Parameters:
|
centerAt | ||||
---|---|---|---|---|
public void centerAt( float x, float y ) Sets the position of the text sprite so that it is centered at the given point. Parameters:
|
getFont |
---|
public final Font getFont() Gets the current font assigned to this TextSprite. Returns:
The assigned font |
getText |
---|
public final String getText() Gets the string representation of the text currently displayed for this TextSprite.
Keep in mind that this method returns a newly created String and can have memory overhead. Returns:
The string representation of the current text |
isTextEmpty |
---|
public final boolean isTextEmpty() Determines whether this TextSprite represents an empty text. This is a faster
method than to retrieve the text and examine it manually. Returns:
true if the text is an empty string, and false otherwise |
render |
---|
public final void render( RenderingContext ctx, int flags ) Renders the visual content. |
setFont | ||
---|---|---|
public final void setFont( Font font ) Assigns a new font to this TextSprite. Parameters:
|
setRTL | ||
---|---|---|
public void setRTL( boolean isRtl ) Sets the right-to-left state of this TextSprite. If a text sprite is right-to-left,
its characters will flow from right to left. Parameters:
|
setText | ||
---|---|---|
public final void setText( String value ) Sets the text on this TextSprite. Changes will take effect immediately. Parameters:
|