Class StyledText

java.lang.Object
tripleplay.util.StyledText
Direct Known Subclasses:
StyledText.Plain

public abstract class StyledText extends Object
Manages styled text. This comes in many flavors: a single line of plain (uniformly styled) text, multiple lines of plain text, and (coming soon) multiple lines of rich (non-uniformly styled) text.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Multiple lines of plain (uniformly styled) text.
    static class 
    A shared base class for single- and multi-line plain text.
    static class 
    A single line of plain (uniformly styled) text.
  • Method Summary

    Modifier and Type
    Method
    Description
    block(Graphics gfx, String text, TextStyle style, float wrapWidth)
    Creates a uniformly formatted multiple-lines of text wrapped at wrapWidth and left-aligned.
    abstract float
    The height of this styled text when rendered.
    abstract void
    render(Canvas canvas, float x, float y)
    Renders this styled text into the supplied canvas at the specified offset.
    span(Graphics gfx, String text, TextStyle style)
    Creates a uniformly formatted single-line of text.
    Creates a canvas large enough to accommodate this styled text, and renders it therein.
    Creates an image large enough to accommodate this styled text, renders it therein and returns an image layer with its translation adjusted per the effect renderer.
    abstract ImageLayer
    Creates an image large enough to accommodate this styled text, renders it therein and applies it to layer, adjusting its translation per the effect renderer.
    abstract float
    The width of this styled text when rendered.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • span

      public static StyledText.Span span(Graphics gfx, String text, TextStyle style)
      Creates a uniformly formatted single-line of text.
    • block

      public static StyledText.Block block(Graphics gfx, String text, TextStyle style, float wrapWidth)
      Creates a uniformly formatted multiple-lines of text wrapped at wrapWidth and left-aligned.
    • width

      public abstract float width()
      The width of this styled text when rendered.
    • height

      public abstract float height()
      The height of this styled text when rendered.
    • render

      public abstract void render(Canvas canvas, float x, float y)
      Renders this styled text into the supplied canvas at the specified offset.
    • toCanvas

      public Canvas toCanvas()
      Creates a canvas large enough to accommodate this styled text, and renders it therein. The canvas will include a one pixel border beyond the size of the styled text which is needed to accommodate antialiasing.
    • toLayer

      public ImageLayer toLayer()
      Creates an image large enough to accommodate this styled text, renders it therein and returns an image layer with its translation adjusted per the effect renderer.
    • toLayer

      public abstract ImageLayer toLayer(ImageLayer target)
      Creates an image large enough to accommodate this styled text, renders it therein and applies it to layer, adjusting its translation per the effect renderer.