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 TypeMethodDescriptionvoidAdds the necessary glue and penalty to end a paragraph.voidaddText(String text, SizedFont font, HyphenDictionary hyphenDictionary) Add the specified text, in the specified font, to the horizontal list.voidaddTextSpan(TextSpan textSpan, FontPack fontPack, HyphenDictionary hyphenDictionary) Add the text span to the horizontal list, properly picking the font.static HorizontalListcentered()Create a new object that's centered.static HorizontalListcenteredLine(long width) Make a centered thin horizontal divider line, ready to be formatted into a vertical list.protected intgetChunkExtraIncrement(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 longgetElementSize(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).intGet the number of footnotes in this horizontal list.static booleanisWordCharacter(int ch) Whether the character can be part of a hyphenated word.protected HBoxmakeOutputBox(List<Element> elements, int lineNumber, long shift) Generate the Box that will be sent to the output.static HorizontalListCreate a new object that does not permit line breaks at spaces.static HorizontalListCreate 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:ElementListGenerate the Box that will be sent to the output.- Specified by:
makeOutputBoxin 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:ElementListReturn the size (width for horizontal lists, height + depth for vertical lists) of the element.- Specified by:
getElementSizein 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:
getElementSublistin classElementList
-
getChunkExtraIncrement
Description copied from class:ElementListWhen 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:
getChunkExtraIncrementin classElementList
-
reverseRightToLeftText
Description copied from class:ElementListOptional function to reverse any right-to-left text in the list of elements.- Overrides:
reverseRightToLeftTextin 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.
-