public class RenderableString
extends java.lang.Object
| Constructor and Description |
|---|
RenderableString(java.lang.String string,
Font font)
Creates a renderable string for given string and font.
|
| Modifier and Type | Method and Description |
|---|---|
void |
draw(GraphicsContext gc,
int x,
int y,
int anchor)
Draws the string using the font and given graphics context color.
|
Font |
getFont()
Gets the font used to draw the string.
|
int |
getHeight()
Gets the height of a line of text with this font and its y ratio.
|
java.lang.String |
getString()
Gets the string to draw.
|
int |
getWidth()
Gets the width of the string with the font.
|
public RenderableString(java.lang.String string,
Font font)
string - the string to renderfont - the font used to render the stringjava.lang.NullPointerException - when font or string is nulljava.lang.IllegalArgumentException - when string is emptypublic java.lang.String getString()
public Font getFont()
public int getWidth()
Font.stringWidth(String).Font.stringWidth(String)public int getHeight()
Font.getHeight().public void draw(GraphicsContext gc, int x, int y, int anchor)
GraphicsContext.drawString(String, int, int, int)gc - the graphics context where draw the stringx - the x coordinate of the anchor point.y - the y coordinate of the anchor point.anchor - position of the string around the anchor point.GraphicsContext.drawString(String, int, int, int)