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
Represents a renderer for block elements.
-
Field Summary
Fields inherited from class AbstractRenderer
BOTTOM_SIDE, childRenderers, EPS, flushed, INF, isLastRendererForModelElement, LEFT_SIDE, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties, RIGHT_SIDE, TOP_SIDE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlockRenderer(IElement modelElement) Creates a BlockRenderer from its corresponding layout object. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMarkedContent(DrawContext drawContext, boolean isBegin) (package private) booleanapplyMaxHeight(Rectangle parentBBox, Float blockMaxHeight, MarginsCollapseHandler marginsCollapseHandler, boolean isCellRenderer, boolean wasParentsHeightClipped, OverflowPropertyValue overflowY) (package private) AbstractRendererapplyMinHeight(OverflowPropertyValue overflowY, Rectangle layoutBox) protected voidapplyRotationLayout(Rectangle layoutBox) This method rotates content of the renderer and calculates correct occupied area for the rotated element.protected voidThis method applies vertical alignment for the occupied area of the renderer and its children renderers.(package private) voidapplyWidth(Rectangle parentBBox, Float blockWidth, OverflowPropertyValue overflowX) protected voidbeginRotationIfApplied(PdfCanvas canvas) This method starts rotation for the renderer if rotation angle property is specified.private intcheckPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd) clipPolygon(List<Point> points, Point clipLineBeg, Point clipLineEnd) (package private) voidcorrectFixedLayout(Rectangle layoutBox) protected AbstractRenderercreateOverflowRenderer(int layoutResult) Creates an overflow renderer.protected AffineTransformThis method createsAffineTransforminstance that could be used to rotate content inside the occupied area.(package private) AbstractRenderer[]createSplitAndOverflowRenderers(int childPos, int layoutStatus, LayoutResult childResult, Map<Integer, IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers) protected AbstractRenderercreateSplitRenderer(int layoutResult) Creates a split renderer.(package private) voiddecreaseLayoutBoxAfterChildPlacement(Rectangle layoutBox, LayoutResult result, IRenderer childRenderer) voiddraw(DrawContext drawContext) Flushes the renderer subtree contents, i.e.protected voidendRotationIfApplied(PdfCanvas canvas) This method ends rotation for the renderer if applied.(package private) voidfixOccupiedAreaIfOverflowedX(OverflowPropertyValue overflowX, Rectangle layoutBox) (package private) voidfixOccupiedAreaIfOverflowedY(OverflowPropertyValue overflowY, Rectangle layoutBox) private PointgetIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd) Calculates min and max width values for current renderer.getMinMaxWidth(Float parentBoxWidth) Calculates min and max width values for current renderer.Gets the bounding box that contains all content written to theDrawContextby thisIRenderer.protected PdfFontgetResolvedFont(PdfDocument pdfDocument) Get the font set in properties, if it is not set, then resolves the firstPdfFontfromFontProvider.(package private) voidhandleForcedPlacement(boolean anythingPlaced) private booleanlayout(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) LayoutResultprocessNotFullChildResult(LayoutContext layoutContext, Map<Integer, IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers, boolean wasHeightClipped, List<Rectangle> floatRendererAreas, boolean marginsCollapsingEnabled, float clearHeightCorrection, Border[] borders, UnitValue[] paddings, List<Rectangle> areas, int currentAreaPos, Rectangle layoutBox, Set<Rectangle> nonChildFloatingRendererAreas, IRenderer causeOfNothing, boolean anythingPlaced, int childPos, LayoutResult result) (package private) RectanglerecalculateLayoutBoxBeforeChildLayout(Rectangle layoutBox, IRenderer childRenderer, Rectangle initialLayoutBox) (package private) voidrecalculateOccupiedAreaAfterChildLayout(Rectangle resultBBox, Float blockMaxHeight) private voidreplaceSplitRendererKidFloats(Map<Integer, IRenderer> waitingFloatsSplitRenderers, IRenderer splitRenderer) (package private) MarginsCollapseInfostartChildMarginsHandling(IRenderer childRenderer, Rectangle layoutBox, MarginsCollapseHandler marginsCollapseHandler) (package private) booleanstopLayoutingChildrenIfChildResultNotFull(LayoutResult returnResult) Methods inherited from class 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, retrieveResolvedDeclaredHeight, retrieveUnitValue, retrieveUnitValue, retrieveWidth, returnBackOwnProperty, setBorders, setChildRenderer, setChildRenderers, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, setThisAsParent, shrinkOccupiedAreaForAbsolutePosition, toString, transformPoints, updateHeight, updateHeightsOnSplit, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidthMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IRenderer
getNextRenderer
-
Constructor Details
-
BlockRenderer
-
-
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.LayoutResultcan be extended to return custom layout results for custom elements, e.g.TextRendererusesTextLayoutResultas 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:AbstractRendererFlushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocumentetc.- Specified by:
drawin interfaceIRenderer- Overrides:
drawin classAbstractRenderer- Parameters:
drawContext- contains thePdfDocumentto which the renderer subtree if flushed, thePdfCanvason which the renderer subtree is drawn and other additional parameters needed to perform drawing
-
getOccupiedAreaBBox
Description copied from class:AbstractRendererGets the bounding box that contains all content written to theDrawContextby thisIRenderer.- Overrides:
getOccupiedAreaBBoxin classAbstractRenderer- Returns:
- the smallest
Rectanglethat surrounds the content
-
createSplitRenderer
Creates a split renderer.- Parameters:
layoutResult- the result of content layouting- Returns:
- a new
AbstractRendererinstance
-
createOverflowRenderer
Creates an overflow renderer.- Parameters:
layoutResult- the result of content layouting- Returns:
- a new
AbstractRendererinstance
-
recalculateOccupiedAreaAfterChildLayout
-
startChildMarginsHandling
MarginsCollapseInfo startChildMarginsHandling(IRenderer childRenderer, Rectangle layoutBox, MarginsCollapseHandler marginsCollapseHandler) -
recalculateLayoutBoxBeforeChildLayout
-
createSplitAndOverflowRenderers
AbstractRenderer[] createSplitAndOverflowRenderers(int childPos, int layoutStatus, LayoutResult childResult, Map<Integer, IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers) -
applyVerticalAlignment
protected void applyVerticalAlignment()This method applies vertical alignment for the occupied area of the renderer and its children renderers. -
applyRotationLayout
-
createRotationTransformInsideOccupiedArea
This method createsAffineTransforminstance 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:
AffineTransformthat rotates the content and places it inside occupied area.
-
beginRotationIfApplied
-
endRotationIfApplied
-
getResolvedFont
Get the font set in properties, if it is not set, then resolves the firstPdfFontfromFontProvider. IfFontProvideris not set, then returns null.- Parameters:
pdfDocument- thePdfDocumentto get default font from.- Returns:
- the font or null if it is not set and
FontProvideris not set.
-
stopLayoutingChildrenIfChildResultNotFull
-
processNotFullChildResult
LayoutResult processNotFullChildResult(LayoutContext layoutContext, Map<Integer, IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers, boolean wasHeightClipped, List<Rectangle> floatRendererAreas, boolean marginsCollapsingEnabled, float clearHeightCorrection, Border[] borders, UnitValue[] paddings, List<Rectangle> areas, int currentAreaPos, Rectangle layoutBox, Set<Rectangle> nonChildFloatingRendererAreas, IRenderer causeOfNothing, boolean anythingPlaced, int childPos, LayoutResult result) -
decreaseLayoutBoxAfterChildPlacement
void decreaseLayoutBoxAfterChildPlacement(Rectangle layoutBox, LayoutResult result, IRenderer childRenderer) -
correctFixedLayout
-
applyWidth
-
applyMaxHeight
boolean applyMaxHeight(Rectangle parentBBox, Float blockMaxHeight, MarginsCollapseHandler marginsCollapseHandler, boolean isCellRenderer, boolean wasParentsHeightClipped, OverflowPropertyValue overflowY) -
applyMinHeight
-
fixOccupiedAreaIfOverflowedX
-
fixOccupiedAreaIfOverflowedY
-
getMinMaxWidth
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidthin classAbstractRenderer- Returns:
- instance of
MinMaxWidth
-
getMinMaxWidth
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidthin classAbstractRenderer- Parameters:
parentBoxWidth- max width of the area on which current renderer will be laid out- Returns:
- instance of
MinMaxWidth
-
handleForcedPlacement
void handleForcedPlacement(boolean anythingPlaced) -
isAnythingOccupied
private boolean isAnythingOccupied() -
replaceSplitRendererKidFloats
-
addMarkedContent
-
clipPolygon
-
checkPointSide
-
getIntersectionPoint
-