Class Text

java.lang.Object
nl.colorize.multimedialib.stage.Text
All Implemented Interfaces:
StageNode2D

public class Text extends Object implements StageNode2D
Draws text to the screen using the specified TrueType font. Multiline text is supported, and any newline characters in the text will be preserved when the text is rendered. By default, the text will occupy whatever horizontal space it needs, but word-wrapping can optionally be enabled by specifying an explicit line width.
  • Constructor Details

  • Method Details

    • setText

      public void setText(String text)
    • setText

      public void setText(List<String> text)
    • forLines

      public void forLines(BiConsumer<Integer,String> callback)
    • getStageBounds

      public Rect getStageBounds()
      Description copied from interface: StageNode2D
      Returns the bounding box currently occopied by this node, relative to the stage. This method uses StageNode2D.getGlobalTransform().
      Specified by:
      getStageBounds in interface StageNode2D
    • animate

      public void animate(Timer sceneTime)
      Description copied from interface: StageNode2D
      Called by the renderer at the end of frame updates, while rendering the stage. animationTimer contains the elapsed time since the currently active scene was started. This allows animations to display correctly, without the need to update every single node during each frame update.
      Specified by:
      animate in interface StageNode2D
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTransform

      public Transform getTransform()
      Description copied from interface: StageNode2D
      Returns this node's local transform, which is interpreted relative to its parent node. The local transform can be modified by application code to modify how and where the node is displayed.
      Specified by:
      getTransform in interface StageNode2D
    • getGlobalTransform

      public Transform getGlobalTransform()
      Description copied from interface: StageNode2D
      Returns this node's global transform, which is interpreted relative to the stage. The global transform is updated by the renderer when drawing the stage at the end of frame updates. Recalculating the global transform is relatively expensive, and is therefore only done once per frame. This means that any changes made to a node's local transform since the last frame update may not yet been reflected in the current state of its global transform.
      Specified by:
      getGlobalTransform in interface StageNode2D
    • getLines

      public List<String> getLines()
    • getFont

      public FontFace getFont()
    • getAlign

      public Align getAlign()
    • getLineWidth

      public int getLineWidth()
    • getLineHeight

      public float getLineHeight()
    • setTransform

      public void setTransform(Transform transform)
    • setGlobalTransform

      public void setGlobalTransform(Transform globalTransform)
    • setLines

      public void setLines(List<String> lines)
    • setFont

      public void setFont(FontFace font)
    • setAlign

      public void setAlign(Align align)
    • setLineWidth

      public void setLineWidth(int lineWidth)
    • setLineHeight

      public void setLineHeight(float lineHeight)