Class TextNode

java.lang.Object
com.codename1.art.ArtNode
com.codename1.art.TextNode

public class TextNode extends ArtNode
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.
  • Field Details

    • ALIGN_LEFT

      public static final int ALIGN_LEFT
      Lines start at x.
      See Also:
    • ALIGN_CENTER

      public static final int ALIGN_CENTER
      Lines are centered on the box (or on x with no box).
      See Also:
    • ALIGN_RIGHT

      public static final int ALIGN_RIGHT
      Lines end at the box's right edge (or at x with no box).
      See Also:
  • 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: the characters
      • size: the font size
      • color: 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: x
      • y: 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: 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: 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: a multiple of the font size
    • getLocalBounds

      public double[] getLocalBounds()
      Description copied from class: ArtNode
      The bounds of this node's own content in its own space as x, y, w, h, without effects; null when it has none.
      Specified by:
      getLocalBounds in class ArtNode
    • copy

      public ArtNode copy()
      Description copied from class: ArtNode
      A deep copy.
      Specified by:
      copy in class ArtNode