Class AbstractFormFieldRenderer

All Implemented Interfaces:
IPropertyContainer, IRenderer
Direct Known Subclasses:
AbstractTextFieldRenderer, CheckBoxRenderer, RadioRenderer

public abstract class AbstractFormFieldRenderer extends BlockRenderer
Abstract BlockRenderer for form fields.
  • Field Details

    • flatRenderer

      protected IRenderer flatRenderer
      The flat renderer.
  • Method Details

    • isFlatten

      public boolean isFlatten()
      Checks if form fields need to be flattened.
      Returns:
      true, if fields need to be flattened.
    • getDefaultValue

      public String getDefaultValue()
      Gets the default value of the form field.
      Returns:
      the default value of the form field.
    • 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
      Overrides:
      layout in class BlockRenderer
      Parameters:
      layoutContext - the description of layout area and any other additional information
      Returns:
      result of the layout process
    • 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
      Overrides:
      draw in class BlockRenderer
      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
    • getMinMaxWidth

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

      public void drawChildren (DrawContext drawContext)
      Performs the drawing operation for all children of this renderer.
      Overrides:
      drawChildren in class AbstractRenderer
      Parameters:
      drawContext - the context (canvas, document, etc) of this drawing operation.
    • applyAccessibilityProperties

      protected void applyAccessibilityProperties (PdfFormField formField, PdfDocument pdfDocument)
      Applies the accessibility properties to the form field.
      Parameters:
      formField - The form field to which the accessibility properties should be applied.
      pdfDocument - The document to which the form field belongs.
    • adjustFieldLayout

      protected abstract void adjustFieldLayout (LayoutContext layoutContext)
      Adjusts the field layout.
      Parameters:
      layoutContext - layout context
    • createFlatRenderer

      protected abstract IRenderer createFlatRenderer()
      Creates the flat renderer instance.
      Returns:
      the renderer instance.
    • applyAcroField

      protected abstract void applyAcroField (DrawContext drawContext)
      Applies the AcroField widget.
      Parameters:
      drawContext - the draw context
    • getModelId

      protected String getModelId()
      Gets the model id.
      Returns:
      the model id.
    • isRendererFit

      protected boolean isRendererFit (float availableWidth, float availableHeight)
      Checks if the renderer fits a certain width and height.
      Parameters:
      availableWidth - the available width
      availableHeight - the available height
      Returns:
      true, if the renderer fits.
    • getLang

      @Deprecated protected String getLang()
      Gets the accessibility language.
      Returns:
      the accessibility language.
    • getConformanceLevel

      @Deprecated protected PdfAConformanceLevel getConformanceLevel (PdfDocument document)
      Deprecated.
      since 8.0.4 will return IConformanceLevel
      Gets the conformance level. If the conformance level is not set, the conformance level of the document is used.
      Parameters:
      document - the document
      Returns:
      the conformance level or null if the conformance level is not set.
    • getGenericConformanceLevel

      @Deprecated protected IConformanceLevel getGenericConformanceLevel (PdfDocument document)
      Deprecated.
      since 8.0.4 will be renamed to getConformanceLevel()
      Gets the conformance level. If the conformance level is not set, the conformance level of the document is used.
      Parameters:
      document - the document
      Returns:
      the conformance level or null if the conformance level is not set.
    • isLayoutBasedOnFlatRenderer

      protected boolean isLayoutBasedOnFlatRenderer()
      Determines, whether the layout is based in the renderer itself or flat renderer.
      Returns:
      true if layout is based on flat renderer, false otherwise.
    • writeAcroFormFieldLangAttribute

      protected void writeAcroFormFieldLangAttribute (PdfDocument pdfDoc)
      Sets the form accessibility language identifier of the form element in case the document is tagged.
      Parameters:
      pdfDoc - the document which contains form field