Class ElementPropertyContainerIPropertyContainer>

Type Parameters:
T - this type
All Implemented Interfaces:
IPropertyContainer
Direct Known Subclasses:
AbstractElement, RootElement, Style

public abstract class ElementPropertyContainerIPropertyContainer> extends AbstractIdentifiableElement implements IPropertyContainer
A generic abstract element that fits in a PDF layout object hierarchy. A superclass of all layout object implementations.
  • Field Details

  • Constructor Details

    • ElementPropertyContainer

      public ElementPropertyContainer()
  • Method Details

    • 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
      Parameters:
      property - the property to be set
      value - the value of the property
    • 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
      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
      Parameters:
      property - the property to be checked
      Returns:
      true if this instance has given own property, false otherwise
    • deleteOwnProperty

      public void deleteOwnProperty (int property)
      Description copied from interface: IPropertyContainer
      Deletes the own property of this entity.
      Specified by:
      deleteOwnProperty in interface IPropertyContainer
      Parameters:
      property - the property to be deleted
    • 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
      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
      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
      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
    • setRelativePosition

      public T setRelativePosition (float left, float top, float right, float bottom)
      Sets values for a relative repositioning of the Element. Also has as a side effect that the Element's Property.POSITION is changed to relative. The default implementation in AbstractRenderer treats left and top as the most important values. Only if left == 0 will right be used for the calculation; ditto for top vs. bottom.
      Parameters:
      left - movement to the left
      top - movement upwards on the page
      right - movement to the right
      bottom - movement downwards on the page
      Returns:
      this Element.
      See Also:
    • setFixedPosition

      public T setFixedPosition (float left, float bottom, float width)
      Sets values for a absolute repositioning of the Element. The coordinates specified correspond to the bottom-left corner of the element and it grows upwards. Also has as a side effect that the Element's Property.POSITION is changed to fixed.
      Parameters:
      left - horizontal position of the bottom-left corner on the page
      bottom - vertical position of the bottom-left corner on the page
      width - a floating point value measured in points.
      Returns:
      this Element.
    • setFixedPosition

      public T setFixedPosition (float left, float bottom, UnitValue width)
      Sets values for an absolute repositioning of the Element. The coordinates specified correspond to the bottom-left corner of the element, and it grows upwards. Also has as a side effect that the Element's Property.POSITION is changed to fixed.
      Parameters:
      left - horizontal position of the bottom-left corner on the page
      bottom - vertical position of the bottom-left corner on the page
      width - a UnitValue
      Returns:
      this Element.
    • setFixedPosition

      public T setFixedPosition (int pageNumber, float left, float bottom, float width)
      Sets values for a absolute repositioning of the Element. The coordinates specified correspond to the bottom-left corner of the element and it grows upwards. Also has as a side effect that the Element's Property.POSITION is changed to fixed.
      Parameters:
      pageNumber - the page where the element must be positioned
      left - horizontal position of the bottom-left corner on the page
      bottom - vertical position of the bottom-left corner on the page
      width - a floating point value measured in points.
      Returns:
      this Element.
    • setFixedPosition

      public T setFixedPosition (int pageNumber, float left, float bottom, UnitValue width)
      Sets values for a absolute repositioning of the Element. The coordinates specified correspond to the bottom-left corner of the element and it grows upwards. Also has as a side effect that the Element's Property.POSITION is changed to fixed.
      Parameters:
      pageNumber - the page where the element must be positioned
      left - horizontal position of the bottom-left corner on the page
      bottom - vertical position of the bottom-left corner on the page
      width - a floating point value measured in points.
      Returns:
      this Element.
    • setHorizontalAlignment

      public T setHorizontalAlignment (HorizontalAlignment horizontalAlignment)
      Sets the horizontal alignment of this Element.
      Parameters:
      horizontalAlignment - an enum value of type HorizontalAlignment
      Returns:
      this Element.
    • setFont

      public T setFont (PdfFont font)
      Sets the font of this Element.

      This property overrides the value set by setFontFamily(java.lang.String...). Font is set either via exact PdfFont instance or via font-family name that should correspond to the font in FontProvider, but not both.

      Parameters:
      font - a font
      Returns:
      this Element.
    • setFontFamily

      public T setFontFamily (String... fontFamilyNames)
      Sets the preferable font families for this Element. Note that FontProvider shall be set as well. See RootElement.setFontProvider(FontProvider)

      This property overrides the value set by setFont(PdfFont). Font is set either via exact PdfFont instance or via font-family name that should correspond to the font in FontProvider, but not both.

      All String that are passed as argument are directly handled as a collection of font family names, without any pre-processing. Every font family name is treated as a preferable font-family to be used inside the element. The fontFamilyNames argument is interpreted as as an ordered list, where every next font-family should be used if font for the previous one was not found or doesn't contain required glyphs.

      Parameters:
      fontFamilyNames - defines an ordered list of preferable font families for this Element.
      Returns:
      this Element.
      See Also:
    • setFontFamily

      public T setFontFamily (List<String> fontFamilyNames)
      Sets the preferable font families for this Element. Note that FontProvider shall be set as well. See RootElement.setFontProvider(FontProvider)

      This property overrides the value set by setFont(PdfFont). Font is set either via exact PdfFont instance or via font-family name that should correspond to the font in FontProvider, but not both.

      All String that are passed as argument are directly handled as a collection of font family names, without any pre-processing. Every font family name is treated as a preferable font-family to be used inside the element. The fontFamilyNames argument is interpreted as as an ordered list, where every next font-family should be used if font for the previous one was not found or doesn't contain required glyphs.

      Parameters:
      fontFamilyNames - defines an ordered list of preferable font families for this Element.
      Returns:
      this Element.
      See Also:
    • setFontColor

      public T setFontColor (Color fontColor)
      Sets the font color of this Element.
      Parameters:
      fontColor - a Color for the text in this Element.
      Returns:
      this Element.
    • setFontColor

      public T setFontColor (Color fontColor, float opacity)
      Sets the font color of this Element and the opacity of the text.
      Parameters:
      fontColor - a Color for the text in this Element.
      opacity - an opacity for the text in this Element; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent.
      Returns:
      this Element.
    • setFontColor

      public T setFontColor (TransparentColor transparentColor)
    • setFontSize

      public T setFontSize (float fontSize)
      Sets the font size of this Element, measured in points.
      Parameters:
      fontSize - a floating point value
      Returns:
      this Element.
    • setTextAlignment

      public T setTextAlignment (TextAlignment alignment)
      Sets the text alignment of this Element.
      Parameters:
      alignment - an enum value of type TextAlignment
      Returns:
      this Element.
    • setCharacterSpacing

      public T setCharacterSpacing (float charSpacing)
      Defines a custom spacing distance between all characters of a textual element. The character-spacing parameter is added to the glyph's horizontal or vertical displacement (depending on the writing mode).
      Parameters:
      charSpacing - a floating point value
      Returns:
      this Element.
    • setWordSpacing

      public T setWordSpacing (float wordSpacing)
      Defines a custom spacing distance between words of a textual element. This value works exactly like the character spacing, but only kicks in at word boundaries.
      Parameters:
      wordSpacing - a floating point value
      Returns:
      this Element.
    • setFontKerning

      public T setFontKerning (FontKerning fontKerning)
      Enable or disable kerning. Some fonts may specify kern pairs, i.e. pair of glyphs, between which the amount of horizontal space is adjusted. This adjustment is typically negative, e.g. in "AV" pair the glyphs will typically be moved closer to each other.
      Parameters:
      fontKerning - an enum value as a boolean wrapper specifying whether or not to apply kerning
      Returns:
      this Element.
    • setBackgroundColor

      public T setBackgroundColor (Color backgroundColor)
      Specifies a background color for the Element.
      Parameters:
      backgroundColor - the background color
      Returns:
      this Element.
    • setBackgroundColor

      public T setBackgroundColor (Color backgroundColor, float opacity)
      Specifies a background color for the Element.
      Parameters:
      backgroundColor - the background color
      opacity - the background color opacity; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent.
      Returns:
      this Element.
    • setBackgroundColor

      public T setBackgroundColor (Color backgroundColor, float extraLeft, float extraTop, float extraRight, float extraBottom)
      Specifies a background color for the Element, and extra space that must be counted as part of the background and therefore colored.
      Parameters:
      backgroundColor - the background color
      extraLeft - extra coloring to the left side
      extraTop - extra coloring at the top
      extraRight - extra coloring to the right side
      extraBottom - extra coloring at the bottom
      Returns:
      this Element.
    • setBackgroundColor

      public T setBackgroundColor (Color backgroundColor, float opacity, float extraLeft, float extraTop, float extraRight, float extraBottom)
      Specifies a background color for the Element, and extra space that must be counted as part of the background and therefore colored.
      Parameters:
      backgroundColor - the background color
      opacity - the background color opacity; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent
      extraLeft - extra coloring to the left side
      extraTop - extra coloring at the top
      extraRight - extra coloring to the right side
      extraBottom - extra coloring at the bottom
      Returns:
      this Element.
    • setBackgroundImage

      public T setBackgroundImage (BackgroundImage image)
      Specifies a background image for the Element.
      Parameters:
      image - BackgroundImage
      Returns:
      this Element.
    • setBackgroundImage

      public T setBackgroundImage (List<BackgroundImage> imagesList)
      Specifies a list of background images for the Element.
      Parameters:
      imagesList - List of BackgroundImage
      Returns:
      this Element.
    • setBorder

      public T setBorder (Border border)
      Sets a border for all four edges of this Element with customizable color, width, pattern type.
      Parameters:
      border - a customized Border
      Returns:
      this Element.
    • setBorderTop

      public T setBorderTop (Border border)
      Sets a border for the upper limit of this Element with customizable color, width, pattern type.
      Parameters:
      border - a customized Border
      Returns:
      this Element.
    • setBorderRight

      public T setBorderRight (Border border)
      Sets a border for the right limit of this Element with customizable color, width, pattern type.
      Parameters:
      border - a customized Border
      Returns:
      this Element.
    • setBorderBottom

      public T setBorderBottom (Border border)
      Sets a border for the bottom limit of this Element with customizable color, width, pattern type.
      Parameters:
      border - a customized Border
      Returns:
      this Element.
    • setBorderLeft

      public T setBorderLeft (Border border)
      Sets a border for the left limit of this Element with customizable color, width, pattern type.
      Parameters:
      border - a customized Border
      Returns:
      this Element.
    • setBorderRadius

      public T setBorderRadius (BorderRadius borderRadius)
      Sets a border radius for all four edges of this Element.
      Parameters:
      borderRadius - a customized BorderRadius
      Returns:
      this Element.
    • setBorderBottomLeftRadius

      public T setBorderBottomLeftRadius (BorderRadius borderRadius)
      Sets a border radius for the bottom left corner of this Element.
      Parameters:
      borderRadius - a customized BorderRadius
      Returns:
      this Element.
    • setBorderBottomRightRadius

      public T setBorderBottomRightRadius (BorderRadius borderRadius)
      Sets a border radius for the bottom right corner of this Element.
      Parameters:
      borderRadius - a customized BorderRadius
      Returns:
      this Element.
    • setBorderTopLeftRadius

      public T setBorderTopLeftRadius (BorderRadius borderRadius)
      Sets a border radius for the top left corner of this Element.
      Parameters:
      borderRadius - a customized BorderRadius
      Returns:
      this Element.
    • setBorderTopRightRadius

      public T setBorderTopRightRadius (BorderRadius borderRadius)
      Sets a border radius for the top right corner of this Element.
      Parameters:
      borderRadius - a customized BorderRadius
      Returns:
      this Element.
    • setSplitCharacters

      public T setSplitCharacters (ISplitCharacters splitCharacters)
      Sets a rule for splitting strings when they don't fit into one line. The default implementation is DefaultSplitCharacters
      Parameters:
      splitCharacters - an implementation of ISplitCharacters
      Returns:
      this Element.
    • getSplitCharacters

      public ISplitCharacters getSplitCharacters()
      Gets a rule for splitting strings when they don't fit into one line.
      Returns:
      the current string splitting rule, an implementation of ISplitCharacters
    • getTextRenderingMode

      public Integer getTextRenderingMode()
      Gets the text rendering mode, a variable that determines whether showing text causes glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three.
      Returns:
      the current text rendering mode
      See Also:
    • setTextRenderingMode

      public T setTextRenderingMode (int textRenderingMode)
      Sets the text rendering mode, a variable that determines whether showing text causes glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three.
      Parameters:
      textRenderingMode - an int value
      Returns:
      this Element.
      See Also:
    • getStrokeColor

      public Color getStrokeColor()
      Gets the stroke color for the current element. The stroke color is the color of the outlines or edges of a shape.
      Returns:
      the current stroke color
    • setStrokeColor

      public T setStrokeColor (Color strokeColor)
      Sets the stroke color for the current element. The stroke color is the color of the outlines or edges of a shape.
      Parameters:
      strokeColor - a new stroke color
      Returns:
      this Element.
    • getStrokeWidth

      public Float getStrokeWidth()
      Gets the stroke width for the current element. The stroke width is the width of the outlines or edges of a shape.
      Returns:
      the current stroke width
    • setStrokeWidth

      public T setStrokeWidth (float strokeWidth)
      Sets the stroke width for the current element. The stroke width is the width of the outlines or edges of a shape.
      Parameters:
      strokeWidth - a new stroke width
      Returns:
      this Element.
    • simulateBold

      public T simulateBold()
      Simulates bold style for a font. Be aware that using correct bold font is highly preferred over this option.
      Returns:
      this element
    • simulateItalic

      public T simulateItalic()
      Simulates italic style for a font. Be aware that using correct italic (oblique) font is highly preferred over this option.
      Returns:
      this element
    • setLineThrough

      public T setLineThrough()
      Sets default line-through attributes for text. See setUnderline(Color, float, float, float, float, int) for more fine tuning.
      Returns:
      this element
    • setUnderline

      public T setUnderline()
      Sets default underline attributes for text. See other overloads for more fine tuning.
      Returns:
      this element
    • setUnderline

      public T setUnderline (float thickness, float yPosition)
      Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always the text width. Multiple call to this method will produce multiple lines.
      Parameters:
      thickness - the absolute thickness of the line
      yPosition - the absolute y position relative to the baseline
      Returns:
      this element
    • setUnderline

      public T setUnderline (Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle)
      Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically due to position parameter. Multiple call to this method will produce multiple lines.

      The thickness of the line will be thickness + thicknessMul * fontSize. The position of the line will be baseLine + yPosition + yPositionMul * fontSize.

      Parameters:
      color - the color of the line or null to follow the text color
      thickness - the absolute thickness of the line
      thicknessMul - the thickness multiplication factor with the font size
      yPosition - the absolute y position relative to the baseline
      yPositionMul - the position multiplication factor with the font size
      lineCapStyle - the end line cap style. Allowed values are enumerated in PdfCanvasConstants.LineCapStyle
      Returns:
      this element
    • setUnderline

      public T setUnderline (Color color, float opacity, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle)
      Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically due to position parameter. Multiple call to this method will produce multiple lines.

      The thickness of the line will be thickness + thicknessMul * fontSize. The position of the line will be baseLine + yPosition + yPositionMul * fontSize.

      Parameters:
      color - the color of the line or null to follow the text color
      opacity - the opacity of the line; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent
      thickness - the absolute thickness of the line
      thicknessMul - the thickness multiplication factor with the font size
      yPosition - the absolute y position relative to the baseline
      yPositionMul - the position multiplication factor with the font size
      lineCapStyle - the end line cap style. Allowed values are enumerated in PdfCanvasConstants.LineCapStyle
      Returns:
      this element
    • setBaseDirection

      public T setBaseDirection (BaseDirection baseDirection)
      This attribute specifies the base direction of directionally neutral text (i.e., text that doesn't have inherent directionality as defined in Unicode) in an element's content and attribute values.
      Parameters:
      baseDirection - base direction
      Returns:
      this element
    • setHyphenation

      public T setHyphenation (HyphenationConfig hyphenationConfig)
      Sets a custom hyphenation configuration which will hyphenate words automatically accordingly to the language and country.
      Parameters:
      hyphenationConfig - The hyphenation configuration
      Returns:
      this element
    • setFontScript

      public T setFontScript (Character.UnicodeScript script)
      Sets the writing system for this text element.
      Parameters:
      script - a new script type
      Returns:
      this Element.
    • setDestination

      public T setDestination (String destination)
      Sets a destination name that will be created when this element is drawn to content.
      Parameters:
      destination - the destination name to be created
      Returns:
      this Element.
    • setOpacity

      public T setOpacity (Float opacity)
      Sets an opacity of the given element. It will affect element content, borders and background. Note, that it will also affect all element children, as they are the content of the given element.
      Parameters:
      opacity - a float between 0 and 1, where 1 stands for fully opaque element and 0 - for fully transparent
      Returns:
      this Element.