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:
AbstractFormFieldRenderer
,AbstractSelectFieldRenderer
,CellRenderer
,DivRenderer
,GridContainerRenderer
,GridItemRenderer
,LineSeparatorRenderer
,ListRenderer
,ParagraphRenderer
public abstract class BlockRenderer extends AbstractRenderer
Represents a renderer for block elements.
-
-
Field Summary
-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
BOTTOM_SIDE, childRenderers, EPS, flushed, INF, isLastRendererForModelElement, LEFT_SIDE, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties, RIGHT_SIDE, TOP_SIDE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BlockRenderer(IElement modelElement)
Creates a BlockRenderer from its corresponding layout object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addMarkedContent(DrawContext drawContext, boolean isBegin)
(package private) boolean
applyMaxHeight(Rectangle parentBBox, java.lang.Float blockMaxHeight, MarginsCollapseHandler marginsCollapseHandler, boolean isCellRenderer, boolean wasParentsHeightClipped, OverflowPropertyValue overflowY)
(package private) AbstractRenderer
applyMinHeight(OverflowPropertyValue overflowY, Rectangle layoutBox)
protected void
applyRotationLayout(Rectangle layoutBox)
This method rotates content of the renderer and calculates correct occupied area for the rotated element.protected void
applyVerticalAlignment()
This method applies vertical alignment for the occupied area of the renderer and its children renderers.(package private) void
applyWidth(Rectangle parentBBox, java.lang.Float blockWidth, OverflowPropertyValue overflowX)
protected void
beginRotationIfApplied(PdfCanvas canvas)
This method starts rotation for the renderer if rotation angle property is specified.private int
checkPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd)
private java.util.List<Point>
clipPolygon(java.util.List<Point> points, Point clipLineBeg, Point clipLineEnd)
(package private) void
correctFixedLayout(Rectangle layoutBox)
protected AbstractRenderer
createOverflowRenderer(int layoutResult)
Creates an overflow renderer.protected AffineTransform
createRotationTransformInsideOccupiedArea()
This method createsAffineTransform
instance that could be used to rotate content inside the occupied area.(package private) AbstractRenderer[]
createSplitAndOverflowRenderers(int childPos, int layoutStatus, LayoutResult childResult, java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, java.util.List<IRenderer> waitingOverflowFloatRenderers)
protected AbstractRenderer
createSplitRenderer(int layoutResult)
Creates a split renderer.(package private) void
decreaseLayoutBoxAfterChildPlacement(Rectangle layoutBox, LayoutResult result, IRenderer childRenderer)
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.(package private) void
fixOccupiedAreaIfOverflowedX(OverflowPropertyValue overflowX, Rectangle layoutBox)
(package private) void
fixOccupiedAreaIfOverflowedY(OverflowPropertyValue overflowY, Rectangle layoutBox)
private Point
getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd)
MinMaxWidth
getMinMaxWidth()
Calculates min and max width values for current renderer.Rectangle
getOccupiedAreaBBox()
Gets the bounding box that contains all content written to theDrawContext
by thisIRenderer
.protected PdfFont
getResolvedFont(PdfDocument pdfDocument)
Get the font set in properties, if it is not set, then resolves the firstPdfFont
fromFontProvider
.(package private) void
handleForcedPlacement(boolean anythingPlaced)
private boolean
isAnythingOccupied()
LayoutResult
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.(package private) LayoutResult
processNotFullChildResult(LayoutContext layoutContext, java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, java.util.List<IRenderer> waitingOverflowFloatRenderers, boolean wasHeightClipped, java.util.List<Rectangle> floatRendererAreas, boolean marginsCollapsingEnabled, float clearHeightCorrection, Border[] borders, UnitValue[] paddings, java.util.List<Rectangle> areas, int currentAreaPos, Rectangle layoutBox, java.util.Set<Rectangle> nonChildFloatingRendererAreas, IRenderer causeOfNothing, boolean anythingPlaced, int childPos, LayoutResult result)
(package private) Rectangle
recalculateLayoutBoxBeforeChildLayout(Rectangle layoutBox, IRenderer childRenderer, Rectangle initialLayoutBox)
(package private) void
recalculateOccupiedAreaAfterChildLayout(Rectangle resultBBox, java.lang.Float blockMaxHeight)
private void
replaceSplitRendererKidFloats(java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, IRenderer splitRenderer)
(package private) MarginsCollapseInfo
startChildMarginsHandling(IRenderer childRenderer, Rectangle layoutBox, MarginsCollapseHandler marginsCollapseHandler)
(package private) boolean
stopLayoutingChildrenIfChildResultNotFull(LayoutResult returnResult)
-
Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllChildRenderers, addAllChildRenderers, addAllProperties, addChild, addChildRenderer, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAbsolutePositionIfNeeded, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyMarginsBordersPaddings, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateAdditionalWidth, calculateBBox, calculatePaddingBorderHeight, calculatePaddingBorderWidth, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createFontCharacteristics, createXObject, deleteOwnProperty, deleteProperty, drawBackground, drawBorder, drawChildren, drawPositionedChildren, endElementOpacityApplying, endTransformationIfApplied, getAspectRatio, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getModelElement, getOccupiedArea, getOwnProperties, getOwnProperty, getPaddings, getParent, getPdfDocument, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, getPropertyAsUnitValue, getRootRenderer, hasAbsoluteUnitValue, hasAspectRatio, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, logWarningIfGetNextRendererNotOverridden, move, noAbsolutePositionInfo, preparePositionedRendererAndAreaForLayout, processWaitingDrawing, rectangleToPointsList, removeAllChildRenderers, removeChildRenderer, replaceOwnProperty, resolveFirstPdfFont, resolveFirstPdfFont, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveUnitValue, retrieveUnitValue, retrieveWidth, returnBackOwnProperty, setBorders, setChildRenderer, setChildRenderers, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, setThisAsParent, shrinkOccupiedAreaForAbsolutePosition, toString, transformPoints, updateHeight, updateHeightsOnSplit, 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
-
-
-
-
Method Detail
-
layout
public LayoutResult 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. 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
public void draw(DrawContext drawContext)
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
public Rectangle 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
protected AbstractRenderer createSplitRenderer(int layoutResult)
Creates a split renderer.- Parameters:
layoutResult
- the result of content layouting- Returns:
- a new
AbstractRenderer
instance
-
createOverflowRenderer
protected AbstractRenderer createOverflowRenderer(int layoutResult)
Creates an overflow renderer.- Parameters:
layoutResult
- the result of content layouting- Returns:
- a new
AbstractRenderer
instance
-
recalculateOccupiedAreaAfterChildLayout
void recalculateOccupiedAreaAfterChildLayout(Rectangle resultBBox, java.lang.Float blockMaxHeight)
-
startChildMarginsHandling
MarginsCollapseInfo startChildMarginsHandling(IRenderer childRenderer, Rectangle layoutBox, MarginsCollapseHandler marginsCollapseHandler)
-
recalculateLayoutBoxBeforeChildLayout
Rectangle recalculateLayoutBoxBeforeChildLayout(Rectangle layoutBox, IRenderer childRenderer, Rectangle initialLayoutBox)
-
createSplitAndOverflowRenderers
AbstractRenderer[] createSplitAndOverflowRenderers(int childPos, int layoutStatus, LayoutResult childResult, java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, java.util.List<IRenderer> waitingOverflowFloatRenderers)
-
applyVerticalAlignment
protected void applyVerticalAlignment()
This method applies vertical alignment for the occupied area of the renderer and its children renderers.
-
applyRotationLayout
protected void applyRotationLayout(Rectangle layoutBox)
This method rotates content of the renderer and calculates correct occupied area for the rotated element.- Parameters:
layoutBox
- aRectangle
-
createRotationTransformInsideOccupiedArea
protected AffineTransform 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
protected void beginRotationIfApplied(PdfCanvas canvas)
This method starts rotation for the renderer if rotation angle property is specified.- Parameters:
canvas
- thePdfCanvas
to draw on
-
endRotationIfApplied
protected void endRotationIfApplied(PdfCanvas canvas)
This method ends rotation for the renderer if applied.- Parameters:
canvas
- thePdfCanvas
to draw on
-
getResolvedFont
protected PdfFont getResolvedFont(PdfDocument pdfDocument)
Get the font set in properties, if it is not set, then resolves the firstPdfFont
fromFontProvider
. IfFontProvider
is not set, then returns null.- Parameters:
pdfDocument
- thePdfDocument
to get default font from.- Returns:
- the font or null if it is not set and
FontProvider
is not set.
-
stopLayoutingChildrenIfChildResultNotFull
boolean stopLayoutingChildrenIfChildResultNotFull(LayoutResult returnResult)
-
processNotFullChildResult
LayoutResult processNotFullChildResult(LayoutContext layoutContext, java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, java.util.List<IRenderer> waitingOverflowFloatRenderers, boolean wasHeightClipped, java.util.List<Rectangle> floatRendererAreas, boolean marginsCollapsingEnabled, float clearHeightCorrection, Border[] borders, UnitValue[] paddings, java.util.List<Rectangle> areas, int currentAreaPos, Rectangle layoutBox, java.util.Set<Rectangle> nonChildFloatingRendererAreas, IRenderer causeOfNothing, boolean anythingPlaced, int childPos, LayoutResult result)
-
decreaseLayoutBoxAfterChildPlacement
void decreaseLayoutBoxAfterChildPlacement(Rectangle layoutBox, LayoutResult result, IRenderer childRenderer)
-
correctFixedLayout
void correctFixedLayout(Rectangle layoutBox)
-
applyWidth
void applyWidth(Rectangle parentBBox, java.lang.Float blockWidth, OverflowPropertyValue overflowX)
-
applyMaxHeight
boolean applyMaxHeight(Rectangle parentBBox, java.lang.Float blockMaxHeight, MarginsCollapseHandler marginsCollapseHandler, boolean isCellRenderer, boolean wasParentsHeightClipped, OverflowPropertyValue overflowY)
-
applyMinHeight
AbstractRenderer applyMinHeight(OverflowPropertyValue overflowY, Rectangle layoutBox)
-
fixOccupiedAreaIfOverflowedX
void fixOccupiedAreaIfOverflowedX(OverflowPropertyValue overflowX, Rectangle layoutBox)
-
fixOccupiedAreaIfOverflowedY
void fixOccupiedAreaIfOverflowedY(OverflowPropertyValue overflowY, Rectangle layoutBox)
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth()
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidth
in classAbstractRenderer
- Returns:
- instance of
MinMaxWidth
-
handleForcedPlacement
void handleForcedPlacement(boolean anythingPlaced)
-
isAnythingOccupied
private boolean isAnythingOccupied()
-
replaceSplitRendererKidFloats
private void replaceSplitRendererKidFloats(java.util.Map<java.lang.Integer,IRenderer> waitingFloatsSplitRenderers, IRenderer splitRenderer)
-
addMarkedContent
private void addMarkedContent(DrawContext drawContext, boolean isBegin)
-
clipPolygon
private java.util.List<Point> clipPolygon(java.util.List<Point> points, Point clipLineBeg, Point clipLineEnd)
-
checkPointSide
private int checkPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd)
-
-