Package com.itextpdf.layout.renderer
Class BlockRenderer
java.lang.Object
com.itextpdf.layout.renderer.AbstractRenderer
com.itextpdf.layout.renderer.BlockRenderer
- All Implemented Interfaces:
-
IPropertyContainer
,IRenderer
- Direct Known Subclasses:
-
CellRenderer
,DivRenderer
,LineSeparatorRenderer
,ListRenderer
,ParagraphRenderer
Represents a renderer for block elements.
-
Field Summary
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties
-
Constructor Summary
ModifierConstructorDescriptionprotected
BlockRenderer
(IElement modelElement) Creates a BlockRenderer from its corresponding layout object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyRotationLayout
(Rectangle layoutBox) This method rotates content of the renderer and calculates correct occupied area for the rotated element.protected void
This method applies vertical alignment for the occupied area of the renderer and its children renderers.protected void
beginRotationIfApplied
(PdfCanvas canvas) This method starts rotation for the renderer if rotation angle property is specified.protected AbstractRenderer
createOverflowRenderer
(int layoutResult) Creates an overflow renderer.protected AffineTransform
This method createsAffineTransform
instance that could be used to rotate content inside the occupied area.protected AbstractRenderer
createSplitRenderer
(int layoutResult) Creates a split renderer.void
draw
(DrawContext drawContext) Flushes the renderer subtree contents, i.e.protected void
endRotationIfApplied
(PdfCanvas canvas) This method ends rotation for the renderer if applied.Calculates min and max width values for current renderer.Gets the bounding box that contains all content written to theDrawContext
by thisIRenderer
.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.Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllProperties, addChild, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateBBox, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createXObject, deleteOwnProperty, deleteProperty, drawBackground, drawBorder, drawChildren, endElementOpacityApplying, endTransformationIfApplied, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getModelElement, getOccupiedArea, getOwnProperties, getOwnProperty, getPaddings, getParent, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, hasAbsoluteUnitValue, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, move, rectangleToPointsList, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveUnitValue, retrieveUnitValue, retrieveWidth, setBorders, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, toString, transformPoints, updateHeight, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidth
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.itextpdf.layout.renderer.IRenderer
getNextRenderer
-
Constructor Details
-
BlockRenderer
Creates a BlockRenderer from its corresponding layout object.- Parameters:
-
modelElement
- theIElement
which this object should manage
-
-
Method Details
-
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 beforeIRenderer.draw(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
Description copied from class:AbstractRenderer
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocument
etc.- Specified by:
-
draw
in interfaceIRenderer
- Overrides:
-
draw
in classAbstractRenderer
- 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
-
getOccupiedAreaBBox
Description copied from class:AbstractRenderer
Gets the bounding box that contains all content written to theDrawContext
by thisIRenderer
.- Overrides:
-
getOccupiedAreaBBox
in classAbstractRenderer
- Returns:
-
the smallest
Rectangle
that surrounds the content
-
createSplitRenderer
Creates a split renderer.- Parameters:
-
layoutResult
- the result of content layouting - Returns:
-
a new
AbstractRenderer
instance
-
createOverflowRenderer
Creates an overflow renderer.- Parameters:
-
layoutResult
- the result of content layouting - Returns:
-
a new
AbstractRenderer
instance
-
applyVerticalAlignment
protected void applyVerticalAlignment()This method applies vertical alignment for the occupied area of the renderer and its children renderers. -
applyRotationLayout
This method rotates content of the renderer and calculates correct occupied area for the rotated element.- Parameters:
-
layoutBox
- aRectangle
-
createRotationTransformInsideOccupiedArea
This method createsAffineTransform
instance that could be used to rotate content inside the occupied area. Be aware that it should be used only after layout rendering is finished and correct occupied area for the rotated element is calculated.- Returns:
-
AffineTransform
that rotates the content and places it inside occupied area.
-
beginRotationIfApplied
This method starts rotation for the renderer if rotation angle property is specified.- Parameters:
-
canvas
- thePdfCanvas
to draw on
-
endRotationIfApplied
This method ends rotation for the renderer if applied.- Parameters:
-
canvas
- thePdfCanvas
to draw on
-
getMinMaxWidth
Calculates min and max width values for current renderer.- Overrides:
-
getMinMaxWidth
in classAbstractRenderer
- Returns:
-
instance of
MinMaxWidth
-