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 Object implements IRenderer
Defines the most common properties and behavior that are shared by most IRenderer implementations. All default Renderers are subclasses of this default implementation.
  • Field Details

    • OVERLAP_EPSILON

      public static final float OVERLAP_EPSILON
      See Also:
    • EPS

      protected static final float EPS
      The maximum difference between Rectangle coordinates to consider rectangles equal
      See Also:
    • INF

      protected static final float INF
      The infinity value which is used while layouting
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • ARC_RIGHT_DEGREE

      private static final int ARC_RIGHT_DEGREE
      See Also:
    • ARC_TOP_DEGREE

      private static final int ARC_TOP_DEGREE
      See Also:
    • ARC_LEFT_DEGREE

      private static final int ARC_LEFT_DEGREE
      See Also:
    • ARC_BOTTOM_DEGREE

      private static final int ARC_BOTTOM_DEGREE
      See Also:
    • ARC_QUARTER_CLOCKWISE_EXTENT

      private static final int ARC_QUARTER_CLOCKWISE_EXTENT
      See Also:
    • CHECK_TUPLE2_TYPE

      private static final Tuple2<String,PdfDictionary> CHECK_TUPLE2_TYPE
    • childRenderers

      protected List<IRenderer> childRenderers
    • positionedRenderers

      protected List<IRenderer> positionedRenderers
    • modelElement

      protected IPropertyContainer modelElement
    • flushed

      protected boolean flushed
    • occupiedArea

      protected LayoutArea occupiedArea
    • parent

      protected IRenderer parent
    • properties

      protected Map<Integer,Object> properties
    • isLastRendererForModelElement

      protected boolean isLastRendererForModelElement
  • Constructor Details

    • 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 Details

    • addChild

      public void addChild(IRenderer renderer)
      Adds a child to the current renderer
      Specified by:
      addChild in interface IRenderer
      Parameters:
      renderer - a child to be added
    • getModelElement

      public IPropertyContainer getModelElement()
      Gets the model element associated with this renderer.
      Specified by:
      getModelElement in interface IRenderer
      Returns:
      the model element, as a container of properties
    • getChildRenderers

      public List<IRenderer> getChildRenderers()
      Gets the child IRenderers.
      Specified by:
      getChildRenderers in interface IRenderer
      Returns:
      a list of direct child renderers of this instance
    • hasProperty

      public boolean hasProperty(int property)
      Checks if this entity has the specified property. Compared to IPropertyContainer.hasOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance
      Specified by:
      hasProperty in interface IPropertyContainer
      Parameters:
      property - the property to be checked
      Returns:
      true if this instance has given property, false otherwise
    • 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:
      hasOwnProperty in interface IPropertyContainer
      Parameters:
      property - the property to be checked
      Returns:
      true if this instance has given own property, false otherwise
    • 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:
      true if this instance or its model element have given own property, false otherwise
    • deleteOwnProperty

      public void deleteOwnProperty(int property)
      Deletes the own property of this entity.
      Specified by:
      deleteOwnProperty in interface IPropertyContainer
      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 to IPropertyContainer.getOwnProperty(int), this method can check parent's properties, styles, etc, depending on the origin of the instance
      Specified by:
      getProperty in interface IPropertyContainer
      Type Parameters:
      T1 - the return type associated with the property
      Parameters:
      key - the property to be retrieved
      Returns:
      the value of the given property. null will 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, null will be returned.
      Specified by:
      getOwnProperty in interface IPropertyContainer
      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. null will 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, defaultValue will be returned.
      Specified by:
      getProperty in interface IRenderer
      Type Parameters:
      T1 - the return type associated with the property
      Parameters:
      property - the property to be retrieved
      defaultValue - a fallback value
      Returns:
      the value of the given property
    • setProperty

      public void setProperty(int property, Object value)
      Sets a property for this entity.
      Specified by:
      setProperty in interface IPropertyContainer
      Parameters:
      property - the property to be set
      value - the value of the property
    • getDefaultProperty

      public <T1> T1 getDefaultProperty(int property)
      Gets the default property from this entity.
      Specified by:
      getDefaultProperty in interface IPropertyContainer
      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, null will be returned
    • getPropertyAsFont

      public PdfFont getPropertyAsFont(int property)
      Returns a property with a certain key, as a font object.
      Parameters:
      property - an enum value
      Returns:
      a PdfFont
    • getPropertyAsColor

      public Color getPropertyAsColor(int property)
      Returns a property with a certain key, as a color.
      Parameters:
      property - an enum value
      Returns:
      a Color
    • getPropertyAsTransparentColor

      public TransparentColor getPropertyAsTransparentColor(int property)
      Returns a property with a certain key, as a TransparentColor.
      Parameters:
      property - an enum value
      Returns:
      a TransparentColor
    • getPropertyAsFloat

      public Float getPropertyAsFloat(int property)
      Returns a property with a certain key, as a floating point value.
      Parameters:
      property - an enum value
      Returns:
      a Float
    • getPropertyAsFloat

      public Float getPropertyAsFloat(int property, Float defaultValue)
      Returns a property with a certain key, as a floating point value.
      Parameters:
      property - an enum value
      defaultValue - default value to be returned if property is not found
      Returns:
      a Float
    • getPropertyAsBoolean

      public Boolean getPropertyAsBoolean(int property)
      Returns a property with a certain key, as a boolean value.
      Parameters:
      property - an enum value
      Returns:
      a Boolean
    • getPropertyAsUnitValue

      public UnitValue getPropertyAsUnitValue(int property)
      Returns a property with a certain key, as a unit value.
      Parameters:
      property - an enum value
      Returns:
      a UnitValue
    • getPropertyAsInteger

      public Integer getPropertyAsInteger(int property)
      Returns a property with a certain key, as an integer value.
      Parameters:
      property - an enum value
      Returns:
      a Integer
    • toString

      public String toString()
      Returns a string representation of the renderer.
      Overrides:
      toString in class Object
      Returns:
      a String
      See Also:
    • getOccupiedArea

      public LayoutArea getOccupiedArea()
      Gets the resultant occupied area after the last call to the IRenderer.layout(LayoutContext) method.
      Specified by:
      getOccupiedArea in interface IRenderer
      Returns:
      LayoutArea instance
    • draw

      public void draw(DrawContext drawContext)
      Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the PdfDocument etc.
      Specified by:
      draw in interface IRenderer
      Parameters:
      drawContext - contains the PdfDocument to which the renderer subtree if flushed, the PdfCanvas on which the renderer subtree is drawn and other additional parameters needed to perform drawing
    • beginElementOpacityApplying

      protected void beginElementOpacityApplying(DrawContext drawContext)
      Apply Property.OPACITY property if specified by setting corresponding values in graphic state dictionary opacity will be applied to all elements drawn after calling this method and before calling endElementOpacityApplying(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 key Property.BACKGROUND in either the layout element or this IRenderer itself.
      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(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 a PdfFormXObject with the given area and containing a linear gradient inside.
      Parameters:
      linearGradientBuilder - the linear gradient builder
      xObjectArea - the result object area
      document - 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 all children of 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 any of the Property.BORDER values in either the layout element or this IRenderer itself.
      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. if draw(DrawContext) has already been called.
      Specified by:
      isFlushed in interface IRenderer
      Returns:
      whether the renderer has been flushed
      See Also:
    • setParent

      public IRenderer setParent(IRenderer parent)
      Explicitly sets this object as the child of another IRenderer in the renderer hierarchy. Some implementations also use this method internally to create a consistent hierarchy tree.
      Specified by:
      setParent in interface IRenderer
      Parameters:
      parent - the object to place higher in the renderer hierarchy
      Returns:
      by default, this object
    • getParent

      public IRenderer getParent()
      Gets the parent IRenderer.
      Specified by:
      getParent in interface IRenderer
      Returns:
      direct parent renderer of this instance
    • move

      public void move(float dxRight, float dyUp)
      Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.
      Specified by:
      move in interface IRenderer
      Parameters:
      dxRight - the x-axis offset in points. Positive value will move the renderer subtree to the right.
      dyUp - the y-axis offset in points. Positive value will move the renderer subtree to the top.
    • initElementAreas

      public List<Rectangle> initElementAreas(LayoutArea area)
      Gets all rectangles that this IRenderer can draw upon in the given area.
      Parameters:
      area - a physical area on the DrawContext
      Returns:
      a list of rectangles
    • getOccupiedAreaBBox

      public Rectangle getOccupiedAreaBBox()
      Gets the bounding box that contains all content written to the DrawContext by this IRenderer.
      Returns:
      the smallest Rectangle that 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 box of 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 box of the renderer
      See Also:
    • 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 box of the renderer
      See Also:
    • 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 box of the renderer
      See Also:
    • 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 replaced
      replacementValue - 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 back
      prevValue - 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

      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, List<IRenderer> waitingDrawing)
    • retrieveWidth

      protected Float retrieveWidth(float parentBoxWidth)
      Retrieves element's fixed content box width, if it's set. Takes into account Property.BOX_SIZING, Property.MIN_WIDTH, and Property.MAX_WIDTH properties.
      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:
    • retrieveMaxWidth

      protected Float retrieveMaxWidth(float parentBoxWidth)
      Retrieves element's fixed content box max width, if it's set. Takes into account Property.BOX_SIZING and Property.MIN_WIDTH properties.
      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:
    • retrieveMinWidth

      protected Float retrieveMinWidth(float parentBoxWidth)
      Retrieves element's fixed content box max width, if it's set. Takes into account Property.BOX_SIZING property 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:
    • updateWidth

      protected void updateWidth(UnitValue updatedWidthValue)
      Updates fixed content box width value for this renderer. Takes into account Property.BOX_SIZING property value.
      Parameters:
      updatedWidthValue - element's new fixed content box width.
    • retrieveHeight

      protected Float retrieveHeight()
      Retrieves the element's fixed content box height, if it's set. Takes into account Property.BOX_SIZING, Property.MIN_HEIGHT, and Property.MAX_HEIGHT properties.
      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 element
      area - defines the area of the element
      horizontal - 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 account Property.BOX_SIZING property value.
      Parameters:
      updatedHeight - element's new fixed content box height, shall be not null.
    • retrieveMaxHeight

      protected Float retrieveMaxHeight()
      Retrieve element's content box max-ehight, if it's set. Takes into account Property.BOX_SIZING property 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 account Property.BOX_SIZING property value.
      Parameters:
      updatedMaxHeight - element's new content box max-height, shall be not null.
    • retrieveMinHeight

      protected Float retrieveMinHeight()
      Retrieves element's content box min-height, if it's set. Takes into account Property.BOX_SIZING property 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 account Property.BOX_SIZING property value.
      Parameters:
      updatedMinHeight - element's new content box min-height, shall be not null.
    • retrieveUnitValue

      protected Float retrieveUnitValue(float baseValue, int property)
    • retrieveUnitValue

      protected Float retrieveUnitValue(float baseValue, int property, boolean pointOnly)
    • getOwnProperties

      protected Map<Integer,Object> getOwnProperties()
    • addAllProperties

      protected void addAllProperties(Map<Integer,Object> properties)
    • getFirstYLineRecursively

      protected 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 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 rectangle
      reverse - indicates whether margins will be applied inside (in case of false) or outside (in case of true) the rectangle.
      Returns:
      a border box of 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 rectangle
      reverse - indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.
      Returns:
      a border box of 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 - the borders to be applied on the given rectangle
      reverse - indicates whether the border box will be applied inside (in case of false) or outside (in case of false) the rectangle.
      Returns:
      a border box of 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)
    • retrieveResolvedParentDeclaredHeight

      private Float retrieveResolvedParentDeclaredHeight()
      Retrieve the parent's resolved height declaration. If the parent has a relative height declaration, it will check it's parent recursively,
      Returns:
      null if no height declaration is set on the parent, or if it's own height declaration cannot be resolved The float value of the resolved height otherwiser
    • retrieveDirectParentDeclaredHeight

      private 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
    • 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.BORDER is used, and if Property.BORDER is also not set then null is 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_RADIUS is used, and if Property.BORDER_RADIUS is also not set then null is 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 Rectangle which 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(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
    • rectangleToPointsList

      protected List<Point> rectangleToPointsList(Rectangle rect)
    • transformPoints

      protected List<Point> transformPoints(List<Point> points, AffineTransform transform)
    • calculateShiftToPositionBBoxOfPointsAt

      protected float[] calculateShiftToPositionBBoxOfPointsAt(float left, float top, 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 aligned
      top - y coordinate at which points bbox upper border is to be aligned
      points - 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 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 from
      property - 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 valid PdfFont for this renderer, based on Property.FONT, Property.FONT_PROVIDER and Property.FONT_SET properties. 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 PdfFont instance based on renderer Property.FONT property.
    • resolveFirstPdfFont

      PdfFont resolveFirstPdfFont(String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts)
      Get first valid PdfFont for 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 PdfFont instance based on renderer Property.FONT property.
    • getBorders

      static Border[] getBorders(IRenderer renderer)
    • applyAbsolutePositionIfNeeded

      void applyAbsolutePositionIfNeeded(LayoutContext layoutContext)
    • preparePositionedRendererAndAreaForLayout

      void preparePositionedRendererAndAreaForLayout(IRenderer childPositionedRenderer, Rectangle fullBbox, Rectangle parentBbox)
    • updateMinHeightForAbsolutelyPositionedRenderer

      private void updateMinHeightForAbsolutelyPositionedRenderer(IRenderer renderer, Rectangle parentRendererBox, Float top, Float bottom)
    • adjustPositionedRendererLayoutBoxWidth

      private void adjustPositionedRendererLayoutBoxWidth(IRenderer renderer, Rectangle fullBbox, Float left, Float right)
    • calculatePaddingBorderWidth

      static float calculatePaddingBorderWidth(AbstractRenderer renderer)
    • calculatePaddingBorderHeight

      static float calculatePaddingBorderHeight(AbstractRenderer renderer)
    • createTransformationInsideOccupiedArea

      private AffineTransform createTransformationInsideOccupiedArea()
      This method creates AffineTransform instance 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:
      AffineTransform that 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 specified renderer to the end of children list and update its parent link to this.
      Parameters:
      child - the child renderer to be add
    • addAllChildRenderers

      void addAllChildRenderers(List<IRenderer> children)
      Add the specified collection of renderers to the end of children list and update their parent links to this.
      Parameters:
      children - the collection of child renderers to be add
    • addAllChildRenderers

      void addAllChildRenderers(int index, List<IRenderer> children)
      Inserts the specified collection of renderers at the specified space of children list and update their parent links to this.
      Parameters:
      index - index at which to insert the first element from the specified collection
      children - the collection of child renderers to be add
    • setChildRenderers

      void setChildRenderers(List<IRenderer> children)
      Set the specified collection of renderers as the children for this element. That meant that the old collection would be cleaned, all parent links in old children to this would be erased (i.e. set to null) and then the specified list of children would be added similar to addAllChildRenderers(List).
      Parameters:
      children - the collection of children renderers to be set
    • removeChildRenderer

      IRenderer removeChildRenderer(int index)
      Remove the child renderer at the specified place. If the removed renderer has the parent link set to this and it would not present in the children list after removal, then the parent link of the removed renderer would be erased (i.e. set to null.
      Parameters:
      index - the index of the renderer to be removed
      Returns:
      the removed renderer
    • removeAllChildRenderers

      boolean removeAllChildRenderers(Collection<IRenderer> children)
      Remove the children renderers which are contains in the specified collection. If some of the removed renderers has the parent link set to this, then the parent link of the removed renderer would be erased (i.e. set to null.
      Parameters:
      children - the collections of renderers to be removed from children list
      Returns:
      true if the children list has been changed
    • setChildRenderer

      IRenderer setChildRenderer(int index, IRenderer child)
      Update the child renderer at the specified place with the specified one. If the removed renderer has the parent link set to this, then it would be erased (i.e. set to null).
      Parameters:
      index - the index of the renderer to be updated
      child - the renderer to be set
      Returns:
      the removed renderer
    • setThisAsParent

      void setThisAsParent(Collection<IRenderer> children)
      Sets current AbstractRenderer as parent to renderers in specified collection.
      Parameters:
      children - the collection of renderers to set the parent renderer on
    • logWarningIfGetNextRendererNotOverridden

      boolean logWarningIfGetNextRendererNotOverridden(Class<?> baseClass, Class<?> rendererClass)
    • removeThisFromParent

      private void removeThisFromParent(IRenderer toRemove)
    • removeThisFromParents

      private void removeThisFromParents(Collection<IRenderer> children)
    • getMargins

      private static UnitValue[] getMargins(IRenderer renderer)
    • getBorderRadii

      private static BorderRadius[] getBorderRadii(IRenderer renderer)
    • getPaddings

      private static UnitValue[] getPaddings(IRenderer renderer)
    • hasOwnOrModelProperty

      private static boolean hasOwnOrModelProperty(IRenderer renderer, int property)
    • getCurrentStructElem

      private static PdfStructElem getCurrentStructElem(PdfDocument document)