Class TextAligning

java.lang.Object
org.luwrain.util.TextAligning

public class TextAligning extends Object
Splits a text preserving lenth of lines not exceeding some given number. This class takes a set of lines and makes new dividing trying to make the length of each line close to some value as much as it is possible. The dividing is performed only on space characters ( Character.isSpaceChar()), so in common sense there is no guarantee that all lines will have the length not greater of the given value, because very long words go without splitting. If the position of the hot point is provided, it is moved to the corresponding place in the new lines.
  • Field Details

    • origHotPointX

      public int origHotPointX
      The original X position of the hot point; must be -1, if there is no hot point
    • origHotPointY

      public int origHotPointY
      The original Y position of the hot point; must be -1, if there is no hot point
    • origLines

      public String[] origLines
      The text to split
    • hotPointX

      public int hotPointX
      New X position of the hot point
    • hotPointY

      public int hotPointY
      New Y position of the hot point
    • res

      public final LinkedList<String> res
      The result with new text dividing
  • Constructor Details

    • TextAligning

      public TextAligning(int maxLineLen)
  • Method Details

    • align

      public void align()
    • onWord

      protected void onWord(String word, int hotPointPos, boolean wereSpaces, boolean wereSpacesWithHotPoint)
    • getLastLineLen

      protected int getLastLineLen()
    • getLastLineSpaceLeft

      protected int getLastLineSpaceLeft()
    • addLastLine

      protected void addLastLine(String text)