Class TextHelper


  • public class TextHelper
    extends Object
    Provides some text facilities.
    • Method Detail

      • wrap

        public static String[] wrap​(String string,
                                    Font font,
                                    int width)
        Wraps a text in lines.

        A new line is started:

        • after a '\n',
        • when there is no more space on the current line.
        Parameters:
        string - the text.
        font - the font used to render the text.
        width - the size of a line.
        Returns:
        the array of lines.
      • getLines

        public static String[] getLines​(String string)
        Gets the lines in a text.

        A new line is started after a '\n'.

        Parameters:
        string - the text to split.
        Returns:
        the array of lines.
      • getWords

        public static String[] getWords​(String string)
        Gets the words in a text.

        A new word is started after a space ' '.

        Parameters:
        string - the text.
        Returns:
        the array of words.