Package com.teamten.typeset.element
Class Element
java.lang.Object
com.teamten.typeset.element.Element
- All Implemented Interfaces:
Dimensions
- Direct Known Subclasses:
DiscardableElement,NonDiscardableElement
An element that can be stacked horizontally to make a line or vertically to make a page.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract longgetDepth()Return the depth (below the baseline) of the element.abstract longReturn the height (above the baseline) of the element.final longConvenience method for adding the height and depth.abstract longgetWidth()Return the width of the element.abstract longlayOutHorizontally(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) Add the element to the contents as part of a horizontal sequence.abstract longlayOutVertically(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) Add the element to the contents as part of a vertical sequence.voidprintln(PrintStream stream, String indent) Pretty prints the element to the PrintWriter with the given indent.static voidprintln(Iterable<? extends Element> elements, PrintStream stream, String indent) Convenience method for implementingprintln(PrintStream, String)from a list of elements.booleanReturns whether this element, at the beginning of a line or page, should be skipped.Return a text version of the element, ideally containing only the text of the element and its children.protected static StringtoTextString(List<Element> elements) Convenience method for implementingtoTextString()from a list of elements.voidCalls the consumer on this element and all child elements in pre-order.
-
Field Details
-
DRAW_DEBUG
protected final boolean DRAW_DEBUG- See Also:
-
-
Constructor Details
-
Element
public Element()
-
-
Method Details
-
getWidth
public abstract long getWidth()Return the width of the element.- Specified by:
getWidthin interfaceDimensions
-
getHeight
public abstract long getHeight()Return the height (above the baseline) of the element.- Specified by:
getHeightin interfaceDimensions
-
getDepth
public abstract long getDepth()Return the depth (below the baseline) of the element.- Specified by:
getDepthin interfaceDimensions
-
visit
Calls the consumer on this element and all child elements in pre-order. The default implementation just calls the consumer on this element. -
layOutHorizontally
public abstract long layOutHorizontally(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException Add the element to the contents as part of a horizontal sequence.- Parameters:
x- the left-most point of the element.y- the baseline of the element.contents- the stream to add the element to.- Returns:
- how much to move right afterward.
- Throws:
IOException
-
layOutVertically
public abstract long layOutVertically(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException Add the element to the contents as part of a vertical sequence.- Parameters:
x- the left-most point of the element.y- the upper-left point of the element.contents- the stream to add the element to.- Returns:
- how much to move down afterward.
- Throws:
IOException
-
println
Pretty prints the element to the PrintWriter with the given indent. The method must print its own newline. -
println
Convenience method for implementingprintln(PrintStream, String)from a list of elements. -
toTextString
Return a text version of the element, ideally containing only the text of the element and its children. -
getVerticalSize
public final long getVerticalSize()Convenience method for adding the height and depth. -
toTextString
Convenience method for implementingtoTextString()from a list of elements. -
shouldSkipElementAtStart
public boolean shouldSkipElementAtStart()Returns whether this element, at the beginning of a line or page, should be skipped.
-