Top Description Inners Fields Constructors Methods
com.openhtmltopdf.layout

public Class Breaker

extends Object
Class Inheritance
Imports
java.util.function.ToIntFunction, com.openhtmltopdf.css.constants.CSSName, .IdentValue, com.openhtmltopdf.css.style.CalculatedStyle, .CssContext, com.openhtmltopdf.extend.FSTextBreaker, com.openhtmltopdf.layout.LineBreakContext.LineBreakResult, com.openhtmltopdf.render.FSFont

A utility class that scans the text of a single inline box, looking for the next break point.
Author
Torbjoern Gannholm

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
private static class
private static class
public static interface

Field Summary

Modifier and TypeField and Description
public static final char
public static final Breaker.TextBreakerSupplier
public static final Breaker.TextBreakerSupplier

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static Breaker.BreakTextResult
breakText(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style, boolean tryToBreakAnywhere, int lineWidth, boolean forceOutput)

pack-priv static LineBreakContext.LineBreakResult
doBreakCharacters(String currentString, FSTextBreaker lineIterator, FSTextBreaker charIterator, LineBreakContext context, int avail, float letterSpacing, ToIntFunction<String> measurer)

Breaks at most one word (until the next word break) going character by character to see what will fit in.

private static LineBreakContext.LineBreakResult
doBreakText(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style, boolean tryToBreakAnywhere)

public static LineBreakContext.LineBreakResult
pack-priv static LineBreakContext.LineBreakResult
doBreakTextWords(String currentString, LineBreakContext context, int avail, FSTextBreaker iterator, float letterSpacing, ToIntFunction<String> measurer)

public static FSTextBreaker
getCharacterBreakStream(String currentString, SharedContext sharedContext)

private static int
getFirstLetterEnd(String text, int start)

public static FSTextBreaker
public static int
getTextWidthWithLetterSpacing(CssContext c, FSFont font, String text, float letterSpacing)

Gets the width of a string with letter spacing factored in. Favor this method over using the text renderer directly.

private static Breaker.BreakTextResult
toBreakTextResult(LineBreakContext.LineBreakResult res)

Converts a LineBreakResult returned from doBreakText in word-wrapping mode to a BreakTextResult.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SOFT_HYPHENback to summary
public static final char SOFT_HYPHEN
STANDARD_CHARACTER_BREAKERback to summary
public static final Breaker.TextBreakerSupplier STANDARD_CHARACTER_BREAKER
STANDARD_LINE_BREAKERback to summary
public static final Breaker.TextBreakerSupplier STANDARD_LINE_BREAKER

Constructor Detail

Breakerback to summary
public Breaker()

Method Detail

breakFirstLetterback to summary
public static void breakFirstLetter(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style)
breakTextback to summary
public static Breaker.BreakTextResult breakText(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style, boolean tryToBreakAnywhere, int lineWidth, boolean forceOutput)
doBreakCharactersback to summary
pack-priv static LineBreakContext.LineBreakResult doBreakCharacters(String currentString, FSTextBreaker lineIterator, FSTextBreaker charIterator, LineBreakContext context, int avail, float letterSpacing, ToIntFunction<String> measurer)

Breaks at most one word (until the next word break) going character by character to see what will fit in.

doBreakTextback to summary
private static LineBreakContext.LineBreakResult doBreakText(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style, boolean tryToBreakAnywhere)
doBreakTextback to summary
public static LineBreakContext.LineBreakResult doBreakText(LayoutContext c, LineBreakContext context, int avail, CalculatedStyle style, Breaker.TextBreakerSupplier lineBreaker)
doBreakTextWordsback to summary
pack-priv static LineBreakContext.LineBreakResult doBreakTextWords(String currentString, LineBreakContext context, int avail, FSTextBreaker iterator, float letterSpacing, ToIntFunction<String> measurer)
getCharacterBreakStreamback to summary
public static FSTextBreaker getCharacterBreakStream(String currentString, SharedContext sharedContext)
getFirstLetterEndback to summary
private static int getFirstLetterEnd(String text, int start)
getLineBreakStreamback to summary
public static FSTextBreaker getLineBreakStream(String s, SharedContext shared)
getTextWidthWithLetterSpacingback to summary
public static int getTextWidthWithLetterSpacing(CssContext c, FSFont font, String text, float letterSpacing)

Gets the width of a string with letter spacing factored in. Favor this method over using the text renderer directly.

toBreakTextResultback to summary
private static Breaker.BreakTextResult toBreakTextResult(LineBreakContext.LineBreakResult res)

Converts a LineBreakResult returned from doBreakText in word-wrapping mode to a BreakTextResult. Throws a runtime exception if unexpected result found.

com.openhtmltopdf.layout back to summary

private Class Breaker.AppBreakOpportunity

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv boolean
pack-priv int
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

graphicsLengthback to summary
pack-priv int graphicsLength
isSoftHyphenBreakback to summary
pack-priv boolean isSoftHyphenBreak
leftback to summary
pack-priv int left
rightback to summary
pack-priv int right
withHyphenGraphicsLengthback to summary
pack-priv int withHyphenGraphicsLength

Constructor Detail

AppBreakOpportunityback to summary
private AppBreakOpportunity()

Method Detail

copyToback to summary
pack-priv void copyTo(Breaker.AppBreakOpportunity other)
com.openhtmltopdf.layout back to summary

public final Enum Breaker.BreakTextResult

extends Enum<Breaker.BreakTextResult>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Breaker.BreakTextResult
CHAR_UNBREAKABLE_BUT_CONSUMED

Not a single char fitted, but we consumed one character anyway.

public static final Breaker.BreakTextResult
CONTINUE_CHAR_BREAKING_ON_NL

In char breaking mode, need a newline before continuing.

public static final Breaker.BreakTextResult
CONTINUE_WORD_BREAKING_ON_NL

In word breaking mode, need a newline before continuing.

public static final Breaker.BreakTextResult
DANGER_RECONSUME_CHAR_ON_NL

DANGER: Last char did not fit and we are directing the parent method to reconsume char on a newline.

public static final Breaker.BreakTextResult
DANGER_RECONSUME_WORD_ON_NL

DANGER: Last word did not fit and we are directing the parent method to reconsume word on a newline.

public static final Breaker.BreakTextResult
FINISHED

Has completely consumed the string.

public static final Breaker.BreakTextResult
WORD_UNBREAKABLE_BUT_CONSUMED

Not a single word fitted, but we consumed a word anyway.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Breaker.BreakTextResult
public static Breaker.BreakTextResult[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CHAR_UNBREAKABLE_BUT_CONSUMEDback to summary
public static final Breaker.BreakTextResult CHAR_UNBREAKABLE_BUT_CONSUMED

Not a single char fitted, but we consumed one character anyway.

CONTINUE_CHAR_BREAKING_ON_NLback to summary
public static final Breaker.BreakTextResult CONTINUE_CHAR_BREAKING_ON_NL

In char breaking mode, need a newline before continuing. At least one character has been consumed.

CONTINUE_WORD_BREAKING_ON_NLback to summary
public static final Breaker.BreakTextResult CONTINUE_WORD_BREAKING_ON_NL

In word breaking mode, need a newline before continuing. At least one word has been consumed.

DANGER_RECONSUME_CHAR_ON_NLback to summary
public static final Breaker.BreakTextResult DANGER_RECONSUME_CHAR_ON_NL

DANGER: Last char did not fit and we are directing the parent method to reconsume char on a newline. Example, below floats.

DANGER_RECONSUME_WORD_ON_NLback to summary
public static final Breaker.BreakTextResult DANGER_RECONSUME_WORD_ON_NL

DANGER: Last word did not fit and we are directing the parent method to reconsume word on a newline. Example, below floats.

FINISHEDback to summary
public static final Breaker.BreakTextResult FINISHED

Has completely consumed the string.

WORD_UNBREAKABLE_BUT_CONSUMEDback to summary
public static final Breaker.BreakTextResult WORD_UNBREAKABLE_BUT_CONSUMED

Not a single word fitted, but we consumed a word anyway. Only returned when word-wrap is not break-word.

Constructor Detail

BreakTextResultback to summary
private BreakTextResult()

Method Detail

valueOfback to summary
public static Breaker.BreakTextResult valueOf(String name)
valuesback to summary
public static Breaker.BreakTextResult[] values()
com.openhtmltopdf.layout back to summary

private Class Breaker.CharacterBreakerSupplier

extends Object
implements TextBreakerSupplier
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.layout.Breaker.TextBreakerSupplier

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public FSTextBreaker
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CharacterBreakerSupplierback to summary
private CharacterBreakerSupplier()

Method Detail

getBreakerback to summary
public FSTextBreaker getBreaker(String str, SharedContext sharedContext)

Implements com.openhtmltopdf.layout.Breaker.TextBreakerSupplier.getBreaker.

Annotations
@Override
com.openhtmltopdf.layout back to summary

private Class Breaker.LineBreakerSupplier

extends Object
implements TextBreakerSupplier
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.layout.Breaker.TextBreakerSupplier

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public FSTextBreaker
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LineBreakerSupplierback to summary
private LineBreakerSupplier()

Method Detail

getBreakerback to summary
public FSTextBreaker getBreaker(String str, SharedContext sharedContext)

Implements com.openhtmltopdf.layout.Breaker.TextBreakerSupplier.getBreaker.

Annotations
@Override
com.openhtmltopdf.layout back to summary

public Interface Breaker.TextBreakerSupplier

Known Direct Implementers
com.openhtmltopdf.layout.Breaker.CharacterBreakerSupplier, com.openhtmltopdf.layout.Breaker.LineBreakerSupplier

Method Summary

Modifier and TypeMethod and Description
public FSTextBreaker
getBreaker(String str, SharedContext sharedContext)

Method Detail

getBreakerback to summary
public FSTextBreaker getBreaker(String str, SharedContext sharedContext)