Class HorizontalList

java.lang.Object
com.teamten.typeset.ElementList
com.teamten.typeset.HorizontalList
All Implemented Interfaces:
ElementSink

public class HorizontalList extends ElementList
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.
  • Constructor Details

    • HorizontalList

      public HorizontalList()
  • Method Details

    • raggedRight

      public static HorizontalList raggedRight()
      Create a new object that has a ragged right edge (no justification).
    • centered

      public static HorizontalList centered()
      Create a new object that's centered.
    • noLineBreaks

      public static HorizontalList noLineBreaks()
      Create a new object that does not permit line breaks at spaces. This implicitly is also ragged right.
    • centeredLine

      public static HorizontalList centeredLine(long width)
      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

      public void addTextSpan(TextSpan textSpan, FontPack fontPack, HyphenDictionary hyphenDictionary)
      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

      protected HBox makeOutputBox(List<Element> elements, int lineNumber, long shift)
      Description copied from class: ElementList
      Generate the Box that will be sent to the output.
      Specified by:
      makeOutputBox in class ElementList
      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

      protected long getElementSize(Element element)
      Description copied from class: ElementList
      Return the size (width for horizontal lists, height + depth for vertical lists) of the element.
      Specified by:
      getElementSize in class ElementList
    • 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 class ElementList
    • getChunkExtraIncrement

      protected int getChunkExtraIncrement(Chunk chunk)
      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 class ElementList
    • reverseRightToLeftText

      protected List<Element> reverseRightToLeftText(List<Element> elements)
      Description copied from class: ElementList
      Optional function to reverse any right-to-left text in the list of elements.
      Overrides:
      reverseRightToLeftText in class ElementList
    • addText

      public void addText(String text, SizedFont font, HyphenDictionary hyphenDictionary)
      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

      public List<Element> textToElements(String text, SizedFont font, HyphenDictionary hyphenDictionary)
      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.