Package org.xjge.core

Class Text

java.lang.Object
org.xjge.core.Text

public final class Text
extends java.lang.Object
Provides utilities for rendering text to the screen.

NOTE: The primary method used by this class to draw strings of text is exposed exclusively to subclasses of Widget. All other additional methods can be accessed statically.

Since:
2.0.0
  • Method Summary

    Modifier and Type Method Description
    static int lengthInPixels​(java.lang.String text, Font font)
    Finds the length of a string in pixels.
    static int numCharOccurences​(java.lang.String text, char c, int index)
    Finds the amount of times a character appears in a string from some point.
    static java.lang.String wrap​(java.lang.String text, int advanceLimit, Font font)
    Attempts to wrap a string inside of the width specified.

    Methods inherited from class java.lang.Object

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

    • wrap

      public static java.lang.String wrap​(java.lang.String text, int advanceLimit, Font font)
      Attempts to wrap a string inside of the width specified. Will not break words.
      Parameters:
      text - the string of text to wrap
      advanceLimit - the width that the string may not exceed
      font - the current font of the string being wrapped
      Returns:
      a string formatted to fit inside the width specified
    • lengthInPixels

      public static int lengthInPixels​(java.lang.String text, Font font)
      Finds the length of a string in pixels.
      Parameters:
      text - the string of text to measure
      font - the current font of the string being measured
      Returns:
      the length of the string in pixels
    • numCharOccurences

      public static int numCharOccurences​(java.lang.String text, char c, int index)
      Finds the amount of times a character appears in a string from some point.
      Parameters:
      text - the string of text to examine
      c - the character to search for
      index - the index to offset the search by. Any index preceding the one specified will be omitted from the search.
      Returns:
      the number of times the character was found in the string provided