Package com.itextpdf.layout.renderer
Class AbstractRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- All Implemented Interfaces:
IPropertyContainer,IRenderer
- Direct Known Subclasses:
BlockRenderer,ImageRenderer,LineRenderer,MulticolRenderer,RootRenderer,TableRenderer,TabRenderer,TextRenderer
public abstract class AbstractRenderer extends java.lang.Object implements IRenderer
Defines the most common properties and behavior that are shared by mostIRendererimplementations. All default Renderers are subclasses of this default implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private static intARC_BOTTOM_DEGREEprivate static intARC_LEFT_DEGREEprivate static intARC_QUARTER_CLOCKWISE_EXTENTprivate static intARC_RIGHT_DEGREEprivate static intARC_TOP_DEGREE(package private) static intBOTTOM_SIDEThe common ordering index of bottom side in arrays of four elements which define top, right, bottom, left sides values (e.g.private static Tuple2<java.lang.String,PdfDictionary>CHECK_TUPLE2_TYPEprotected java.util.List<IRenderer>childRenderersprotected static floatEPSThe maximum difference betweenRectanglecoordinates to consider rectangles equalprotected booleanflushedprotected static floatINFThe infinity value which is used while layoutingprotected booleanisLastRendererForModelElement(package private) static intLEFT_SIDEThe common ordering index of left side in arrays of four elements which define top, right, bottom, left sides values (e.g.protected IPropertyContainermodelElementprotected LayoutAreaoccupiedAreastatic floatOVERLAP_EPSILONprotected IRendererparentprotected java.util.List<IRenderer>positionedRenderersprotected java.util.Map<java.lang.Integer,java.lang.Object>properties(package private) static intRIGHT_SIDEThe common ordering index of right side in arrays of four elements which define top, right, bottom, left sides values (e.g.(package private) static intTOP_SIDEThe common ordering index of top side in arrays of four elements which define top, right, bottom, left sides values (e.g.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRenderer()Creates a renderer.protectedAbstractRenderer(IElement modelElement)Creates a renderer for the specified layout element.protectedAbstractRenderer(AbstractRenderer other)Creates a new renderer based on an instance of another renderer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddAllChildRenderers(int index, java.util.List<IRenderer> children)Inserts the specified collection ofrenderersat the specified space of children list and update their parent links tothis.(package private) voidaddAllChildRenderers(java.util.List<IRenderer> children)Add the specified collection ofrenderersto the end of children list and update their parent links tothis.protected voidaddAllProperties(java.util.Map<java.lang.Integer,java.lang.Object> properties)voidaddChild(IRenderer renderer)Adds a child to the current renderer(package private) voidaddChildRenderer(IRenderer child)Add the specifiedrendererto the end of children list and update its parent link tothis.private voidadjustPositionedRendererLayoutBoxWidth(IRenderer renderer, Rectangle fullBbox, java.lang.Float left, java.lang.Float right)protected voidalignChildHorizontally(IRenderer childRenderer, Rectangle currentArea)protected booleanallowLastYLineRecursiveExtraction()protected voidapplyAbsolutePosition(Rectangle parentRect)(package private) voidapplyAbsolutePositionIfNeeded(LayoutContext layoutContext)protected voidapplyAction(PdfDocument document)private RectangleapplyBackgroundBoxProperty(Rectangle rectangle, BackgroundBox clip)RectangleapplyBorderBox(Rectangle rect, boolean reverse)Applies the border box of the renderer on the given rectangle If the border of a certain side is null, the side will remain as it was.protected RectangleapplyBorderBox(Rectangle rect, Border[] borders, boolean reverse)Applies the given border box (borders) on the given rectangleprotected voidapplyDestination(PdfDocument document)protected voidapplyDestinationsAndAnnotation(DrawContext drawContext)protected voidapplyLinkAnnotation(PdfDocument document)RectangleapplyMargins(Rectangle rect, boolean reverse)Applies margins of the renderer on the given rectangleprotected RectangleapplyMargins(Rectangle rect, UnitValue[] margins, boolean reverse)Applies given margins on the given rectangle(package private) RectangleapplyMarginsBordersPaddings(Rectangle rect, boolean reverse)Applies margins, borders and paddings of the renderer on the given rectangle.RectangleapplyPaddings(Rectangle rect, boolean reverse)Applies paddings of the renderer on the given rectangleprotected RectangleapplyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse)Applies given paddings to the given rectangle.protected voidapplyRelativePositioningTranslation(boolean reverse)protected voidbeginElementOpacityApplying(DrawContext drawContext)ApplyProperty.OPACITYproperty if specified by setting corresponding values in graphic state dictionary opacity will be applied to all elements drawn after calling this method and before callingendElementOpacityApplying(DrawContext)()}.protected voidbeginTransformationIfApplied(PdfCanvas canvas)protected RectanglecalculateAbsolutePdfBBox()Calculates the bounding box of the content in the coordinate system of the pdf entity on which content is placed, e.g.(package private) static floatcalculateAdditionalWidth(AbstractRenderer renderer)protected RectanglecalculateBBox(java.util.List<Point> points)Calculates bounding box around points.(package private) static floatcalculatePaddingBorderHeight(AbstractRenderer renderer)(package private) static floatcalculatePaddingBorderWidth(AbstractRenderer renderer)private float[]calculateRadii(BorderRadius[] radii, Rectangle area, boolean horizontal)Calculates the element corner's border radii.protected float[]calculateShiftToPositionBBoxOfPointsAt(float left, float top, java.util.List<Point> points)This method calculates the shift needed to be applied to the points in order to position upper and left borders of their bounding box at the given lines.private booleanclipArea(DrawContext drawContext, Rectangle outerBorderBox, boolean clipOuter, boolean clipInner, boolean considerBordersBeforeOuterClipping, boolean considerBordersBeforeInnerClipping)protected booleanclipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox)protected booleanclipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox, boolean considerBordersBeforeClipping)protected booleanclipBorderArea(DrawContext drawContext, Rectangle outerBorderBox)private voidclipInnerArea(PdfCanvas canvas, float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY, float[] borderWidths)private voidclipOuterArea(PdfCanvas canvas, float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY)(package private) FontCharacteristicscreateFontCharacteristics()private AffineTransformcreateTransformationInsideOccupiedArea()This method createsAffineTransforminstance that could be used to transform content inside the occupied area, considering the centre of the occupiedArea as the origin of a coordinate system for transformation.static PdfFormXObjectcreateXObject(AbstractLinearGradientBuilder linearGradientBuilder, Rectangle xObjectArea, PdfDocument document)Create aPdfFormXObjectwith the given area and containing a linear gradient inside.private float[]decreaseBorderRadiiWithBorders(float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY)voiddeleteOwnProperty(int property)Deletes the own property of this entity.voiddeleteProperty(int property)Deletes property from this very renderer, or in case the property is specified on its model element, the property of the model element is deletedvoiddraw(DrawContext drawContext)Flushes the renderer subtree contents, i.e.voiddrawBackground(DrawContext drawContext)Draws a background layer if it is defined by a keyProperty.BACKGROUNDin either the layout element or thisIRendereritself.private voiddrawBackgroundImage(BackgroundImage backgroundImage, DrawContext drawContext, Rectangle backgroundArea)private booleandrawBackgroundImagesList(java.util.List<BackgroundImage> backgroundImagesList, boolean backgroundAreaIsClipped, DrawContext drawContext, Rectangle backgroundArea)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.voiddrawChildren(DrawContext drawContext)Performs the drawing operation for allchildrenof this renderer.private voiddrawColorBackground(Background background, DrawContext drawContext, Rectangle colorBackgroundArea)private static voiddrawPdfXObject(Rectangle imageRectangle, BackgroundImage backgroundImage, DrawContext drawContext, PdfXObject backgroundXObject, Rectangle backgroundArea, Rectangle originBackgroundArea)private static voiddrawPdfXObjectHorizontally(Rectangle imageRectangle, BackgroundImage backgroundImage, DrawContext drawContext, PdfXObject backgroundXObject, Rectangle backgroundArea, boolean firstDraw, float xWhitespace)(package private) voiddrawPositionedChildren(DrawContext drawContext)protected voidendElementOpacityApplying(DrawContext drawContext)protected voidendTransformationIfApplied(PdfCanvas canvas)(package private) java.lang.FloatgetAspectRatio()Gets intrinsic aspect ratio for this renderer.protected RectanglegetBackgroundArea(Rectangle occupiedAreaWithMargins)Evaluate the actual backgroundRectanglegetBorderAreaBBox()Gets the border box of a renderer.protected BorderRadius[]getBorderRadii()Gets border radii of the element in the specified order: top-left, top-right, bottom-right, bottom-left.private static BorderRadius[]getBorderRadii(IRenderer renderer)protected Border[]getBorders()Gets borders of the element in the specified order: top, right, bottom, left.(package private) static Border[]getBorders(IRenderer renderer)java.util.List<IRenderer>getChildRenderers()Gets the childIRenderers.private static PdfStructElemgetCurrentStructElem(PdfDocument document)<T1> T1getDefaultProperty(int property)Gets the default property from this entity.protected java.lang.FloatgetFirstYLineRecursively()Gets the first yLine of the nested children recursively.RectanglegetInnerAreaBBox()protected java.lang.FloatgetLastYLineRecursively()protected UnitValue[]getMargins()Returns margins of the renderer [0] - top; [1] - right; [2] - bottom; [3] - leftprivate static UnitValue[]getMargins(IRenderer renderer)MinMaxWidthgetMinMaxWidth()Calculates min and max width values for current renderer.MinMaxWidthgetMinMaxWidth(java.lang.Float areaMaxWidth)Calculates min and max width values for current renderer.IPropertyContainergetModelElement()Gets the model element associated with this renderer.LayoutAreagetOccupiedArea()Gets the resultant occupied area after the last call to theIRenderer.layout(LayoutContext)method.RectanglegetOccupiedAreaBBox()Gets the bounding box that contains all content written to theDrawContextby thisIRenderer.protected java.util.Map<java.lang.Integer,java.lang.Object>getOwnProperties()<T1> T1getOwnProperty(int property)Gets own property from this entity.protected UnitValue[]getPaddings()Returns paddings of the renderer [0] - top; [1] - right; [2] - bottom; [3] - leftprivate static UnitValue[]getPaddings(IRenderer renderer)IRenderergetParent()Gets the parentIRenderer.(package private) PdfDocumentgetPdfDocument()Gets pdf document from root renderers.<T1> T1getProperty(int key)Gets the property from this entity.<T1> T1getProperty(int property, T1 defaultValue)Gets a property from this entity or one of its hierarchical parents.java.lang.BooleangetPropertyAsBoolean(int property)Returns a property with a certain key, as a boolean value.ColorgetPropertyAsColor(int property)Returns a property with a certain key, as a color.java.lang.FloatgetPropertyAsFloat(int property)Returns a property with a certain key, as a floating point value.java.lang.FloatgetPropertyAsFloat(int property, java.lang.Float defaultValue)Returns a property with a certain key, as a floating point value.(package private) static java.lang.FloatgetPropertyAsFloat(IRenderer renderer, int property)PdfFontgetPropertyAsFont(int property)Returns a property with a certain key, as a font object.java.lang.IntegergetPropertyAsInteger(int property)Returns a property with a certain key, as an integer value.TransparentColorgetPropertyAsTransparentColor(int property)Returns a property with a certain key, as aTransparentColor.UnitValuegetPropertyAsUnitValue(int property)Returns a property with a certain key, as a unit value.(package private) static UnitValuegetPropertyAsUnitValue(IRenderer renderer, int property)Returns the property of the renderer as a UnitValue if it exists and is a UnitValue, null otherwise(package private) RootRenderergetRootRenderer()protected booleanhasAbsoluteUnitValue(int property)Check if corresponding property has point value.(package private) booleanhasAspectRatio()Checks if this renderer has intrinsic aspect ratio.booleanhasOwnOrModelProperty(int property)Checks if this renderer or its model element have the specified property, i.e.private static booleanhasOwnOrModelProperty(IRenderer renderer, int property)booleanhasOwnProperty(int property)Checks if this entity has the specified property, i.e.booleanhasProperty(int property)Checks if this entity has the specified property.protected booleanhasRelativeUnitValue(int property)Check if corresponding property has relative value.java.util.List<Rectangle>initElementAreas(LayoutArea area)Gets all rectangles that thisIRenderercan draw upon in the given area.protected booleanisAbsolutePosition()protected static booleanisBorderBoxSizing(IRenderer renderer)booleanisFirstOnRootArea()(package private) booleanisFirstOnRootArea(boolean checkRootAreaOnly)protected booleanisFixedLayout()Indicates whether the renderer's position is fixed or not.booleanisFlushed()Indicates whether this renderer is flushed or not, i.e.protected booleanisKeepTogether()(package private) booleanisKeepTogether(IRenderer causeOfNothing)protected booleanisNotFittingHeight(LayoutArea layoutArea)protected booleanisNotFittingLayoutArea(LayoutArea layoutArea)protected booleanisNotFittingWidth(LayoutArea layoutArea)protected static booleanisOverflowFit(OverflowPropertyValue rendererOverflowProperty)protected booleanisOverflowProperty(OverflowPropertyValue equalsTo, int overflowProperty)protected static booleanisOverflowProperty(OverflowPropertyValue equalsTo, OverflowPropertyValue rendererOverflowProperty)protected static booleanisOverflowProperty(OverflowPropertyValue equalsTo, IRenderer renderer, int overflowProperty)protected booleanisPositioned()Indicates whether the renderer's position is fixed or not.protected booleanisRelativePosition()protected booleanisStaticLayout()(package private) booleanlogWarningIfGetNextRendererNotOverridden(java.lang.Class<?> baseClass, java.lang.Class<?> rendererClass)voidmove(float dxRight, float dyUp)Moves the renderer subtree by the specified offset.(package private) static booleannoAbsolutePositionInfo(IRenderer renderer)(package private) voidpreparePositionedRendererAndAreaForLayout(IRenderer childPositionedRenderer, Rectangle fullBbox, Rectangle parentBbox)(package private) static voidprocessWaitingDrawing(IRenderer child, Transform transformProp, java.util.List<IRenderer> waitingDrawing)protected java.util.List<Point>rectangleToPointsList(Rectangle rect)(package private) booleanremoveAllChildRenderers(java.util.Collection<IRenderer> children)Remove the childrenrendererswhich are contains in the specified collection.(package private) IRendererremoveChildRenderer(int index)Remove the childrendererat the specified place.private voidremoveThisFromParent(IRenderer toRemove)private voidremoveThisFromParents(java.util.Collection<IRenderer> children)(package private) <T> TreplaceOwnProperty(int property, T replacementValue)Replaces given property own value with the given value.(package private) PdfFontresolveFirstPdfFont()Gets any validPdfFontfor this renderer, based onProperty.FONT,Property.FONT_PROVIDERandProperty.FONT_SETproperties.(package private) PdfFontresolveFirstPdfFont(java.lang.String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts)Get first validPdfFontfor this renderer, based on given font-families, font provider and font characteristics.private java.lang.FloatretrieveDirectParentDeclaredHeight()Retrieve the direct parent's absolute height propertyprotected java.lang.FloatretrieveHeight()Retrieves the element's fixed content box height, if it's set.protected java.lang.FloatretrieveMaxHeight()Retrieve element's content box max-ehight, if it's set.protected java.lang.FloatretrieveMaxWidth(float parentBoxWidth)Retrieves element's fixed content box max width, if it's set.protected java.lang.FloatretrieveMinHeight()Retrieves element's content box min-height, if it's set.protected java.lang.FloatretrieveMinWidth(float parentBoxWidth)Retrieves element's fixed content box max width, if it's set.protected java.lang.FloatretrieveResolvedDeclaredHeight()Retrieve the resolved height declaration.protected java.lang.FloatretrieveUnitValue(float baseValue, int property)protected java.lang.FloatretrieveUnitValue(float baseValue, int property, boolean pointOnly)protected java.lang.FloatretrieveWidth(float parentBoxWidth)Retrieves element's fixed content box width, if it's set.(package private) <T> voidreturnBackOwnProperty(int property, T prevValue)Returns back own value of the given property.protected AbstractRenderersetBorders(Border border, int borderNumber)(package private) IRenderersetChildRenderer(int index, IRenderer child)Update the childrendererat the specified place with the specified one.(package private) voidsetChildRenderers(java.util.List<IRenderer> children)Set the specified collection ofrenderersas the children forthiselement.protected booleansetMinMaxWidthBasedOnFixedWidth(MinMaxWidth minMaxWidth)IRenderersetParent(IRenderer parent)Explicitly sets this object as the child of anotherIRendererin the renderer hierarchy.voidsetProperty(int property, java.lang.Object value)Sets a property for this entity.(package private) voidsetThisAsParent(java.util.Collection<IRenderer> children)Sets currentAbstractRendereras parent to renderers in specified collection.(package private) voidshrinkOccupiedAreaForAbsolutePosition()java.lang.StringtoString()Returns a string representation of the renderer.protected java.util.List<Point>transformPoints(java.util.List<Point> points, AffineTransform transform)protected voidupdateHeight(UnitValue updatedHeight)Updates fixed content box height value for this renderer.protected voidupdateHeightsOnSplit(boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer)(package private) voidupdateHeightsOnSplit(float usedHeight, boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer, boolean enlargeOccupiedAreaOnHeightWasClipped)protected voidupdateMaxHeight(UnitValue updatedMaxHeight)Updates content box max-height value for this renderer.protected voidupdateMinHeight(UnitValue updatedMinHeight)Updates content box min-height value for this renderer.private voidupdateMinHeightForAbsolutelyPositionedRenderer(IRenderer renderer, Rectangle parentRendererBox, java.lang.Float top, java.lang.Float bottom)protected voidupdateWidth(UnitValue updatedWidthValue)Updates fixed content box width value for this renderer.-
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, layout
-
-
-
-
Field Detail
-
OVERLAP_EPSILON
public static final float OVERLAP_EPSILON
- See Also:
- Constant Field Values
-
EPS
protected static final float EPS
The maximum difference betweenRectanglecoordinates to consider rectangles equal- See Also:
- Constant Field Values
-
INF
protected static final float INF
The infinity value which is used while layouting- See Also:
- Constant Field Values
-
TOP_SIDE
static final int TOP_SIDE
The common ordering index of top side in arrays of four elements which define top, right, bottom, left sides values (e.g. margins, borders, paddings).- See Also:
- Constant Field Values
-
RIGHT_SIDE
static final int RIGHT_SIDE
The common ordering index of right side in arrays of four elements which define top, right, bottom, left sides values (e.g. margins, borders, paddings).- See Also:
- Constant Field Values
-
BOTTOM_SIDE
static final int BOTTOM_SIDE
The common ordering index of bottom side in arrays of four elements which define top, right, bottom, left sides values (e.g. margins, borders, paddings).- See Also:
- Constant Field Values
-
LEFT_SIDE
static final int LEFT_SIDE
The common ordering index of left side in arrays of four elements which define top, right, bottom, left sides values (e.g. margins, borders, paddings).- See Also:
- Constant Field Values
-
ARC_RIGHT_DEGREE
private static final int ARC_RIGHT_DEGREE
- See Also:
- Constant Field Values
-
ARC_TOP_DEGREE
private static final int ARC_TOP_DEGREE
- See Also:
- Constant Field Values
-
ARC_LEFT_DEGREE
private static final int ARC_LEFT_DEGREE
- See Also:
- Constant Field Values
-
ARC_BOTTOM_DEGREE
private static final int ARC_BOTTOM_DEGREE
- See Also:
- Constant Field Values
-
ARC_QUARTER_CLOCKWISE_EXTENT
private static final int ARC_QUARTER_CLOCKWISE_EXTENT
- See Also:
- Constant Field Values
-
CHECK_TUPLE2_TYPE
private static final Tuple2<java.lang.String,PdfDictionary> CHECK_TUPLE2_TYPE
-
childRenderers
protected java.util.List<IRenderer> childRenderers
-
positionedRenderers
protected java.util.List<IRenderer> positionedRenderers
-
modelElement
protected IPropertyContainer modelElement
-
flushed
protected boolean flushed
-
occupiedArea
protected LayoutArea occupiedArea
-
parent
protected IRenderer parent
-
properties
protected java.util.Map<java.lang.Integer,java.lang.Object> properties
-
isLastRendererForModelElement
protected boolean isLastRendererForModelElement
-
-
Constructor Detail
-
AbstractRenderer
protected AbstractRenderer()
Creates a renderer.
-
AbstractRenderer
protected AbstractRenderer(IElement modelElement)
Creates a renderer for the specified layout element.- Parameters:
modelElement- the layout element that will be drawn by this renderer
-
AbstractRenderer
protected AbstractRenderer(AbstractRenderer other)
Creates a new renderer based on an instance of another renderer.- Parameters:
other- renderer from which to copy essential properties
-
-
Method Detail
-
addChild
public void addChild(IRenderer renderer)
Adds a child to the current renderer
-
getModelElement
public IPropertyContainer getModelElement()
Gets the model element associated with this renderer.- Specified by:
getModelElementin interfaceIRenderer- Returns:
- the model element, as a
container of properties
-
getChildRenderers
public java.util.List<IRenderer> getChildRenderers()
Gets the childIRenderers.- Specified by:
getChildRenderersin interfaceIRenderer- Returns:
- a list of direct child
renderersof this instance
-
hasProperty
public boolean hasProperty(int property)
Checks if this entity has the specified property. Compared toIPropertyContainer.hasOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance- Specified by:
hasPropertyin interfaceIPropertyContainer- Parameters:
property- the property to be checked- Returns:
trueif this instance has given property,falseotherwise
-
hasOwnProperty
public boolean hasOwnProperty(int property)
Checks if this entity has the specified property, i.e. if it was set to this very element earlier- Specified by:
hasOwnPropertyin interfaceIPropertyContainer- Parameters:
property- the property to be checked- Returns:
trueif this instance has given own property,falseotherwise
-
hasOwnOrModelProperty
public boolean hasOwnOrModelProperty(int property)
Checks if this renderer or its model element have the specified property, i.e. if it was set to this very element or its very model element earlier.- Parameters:
property- the property to be checked- Returns:
trueif this instance or its model element have given own property,falseotherwise
-
deleteOwnProperty
public void deleteOwnProperty(int property)
Deletes the own property of this entity.- Specified by:
deleteOwnPropertyin interfaceIPropertyContainer- Parameters:
property- the property to be deleted
-
deleteProperty
public void deleteProperty(int property)
Deletes property from this very renderer, or in case the property is specified on its model element, the property of the model element is deleted- Parameters:
property- the property key to be deleted
-
getProperty
public <T1> T1 getProperty(int key)
Gets the property from this entity. Compared toIPropertyContainer.getOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance- Specified by:
getPropertyin interfaceIPropertyContainer- Type Parameters:
T1- the return type associated with the property- Parameters:
key- the property to be retrieved- Returns:
- the value of the given property.
nullwill be returned if the property value was not found
-
getOwnProperty
public <T1> T1 getOwnProperty(int property)
Gets own property from this entity. The property must have been set earlier to this entity. If the property is not found,nullwill be returned.- Specified by:
getOwnPropertyin interfaceIPropertyContainer- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieved- Returns:
- the value of the given own property.
nullwill be returned if the property value was not found
-
getProperty
public <T1> T1 getProperty(int property, T1 defaultValue)Gets a property from this entity or one of its hierarchical parents. If the property is not found,defaultValuewill be returned.- Specified by:
getPropertyin interfaceIRenderer- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieveddefaultValue- a fallback value- Returns:
- the value of the given property
-
setProperty
public void setProperty(int property, java.lang.Object value)Sets a property for this entity.- Specified by:
setPropertyin interfaceIPropertyContainer- Parameters:
property- the property to be setvalue- the value of the property
-
getDefaultProperty
public <T1> T1 getDefaultProperty(int property)
Gets the default property from this entity.- Specified by:
getDefaultPropertyin interfaceIPropertyContainer- Type Parameters:
T1- the return type associated with the property- Parameters:
property- the property to be retrieved- Returns:
- the default property value. If the default property is not defined,
nullwill be returned
-
getPropertyAsFont
public PdfFont getPropertyAsFont(int property)
Returns a property with a certain key, as a font object.- Parameters:
property- anenum value- Returns:
- a
PdfFont
-
getPropertyAsColor
public Color getPropertyAsColor(int property)
Returns a property with a certain key, as a color.- Parameters:
property- anenum value- Returns:
- a
Color
-
getPropertyAsTransparentColor
public TransparentColor getPropertyAsTransparentColor(int property)
Returns a property with a certain key, as aTransparentColor.- Parameters:
property- anenum value- Returns:
- a
TransparentColor
-
getPropertyAsFloat
public java.lang.Float getPropertyAsFloat(int property)
Returns a property with a certain key, as a floating point value.- Parameters:
property- anenum value- Returns:
- a
Float
-
getPropertyAsFloat
public java.lang.Float getPropertyAsFloat(int property, java.lang.Float defaultValue)Returns a property with a certain key, as a floating point value.- Parameters:
property- anenum valuedefaultValue- default value to be returned if property is not found- Returns:
- a
Float
-
getPropertyAsBoolean
public java.lang.Boolean getPropertyAsBoolean(int property)
Returns a property with a certain key, as a boolean value.- Parameters:
property- anenum value- Returns:
- a
Boolean
-
getPropertyAsUnitValue
public UnitValue getPropertyAsUnitValue(int property)
Returns a property with a certain key, as a unit value.- Parameters:
property- anenum value- Returns:
- a
UnitValue
-
getPropertyAsInteger
public java.lang.Integer getPropertyAsInteger(int property)
Returns a property with a certain key, as an integer value.- Parameters:
property- anenum value- Returns:
- a
Integer
-
toString
public java.lang.String toString()
Returns a string representation of the renderer.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
String - See Also:
Object.toString()
-
getOccupiedArea
public LayoutArea getOccupiedArea()
Gets the resultant occupied area after the last call to theIRenderer.layout(LayoutContext)method.- Specified by:
getOccupiedAreain interfaceIRenderer- Returns:
LayoutAreainstance
-
draw
public void draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocumentetc.- Specified by:
drawin interfaceIRenderer- 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
-
beginElementOpacityApplying
protected void beginElementOpacityApplying(DrawContext drawContext)
ApplyProperty.OPACITYproperty if specified by setting corresponding values in graphic state dictionary opacity will be applied to all elements drawn after calling this method and before callingendElementOpacityApplying(DrawContext)()}.- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
endElementOpacityApplying
protected void endElementOpacityApplying(DrawContext drawContext)
- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
drawBackground
public void drawBackground(DrawContext drawContext)
Draws a background layer if it is defined by a keyProperty.BACKGROUNDin either the layout element or thisIRendereritself.- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
drawColorBackground
private void drawColorBackground(Background background, DrawContext drawContext, Rectangle colorBackgroundArea)
-
applyBackgroundBoxProperty
private Rectangle applyBackgroundBoxProperty(Rectangle rectangle, BackgroundBox clip)
-
drawBackgroundImagesList
private boolean drawBackgroundImagesList(java.util.List<BackgroundImage> backgroundImagesList, boolean backgroundAreaIsClipped, DrawContext drawContext, Rectangle backgroundArea)
-
drawBackgroundImage
private void drawBackgroundImage(BackgroundImage backgroundImage, DrawContext drawContext, Rectangle backgroundArea)
-
drawPdfXObject
private static void drawPdfXObject(Rectangle imageRectangle, BackgroundImage backgroundImage, DrawContext drawContext, PdfXObject backgroundXObject, Rectangle backgroundArea, Rectangle originBackgroundArea)
-
drawPdfXObjectHorizontally
private static void drawPdfXObjectHorizontally(Rectangle imageRectangle, BackgroundImage backgroundImage, DrawContext drawContext, PdfXObject backgroundXObject, Rectangle backgroundArea, boolean firstDraw, float xWhitespace)
-
createXObject
public static PdfFormXObject createXObject(AbstractLinearGradientBuilder linearGradientBuilder, Rectangle xObjectArea, PdfDocument document)
Create aPdfFormXObjectwith the given area and containing a linear gradient inside.- Parameters:
linearGradientBuilder- the linear gradient builderxObjectArea- the result object areadocument- the pdf document- Returns:
- the xObject with a specified area and a linear gradient
-
getBackgroundArea
protected Rectangle getBackgroundArea(Rectangle occupiedAreaWithMargins)
Evaluate the actual background- Parameters:
occupiedAreaWithMargins- the current occupied area with applied margins- Returns:
- the actual background area
-
clipBorderArea
protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderBox)
-
clipBackgroundArea
protected boolean clipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox)
-
clipBackgroundArea
protected boolean clipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox, boolean considerBordersBeforeClipping)
-
clipArea
private boolean clipArea(DrawContext drawContext, Rectangle outerBorderBox, boolean clipOuter, boolean clipInner, boolean considerBordersBeforeOuterClipping, boolean considerBordersBeforeInnerClipping)
-
clipOuterArea
private void clipOuterArea(PdfCanvas canvas, float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY)
-
clipInnerArea
private void clipInnerArea(PdfCanvas canvas, float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY, float[] borderWidths)
-
decreaseBorderRadiiWithBorders
private float[] decreaseBorderRadiiWithBorders(float[] horizontalRadii, float[] verticalRadii, float[] outerBox, float[] cornersX, float[] cornersY)
-
drawChildren
public void drawChildren(DrawContext drawContext)
Performs the drawing operation for allchildrenof this renderer.- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
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.- Parameters:
drawContext- the context (canvas, document, etc.) of this drawing operation
-
isFlushed
public boolean isFlushed()
Indicates whether this renderer is flushed or not, i.e. ifdraw(DrawContext)has already been called.- Specified by:
isFlushedin interfaceIRenderer- Returns:
- whether the renderer has been flushed
- See Also:
draw(com.itextpdf.layout.renderer.DrawContext)
-
setParent
public IRenderer setParent(IRenderer parent)
Explicitly sets this object as the child of anotherIRendererin the renderer hierarchy. Some implementations also use this method internally to create a consistent hierarchy tree.
-
move
public void move(float dxRight, float dyUp)Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.
-
initElementAreas
public java.util.List<Rectangle> initElementAreas(LayoutArea area)
Gets all rectangles that thisIRenderercan draw upon in the given area.- Parameters:
area- a physical area on theDrawContext- Returns:
- a list of
rectangles
-
getOccupiedAreaBBox
public Rectangle getOccupiedAreaBBox()
Gets the bounding box that contains all content written to theDrawContextby thisIRenderer.- Returns:
- the smallest
Rectanglethat surrounds the content
-
getBorderAreaBBox
public Rectangle getBorderAreaBBox()
Gets the border box of a renderer. This is a box used to draw borders.- Returns:
- border box of a renderer
-
getInnerAreaBBox
public Rectangle getInnerAreaBBox()
-
applyMarginsBordersPaddings
Rectangle applyMarginsBordersPaddings(Rectangle rect, boolean reverse)
Applies margins, borders and paddings of the renderer on the given rectangle.- Parameters:
rect- a rectangle margins, borders and paddings will be applied on.reverse- indicates whether margins, borders and paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer
-
applyMargins
public Rectangle applyMargins(Rectangle rect, boolean reverse)
Applies margins of the renderer on the given rectangle- Parameters:
rect- a rectangle margins will be applied on.reverse- indicates whether margins will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer - See Also:
getMargins()
-
applyBorderBox
public Rectangle applyBorderBox(Rectangle rect, boolean reverse)
Applies the border box of the renderer on the given rectangle If the border of a certain side is null, the side will remain as it was.- Parameters:
rect- a rectangle the border box will be applied on.reverse- indicates whether the border box will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer - See Also:
getBorders()
-
applyPaddings
public Rectangle applyPaddings(Rectangle rect, boolean reverse)
Applies paddings of the renderer on the given rectangle- Parameters:
rect- a rectangle paddings will be applied on.reverse- indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer - See Also:
getPaddings()
-
isFirstOnRootArea
public boolean isFirstOnRootArea()
-
applyDestinationsAndAnnotation
protected void applyDestinationsAndAnnotation(DrawContext drawContext)
-
isBorderBoxSizing
protected static boolean isBorderBoxSizing(IRenderer renderer)
-
isOverflowProperty
protected boolean isOverflowProperty(OverflowPropertyValue equalsTo, int overflowProperty)
-
isOverflowProperty
protected static boolean isOverflowProperty(OverflowPropertyValue equalsTo, IRenderer renderer, int overflowProperty)
-
isOverflowProperty
protected static boolean isOverflowProperty(OverflowPropertyValue equalsTo, OverflowPropertyValue rendererOverflowProperty)
-
isOverflowFit
protected static boolean isOverflowFit(OverflowPropertyValue rendererOverflowProperty)
-
replaceOwnProperty
<T> T replaceOwnProperty(int property, T replacementValue)Replaces given property own value with the given value.- Type Parameters:
T- the type associated with the property- Parameters:
property- the property to be replacedreplacementValue- the value with which property will be replaced- Returns:
- previous property value
-
returnBackOwnProperty
<T> void returnBackOwnProperty(int property, T prevValue)Returns back own value of the given property.- Type Parameters:
T- the type associated with the property- Parameters:
property- the property to be returned backprevValue- the value which will be returned back
-
hasAspectRatio
boolean hasAspectRatio()
Checks if this renderer has intrinsic aspect ratio.- Returns:
- true, if aspect ratio is defined for this renderer, false otherwise
-
getAspectRatio
java.lang.Float getAspectRatio()
Gets intrinsic aspect ratio for this renderer.- Returns:
- aspect ratio, if it is defined for this renderer, null otherwise
-
processWaitingDrawing
static void processWaitingDrawing(IRenderer child, Transform transformProp, java.util.List<IRenderer> waitingDrawing)
-
retrieveWidth
protected java.lang.Float retrieveWidth(float parentBoxWidth)
Retrieves element's fixed content box width, if it's set. Takes into accountProperty.BOX_SIZING,Property.MIN_WIDTH, andProperty.MAX_WIDTHproperties.- Parameters:
parentBoxWidth- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.- Returns:
- element's fixed content box width or null if it's not set.
- See Also:
hasAbsoluteUnitValue(int)
-
retrieveMaxWidth
protected java.lang.Float retrieveMaxWidth(float parentBoxWidth)
Retrieves element's fixed content box max width, if it's set. Takes into accountProperty.BOX_SIZINGandProperty.MIN_WIDTHproperties.- Parameters:
parentBoxWidth- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.- Returns:
- element's fixed content box max width or null if it's not set.
- See Also:
hasAbsoluteUnitValue(int)
-
retrieveMinWidth
protected java.lang.Float retrieveMinWidth(float parentBoxWidth)
Retrieves element's fixed content box max width, if it's set. Takes into accountProperty.BOX_SIZINGproperty value.- Parameters:
parentBoxWidth- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.- Returns:
- element's fixed content box max width or null if it's not set.
- See Also:
hasAbsoluteUnitValue(int)
-
updateWidth
protected void updateWidth(UnitValue updatedWidthValue)
Updates fixed content box width value for this renderer. Takes into accountProperty.BOX_SIZINGproperty value.- Parameters:
updatedWidthValue- element's new fixed content box width.
-
retrieveHeight
protected java.lang.Float retrieveHeight()
Retrieves the element's fixed content box height, if it's set. Takes into accountProperty.BOX_SIZING,Property.MIN_HEIGHT, andProperty.MAX_HEIGHTproperties.- Returns:
- element's fixed content box height or null if it's not set.
-
calculateRadii
private float[] calculateRadii(BorderRadius[] radii, Rectangle area, boolean horizontal)
Calculates the element corner's border radii.- Parameters:
radii- defines border radii of the elementarea- defines the area of the elementhorizontal- defines whether horizontal or vertical radii should be calculated- Returns:
- the element corner's border radii.
-
updateHeight
protected void updateHeight(UnitValue updatedHeight)
Updates fixed content box height value for this renderer. Takes into accountProperty.BOX_SIZINGproperty value.- Parameters:
updatedHeight- element's new fixed content box height, shall be not null.
-
retrieveMaxHeight
protected java.lang.Float retrieveMaxHeight()
Retrieve element's content box max-ehight, if it's set. Takes into accountProperty.BOX_SIZINGproperty value.- Returns:
- element's content box max-height or null if it's not set.
-
updateMaxHeight
protected void updateMaxHeight(UnitValue updatedMaxHeight)
Updates content box max-height value for this renderer. Takes into accountProperty.BOX_SIZINGproperty value.- Parameters:
updatedMaxHeight- element's new content box max-height, shall be not null.
-
retrieveMinHeight
protected java.lang.Float retrieveMinHeight()
Retrieves element's content box min-height, if it's set. Takes into accountProperty.BOX_SIZINGproperty value.- Returns:
- element's content box min-height or null if it's not set.
-
updateMinHeight
protected void updateMinHeight(UnitValue updatedMinHeight)
Updates content box min-height value for this renderer. Takes into accountProperty.BOX_SIZINGproperty value.- Parameters:
updatedMinHeight- element's new content box min-height, shall be not null.
-
retrieveUnitValue
protected java.lang.Float retrieveUnitValue(float baseValue, int property)
-
retrieveUnitValue
protected java.lang.Float retrieveUnitValue(float baseValue, int property, boolean pointOnly)
-
getOwnProperties
protected java.util.Map<java.lang.Integer,java.lang.Object> getOwnProperties()
-
addAllProperties
protected void addAllProperties(java.util.Map<java.lang.Integer,java.lang.Object> properties)
-
getFirstYLineRecursively
protected java.lang.Float getFirstYLineRecursively()
Gets the first yLine of the nested children recursively. E.g. for a list, this will be the yLine of the first item (if the first item is indeed a paragraph). NOTE: this method will no go further than the first child.- Returns:
- the first yline of the nested children, null if there is no text found
-
getLastYLineRecursively
protected java.lang.Float getLastYLineRecursively()
-
allowLastYLineRecursiveExtraction
protected boolean allowLastYLineRecursiveExtraction()
-
applyMargins
protected Rectangle applyMargins(Rectangle rect, UnitValue[] margins, boolean reverse)
Applies given margins on the given rectangle- Parameters:
rect- a rectangle margins will be applied on.margins- the margins to be applied on the given rectanglereverse- indicates whether margins will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer
-
getMargins
protected UnitValue[] getMargins()
Returns margins of the renderer [0] - top; [1] - right; [2] - bottom; [3] - left- Returns:
- a
float[]margins of the renderer
-
getPaddings
protected UnitValue[] getPaddings()
Returns paddings of the renderer [0] - top; [1] - right; [2] - bottom; [3] - left- Returns:
- a
float[]paddings of the renderer
-
applyPaddings
protected Rectangle applyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse)
Applies given paddings to the given rectangle.- Parameters:
rect- a rectangle paddings will be applied on.paddings- the paddings to be applied on the given rectanglereverse- indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- a
border boxof the renderer
-
applyBorderBox
protected Rectangle applyBorderBox(Rectangle rect, Border[] borders, boolean reverse)
Applies the given border box (borders) on the given rectangle- Parameters:
rect- a rectangle paddings will be applied on.borders- thebordersto be applied on the given rectanglereverse- indicates whether the border box will be applied inside (in case of false) or outside (in case of false) the rectangle.- Returns:
- a
border boxof the renderer
-
applyAbsolutePosition
protected void applyAbsolutePosition(Rectangle parentRect)
-
applyRelativePositioningTranslation
protected void applyRelativePositioningTranslation(boolean reverse)
-
applyDestination
protected void applyDestination(PdfDocument document)
-
applyAction
protected void applyAction(PdfDocument document)
-
applyLinkAnnotation
protected void applyLinkAnnotation(PdfDocument document)
-
retrieveResolvedDeclaredHeight
protected java.lang.Float retrieveResolvedDeclaredHeight()
Retrieve the resolved height declaration. If it has a relative height declaration,retrieveHeight()is called.- Returns:
nullif no height declaration is set on the parent, or if its own height declaration cannot be resolved. The float value of the resolved height otherwise
-
retrieveDirectParentDeclaredHeight
private java.lang.Float retrieveDirectParentDeclaredHeight()
Retrieve the direct parent's absolute height property- Returns:
- the direct parent's absolute height property value if it exists, null otherwise
-
updateHeightsOnSplit
protected void updateHeightsOnSplit(boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer)
-
updateHeightsOnSplit
void updateHeightsOnSplit(float usedHeight, boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer, boolean enlargeOccupiedAreaOnHeightWasClipped)
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth()
Calculates min and max width values for current renderer.- Returns:
- instance of
MinMaxWidth
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth(java.lang.Float areaMaxWidth)
Calculates min and max width values for current renderer.- Parameters:
areaMaxWidth- max width of the area on which current renderer will be laid out- Returns:
- instance of
MinMaxWidth
-
setMinMaxWidthBasedOnFixedWidth
protected boolean setMinMaxWidthBasedOnFixedWidth(MinMaxWidth minMaxWidth)
-
isNotFittingHeight
protected boolean isNotFittingHeight(LayoutArea layoutArea)
-
isNotFittingWidth
protected boolean isNotFittingWidth(LayoutArea layoutArea)
-
isNotFittingLayoutArea
protected boolean isNotFittingLayoutArea(LayoutArea layoutArea)
-
isPositioned
protected boolean isPositioned()
Indicates whether the renderer's position is fixed or not.- Returns:
- a
boolean
-
isFixedLayout
protected boolean isFixedLayout()
Indicates whether the renderer's position is fixed or not.- Returns:
- a
boolean
-
isStaticLayout
protected boolean isStaticLayout()
-
isRelativePosition
protected boolean isRelativePosition()
-
isAbsolutePosition
protected boolean isAbsolutePosition()
-
isKeepTogether
protected boolean isKeepTogether()
-
isKeepTogether
boolean isKeepTogether(IRenderer causeOfNothing)
-
alignChildHorizontally
protected void alignChildHorizontally(IRenderer childRenderer, Rectangle currentArea)
-
getBorders
protected Border[] getBorders()
Gets borders of the element in the specified order: top, right, bottom, left.- Returns:
- an array of BorderDrawer objects.
In case when certain border isn't set
Property.BORDERis used, and ifProperty.BORDERis also not set thennullis returned on position of this border
-
getBorderRadii
protected BorderRadius[] getBorderRadii()
Gets border radii of the element in the specified order: top-left, top-right, bottom-right, bottom-left.- Returns:
- an array of BorderRadius objects.
In case when certain border radius isn't set
Property.BORDER_RADIUSis used, and ifProperty.BORDER_RADIUSis also not set thennullis returned on position of this border radius
-
setBorders
protected AbstractRenderer setBorders(Border border, int borderNumber)
-
calculateAbsolutePdfBBox
protected Rectangle calculateAbsolutePdfBBox()
Calculates the bounding box of the content in the coordinate system of the pdf entity on which content is placed, e.g. document page or form xObject. This is particularly useful for the cases when element is nested in the rotated element.- Returns:
- a
Rectanglewhich is a bbox of the content not relative to the parent's layout area but rather to the some pdf entity coordinate system.
-
calculateBBox
protected Rectangle calculateBBox(java.util.List<Point> points)
Calculates bounding box around points.- Parameters:
points- list of the points calculated bbox will enclose.- Returns:
- array of float values which denote left, bottom, right, top lines of bbox in this specific order
-
transformPoints
protected java.util.List<Point> transformPoints(java.util.List<Point> points, AffineTransform transform)
-
calculateShiftToPositionBBoxOfPointsAt
protected float[] calculateShiftToPositionBBoxOfPointsAt(float left, float top, java.util.List<Point> points)This method calculates the shift needed to be applied to the points in order to position upper and left borders of their bounding box at the given lines.- Parameters:
left- x coordinate at which points bbox left border is to be alignedtop- y coordinate at which points bbox upper border is to be alignedpoints- the points, which bbox will be aligned at the given position- Returns:
- array of two floats, where first element denotes x-coordinate shift and the second element denotes y-coordinate shift which are needed to align points bbox at the given lines.
-
hasAbsoluteUnitValue
protected boolean hasAbsoluteUnitValue(int property)
Check if corresponding property has point value.- Parameters:
property-Property- Returns:
- false if property value either null, or percent, otherwise true.
-
hasRelativeUnitValue
protected boolean hasRelativeUnitValue(int property)
Check if corresponding property has relative value.- Parameters:
property-Property- Returns:
- false if property value either null, or point, otherwise true.
-
isFirstOnRootArea
boolean isFirstOnRootArea(boolean checkRootAreaOnly)
-
getPdfDocument
PdfDocument getPdfDocument()
Gets pdf document from root renderers.- Returns:
- PdfDocument, or null if there are no document
-
getRootRenderer
RootRenderer getRootRenderer()
-
calculateAdditionalWidth
static float calculateAdditionalWidth(AbstractRenderer renderer)
-
noAbsolutePositionInfo
static boolean noAbsolutePositionInfo(IRenderer renderer)
-
getPropertyAsFloat
static java.lang.Float getPropertyAsFloat(IRenderer renderer, int property)
-
getPropertyAsUnitValue
static UnitValue getPropertyAsUnitValue(IRenderer renderer, int property)
Returns the property of the renderer as a UnitValue if it exists and is a UnitValue, null otherwise- Parameters:
renderer- renderer to retrieve the property fromproperty- key for the property to retrieve- Returns:
- A UnitValue if the property is present and is a UnitValue, null otherwise
-
shrinkOccupiedAreaForAbsolutePosition
void shrinkOccupiedAreaForAbsolutePosition()
-
drawPositionedChildren
void drawPositionedChildren(DrawContext drawContext)
-
createFontCharacteristics
FontCharacteristics createFontCharacteristics()
-
resolveFirstPdfFont
PdfFont resolveFirstPdfFont()
Gets any validPdfFontfor this renderer, based onProperty.FONT,Property.FONT_PROVIDERandProperty.FONT_SETproperties. This method will not change font property of renderer. Also it is not guarantied that returned font will contain all glyphs used in renderer or its children.This method is usually needed for evaluating some layout characteristics like ascender or descender.
- Returns:
- a valid
PdfFontinstance based on rendererProperty.FONTproperty.
-
resolveFirstPdfFont
PdfFont resolveFirstPdfFont(java.lang.String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts)
Get first validPdfFontfor this renderer, based on given font-families, font provider and font characteristics. This method will not change font property of renderer. Also it is not guarantied that returned font will contain all glyphs used in renderer or its children.This method is usually needed for evaluating some layout characteristics like ascender or descender.
- Returns:
- a valid
PdfFontinstance based on rendererProperty.FONTproperty.
-
applyAbsolutePositionIfNeeded
void applyAbsolutePositionIfNeeded(LayoutContext layoutContext)
-
preparePositionedRendererAndAreaForLayout
void preparePositionedRendererAndAreaForLayout(IRenderer childPositionedRenderer, Rectangle fullBbox, Rectangle parentBbox)
-
updateMinHeightForAbsolutelyPositionedRenderer
private void updateMinHeightForAbsolutelyPositionedRenderer(IRenderer renderer, Rectangle parentRendererBox, java.lang.Float top, java.lang.Float bottom)
-
adjustPositionedRendererLayoutBoxWidth
private void adjustPositionedRendererLayoutBoxWidth(IRenderer renderer, Rectangle fullBbox, java.lang.Float left, java.lang.Float right)
-
calculatePaddingBorderWidth
static float calculatePaddingBorderWidth(AbstractRenderer renderer)
-
calculatePaddingBorderHeight
static float calculatePaddingBorderHeight(AbstractRenderer renderer)
-
createTransformationInsideOccupiedArea
private AffineTransform createTransformationInsideOccupiedArea()
This method createsAffineTransforminstance that could be used to transform content inside the occupied area, considering the centre of the occupiedArea as the origin of a coordinate system for transformation.- Returns:
AffineTransformthat transforms the content and places it inside occupied area.
-
beginTransformationIfApplied
protected void beginTransformationIfApplied(PdfCanvas canvas)
-
endTransformationIfApplied
protected void endTransformationIfApplied(PdfCanvas canvas)
-
addChildRenderer
void addChildRenderer(IRenderer child)
Add the specifiedrendererto the end of children list and update its parent link tothis.- Parameters:
child- thechild rendererto be add
-
addAllChildRenderers
void addAllChildRenderers(java.util.List<IRenderer> children)
Add the specified collection ofrenderersto the end of children list and update their parent links tothis.- Parameters:
children- the collection ofchild renderersto be add
-
addAllChildRenderers
void addAllChildRenderers(int index, java.util.List<IRenderer> children)Inserts the specified collection ofrenderersat the specified space of children list and update their parent links tothis.- Parameters:
index- index at which to insert the first element from the specified collectionchildren- the collection ofchild renderersto be add
-
setChildRenderers
void setChildRenderers(java.util.List<IRenderer> children)
Set the specified collection ofrenderersas the children forthiselement. That meant that the old collection would be cleaned, all parent links in old children tothiswould be erased (i.e. set tonull) and then the specified list of children would be added similar toaddAllChildRenderers(List).- Parameters:
children- the collection of childrenrenderersto be set
-
removeChildRenderer
IRenderer removeChildRenderer(int index)
Remove the childrendererat the specified place. If the removed renderer has the parent link set tothisand it would not present in the children list after removal, then the parent link of the removed renderer would be erased (i.e. set tonull.- Parameters:
index- the index of the renderer to be removed- Returns:
- the removed renderer
-
removeAllChildRenderers
boolean removeAllChildRenderers(java.util.Collection<IRenderer> children)
Remove the childrenrendererswhich are contains in the specified collection. If some of the removed renderers has the parent link set tothis, then the parent link of the removed renderer would be erased (i.e. set tonull.- Parameters:
children- the collections of renderers to be removed from children list- Returns:
trueif the children list has been changed
-
setChildRenderer
IRenderer setChildRenderer(int index, IRenderer child)
Update the childrendererat the specified place with the specified one. If the removed renderer has the parent link set tothis, then it would be erased (i.e. set tonull).- Parameters:
index- the index of the renderer to be updatedchild- the renderer to be set- Returns:
- the removed renderer
-
setThisAsParent
void setThisAsParent(java.util.Collection<IRenderer> children)
Sets currentAbstractRendereras parent to renderers in specified collection.- Parameters:
children- the collection of renderers to set the parent renderer on
-
logWarningIfGetNextRendererNotOverridden
boolean logWarningIfGetNextRendererNotOverridden(java.lang.Class<?> baseClass, java.lang.Class<?> rendererClass)
-
removeThisFromParent
private void removeThisFromParent(IRenderer toRemove)
-
removeThisFromParents
private void removeThisFromParents(java.util.Collection<IRenderer> children)
-
getBorderRadii
private static BorderRadius[] getBorderRadii(IRenderer renderer)
-
hasOwnOrModelProperty
private static boolean hasOwnOrModelProperty(IRenderer renderer, int property)
-
getCurrentStructElem
private static PdfStructElem getCurrentStructElem(PdfDocument document)
-
-