public interface Text extends Renderable
String
on screen, at a specified location, using a specified font.
A font is described by a:
String
int
, in pixelint
(TextStyle.NORMAL
,
TextStyle.ITALIC
, TextStyle.BOLD
)Example:
// Create the text final Text text = Graphics.createText(Text.SANS_SERIF, 12, TextStyle.NORMAL); // Rendering type 1 text.setText("Hello"); text.setLocation(0, 0); text.setAlign(Align.CENTER); text.render(g); // Rendering type 2 text.draw(g, 0, 0, "World");
Modifier and Type | Field and Description |
---|---|
static String |
DIALOG
Standard text dialog.
|
static String |
SANS_SERIF
Standard text font sans serif.
|
static String |
SERIF
Standard text font serif.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Graphic g,
int x,
int y,
Align alignment,
String text)
Renders text on graphic output, to the specified location and alignment.
|
void |
draw(Graphic g,
int x,
int y,
String text)
Renders text on graphic output, to the specified location.
|
int |
getHeight()
Get the text height.
|
int |
getLocationX()
Get the horizontal location.
|
int |
getLocationY()
Get the vertical location.
|
int |
getSize()
Get the text size in pixel (8px, 12px...).
|
int |
getStringHeight(Graphic g,
String str)
Get string height size.
|
int |
getStringWidth(Graphic g,
String str)
Get string width size.
|
int |
getWidth()
Get the text width.
|
void |
setAlign(Align align)
Set text alignment.
|
void |
setColor(ColorRgba color)
Set the new text color value.
|
void |
setLocation(int x,
int y)
Set text location.
|
void |
setText(String text)
Set text to render.
|
render
static final String SANS_SERIF
static final String SERIF
static final String DIALOG
void draw(Graphic g, int x, int y, String text)
g
- The graphic output.x
- The horizontal location.y
- The vertical location.text
- The text string.void draw(Graphic g, int x, int y, Align alignment, String text)
g
- The graphic output.x
- The horizontal location.y
- The vertical location.alignment
- The alignment value.text
- The text string.void setLocation(int x, int y)
x
- The text x.y
- The text y.void setText(String text)
text
- The text to render.void setAlign(Align align)
align
- The text alignment.void setColor(ColorRgba color)
color
- The color value.int getSize()
int getLocationX()
int getLocationY()
int getWidth()
int getHeight()
int getStringWidth(Graphic g, String str)
g
- The graphic context.str
- The input string.Copyright © 2017 Byron 3D Games Studio. All rights reserved.