Package com.adobe.xfa.layout
Class BoxModelLayout
java.lang.Object
com.adobe.xfa.layout.BoxModelLayout
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intFor a node that is a barcode; it requires a box model implementation that formats the barcode data and any text label.static final intFor a node that can use the base box model implementation.static final intFor a node that is a button; it requires a box model implementation that makes the caption extent cover the entire margined nominal extent.static final intFor 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.static final intFor a node that is a exclusion group group; it requires a specialized box model implementation.static final intFor 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.static final intFor a node that is a pageArea; it requires a box model implementation that resolves the correct pagesizesstatic final intFor a node that is a paperMetaData barcode, including PDF417, DataMatrix, QRCode, etc.static final intFor a node that has flowing textual contents; it requires a box model implementation that can format them. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the box model layout.voidResets the bottom margin inset to zero.voidReset the caption bottom margin to zero.voidResets the caption top margin to zero.voidResets the content bottom margin to zero.voidResets the content top margin to zero.voidResets the top margin inset to zero.booleanenumerateCaption(LayoutHandler pHandler, CoordPair oOffset, boolean bTruncate, Rect oInvalidatedRect) Enumerates the box model's caption using given layout handler.booleanenumerateContent(LayoutHandler pHandler, CoordPair oOffset, boolean bWrapText, boolean bTruncate, Rect oInvalidatedRect) Enumerates the box model's contents through the given layout handler.intgetAngle()Gets the rotation angle.Gets the nominal extent border rectangle relative to the local box model origin.static intgetBoxModelType(Element oNode, LayoutEnv oEnv) Gets the box model type required for the node.getCaptionByType(String sType, List<TemplateResolver.RGB> colorTable, List<String> fontTable) Gets a string containing the box model caption.Gets the caption bounding rectangle relative to the local box model origin.Gets the margins (top/left/bottom/right insets) of the caption extent.Gets the content border rectangle relative to the local box model origin.getContentByType(String sType, List<TemplateResolver.RGB> colorTable, List<String> fontTable) Gets a string containing the box model content.Gets the content rectangle.Gets the margins (top/left/bottom/right insets) of the content extent.Gets the height of the box model.Gets the nominal bounding rectangle relative to the local box model origin.Gets the margins (top/left/bottom/right insets) of the nominal extent.Gets the top left of the caption region adjusted for rotations.Gets the top left of the content region adjusted for rotations.Gets the visual bounding rectangle relative to the local box model origin.getWidth()Gets the width of the box model.booleanDetermines if this box model has any formattable content within it's caption region.booleanDetermines if the caption extent has been fully contained within this box model.booleanDetermines if this box model has any formattable content within it's content region.booleanDetermines if the content extent has been fully contained within this box model.booleanDetermines if this box model has embedded content.booleanDetermines if this box model has a growable height.booleanDetermines if this box model has a growable width.booleanReturn true if this box model contains text that overflows it's allotted space and false otherwise.booleanReturn true if this box model contains text that overflows it's allotted space and false otherwise.booleanDetermines if this box model has had a rotation applied.booleanhasSplit()Determines if this box model has been involved in a split.voidinitAnchorPoint(Element oNode) voidinitBorder(Element oNode) voidinitialize(Element oNode) Initializes the box model internals.voidinitVisualExtent(Element oNode) booleanDetermines if this box model has a font that's been substituted.booleanisProxy()Is this box model is based on a proxy definition -- ie.static BoxModelLayoutnewBoxModel(Element node, LayoutEnv env, boolean bAllowProxy) Creates a new, fully initialized instance of a box model.voidreinitialize(Element oNode) Re-initializes the box model.voidresizeToContent(UnitSpan oContentW, UnitSpan oContentH, Element oNode) Resizes the box model by setting it's new content extent.voidresizeToNominal(UnitSpan oW, UnitSpan oH, Element oNode) Resizes the box model by setting it's new nominal extent.voidresizeToNominalWidth(UnitSpan oW, Element oNode) Resizes the box model by setting it's new nominal extent width.voidsetAnchor(int eVal) voidsetAnchorPoint(CoordPair oPt) booleansplit(UnitSpan oNewHeight, ObjectHolder<BoxModelLayout> oNewBM, Element oNode) Split the contents of this box model by trimming anything would not fit within new height.
-
Field Details
-
eBaseLayout
public static final int eBaseLayoutFor a node that can use the base box model implementation.- See Also:
-
eButtonLayout
public static final int eButtonLayoutFor 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:
-
eCheckButtonLayout
public static final int eCheckButtonLayoutFor 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:
-
eTextContentLayout
public static final int eTextContentLayoutFor a node that has flowing textual contents; it requires a box model implementation that can format them.- See Also:
-
eBarcodeLayout
public static final int eBarcodeLayoutFor a node that is a barcode; it requires a box model implementation that formats the barcode data and any text label.- See Also:
-
ePMDBarcodeLayout
public static final int ePMDBarcodeLayoutFor a node that is a paperMetaData barcode, including PDF417, DataMatrix, QRCode, etc. The boxmodel gives us a BMP image stored in ImageData.- See Also:
-
eImageLayout
public static final int eImageLayoutFor 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:
-
ePageLayout
public static final int ePageLayoutFor a node that is a pageArea; it requires a box model implementation that resolves the correct pagesizes- See Also:
-
eExclGroupLayout
public static final int eExclGroupLayoutFor a node that is a exclusion group group; it requires a specialized box model implementation.- See Also:
-
-
Method Details
-
getBoxModelType
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
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
Gets the nominal bounding rectangle relative to the local box model origin.- Returns:
- The nominal extent rectangle.
-
getWidth
Gets the width of the box model.- Returns:
- The width of the box model.
-
getHeight
Gets the height of the box model.- Returns:
- The height of the box model.
-
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
Gets the nominal extent border rectangle relative to the local box model origin.- Returns:
- The border extent rectangle.
-
getContentBorderExtent
Gets the content border rectangle relative to the local box model origin.- Returns:
- The content border extent rectangle.
-
getCaptionExtent
Gets the caption bounding rectangle relative to the local box model origin.- Returns:
- The caption extent rectangle, which may be empty.
-
getContentExtent
Gets the content rectangle.- Returns:
- The content extent rectangle.
-
getCaptionExtentMargins
Gets the margins (top/left/bottom/right insets) of the caption extent.- Returns:
- The caption extent margins.
-
getContentExtentMargins
Gets the margins (top/left/bottom/right insets) of the content extent.- Returns:
- The content extent margins.
-
getAngle
Gets the rotation angle.- Returns:
- The rotation angle.
-
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 String getCaptionByType(String sType, List<TemplateResolver.RGB> colorTable, List<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 String getContentByType(String sType, List<TemplateResolver.RGB> colorTable, List<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
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
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
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
Re-initializes the box model.- Parameters:
oNode- the form node that the box model applies to.
-
resizeToNominal
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
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
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
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
-
setAnchor
public void setAnchor(int eVal) -
setAnchorPoint
-
initAnchorPoint
-
initBorder
-
initVisualExtent
-
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.
-