Class BoxModelLayout


  • public class BoxModelLayout
    extends java.lang.Object
    A class to access and manipulate the axis-aligned rectangular layout of form objects. Form objects that subscribe to this box model paradigm are <draw>, <field>, <subform>, <contentArea>, <area> and <pageArea>.

    A box model defines a number of rectangular regions. All regions are relative to an offset from the local coordinate space, which has its origin at the top left corner of the nominal extent; this is the local box model origin.

    All regions have a set of margins. A region may also have an optional border that may be inset from its extents.

    A box model is characterized by the following:

    • a nominal extent region corresponding to the bounding rectangle of the form object.
    • an (optional) interior caption region for the presentation of the caption. Caption regions do not have borders.
    • an interior content region for the presentation of content objects. This is the remainder of the nominal extent not occupied by either margins or caption.
    • a rotation angle -- in multiples of 90°.

    The nominal extent is used for graphical placement. However, the actual rendering of the form object may include graphic elements that draw outside of the nominal extent; this is the visual extent.

    Box model instances should be created using the static BoxModelLayout.newBoxModel(...) function.

    • Field Detail

      • eBaseLayout

        public static final int eBaseLayout
        For a node that can use the base box model implementation.
        See Also:
        Constant Field Values
      • eButtonLayout

        public static final int eButtonLayout
        For a node that is a button; it requires a box model implementation that makes the caption extent cover the entire margined nominal extent.
        See Also:
        Constant Field Values
      • eCheckButtonLayout

        public static final int eCheckButtonLayout
        For a node that is a check button; it requires a box model implementation that makes the caption extent cover the entire margined nominal extent except what's covered by the checkbox/radiio button.
        See Also:
        Constant Field Values
      • eTextContentLayout

        public static final int eTextContentLayout
        For a node that has flowing textual contents; it requires a box model implementation that can format them.
        See Also:
        Constant Field Values
      • eBarcodeLayout

        public static final int eBarcodeLayout
        For a node that is a barcode; it requires a box model implementation that formats the barcode data and any text label.
        See Also:
        Constant Field Values
      • ePMDBarcodeLayout

        public static final int ePMDBarcodeLayout
        For a node that is a paperMetaData barcode, including PDF417, DataMatrix, QRCode, etc. The boxmodel gives us a BMP image stored in ImageData.
        See Also:
        Constant Field Values
      • eImageLayout

        public static final int eImageLayout
        For a node that is an image; it requries a box model implementation that separates the nominal extent into a content region for the image data and a caption region for the optional caption text data.
        See Also:
        Constant Field Values
      • ePageLayout

        public static final int ePageLayout
        For a node that is a pageArea; it requires a box model implementation that resolves the correct pagesizes
        See Also:
        Constant Field Values
      • eExclGroupLayout

        public static final int eExclGroupLayout
        For a node that is a exclusion group group; it requires a specialized box model implementation.
        See Also:
        Constant Field Values
    • Method Detail

      • getBoxModelType

        public static int getBoxModelType​(Element oNode,
                                          LayoutEnv oEnv)
        Gets the box model type required for the node.
        Parameters:
        oNode - the form node that the box model applies to.
        oEnv - the layout environment.
        Returns:
        a new box model layout type.
      • newBoxModel

        public static BoxModelLayout newBoxModel​(Element node,
                                                 LayoutEnv env,
                                                 boolean bAllowProxy)
        Creates a new, fully initialized instance of a box model.
        Parameters:
        node - the form node that the box model applies to.
        env - the layout environment.
        bAllowProxy - allow proxy -- ie. drawn from stored text run definitions. ????.
        Returns:
        a new box model layout.
      • clear

        public void clear()
        Clears the box model layout.
      • getNominalExtent

        public Rect getNominalExtent()
        Gets the nominal bounding rectangle relative to the local box model origin.
        Returns:
        The nominal extent rectangle.
      • getWidth

        public UnitSpan getWidth()
        Gets the width of the box model.
        Returns:
        The width of the box model.
      • getHeight

        public UnitSpan getHeight()
        Gets the height of the box model.
        Returns:
        The height of the box model.
      • getVisualExtent

        public Rect getVisualExtent()
        Gets the visual bounding rectangle relative to the local box model origin. The visual extent is the nominal extent plus any border thickness that extends outside.
        Returns:
        The visual extent rectangle.
      • getBorderExtent

        public Rect getBorderExtent()
        Gets the nominal extent border rectangle relative to the local box model origin.
        Returns:
        The border extent rectangle.
      • getContentBorderExtent

        public Rect getContentBorderExtent()
        Gets the content border rectangle relative to the local box model origin.
        Returns:
        The content border extent rectangle.
      • getCaptionExtent

        public Rect getCaptionExtent()
        Gets the caption bounding rectangle relative to the local box model origin.
        Returns:
        The caption extent rectangle, which may be empty.
      • getContentExtent

        public Rect getContentExtent()
        Gets the content rectangle.
        Returns:
        The content extent rectangle.
      • getCaptionExtentMargins

        public Margins getCaptionExtentMargins()
        Gets the margins (top/left/bottom/right insets) of the caption extent.
        Returns:
        The caption extent margins.
      • getContentExtentMargins

        public Margins getContentExtentMargins()
        Gets the margins (top/left/bottom/right insets) of the content extent.
        Returns:
        The content extent margins.
      • getAngle

        public Angle getAngle()
        Gets the rotation angle.
        Returns:
        The rotation angle.
      • getNominalExtentMargins

        public Margins getNominalExtentMargins()
        Gets the margins (top/left/bottom/right insets) of the nominal extent.
        Returns:
        The nominal extent margins.
      • disableTopMargin

        public void disableTopMargin()
        Resets the top margin inset to zero.
      • disableBottomMargin

        public void disableBottomMargin()
        Resets the bottom margin inset to zero.
      • disableContentTopMargin

        public void disableContentTopMargin()
        Resets the content top margin to zero.
      • disableContentBottomMargin

        public void disableContentBottomMargin()
        Resets the content bottom margin to zero.
      • disableCaptionTopMargin

        public void disableCaptionTopMargin()
        Resets the caption top margin to zero.
      • disableCaptionBottomMargin

        public void disableCaptionBottomMargin()
        Reset the caption bottom margin to zero.
      • enumerateCaption

        public boolean enumerateCaption​(LayoutHandler pHandler,
                                        CoordPair oOffset,
                                        boolean bTruncate,
                                        Rect oInvalidatedRect)
        Enumerates the box model's caption using given layout handler.
        Parameters:
        pHandler - enumeration handler.
        oOffset - offset to apply to all enumerated caption data.
      • enumerateContent

        public boolean enumerateContent​(LayoutHandler pHandler,
                                        CoordPair oOffset,
                                        boolean bWrapText,
                                        boolean bTruncate,
                                        Rect oInvalidatedRect)
        Enumerates the box model's contents through the given layout handler.
        Parameters:
        pHandler - enumeration handler.
        oOffset - offset to apply to all enumerated content data.
        bWrapText - indicates whether content data should wrap to. extents
      • getCaptionByType

        public java.lang.String getCaptionByType​(java.lang.String sType,
                                                 java.util.List<TemplateResolver.RGB> colorTable,
                                                 java.util.List<java.lang.String> fontTable)
        Gets a string containing the box model caption.
        Parameters:
        sType - indicates how to represent the data. within the returned string (rtf|html|plain)
        colorTable - array of color values, can be null.
        fontTable - array of fonts used, can be null.
        Returns:
        the string representation of box model caption, or the empty string if there isn't any.
      • getContentByType

        public java.lang.String getContentByType​(java.lang.String sType,
                                                 java.util.List<TemplateResolver.RGB> colorTable,
                                                 java.util.List<java.lang.String> fontTable)
        Gets a string containing the box model content.
        Parameters:
        sType - indicates how to represent the data. within the returned string (rtf|html|plain)
        colorTable - array of color values, can be null.
        fontTable - array of fonts used, can be null.
        Returns:
        the string representation of box model contents, or the empty string if there isn't any.
      • getRotatedContentTopLeft

        public CoordPair getRotatedContentTopLeft()
        Gets the top left of the content region adjusted for rotations. This is key since a rotated content region is adjusted so that it is oriented 'up' always, which is not the correct top left for text when a rotation is used
      • getRotatedCaptionTopLeft

        public CoordPair getRotatedCaptionTopLeft()
        Gets the top left of the caption region adjusted for rotations. This is key since a rotated caption region is adjusted so that it is oriented 'up' always, which is not the correct top left for text when a rotation is used
      • hasCaption

        public boolean hasCaption()
        Determines if this box model has any formattable content within it's caption region.
        Returns:
        true if it has.
      • hasContent

        public boolean hasContent()
        Determines if this box model has any formattable content within it's content region.
        Returns:
        true if it has.
      • hasRotation

        public boolean hasRotation()
        Determines if this box model has had a rotation applied.
        Returns:
        true if it has.
      • hasCaptionExtentContained

        public boolean hasCaptionExtentContained()
        Determines if the caption extent has been fully contained within this box model.
        Returns:
        true if it has.
      • hasContentExtentContained

        public boolean hasContentExtentContained()
        Determines if the content extent has been fully contained within this box model.
        Returns:
        true if it has.
      • hasEmbeddedContent

        public boolean hasEmbeddedContent()
        Determines if this box model has embedded content.
        Returns:
        true if the box model has.
      • hasSplit

        public boolean hasSplit()
        Determines if this box model has been involved in a split.
        Returns:
        true if the box model has.
      • initialize

        public void initialize​(Element oNode)
        Initializes the box model internals. It is not necessary to call this since newBoxModel(...) does this automatically.
        Parameters:
        oNode - the form node that the box model applies to.
      • isFontSubstituted

        public boolean isFontSubstituted()
        Determines if this box model has a font that's been substituted. Used for text caching.
        Returns:
        true if the box model has fonts that were substituted.
      • isProxy

        public boolean isProxy()
        Is this box model is based on a proxy definition -- ie. drawn from stored text run definitions.
        Returns:
        true if drawn from text runs.
      • reinitialize

        public void reinitialize​(Element oNode)
        Re-initializes the box model.
        Parameters:
        oNode - the form node that the box model applies to.
      • resizeToNominal

        public void resizeToNominal​(UnitSpan oW,
                                    UnitSpan oH,
                                    Element oNode)
        Resizes the box model by setting it's new nominal extent. Content/caption extents will be updated as well.
        Parameters:
        oW - new nominal extent width.
        oH - new nominal extent height.
        oNode - the form node that the box model applies to.
      • resizeToNominalWidth

        public void resizeToNominalWidth​(UnitSpan oW,
                                         Element oNode)
        Resizes the box model by setting it's new nominal extent width. The height will automatically update if the box model is h-growable. Content/caption extents will be updated as well.
        Parameters:
        oW - new nominal extent width.
        oNode - the form node that the box model applies to.
      • resizeToContent

        public void resizeToContent​(UnitSpan oContentW,
                                    UnitSpan oContentH,
                                    Element oNode)
        Resizes the box model by setting it's new content extent. The nominal extent + caption extent will be reformulated based on the new content size.
        Parameters:
        oContentW - new width of content.
        oContentH - new height of content.
        oNode - the form node that the box model applies to.
      • split

        public boolean split​(UnitSpan oNewHeight,
                             ObjectHolder<BoxModelLayout> oNewBM,
                             Element oNode)
        Split the contents of this box model by trimming anything would not fit within new height.
        Parameters:
        oNewHeight - the distance from top of nominal extent. at which to perform split.
        oNewBM - upon return this refers to a box model. is the portion of the original box modle that did not fit.
        oNode - the form node that the box model applies to.
        Returns:
        true if box model was successfully split.
      • hasGrowableW

        public boolean hasGrowableW()
        Determines if this box model has a growable width.
        Returns:
        true if it does.
      • hasGrowableH

        public boolean hasGrowableH()
        Determines if this box model has a growable height.
        Returns:
        true if it does.
      • getAnchor

        public int getAnchor()
      • getAnchorPoint

        public CoordPair getAnchorPoint()
      • setAnchor

        public void setAnchor​(int eVal)
      • setAnchorPoint

        public void setAnchorPoint​(CoordPair oPt)
      • initAnchorPoint

        public void initAnchorPoint​(Element oNode)
      • initBorder

        public void initBorder​(Element oNode)
      • initVisualExtent

        public void initVisualExtent​(Element oNode)
      • hasOverflowingContentText

        public boolean hasOverflowingContentText()
        Return true if this box model contains text that overflows it's allotted space and false otherwise.
        Returns:
        false if this object contains no text.
      • hasOverflowingCaptionText

        public boolean hasOverflowingCaptionText()
        Return true if this box model contains text that overflows it's allotted space and false otherwise.
        Returns:
        false if this object contains no text.