Class BlockRenderer

java.lang.Object
com.itextpdf.layout.renderer.AbstractRenderer
com.itextpdf.layout.renderer.BlockRenderer
All Implemented Interfaces:
IPropertyContainer, IRenderer
Direct Known Subclasses:
AbstractFormFieldRenderer, AbstractSelectFieldRenderer, CellRenderer, DivRenderer, GridContainerRenderer, GridItemRenderer, LineSeparatorRenderer, ListRenderer, ParagraphRenderer

public abstract class BlockRenderer extends AbstractRenderer
Represents a renderer for block elements.
  • Constructor Details

    • BlockRenderer

      protected BlockRenderer(IElement modelElement)
      Creates a BlockRenderer from its corresponding layout object.
      Parameters:
      modelElement - the IElement which this object should manage
  • Method Details

    • layout

      public LayoutResult layout(LayoutContext layoutContext)
      This method simulates positioning of the renderer, including all of its children, and returns the LayoutResult, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. LayoutResult can be extended to return custom layout results for custom elements, e.g. TextRenderer uses TextLayoutResult as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called before IRenderer.draw(DrawContext), to prepare the renderer to be flushed to the output stream.
      Parameters:
      layoutContext - the description of layout area and any other additional information
      Returns:
      result of the layout process
    • draw

      public void draw(DrawContext drawContext)
      Description copied from class: AbstractRenderer
      Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the PdfDocument etc.
      Specified by:
      draw in interface IRenderer
      Overrides:
      draw in class AbstractRenderer
      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
    • getOccupiedAreaBBox

      public Rectangle getOccupiedAreaBBox()
      Description copied from class: AbstractRenderer
      Gets the bounding box that contains all content written to the DrawContext by this IRenderer.
      Overrides:
      getOccupiedAreaBBox in class AbstractRenderer
      Returns:
      the smallest Rectangle that surrounds the content
    • createSplitRenderer

      protected AbstractRenderer createSplitRenderer(int layoutResult)
      Creates a split renderer.
      Parameters:
      layoutResult - the result of content layouting
      Returns:
      a new AbstractRenderer instance
    • createOverflowRenderer

      protected AbstractRenderer createOverflowRenderer(int layoutResult)
      Creates an overflow renderer.
      Parameters:
      layoutResult - the result of content layouting
      Returns:
      a new AbstractRenderer instance
    • recalculateOccupiedAreaAfterChildLayout

      void recalculateOccupiedAreaAfterChildLayout(Rectangle resultBBox, Float blockMaxHeight)
    • startChildMarginsHandling

      MarginsCollapseInfo startChildMarginsHandling(IRenderer childRenderer, Rectangle layoutBox, MarginsCollapseHandler marginsCollapseHandler)
    • recalculateLayoutBoxBeforeChildLayout

      Rectangle recalculateLayoutBoxBeforeChildLayout(Rectangle layoutBox, IRenderer childRenderer, Rectangle initialLayoutBox)
    • createSplitAndOverflowRenderers

      AbstractRenderer[] createSplitAndOverflowRenderers(int childPos, int layoutStatus, LayoutResult childResult, Map<Integer,IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers)
    • applyVerticalAlignment

      protected void applyVerticalAlignment()
      This method applies vertical alignment for the occupied area of the renderer and its children renderers.
    • applyRotationLayout

      protected void applyRotationLayout(Rectangle layoutBox)
      This method rotates content of the renderer and calculates correct occupied area for the rotated element.
      Parameters:
      layoutBox - a Rectangle
    • createRotationTransformInsideOccupiedArea

      protected AffineTransform createRotationTransformInsideOccupiedArea()
      This method creates AffineTransform instance that could be used to rotate content inside the occupied area. Be aware that it should be used only after layout rendering is finished and correct occupied area for the rotated element is calculated.
      Returns:
      AffineTransform that rotates the content and places it inside occupied area.
    • beginRotationIfApplied

      protected void beginRotationIfApplied(PdfCanvas canvas)
      This method starts rotation for the renderer if rotation angle property is specified.
      Parameters:
      canvas - the PdfCanvas to draw on
    • endRotationIfApplied

      protected void endRotationIfApplied(PdfCanvas canvas)
      This method ends rotation for the renderer if applied.
      Parameters:
      canvas - the PdfCanvas to draw on
    • getResolvedFont

      protected PdfFont getResolvedFont(PdfDocument pdfDocument)
      Get the font set in properties, if it is not set, then resolves the first PdfFont from FontProvider. If FontProvider is not set, then returns null.
      Parameters:
      pdfDocument - the PdfDocument to get default font from.
      Returns:
      the font or null if it is not set and FontProvider is not set.
    • stopLayoutingChildrenIfChildResultNotFull

      boolean stopLayoutingChildrenIfChildResultNotFull(LayoutResult returnResult)
    • processNotFullChildResult

      LayoutResult processNotFullChildResult(LayoutContext layoutContext, Map<Integer,IRenderer> waitingFloatsSplitRenderers, List<IRenderer> waitingOverflowFloatRenderers, boolean wasHeightClipped, List<Rectangle> floatRendererAreas, boolean marginsCollapsingEnabled, float clearHeightCorrection, Border[] borders, UnitValue[] paddings, List<Rectangle> areas, int currentAreaPos, Rectangle layoutBox, Set<Rectangle> nonChildFloatingRendererAreas, IRenderer causeOfNothing, boolean anythingPlaced, int childPos, LayoutResult result)
    • decreaseLayoutBoxAfterChildPlacement

      void decreaseLayoutBoxAfterChildPlacement(Rectangle layoutBox, LayoutResult result, IRenderer childRenderer)
    • correctFixedLayout

      void correctFixedLayout(Rectangle layoutBox)
    • applyWidth

      void applyWidth(Rectangle parentBBox, Float blockWidth, OverflowPropertyValue overflowX)
    • applyMaxHeight

      boolean applyMaxHeight(Rectangle parentBBox, Float blockMaxHeight, MarginsCollapseHandler marginsCollapseHandler, boolean isCellRenderer, boolean wasParentsHeightClipped, OverflowPropertyValue overflowY)
    • applyMinHeight

      AbstractRenderer applyMinHeight(OverflowPropertyValue overflowY, Rectangle layoutBox)
    • fixOccupiedAreaIfOverflowedX

      void fixOccupiedAreaIfOverflowedX(OverflowPropertyValue overflowX, Rectangle layoutBox)
    • fixOccupiedAreaIfOverflowedY

      void fixOccupiedAreaIfOverflowedY(OverflowPropertyValue overflowY, Rectangle layoutBox)
    • getMinMaxWidth

      public MinMaxWidth getMinMaxWidth()
      Calculates min and max width values for current renderer.
      Overrides:
      getMinMaxWidth in class AbstractRenderer
      Returns:
      instance of MinMaxWidth
    • handleForcedPlacement

      void handleForcedPlacement(boolean anythingPlaced)
    • isAnythingOccupied

      private boolean isAnythingOccupied()
    • replaceSplitRendererKidFloats

      private void replaceSplitRendererKidFloats(Map<Integer,IRenderer> waitingFloatsSplitRenderers, IRenderer splitRenderer)
    • addMarkedContent

      private void addMarkedContent(DrawContext drawContext, boolean isBegin)
    • clipPolygon

      private List<Point> clipPolygon(List<Point> points, Point clipLineBeg, Point clipLineEnd)
    • checkPointSide

      private int checkPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd)
    • getIntersectionPoint

      private Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd)