public final class JPJustifierBasic extends Object implements JPAlignerType
O(n²) performance of a full dynamic
programming approach.| Modifier and Type | Class and Description |
|---|---|
static interface |
JPJustifierBasic.SpaceTextDecisionType
A function that, when evaluated, yields
true iff a line with the
given number of space and text characters should be justified. |
| Modifier and Type | Field and Description |
|---|---|
static JPJustifierBasic.SpaceTextDecisionType |
JUSTIFY_ALWAYS
An instance of the
JPJustifierBasic.SpaceTextDecisionType that always justifies
lines. |
static JPJustifierBasic.SpaceTextDecisionType |
JUSTIFY_UNDER_HALF
An instance of the
JPJustifierBasic.SpaceTextDecisionType that avoids justifying
lines if more than half of the line would be space. |
| Modifier and Type | Method and Description |
|---|---|
void |
addWord(String w)
Add a word to the current layout.
|
void |
breakLine()
Insert a hard line break.
|
static JPAlignerType |
create(JPOverflowBehaviour in_overflow,
JPJustifierBasic.SpaceTextDecisionType in_decider,
int in_width)
Construct a new justifier.
|
List<String> |
finish()
Finish the current layout, effectively resetting it to a blank canvas.
|
public static final JPJustifierBasic.SpaceTextDecisionType JUSTIFY_UNDER_HALF
JPJustifierBasic.SpaceTextDecisionType that avoids justifying
lines if more than half of the line would be space.public static final JPJustifierBasic.SpaceTextDecisionType JUSTIFY_ALWAYS
JPJustifierBasic.SpaceTextDecisionType that always justifies
lines.public static JPAlignerType create(JPOverflowBehaviour in_overflow, JPJustifierBasic.SpaceTextDecisionType in_decider, int in_width)
in_overflow - The behaviour for words that are of a greater length
than the maximum width and therefore cannot fit even
when placed on an otherwise blank linein_decider - A function that decides whether or not lines should be
justifiedin_width - The maximum width in characterspublic void addWord(String w)
JPAlignerTypeaddWord in interface JPAlignerTypew - A wordpublic void breakLine()
JPAlignerTypebreakLine in interface JPAlignerTypepublic List<String> finish()
JPAlignerTypefinish in interface JPAlignerTypeCopyright © 2017 <code@io7m.com> http://io7m.com