Package com.teamten.typeset.element
Class HBox
java.lang.Object
com.teamten.typeset.element.Element
com.teamten.typeset.element.NonDiscardableElement
com.teamten.typeset.element.Box
com.teamten.typeset.element.HBox
- All Implemented Interfaces:
Dimensions
- Direct Known Subclasses:
Columns
Horizontal sequence of elements.
-
Field Summary
Fields inherited from class com.teamten.typeset.element.Element
DRAW_DEBUG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HBox
Make a new HBox with the content centered in a box of the specified width.boolean
Do not modify this list.If the HBox contains only one element, and this element is a Text, then returns the text of this Text.int
hashCode()
boolean
isEmpty()
Whether this horizontal box is empty, i.e., has no elements in it.long
layOutHorizontally
(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) Add the element to the contents as part of a horizontal sequence.long
layOutVertically
(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) Add the element to the contents as part of a vertical sequence.static HBox
leftAligned
(Element element, long width) Make a new HBox with the content left-aligned in a box of the specified width.static HBox
makeOnlyString
(String text, SizedFont font) Make an HBox that contains only a Text with the given string, font, and font size.static HBox
Make a new HBox that's forced to be the specified width.void
println
(PrintStream stream, String indent) Pretty prints the element to the PrintWriter with the given indent.static HBox
rightAligned
(Element element, long width) Make a new HBox with the content right-aligned in a box of the specified width.Return a text version of the element, ideally containing only the text of the element and its children.void
Calls the consumer on this element and all child elements in pre-order.Methods inherited from class com.teamten.typeset.element.Box
drawDebugRectangle, getDepth, getDimensionString, getHeight, getShift, getWidth, toString
Methods inherited from class com.teamten.typeset.element.Element
getVerticalSize, println, shouldSkipElementAtStart, toTextString
-
Constructor Details
-
HBox
-
HBox
-
HBox
-
-
Method Details
-
ofWidth
Make a new HBox that's forced to be the specified width. -
leftAligned
Make a new HBox with the content left-aligned in a box of the specified width. -
centered
Make a new HBox with the content centered in a box of the specified width. -
rightAligned
Make a new HBox with the content right-aligned in a box of the specified width. -
getElements
Do not modify this list. -
isEmpty
public boolean isEmpty()Whether this horizontal box is empty, i.e., has no elements in it. -
getOnlyString
If the HBox contains only one element, and this element is a Text, then returns the text of this Text. If the HBox is empty, returns an empty string.- Throws:
IllegalArgumentException
- if one of the above conditions do not hold.
-
makeOnlyString
Make an HBox that contains only a Text with the given string, font, and font size. -
layOutHorizontally
public long layOutHorizontally(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException Description copied from class:Element
Add the element to the contents as part of a horizontal sequence.- Overrides:
layOutHorizontally
in classBox
- 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 long layOutVertically(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException Description copied from class:Element
Add the element to the contents as part of a vertical sequence.- Overrides:
layOutVertically
in classBox
- 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
-
visit
Description copied from class:Element
Calls the consumer on this element and all child elements in pre-order. The default implementation just calls the consumer on this element. -
println
Description copied from class:Element
Pretty prints the element to the PrintWriter with the given indent. The method must print its own newline. -
toTextString
Description copied from class:Element
Return a text version of the element, ideally containing only the text of the element and its children.- Overrides:
toTextString
in classElement
-
equals
-
hashCode
public int hashCode()
-