Class ParagraphRenderer

All Implemented Interfaces:
IPropertyContainer, IRenderer

public class ParagraphRenderer extends BlockRenderer
This class represents the renderer object for a Paragraph object. It will draw the glyphs of the textual content on the DrawContext.
  • Field Details

  • Constructor Details

    • ParagraphRenderer

      public ParagraphRenderer (Paragraph modelElement)
      Creates a ParagraphRenderer from its corresponding layout object.
      modelElement - the Paragraph 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.
      Specified by:
      layout in interface IRenderer
      layout in class BlockRenderer
      layoutContext - the description of layout area and any other additional information
      result of the layout process
    • directLayout

      protected LayoutResult directLayout (LayoutContext layoutContext)
    • getNextRenderer

      public IRenderer getNextRenderer()
      Gets a new instance of this class to be used as a next renderer, after this renderer is used, if layout(LayoutContext) is called more than once.

      If a renderer overflows to the next area, iText uses this method to create a renderer for the overflow part. So if one wants to extend ParagraphRenderer, one should override this method: otherwise the default method will be used and thus the default rather than the custom renderer will be created.

      new renderer instance
    • getDefaultProperty

      public  T1 getDefaultProperty (int property)
      Gets the default property from this entity.
      Specified by:
      getDefaultProperty in interface IPropertyContainer
      getDefaultProperty in class AbstractRenderer
      Type Parameters:
      T1 - the return type associated with the property
      property - the property to be retrieved
      the default property value. If the default property is not defined, null will be returned
    • toString

      public String toString()
      Returns a string representation of the renderer.
      toString in class AbstractRenderer
      a String
      See Also:
    • drawChildren

      public void drawChildren (DrawContext drawContext)
      Performs the drawing operation for all children of this renderer.
      drawChildren in class AbstractRenderer
      drawContext - the context (canvas, document, etc) of this drawing operation.
    • 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
      move in class AbstractRenderer
      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.
    • getLines

      public List<LineRenderer> getLines()
      Gets the lines which are the result of the layout(LayoutContext).
      paragraph lines, or null if layout hasn't been called yet
    • getFirstYLineRecursively

      protected Float getFirstYLineRecursively()
      Description copied from class: AbstractRenderer
      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.
      getFirstYLineRecursively in class AbstractRenderer
      the first yline of the nested children, null if there is no text found
    • getLastYLineRecursively

      protected Float getLastYLineRecursively()
      getLastYLineRecursively in class AbstractRenderer
    • createOverflowRenderer

      protected ParagraphRenderer createOverflowRenderer (IRenderer parent)
    • createSplitRenderer

      protected ParagraphRenderer createSplitRenderer (IRenderer parent)
    • createOverflowRenderer

      protected AbstractRenderer createOverflowRenderer (int layoutResult)
      Description copied from class: BlockRenderer
      Creates an overflow renderer.
      createOverflowRenderer in class BlockRenderer
      layoutResult - the result of content layouting
      a new AbstractRenderer instance
    • getMinMaxWidth

      public MinMaxWidth getMinMaxWidth()
      Description copied from class: BlockRenderer
      Calculates min and max width values for current renderer.
      getMinMaxWidth in class BlockRenderer
      instance of MinMaxWidth
    • split

      protected ParagraphRenderer[] split()