Package com.itextpdf.layout
Class RootElement<T extends IPropertyContainer>
- java.lang.Object
-
- com.itextpdf.commons.actions.sequence.AbstractIdentifiableElement
-
- com.itextpdf.layout.ElementPropertyContainer<T>
-
- com.itextpdf.layout.RootElement<T>
-
- Type Parameters:
T- this type
- All Implemented Interfaces:
IPropertyContainer,java.io.Closeable,java.lang.AutoCloseable
public abstract class RootElement<T extends IPropertyContainer> extends ElementPropertyContainer<T> implements java.io.Closeable
A generic abstract root element for a PDF layout object hierarchy.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<IElement>childElementsprotected PdfFontdefaultFontprotected FontProviderdefaultFontProviderprivate LayoutTaggingHelperdefaultLayoutTaggingHelperprotected ISplitCharactersdefaultSplitCharactersprotected booleanimmediateFlushprotected PdfDocumentpdfDocumentprotected RootRendererrootRenderer-
Fields inherited from class com.itextpdf.layout.ElementPropertyContainer
properties
-
-
Constructor Summary
Constructors Constructor Description RootElement()Creates a newRootElementinstance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tadd(IBlockElement element)Adds an element to the root.Tadd(Image image)Adds an image to the root.private TaddElement(IElement element)protected voidcreateAndAddRendererSubTree(IElement element)voiddeleteOwnProperty(int property)Deletes the own property of this entity.protected abstract RootRendererensureRootRendererNotNull()protected voidensureRootTagIsCreated()Ensures that the root tag is created in the tagging structure.<T1> T1getDefaultProperty(int property)Gets the default property from this entity.FontProvidergetFontProvider()GetsFontProviderif presents.<T1> T1getOwnProperty(int property)Gets own property from this entity.<T1> T1getProperty(int property)Gets the property from this entity.RootRenderergetRenderer()booleanhasOwnProperty(int property)Checks if this entity has the specified property, i.e.booleanhasProperty(int property)Checks if this entity has the specified property.private LayoutTaggingHelperinitTaggingHelperIfNeeded()voidsetFontProvider(FontProvider fontProvider)SetsFontProvider.voidsetProperty(int property, java.lang.Object value)Sets a property for this entity.TshowTextAligned(Paragraph p, float x, float y, int pageNumber, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)Convenience method to write a text aligned about the specified pointTshowTextAligned(Paragraph p, float x, float y, TextAlignment textAlign)Convenience method to write a text aligned about the specified pointTshowTextAligned(Paragraph p, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign)Convenience method to write a text aligned about the specified pointTshowTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign)Convenience method to write a text aligned about the specified pointTshowTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign, float angle)Convenience method to write a text aligned about the specified pointTshowTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float angle)Convenience method to write a text aligned about the specified pointTshowTextAlignedKerned(java.lang.String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)Convenience method to write a kerned text aligned about the specified pointprivate static voidtraverseAndCallIso(PdfDocument pdfDocument, IRenderer renderer)-
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer
getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getTransparentStrokeColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, setBorder, setBorderBottom, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderLeft, setBorderRadius, setBorderRight, setBorderTop, setBorderTopLeftRadius, setBorderTopRightRadius, setCharacterSpacing, setDashPattern, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFontColor, setFontColor, setFontColor, setFontFamily, setFontFamily, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setLineThrough, setOpacity, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing, simulateBold, simulateItalic
-
-
-
-
Field Detail
-
immediateFlush
protected boolean immediateFlush
-
pdfDocument
protected PdfDocument pdfDocument
-
childElements
protected java.util.List<IElement> childElements
-
defaultFont
protected PdfFont defaultFont
-
defaultFontProvider
protected FontProvider defaultFontProvider
-
defaultSplitCharacters
protected ISplitCharacters defaultSplitCharacters
-
rootRenderer
protected RootRenderer rootRenderer
-
defaultLayoutTaggingHelper
private LayoutTaggingHelper defaultLayoutTaggingHelper
-
-
Constructor Detail
-
RootElement
public RootElement()
Creates a newRootElementinstance.
-
-
Method Detail
-
add
public T add(IBlockElement element)
Adds an element to the root. The element is immediately placed in the contents.- Parameters:
element- an element with spacial margins, tabbing, and alignment- Returns:
- this element
- See Also:
BlockElement
-
add
public T add(Image image)
Adds an image to the root. The element is immediately placed in the contents.- Parameters:
image- a graphical image element- Returns:
- this element
- See Also:
Image
-
getFontProvider
public FontProvider getFontProvider()
GetsFontProviderif presents.- Returns:
- instance of
FontProviderif exists, otherwise null.
-
setFontProvider
public void setFontProvider(FontProvider fontProvider)
SetsFontProvider. Note, font provider is inherited property.- Parameters:
fontProvider- instance ofFontProvider.
-
hasProperty
public boolean hasProperty(int property)
Description copied from interface:IPropertyContainerChecks if this entity has the specified property. Compared toIPropertyContainer.hasOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance- Specified by:
hasPropertyin interfaceIPropertyContainer- Overrides:
hasPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Parameters:
property- the property to be checked- Returns:
trueif this instance has given property,falseotherwise
-
hasOwnProperty
public boolean hasOwnProperty(int property)
Description copied from interface:IPropertyContainerChecks if this entity has the specified property, i.e. if it was set to this very element earlier- Specified by:
hasOwnPropertyin interfaceIPropertyContainer- Overrides:
hasOwnPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Parameters:
property- the property to be checked- Returns:
trueif this instance has given own property,falseotherwise
-
getProperty
public <T1> T1 getProperty(int property)
Description copied from interface:IPropertyContainerGets the property from this entity. Compared toIPropertyContainer.getOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance- Specified by:
getPropertyin interfaceIPropertyContainer- Overrides:
getPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieved- Returns:
- the value of the given property.
nullwill be returned if the property value was not found
-
getOwnProperty
public <T1> T1 getOwnProperty(int property)
Description copied from interface:IPropertyContainerGets own property from this entity. The property must have been set earlier to this entity. If the property is not found,nullwill be returned.- Specified by:
getOwnPropertyin interfaceIPropertyContainer- Overrides:
getOwnPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieved- Returns:
- the value of the given own property.
nullwill be returned if the property value was not found
-
getDefaultProperty
public <T1> T1 getDefaultProperty(int property)
Description copied from interface:IPropertyContainerGets the default property from this entity.- Specified by:
getDefaultPropertyin interfaceIPropertyContainer- Overrides:
getDefaultPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieved- Returns:
- the default property value. If the default property is not defined,
nullwill be returned
-
deleteOwnProperty
public void deleteOwnProperty(int property)
Description copied from interface:IPropertyContainerDeletes the own property of this entity.- Specified by:
deleteOwnPropertyin interfaceIPropertyContainer- Overrides:
deleteOwnPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Parameters:
property- the property to be deleted
-
setProperty
public void setProperty(int property, java.lang.Object value)Description copied from interface:IPropertyContainerSets a property for this entity.- Specified by:
setPropertyin interfaceIPropertyContainer- Overrides:
setPropertyin classElementPropertyContainer<T extends IPropertyContainer>- Parameters:
property- the property to be setvalue- the value of the property
-
getRenderer
public RootRenderer getRenderer()
Gets the rootRenderer attribute, a specializedIRendererthat acts as the root object that otherrenderersdescend from.- Returns:
- the
RootRendererattribute
-
showTextAligned
public T showTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign)
Convenience method to write a text aligned about the specified point- Parameters:
text- text to be placed to the pagex- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified point- Returns:
- this object
-
showTextAligned
public T showTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign, float angle)
Convenience method to write a text aligned about the specified point- Parameters:
text- text to be placed to the pagex- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified pointangle- the angle of rotation applied to the text, in radians- Returns:
- this object
-
showTextAligned
public T showTextAligned(java.lang.String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float angle)
Convenience method to write a text aligned about the specified point- Parameters:
text- text to be placed to the pagex- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified pointvertAlign- vertical alignment about the specified pointangle- the angle of rotation applied to the text, in radians- Returns:
- this object
-
showTextAlignedKerned
public T showTextAlignedKerned(java.lang.String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)
Convenience method to write a kerned text aligned about the specified point- Parameters:
text- text to be placed to the pagex- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified pointvertAlign- vertical alignment about the specified pointradAngle- the angle of rotation applied to the text, in radians- Returns:
- this object
-
showTextAligned
public T showTextAligned(Paragraph p, float x, float y, TextAlignment textAlign)
Convenience method to write a text aligned about the specified point- Parameters:
p- paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.x- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified point- Returns:
- this object
-
showTextAligned
public T showTextAligned(Paragraph p, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign)
Convenience method to write a text aligned about the specified point- Parameters:
p- paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.x- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedtextAlign- horizontal alignment about the specified pointvertAlign- vertical alignment about the specified point- Returns:
- this object
-
showTextAligned
public T showTextAligned(Paragraph p, float x, float y, int pageNumber, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)
Convenience method to write a text aligned about the specified point- Parameters:
p- paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.x- the point about which the text will be aligned and rotatedy- the point about which the text will be aligned and rotatedpageNumber- the page number to write the texttextAlign- horizontal alignment about the specified pointvertAlign- vertical alignment about the specified pointradAngle- the angle of rotation applied to the text, in radians- Returns:
- this object
-
ensureRootRendererNotNull
protected abstract RootRenderer ensureRootRendererNotNull()
-
createAndAddRendererSubTree
protected void createAndAddRendererSubTree(IElement element)
-
ensureRootTagIsCreated
protected final void ensureRootTagIsCreated()
Ensures that the root tag is created in the tagging structure.
-
initTaggingHelperIfNeeded
private LayoutTaggingHelper initTaggingHelperIfNeeded()
-
traverseAndCallIso
private static void traverseAndCallIso(PdfDocument pdfDocument, IRenderer renderer)
-
-