Package com.itextpdf.layout.element
Class AbstractElement<T extends IElement>
- java.lang.Object
-
- com.itextpdf.commons.actions.sequence.AbstractIdentifiableElement
-
- com.itextpdf.layout.ElementPropertyContainer<T>
-
- com.itextpdf.layout.element.AbstractElement<T>
-
- Type Parameters:
T- the type of the implementation
- All Implemented Interfaces:
IAbstractElement,IElement,IPropertyContainer
public abstract class AbstractElement<T extends IElement> extends ElementPropertyContainer<T> implements IAbstractElement
Defines the most common properties that mostIElementimplementations share.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<IElement>childElementsprotected IRenderernextRendererprotected java.util.Set<Style>styles-
Fields inherited from class com.itextpdf.layout.ElementPropertyContainer
properties
-
-
Constructor Summary
Constructors Constructor Description AbstractElement()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddStyle(Style style)Add a new style to this element.IRenderercreateRendererSubTree()Creates a renderer subtree with root in the current element.java.util.List<IElement>getChildren()Gets the child elements of this elements<T1> T1getProperty(int property)Gets the property from this entity.IRenderergetRenderer()Gets a renderer for this element.booleanhasProperty(int property)Checks if this entity has the specified property.booleanisEmpty()Returnstrueif this list contains no elements.protected abstract IRenderermakeNewRenderer()Creates a new renderer instance.TsetAction(PdfAction action)Sets an action on this Element.voidsetNextRenderer(IRenderer renderer)Overrides theIRendererinstance which will be returned by the next call to theIElement.getRenderer().TsetPageNumber(int pageNumber)Explicitly sets the page number this element should be put on.-
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getTransparentStrokeColor, hasOwnProperty, 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, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing, simulateBold, simulateItalic
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, hasOwnProperty, setProperty
-
-
-
-
Method Detail
-
getRenderer
public IRenderer getRenderer()
Description copied from interface:IElementGets a renderer for this element. Note that this method can be called more than once. By default each element should define its own renderer, but the renderer can be overridden byIElement.setNextRenderer(IRenderer)method call.- Specified by:
getRendererin interfaceIElement- Returns:
- a renderer for this element
-
setNextRenderer
public void setNextRenderer(IRenderer renderer)
Description copied from interface:IElementOverrides theIRendererinstance which will be returned by the next call to theIElement.getRenderer().- Specified by:
setNextRendererin interfaceIElement- Parameters:
renderer- the renderer instance
-
createRendererSubTree
public IRenderer createRendererSubTree()
Description copied from interface:IElementCreates a renderer subtree with root in the current element. Compared toIElement.getRenderer(), the renderer returned by this method should contain all the child renderers for children of the current element.- Specified by:
createRendererSubTreein interfaceIElement- Returns:
- a renderer subtree for this element
-
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 IElement>- Parameters:
property- the property to be checked- Returns:
trueif this instance has given 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 IElement>- 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
-
addStyle
public T addStyle(Style style)
Add a new style to this element. A style can be used as an effective way to define multiple equal properties to several elements, however its properties have lower priority than properties, directly set onElementPropertyContainerNote that if several Style objects are added, iText checks them one by one in the order in which they were added and returns the property's value from the last Style object, which contains this property. So, if there are two Style objects added: the first has set width of 100 points and the second of 200 points, iText will get 200 points as width value.- Parameters:
style- the style to be added- Returns:
- this element
-
getChildren
public java.util.List<IElement> getChildren()
Gets the child elements of this elements- Specified by:
getChildrenin interfaceIAbstractElement- Returns:
- a list of children
-
isEmpty
public boolean isEmpty()
Returnstrueif this list contains no elements.- Returns:
trueif this list contains no elements
-
setAction
public T setAction(PdfAction action)
Sets an action on this Element. An action is a general PDF concept that signifies anything that makes the document interactive, e.g. a hyperlink or a button.- Parameters:
action- thePdfActionthat should be performed- Returns:
- this Element
-
setPageNumber
public T setPageNumber(int pageNumber)
Explicitly sets the page number this element should be put on. The location on the page will be the same as if it were added at the end of the document, but it will be located on the specified page.This method should be used very carefully in client code.
- Parameters:
pageNumber- the page number of the page this element should be placed on- Returns:
- this Element
-
-