Package com.teamten.typeset.element
Class Text
java.lang.Object
com.teamten.typeset.element.Element
com.teamten.typeset.element.NonDiscardableElement
com.teamten.typeset.element.Box
com.teamten.typeset.element.Text
- All Implemented Interfaces:
Dimensions
A sequence of characters.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Encodes a character direction according to the Unicode standard. -
Field Summary
Fields inherited from class com.teamten.typeset.element.Element
DRAW_DEBUG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendedWith
(Text other) Returns a new Text object, the text of which is the concatenation of this text and the other text.void
breakUpInto
(Collection<Element> list) Add one Text object for each character in this object.boolean
Whether any character in the text is right-to-left.boolean
Return the character direction of the Text.@NotNull SizedFont
getFont()
The font the text should be displayed in.@NotNull String
getText()
The text that this element was constructed with.int
hashCode()
boolean
isCompatibleWith
(Text other) Whether this text can be appended to the other text.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.void
println
(PrintStream stream, String indent) Pretty prints the element to the PrintWriter with the given indent.toString()
Return a text version of the element, ideally containing only the text of the element and its children.Methods inherited from class com.teamten.typeset.element.Box
drawDebugRectangle, getDepth, getDimensionString, getHeight, getShift, getWidth
Methods inherited from class com.teamten.typeset.element.Element
getVerticalSize, println, shouldSkipElementAtStart, toTextString, visit
-
Constructor Details
-
Method Details
-
getText
The text that this element was constructed with. -
getFont
The font the text should be displayed in. -
isCompatibleWith
Whether this text can be appended to the other text. -
containsRightToLeftText
public boolean containsRightToLeftText()Whether any character in the text is right-to-left. -
getCharacterDirection
Return the character direction of the Text. The Text must contain only a single direction throughout.- Throws:
IllegalStateException
- if the Text contains more than one direction.
-
breakUpInto
Add one Text object for each character in this object. -
appendedWith
Returns a new Text object, the text of which is the concatenation of this text and the other text.- Throws:
IllegalArgumentException
- if the two text objects are not compatible.
-
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
-
println
Description copied from class:Element
Pretty prints the element to the PrintWriter with the given indent. The method must print its own newline. -
toString
-
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()
-