Package com.teamten.typeset
Class HorizontalList
java.lang.Object
com.teamten.typeset.ElementList
com.teamten.typeset.HorizontalList
- All Implemented Interfaces:
ElementSink
Accumulates elements in a horizontal list until a paragraph is finished, at which point a list of
elements is generated and added to a vertical list.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.teamten.typeset.ElementList
ElementList.Breakpoint
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the necessary glue and penalty to end a paragraph.void
addText
(String text, SizedFont font, HyphenDictionary hyphenDictionary) Add the specified text, in the specified font, to the horizontal list.void
addTextSpan
(TextSpan textSpan, FontPack fontPack, HyphenDictionary hyphenDictionary) Add the text span to the horizontal list, properly picking the font.static HorizontalList
centered()
Create a new object that's centered.static HorizontalList
centeredLine
(long width) Make a centered thin horizontal divider line, ready to be formatted into a vertical list.protected int
getChunkExtraIncrement
(Chunk chunk) When generating breakpoints, if there are images and other things in a chunk, we must adjust the counter if those images will take up space (such as a space).protected long
getElementSize
(Element element) Return the size (width for horizontal lists, height + depth for vertical lists) of the element.getElementSublist
(ElementList.Breakpoint beginBreakpoint, ElementList.Breakpoint endBreakpoint) Return the list of elements on this line, from beginBreakpoint (inclusive) to endBreakpoint (inclusive only if it's a discretionary element).int
Get the number of footnotes in this horizontal list.static boolean
isWordCharacter
(int ch) Whether the character can be part of a hyphenated word.protected HBox
makeOutputBox
(List<Element> elements, int lineNumber, long shift) Generate the Box that will be sent to the output.static HorizontalList
Create a new object that does not permit line breaks at spaces.static HorizontalList
Create a new object that has a ragged right edge (no justification).reverseRightToLeftText
(List<Element> elements) Optional function to reverse any right-to-left text in the list of elements.textToElements
(String text, SizedFont font, HyphenDictionary hyphenDictionary) Convert the given text to a sequence of elements.Methods inherited from class com.teamten.typeset.ElementList
addElement, computeStartIndices, findBreakpoints, format, format, getElements, println
-
Constructor Details
-
HorizontalList
public HorizontalList()
-
-
Method Details
-
raggedRight
Create a new object that has a ragged right edge (no justification). -
centered
Create a new object that's centered. -
noLineBreaks
Create a new object that does not permit line breaks at spaces. This implicitly is also ragged right. -
centeredLine
Make a centered thin horizontal divider line, ready to be formatted into a vertical list. Adding this as-is to a vertical list might add some spacing above, to maintain the leading. See uses of it for how to disable this. -
addTextSpan
Add the text span to the horizontal list, properly picking the font. -
getFootnoteCount
public int getFootnoteCount()Get the number of footnotes in this horizontal list. -
makeOutputBox
Description copied from class:ElementList
Generate the Box that will be sent to the output.- Specified by:
makeOutputBox
in classElementList
- Parameters:
elements
- the elements of the box.lineNumber
- the number of the box, starting from 1. For horizontal lists this is the line number of the paragraph. For vertical lists this is the physical page number.shift
- how much to shift the box in the final layout (up or to the right).
-
getElementSize
Description copied from class:ElementList
Return the size (width for horizontal lists, height + depth for vertical lists) of the element.- Specified by:
getElementSize
in classElementList
-
getElementSublist
protected List<Element> getElementSublist(ElementList.Breakpoint beginBreakpoint, ElementList.Breakpoint endBreakpoint) Return the list of elements on this line, from beginBreakpoint (inclusive) to endBreakpoint (inclusive only if it's a discretionary element). All discretionary elements are turned into HBoxes depending on where they are.- Specified by:
getElementSublist
in classElementList
-
getChunkExtraIncrement
Description copied from class:ElementList
When generating breakpoints, if there are images and other things in a chunk, we must adjust the counter if those images will take up space (such as a space).- Specified by:
getChunkExtraIncrement
in classElementList
-
reverseRightToLeftText
Description copied from class:ElementList
Optional function to reverse any right-to-left text in the list of elements.- Overrides:
reverseRightToLeftText
in classElementList
-
addText
Add the specified text, in the specified font, to the horizontal list.- Parameters:
hyphenDictionary
- the dictionary to use for hyphenation, or null to skip hyphenation.
-
textToElements
Convert the given text to a sequence of elements. Perform hyphenation (if non-null), ligatures, and kerning. Does not add the elements to the horizontal list immediately, though the intent is that they will be added eventually (e.g., first by being wrapped in an HBox). -
isWordCharacter
public static boolean isWordCharacter(int ch) Whether the character can be part of a hyphenated word. -
addEndOfParagraph
public void addEndOfParagraph()Adds the necessary glue and penalty to end a paragraph.
-