Package com.itextpdf.layout.renderer
Class MulticolRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.MulticolRenderer
-
- All Implemented Interfaces:
IPropertyContainer,IRenderer
public class MulticolRenderer extends AbstractRenderer
Represents a renderer for columns.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMulticolRenderer.ColumnHeightCalculatorInterface which used for additional height calculationstatic classMulticolRenderer.LayoutInInfiniteHeightCalculatorDefault implementation ofMulticolRenderer.ColumnHeightCalculatorwhich allows 4 relayouts and performs simple additional height calculation (split the elements which don't fit).static classMulticolRenderer.MulticolLayoutResultRepresents result of one iteration of MulticolRenderer layouting It contains split renderers which were lauded on a given height and overflow renderer for which height should be increased, so it can be lauded.
-
Field Summary
Fields Modifier and Type Field Description private floatapproximateHeightprivate intcolumnCountprivate floatcolumnGapprivate floatcolumnWidthprivate floatcontainerWidthprivate BlockRendererelementRendererprivate MulticolRenderer.ColumnHeightCalculatorheightCalculatorprivate java.lang.FloatheightFromPropertiesprivate booleanisFirstLayoutprivate static floatZERO_DELTA-
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 Constructor Description MulticolRenderer(MulticolContainer modelElement)Creates a DivRenderer from its corresponding layout object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidapplyWidth(Rectangle parentBbox, float originalWidth)private MulticolRenderer.MulticolLayoutResultbalanceContentAndLayoutColumns(LayoutContext prelayoutContext, Rectangle actualBbox)private voidcalculateColumnCountAndWidth(float initialWidth)private LayoutAreacalculateContainerOccupiedArea(LayoutContext layoutContext, boolean isFull)private voidclearOverFlowRendererIfNeeded(MulticolRenderer.MulticolLayoutResult result)protected AbstractRenderercreateOverflowRenderer(IRenderer overflowedContentRenderer)Creates an overflow renderer.private java.lang.FloatdetermineHeight(Rectangle parentBBox)voiddrawBorder(DrawContext drawContext)Performs the drawing operation for the border of this renderer, if defined by theProperty.BORDER_TOP,Property.BORDER_RIGHT,Property.BORDER_BOTTOMandProperty.BORDER_LEFTvalues in either the layout element or thisIRendereritself.private voiddrawTaggedWhenNeeded(DrawContext drawContext, java.util.function.Consumer<PdfCanvas> action)private BlockRenderergetElementsRenderer()IRenderergetNextRenderer()Gets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)is called more than once.LayoutResultlayout(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.private MulticolRenderer.MulticolLayoutResultlayoutColumnsAndReturnOverflowRenderer(LayoutContext preLayoutContext, Rectangle actualBBox, float workingHeight)protected MulticolRenderer.MulticolLayoutResultlayoutInColumns(LayoutContext layoutContext, Rectangle actualBBox)Layouts multicol in the passed area.voidsetHeightCalculator(MulticolRenderer.ColumnHeightCalculator heightCalculator)Sets the height calculator to be used by this renderer.private voidsetOverflowForAllChildren(IRenderer renderer)-
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, draw, drawBackground, drawChildren, drawPositionedChildren, endElementOpacityApplying, endTransformationIfApplied, getAspectRatio, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getMinMaxWidth, getMinMaxWidth, getModelElement, getOccupiedArea, getOccupiedAreaBBox, 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, updateWidth
-
-
-
-
Field Detail
-
ZERO_DELTA
private static final float ZERO_DELTA
- See Also:
- Constant Field Values
-
heightCalculator
private MulticolRenderer.ColumnHeightCalculator heightCalculator
-
elementRenderer
private BlockRenderer elementRenderer
-
columnCount
private int columnCount
-
columnWidth
private float columnWidth
-
approximateHeight
private float approximateHeight
-
heightFromProperties
private java.lang.Float heightFromProperties
-
columnGap
private float columnGap
-
containerWidth
private float containerWidth
-
isFirstLayout
private boolean isFirstLayout
-
-
Constructor Detail
-
MulticolRenderer
public MulticolRenderer(MulticolContainer modelElement)
Creates a DivRenderer from its corresponding layout object.- Parameters:
modelElement- theMulticolContainerwhich this object should manage
-
-
Method Detail
-
setHeightCalculator
public final void setHeightCalculator(MulticolRenderer.ColumnHeightCalculator heightCalculator)
Sets the height calculator to be used by this renderer.- Parameters:
heightCalculator- the height calculator to be used by this renderer.
-
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.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
-
getNextRenderer
public IRenderer getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)is called more than once.- Returns:
- new renderer instance
-
drawBorder
public void drawBorder(DrawContext drawContext)
Performs the drawing operation for the border of this renderer, if defined by theProperty.BORDER_TOP,Property.BORDER_RIGHT,Property.BORDER_BOTTOMandProperty.BORDER_LEFTvalues in either the layout element or thisIRendereritself.- Overrides:
drawBorderin classAbstractRenderer- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
layoutInColumns
protected MulticolRenderer.MulticolLayoutResult layoutInColumns(LayoutContext layoutContext, Rectangle actualBBox)
Layouts multicol in the passed area.- Parameters:
layoutContext- the layout contextactualBBox- the area to layout multicol on- Returns:
- the
MulticolRenderer.MulticolLayoutResultinstance
-
createOverflowRenderer
protected AbstractRenderer createOverflowRenderer(IRenderer overflowedContentRenderer)
Creates an overflow renderer.- Parameters:
overflowedContentRenderer- an overflowed content renderer- Returns:
- a new
AbstractRendererinstance
-
setOverflowForAllChildren
private void setOverflowForAllChildren(IRenderer renderer)
-
drawTaggedWhenNeeded
private void drawTaggedWhenNeeded(DrawContext drawContext, java.util.function.Consumer<PdfCanvas> action)
-
applyWidth
private void applyWidth(Rectangle parentBbox, float originalWidth)
-
determineHeight
private java.lang.Float determineHeight(Rectangle parentBBox)
-
balanceContentAndLayoutColumns
private MulticolRenderer.MulticolLayoutResult balanceContentAndLayoutColumns(LayoutContext prelayoutContext, Rectangle actualBbox)
-
calculateColumnCountAndWidth
private void calculateColumnCountAndWidth(float initialWidth)
-
clearOverFlowRendererIfNeeded
private void clearOverFlowRendererIfNeeded(MulticolRenderer.MulticolLayoutResult result)
-
calculateContainerOccupiedArea
private LayoutArea calculateContainerOccupiedArea(LayoutContext layoutContext, boolean isFull)
-
getElementsRenderer
private BlockRenderer getElementsRenderer()
-
layoutColumnsAndReturnOverflowRenderer
private MulticolRenderer.MulticolLayoutResult layoutColumnsAndReturnOverflowRenderer(LayoutContext preLayoutContext, Rectangle actualBBox, float workingHeight)
-
-