Package com.teamten.typeset
Class ElementList
java.lang.Object
com.teamten.typeset.ElementList
- All Implemented Interfaces:
ElementSink
- Direct Known Subclasses:
ColumnVerticalList
,HorizontalList
,VerticalList
Accumulates elements in a list, then finds the best place to break that list to make either lines
or pages.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Keeps track of possible breakpoints in our paragraph or page, their penalty, and their effects on the whole paragraph or page. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(Element element) Add one Element to the receiver.protected void
computeStartIndices
(List<ElementList.Breakpoint> breakpoints) For each possible breakpoint, figure out the next displayed element (after the breakpoint).protected List<ElementList.Breakpoint>
Find all the places that we could break a line or page.void
format
(ElementSink output, long maxSize) Format the list and add the elements to the sink.void
format
(ElementSink output, OutputShape outputShape) Format the list and add the elements to the sink.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).protected abstract 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 or page.protected abstract Box
makeOutputBox
(List<Element> elements, int counter, long shift) Generate the Box that will be sent to the output.void
println
(PrintStream stream, String indent) Pretty prints the list to the PrintWriter with the given indent.reverseRightToLeftText
(List<Element> elements) Optional function to reverse any right-to-left text in the list of elements.
-
Constructor Details
-
ElementList
public ElementList()
-
-
Method Details
-
addElement
Description copied from interface:ElementSink
Add one Element to the receiver.- Specified by:
addElement
in interfaceElementSink
-
getElements
-
format
Format the list and add the elements to the sink. For horizontal lists this makes paragraphs, and for vertical lists this makes pages. -
format
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
Find all the places that we could break a line or page. -
computeStartIndices
For each possible breakpoint, figure out the next displayed element (after the breakpoint). Modifies the breakpoint objects. -
println
Pretty prints the list to the PrintWriter with the given indent. The method must print its own newline. -
reverseRightToLeftText
Optional function to reverse any right-to-left text in the list of elements. -
makeOutputBox
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
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
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).
-