Package com.itextpdf.layout.renderer
Interface IRenderer
- All Superinterfaces:
-
IPropertyContainer
- All Known Subinterfaces:
-
ILeafElementRenderer
- All Known Implementing Classes:
-
AbstractFormFieldRenderer
,AbstractOneLineTextFieldRenderer
,AbstractRenderer
,AbstractSelectFieldRenderer
,AbstractTextFieldRenderer
,AreaBreakRenderer
,BlockRenderer
,ButtonRenderer
,CanvasRenderer
,CellRenderer
,CheckBoxRenderer
,CheckBoxRenderer.FlatParagraphRenderer
,ColumnDocumentRenderer
,DivRenderer
,DocumentRenderer
,FlexContainerRenderer
,ImageRenderer
,InputFieldRenderer
,LineRenderer
,LineSeparatorRenderer
,LinkRenderer
,ListItemRenderer
,ListRenderer
,ParagraphRenderer
,RadioRenderer
,RootRenderer
,SelectFieldComboBoxRenderer
,SelectFieldListBoxRenderer
,TableRenderer
,TabRenderer
,TextAreaRenderer
,TextRenderer
A renderer object is responsible for drawing a corresponding layout object on a document or canvas. Every layout object has a renderer, by default one of the corresponding type, e.g. you can ask an
Image
for its ImageRenderer
. Renderers are designed to be extensible, and custom implementations can be seeded to layout objects (or their custom subclasses) at runtime.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child to the current renderervoid
draw
(DrawContext drawContext) Flushes the renderer subtree contents, i.e.Gets the childIRenderer
s.Gets the model element associated with this renderer.Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.Gets the resultant occupied area after the last call to thelayout(LayoutContext)
method.Gets the parentIRenderer
.T1 getProperty
(int property, T1 defaultValue) Gets a property from this entity or one of its hierarchical parents.boolean
Indicates whether this renderer is flushed or not, i.e.layout
(LayoutContext layoutContext) This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, representing the layout result, including occupied area, status, i.e.void
move
(float dx, float dy) Moves the renderer subtree by the specified offset.Explicitly sets this object as the child of anotherIRenderer
in the renderer hierarchy.Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
-
Method Details
-
addChild
Adds a child to the current renderer- Parameters:
-
renderer
- a child to be added
-
layout
This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc.LayoutResult
can be extended to return custom layout results for custom elements, e.g.TextRenderer
usesTextLayoutResult
as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called beforedraw(DrawContext)
, to prepare the renderer to be flushed to the output stream.- Parameters:
-
layoutContext
- the description of layout area and any other additional information - Returns:
- result of the layout process
-
draw
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocument
etc.- Parameters:
-
drawContext
- contains thePdfDocument
to which the renderer subtree if flushed, thePdfCanvas
on which the renderer subtree is drawn and other additional parameters needed to perform drawing
-
getOccupiedArea
LayoutArea getOccupiedArea()Gets the resultant occupied area after the last call to thelayout(LayoutContext)
method.- Returns:
-
LayoutArea
instance
-
getProperty
T1 getProperty (int property, T1 defaultValue) Gets a property from this entity or one of its hierarchical parents. If the property is not found,defaultValue
will be returned.- Type Parameters:
-
T1
- the return type associated with the property - Parameters:
-
property
- the property to be retrieved -
defaultValue
- a fallback value - Returns:
- the value of the given property
-
setParent
Explicitly sets this object as the child of anotherIRenderer
in the renderer hierarchy. Some implementations also use this method internally to create a consistent hierarchy tree.- Parameters:
-
parent
- the object to place higher in the renderer hierarchy - Returns:
- by default, this object
-
getParent
IRenderer getParent()Gets the parentIRenderer
.- Returns:
-
direct parent
renderer
of this instance
-
getModelElement
IPropertyContainer getModelElement()Gets the model element associated with this renderer.- Returns:
-
the model element, as a
container of properties
-
getChildRenderers
Gets the childIRenderer
s.- Returns:
-
a list of direct child
renderers
of this instance
-
isFlushed
boolean isFlushed()Indicates whether this renderer is flushed or not, i.e. ifdraw(DrawContext)
has already been called.- Returns:
- whether the renderer has been flushed
-
move
void move(float dx, float dy) Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.- Parameters:
-
dx
- the x-axis offset in points. Positive value will move the renderer subtree to the right. -
dy
- the y-axis offset in points. Positive value will move the renderer subtree to the top.
-
getNextRenderer
IRenderer getNextRenderer()Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.- Returns:
- new renderer instance
-