Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class TextNode

  1. Object
  2. ArtNode
  3. TextNode
Styled text. The first line’s baseline starts at x, y; with a box width set, lines wrap at that width and align within it.

Fields

public static final int ALIGN_LEFT = 0Lines start at x.
public static final int ALIGN_CENTER = 1Lines are centered on the box (or on x with no box).
public static final int ALIGN_RIGHT = 2Lines end at the box’s right edge (or at x with no box).

Constructors

public TextNode()Creates an empty text node at the origin.
public TextNode(String text, float size, int color)Creates a text node with one run.

Methods

public List<TextRun> getRuns()The runs.
public String getText()All the characters of every run.
public double getX()Baseline origin x.
public double getY()Baseline origin y.
public void setPosition(double x, double y)Sets the baseline origin.
public double getBoxWidth()The wrapping width, or 0 for none.
public void setBoxWidth(double boxWidth)Sets the wrapping width.
public int getAlign()One of the ALIGN_ constants.
public void setAlign(int align)Sets the alignment.
public float getLineHeight()Line height as a multiple of the font size.
public void setLineHeight(float lineHeight)Sets the line height.
public double[] getLocalBounds()The bounds of this node’s own content in its own space as x, y, w, h, without effects; null when it has none.
public ArtNode copy()A deep copy.

Inherited methods

Field details

ALIGN_LEFT

public static final int ALIGN_LEFT = 0
Lines start at x.

ALIGN_CENTER

public static final int ALIGN_CENTER = 1
Lines are centered on the box (or on x with no box).

ALIGN_RIGHT

public static final int ALIGN_RIGHT = 2
Lines end at the box’s right edge (or at x with no box).

Constructor details

TextNode

public TextNode()
Creates an empty text node at the origin.

TextNode

public TextNode(String text, float size, int color)
Creates a text node with one run.

Parameters

text String
the characters
size float
the font size
color int
the color as 0xAARRGGBB

Method details

getRuns

public List<TextRun> getRuns()
The runs. The list is live.

getText

public String getText()
All the characters of every run.

getX

public double getX()
Baseline origin x.

getY

public double getY()
Baseline origin y.

setPosition

public void setPosition(double x, double y)
Sets the baseline origin.

Parameters

x double
x
y double
y of the first baseline

getBoxWidth

public double getBoxWidth()
The wrapping width, or 0 for none.

setBoxWidth

public void setBoxWidth(double boxWidth)
Sets the wrapping width.

Parameters

boxWidth double
the width; 0 for no wrapping

getAlign

public int getAlign()
One of the ALIGN_ constants.

setAlign

public void setAlign(int align)
Sets the alignment.

Parameters

align int
one of the ALIGN_ constants

getLineHeight

public float getLineHeight()
Line height as a multiple of the font size.

setLineHeight

public void setLineHeight(float lineHeight)
Sets the line height.

Parameters

lineHeight float
a multiple of the font size

getLocalBounds

public double[] getLocalBounds()
The bounds of this node’s own content in its own space as x, y, w, h, without effects; null when it has none.

copy

public ArtNode copy()
A deep copy.