public class TextBlock
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TextBlock.Align
Used to align a block of text.
|
| Modifier and Type | Field and Description |
|---|---|
IRectangle |
bounds
The bounds of this block of text.
|
TextLayout[] |
lines
The individual lines of text in this block.
|
| Constructor and Description |
|---|
TextBlock(TextLayout[] lines)
Creates a text block with the supplied
lines. |
| Modifier and Type | Method and Description |
|---|---|
void |
fill(Canvas canvas,
TextBlock.Align align,
float x,
float y)
Fills
lines into canvas at the specified coordinates, using the specified
alignment. |
static Rectangle |
getBounds(TextLayout[] lines,
Rectangle into)
Computes the bounds of a block of text.
|
void |
stroke(Canvas canvas,
TextBlock.Align align,
float x,
float y)
Strokes
lines into canvas at the specified coordinates, using the specified
alignment. |
float |
textWidth()
Returns the width of the rendered text.
|
Canvas |
toCanvas(Graphics gfx,
TextBlock.Align align,
int fillColor)
Creates a canvas image large enough to accommodate this text block and renders the lines into
it.
|
public final TextLayout[] lines
Graphics.layoutText(String,TextFormat,TextWrap).public final IRectangle bounds
x component of the bounds may be positive,
indicating that the text should be rendered at that offset. This is to account for the fact
that some text renders to the left of its reported origin due to font extravagance. The stroke(playn.core.Canvas, playn.core.TextBlock.Align, float, float) and fill(playn.core.Canvas, playn.core.TextBlock.Align, float, float) methods automatically take into account this x coordinate, the
caller need only account for it if they choose to render lines manually.public TextBlock(TextLayout[] lines)
lines.public static Rectangle getBounds(TextLayout[] lines, Rectangle into)
x component of the bounds may be
positive, indicating that the text should be rendered at that offset. This is to account for
the fact that some text renders to the left of its reported origin due to font
extravagance.public float textWidth()
public void fill(Canvas canvas, TextBlock.Align align, float x, float y)
lines into canvas at the specified coordinates, using the specified
alignment.public void stroke(Canvas canvas, TextBlock.Align align, float x, float y)
lines into canvas at the specified coordinates, using the specified
alignment.public Canvas toCanvas(Graphics gfx, TextBlock.Align align, int fillColor)
Copyright © 2018. All Rights Reserved.