public class Text extends SFMLNativeObject implements Drawable, TextStyle
TextStyle interface for quick access to the constants
provided by it.BOLD, ITALIC, REGULAR, UNDERLINED| Constructor and Description |
|---|
Text()
Creates a new empty text.
|
Text(String string,
ConstFont font)
Creates a new text.
|
Text(String string,
ConstFont font,
int characterSize)
Creates a new text.
|
| Modifier and Type | Method and Description |
|---|---|
void |
draw(RenderTarget target,
RenderStates states)
Draws the object to a render target.
|
Vector2f |
findCharacterPos(int i)
Returns the position of a character inside the string.
|
int |
getCharacterSize()
Gets the text's current font size.
|
Color |
getColor()
Gets the text's current font color.
|
ConstFont |
getFont()
Gets the text's current font.
|
FloatRect |
getGlobalBounds()
Gets the text's global bounding rectangle in the scene,
taking the text's transformation into account.
|
Transform |
getInverseTransform()
Gets the inverse of the current transformation matrix.
|
FloatRect |
getLocalBounds()
Gets the text's local bounding rectangle,
not taking the text's transformation into account.
|
Vector2f |
getOrigin()
Gets the origin of this object.
|
Vector2f |
getPosition()
Gets the position of this object.
|
float |
getRotation()
Gets the rotation angle of this object.
|
Vector2f |
getScale()
Gets the scaling of this object.
|
String |
getString()
Gets the text's string.
|
int |
getStyle()
Gets the text's current font style.
|
Transform |
getTransform()
Gets the current transformation matrix.
|
void |
move(float x,
float y)
Moves this object.
|
void |
move(Vector2f v)
Moves the object.
|
protected long |
nativeCreate()
Deprecated.
|
protected void |
nativeDelete()
Deprecated.
|
protected void |
nativeSetExPtr()
Deprecated.
|
void |
rotate(float angle)
Rotates this object around its origin.
|
void |
scale(float x,
float y)
Scales the object, using its origin as the scaling center.
|
void |
scale(Vector2f factors)
Scales the object, using its origin as the scaling center.
|
void |
setCharacterSize(int characterSize)
Sets the font size for this text.
|
void |
setColor(Color color)
Sets the font color for this text.
|
void |
setFont(ConstFont font)
Sets the text's font.
|
void |
setOrigin(float x,
float y)
Sets the rotation, scaling and drawing origin of this object.
|
void |
setOrigin(Vector2f v)
Sets the rotation, scaling and drawing origin of this object.
|
void |
setPosition(float x,
float y)
Sets the position of this object in the scene so that its origin will be exactly on it.
|
void |
setPosition(Vector2f v)
Sets the position of this object in the scene so that its origin will be exactly on it.
|
void |
setRotation(float angle)
Sets the rotation of this object around its origin.
|
void |
setScale(float x,
float y)
Sets the scaling of this object, using its origin as the scaling center.
|
void |
setScale(Vector2f v)
Sets the scaling of this object, using its origin as the scaling center.
|
void |
setString(String string)
Sets the string to display.
|
void |
setStyle(int style)
Sets the font drawing style.
|
finalizepublic Text()
public Text(String string, ConstFont font)
string - The text string.font - The font to use.@Deprecated protected long nativeCreate()
SFMLNativeObjectnativeCreate in class SFMLNativeObject@Deprecated protected void nativeSetExPtr()
SFMLNativeObjectnativeSetExPtr in class SFMLNativeObject@Deprecated protected void nativeDelete()
SFMLNativeObjectnativeDelete in class SFMLNativeObjectpublic void setString(String string)
string - The string to display.public void setFont(ConstFont font)
font - The text's font.public void setCharacterSize(int characterSize)
characterSize - The font size for this text.public void setStyle(int style)
style - The font drawing style. This should be an combination (OR)
of the style flags TextStyle.BOLD, TextStyle.ITALIC and
TextStyle.UNDERLINED, or TextStyle.REGULAR for the
regular style.public void setColor(Color color)
color - The font color for this text.public String getString()
public ConstFont getFont()
null if no font has been set yet.public int getCharacterSize()
public int getStyle()
setStyle(int)public Color getColor()
public Vector2f findCharacterPos(int i)
i - The index of the character to return the position for.public FloatRect getLocalBounds()
Sprite.getGlobalBounds()public FloatRect getGlobalBounds()
getLocalBounds()public void setPosition(Vector2f v)
TransformablesetPosition in interface Transformablev - the new position.public void setRotation(float angle)
TransformablesetRotation in interface Transformableangle - the new rotation angle in degrees.public void setScale(Vector2f v)
TransformablesetScale in interface Transformablev - the new scaling factors.public void setOrigin(Vector2f v)
TransformablesetOrigin in interface Transformablev - the new origin.public void draw(RenderTarget target, RenderStates states)
Drawablepublic final void setPosition(float x,
float y)
TransformablesetPosition in interface Transformablex - the new X coordinate.y - the new Y coordinate.public final void setScale(float x,
float y)
TransformablesetScale in interface Transformablex - the new X scaling factor.y - the new Y scaling factor.public final void setOrigin(float x,
float y)
TransformablesetOrigin in interface Transformablex - the new X coordinate of the origin.y - the new Y coordinate of the origin.public Vector2f getPosition()
TransformablegetPosition in interface Transformablepublic float getRotation()
TransformablegetRotation in interface Transformablepublic Vector2f getScale()
TransformablegetScale in interface Transformablepublic Vector2f getOrigin()
TransformablegetOrigin in interface Transformablepublic final void move(float x,
float y)
Transformablemove in interface Transformablex - the X offset added to the current position.y - the Y offset added to the current position.public final void move(Vector2f v)
Transformablemove in interface Transformablev - the offset vector added to the current position.public final void rotate(float angle)
Transformablerotate in interface Transformableangle - the rotation angle in degrees.public final void scale(float x,
float y)
Transformablescale in interface Transformablex - the X scaling factor.y - the Y scaling factor.public final void scale(Vector2f factors)
Transformablescale in interface Transformablefactors - the scaling factors.public Transform getTransform()
TransformablegetTransform in interface Transformablepublic Transform getInverseTransform()
TransformablegetInverseTransform in interface Transformable