Class ElementList

java.lang.Object
com.teamten.typeset.ElementList
All Implemented Interfaces:
ElementSink
Direct Known Subclasses:
ColumnVerticalList, HorizontalList, VerticalList

public abstract class ElementList extends Object implements ElementSink
Accumulates elements in a list, then finds the best place to break that list to make either lines or pages.
  • Constructor Details

    • ElementList

      public ElementList()
  • Method Details

    • addElement

      public void addElement(Element element)
      Description copied from interface: ElementSink
      Add one Element to the receiver.
      Specified by:
      addElement in interface ElementSink
    • getElements

      public List<Element> getElements()
    • format

      public void format(ElementSink output, long maxSize)
      Format the list and add the elements to the sink. For horizontal lists this makes paragraphs, and for vertical lists this makes pages.
    • format

      public void format(ElementSink output, OutputShape outputShape)
      Format the list and add the elements to the sink. For horizontal lists this makes paragraphs, and for vertical lists this makes pages.
      Parameters:
      outputShape - the shape of the output paragraph of pages.
    • findBreakpoints

      protected List<ElementList.Breakpoint> findBreakpoints()
      Find all the places that we could break a line or page.
    • computeStartIndices

      protected void computeStartIndices(List<ElementList.Breakpoint> breakpoints)
      For each possible breakpoint, figure out the next displayed element (after the breakpoint). Modifies the breakpoint objects.
    • println

      public void println(PrintStream stream, String indent)
      Pretty prints the list to the PrintWriter with the given indent. The method must print its own newline.
    • reverseRightToLeftText

      protected List<Element> reverseRightToLeftText(List<Element> elements)
      Optional function to reverse any right-to-left text in the list of elements.
    • makeOutputBox

      protected abstract Box makeOutputBox(List<Element> elements, int counter, long shift)
      Generate the Box that will be sent to the output.
      Parameters:
      elements - the elements of the box.
      counter - 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 abstract long getElementSize(Element element)
      Return the size (width for horizontal lists, height + depth for vertical lists) of the element.
    • getElementSublist

      protected abstract List<Element> getElementSublist(ElementList.Breakpoint beginBreakpoint, ElementList.Breakpoint endBreakpoint)
      Return the list of elements on this line or page. Can process elements to make them more appropriate to this particular range.
    • getChunkExtraIncrement

      protected abstract 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).