Class RootElementIPropertyContainer>

Type Parameters:
T - this type
All Implemented Interfaces:
IPropertyContainer, Closeable, AutoCloseable
Direct Known Subclasses:
Canvas, Document

public abstract class RootElementIPropertyContainer> extends ElementPropertyContainer implements Closeable
A generic abstract root element for a PDF layout object hierarchy.
  • Field Details

    • immediateFlush

      protected boolean immediateFlush
    • pdfDocument

      protected PdfDocument pdfDocument
    • childElements

      protected List<IElement> childElements
    • defaultFont

      protected PdfFont defaultFont
    • defaultFontProvider

      protected FontProvider defaultFontProvider
    • defaultSplitCharacters

      protected ISplitCharacters defaultSplitCharacters
    • rootRenderer

      protected RootRenderer rootRenderer
  • Constructor Details

    • RootElement

      public RootElement()
  • Method Details

    • add

      public T add (IBlockElement element)
      Adds an element to the root. The element is immediately placed in the contents.
      Parameters:
      element - an element with spacial margins, tabbing, and alignment
      Returns:
      this element
      See Also:
    • add

      public T add (Image image)
      Adds an image to the root. The element is immediately placed in the contents.
      Parameters:
      image - a graphical image element
      Returns:
      this element
      See Also:
    • getFontProvider

      public FontProvider getFontProvider()
      Gets FontProvider if presents.
      Returns:
      instance of FontProvider if exists, otherwise null.
    • setFontProvider

      public void setFontProvider (FontProvider fontProvider)
      Sets FontProvider. Note, font provider is inherited property.
      Parameters:
      fontProvider - instance of FontProvider.
    • hasProperty

      public boolean hasProperty (int property)
      Description copied from interface: IPropertyContainer
      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
      Overrides:
      hasProperty in class ElementPropertyContainer<T extends IPropertyContainer>
      Parameters:
      property - the property to be checked
      Returns:
      true if this instance has given property, false otherwise
    • hasOwnProperty

      public boolean hasOwnProperty (int property)
      Description copied from interface: IPropertyContainer
      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
      Overrides:
      hasOwnProperty in class ElementPropertyContainer<T extends IPropertyContainer>
      Parameters:
      property - the property to be checked
      Returns:
      true if this instance has given own property, false otherwise
    • getProperty

      public  T1 getProperty (int property)
      Description copied from interface: IPropertyContainer
      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
      Overrides:
      getProperty in class ElementPropertyContainer<T extends IPropertyContainer>
      Type Parameters:
      T1 - the return type associated with the property
      Parameters:
      property - 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 getOwnProperty (int property)
      Description copied from interface: IPropertyContainer
      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
      Overrides:
      getOwnProperty in class ElementPropertyContainer<T extends 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
    • getDefaultProperty

      public  T1 getDefaultProperty (int property)
      Description copied from interface: IPropertyContainer
      Gets the default property from this entity.
      Specified by:
      getDefaultProperty in interface IPropertyContainer
      Overrides:
      getDefaultProperty in class ElementPropertyContainer<T extends 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
    • deleteOwnProperty

      public void deleteOwnProperty (int property)
      Description copied from interface: IPropertyContainer
      Deletes the own property of this entity.
      Specified by:
      deleteOwnProperty in interface IPropertyContainer
      Overrides:
      deleteOwnProperty in class ElementPropertyContainer<T extends IPropertyContainer>
      Parameters:
      property - the property to be deleted
    • setProperty

      public void setProperty (int property, Object value)
      Description copied from interface: IPropertyContainer
      Sets a property for this entity.
      Specified by:
      setProperty in interface IPropertyContainer
      Overrides:
      setProperty in class ElementPropertyContainer<T extends IPropertyContainer>
      Parameters:
      property - the property to be set
      value - the value of the property
    • getRenderer

      public RootRenderer getRenderer()
      Gets the rootRenderer attribute, a specialized IRenderer that acts as the root object that other renderers descend from.
      Returns:
      the RootRenderer attribute
    • showTextAligned

      public T showTextAligned (String text, float x, float y, TextAlignment textAlign)
      Convenience method to write a text aligned about the specified point
      Parameters:
      text - text to be placed to the page
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      Returns:
      this object
    • showTextAligned

      public T showTextAligned (String text, float x, float y, TextAlignment textAlign, float angle)
      Convenience method to write a text aligned about the specified point
      Parameters:
      text - text to be placed to the page
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      angle - the angle of rotation applied to the text, in radians
      Returns:
      this object
    • showTextAligned

      public T showTextAligned (String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float angle)
      Convenience method to write a text aligned about the specified point
      Parameters:
      text - text to be placed to the page
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      vertAlign - vertical alignment about the specified point
      angle - the angle of rotation applied to the text, in radians
      Returns:
      this object
    • showTextAlignedKerned

      public T showTextAlignedKerned (String text, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)
      Convenience method to write a kerned text aligned about the specified point
      Parameters:
      text - text to be placed to the page
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      vertAlign - vertical alignment about the specified point
      radAngle - the angle of rotation applied to the text, in radians
      Returns:
      this object
    • showTextAligned

      public T showTextAligned (Paragraph p, float x, float y, TextAlignment textAlign)
      Convenience method to write a text aligned about the specified point
      Parameters:
      p - paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      Returns:
      this object
    • showTextAligned

      public T showTextAligned (Paragraph p, float x, float y, TextAlignment textAlign, VerticalAlignment vertAlign)
      Convenience method to write a text aligned about the specified point
      Parameters:
      p - paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      textAlign - horizontal alignment about the specified point
      vertAlign - vertical alignment about the specified point
      Returns:
      this object
    • showTextAligned

      public T showTextAligned (Paragraph p, float x, float y, int pageNumber, TextAlignment textAlign, VerticalAlignment vertAlign, float radAngle)
      Convenience method to write a text aligned about the specified point
      Parameters:
      p - paragraph of text to be placed to the page. By default it has no leading and is written in single line. Set width to write multiline text.
      x - the point about which the text will be aligned and rotated
      y - the point about which the text will be aligned and rotated
      pageNumber - the page number to write the text
      textAlign - horizontal alignment about the specified point
      vertAlign - vertical alignment about the specified point
      radAngle - the angle of rotation applied to the text, in radians
      Returns:
      this object
    • ensureRootRendererNotNull

      protected abstract RootRenderer ensureRootRendererNotNull()
    • createAndAddRendererSubTree

      protected void createAndAddRendererSubTree (IElement element)