Package org.luwrain.util
Class TextAligning
java.lang.Object
org.luwrain.util.TextAligning
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 Summary
FieldsModifier and TypeFieldDescriptionintNew X position of the hot pointintNew Y position of the hot pointintThe original X position of the hot point; must be -1, if there is no hot pointintThe original Y position of the hot point; must be -1, if there is no hot pointString[]The text to splitfinal LinkedList<String>The result with new text dividing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddLastLine(String text) voidalign()protected intprotected intprotected void
-
Field Details
-
origHotPointX
public int origHotPointXThe original X position of the hot point; must be -1, if there is no hot point -
origHotPointY
public int origHotPointYThe original Y position of the hot point; must be -1, if there is no hot point -
origLines
The text to split -
hotPointX
public int hotPointXNew X position of the hot point -
hotPointY
public int hotPointYNew Y position of the hot point -
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
-