Package com.openhtmltopdf.render
Class Box
java.lang.Object
com.openhtmltopdf.render.Box
- All Implemented Interfaces:
Styleable,DisplayListItem
- Direct Known Subclasses:
BlockBox,InlineLayoutBox,LineBox
public abstract class Box extends Object implements Styleable, DisplayListItem
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBox.ChildIteratorOfType<T> -
Field Summary
Fields Modifier and Type Field Description static intCHILDREN_FLUXstatic intDONEstatic intDUMP_LAYOUTstatic intDUMP_RENDERstatic intFLUXprotected static StringLINE_SEPARATORstatic intNOTHING -
Constructor Summary
Constructors Modifier Constructor Description protectedBox() -
Method Summary
Modifier and Type Method Description voidaddAllChildren(List<Box> children)voidaddChild(Box child)voidaddChildForLayout(LayoutContext c, Box child)voidanalyzePageBreaks(LayoutContext c, ContentLimitContainer container)List<Box>ancestors()Get all ancestors, up until the root box.List<Box>ancestorsWhile(Predicate<Box> predicate)Creates a list of ancestors by walking up the chain of parent, grandparent, etc.abstract voidcalcCanvasLocation()voidcalcChildLocations()protected voidcalcChildPaintingInfo(CssContext c, PaintingInfo result, boolean useCache)PaintingInfocalcPaintingInfo(CssContext c, boolean useCache)voidcollectText(RenderingContext c, StringBuilder buffer)voidconnectChildrenToCurrentLayer(LayoutContext c)booleancrossesPageBreak(LayoutContext c)voiddetach(LayoutContext c)abstract Stringdump(LayoutContext c, String indent, int which)protected voiddumpBoxes(LayoutContext c, String indent, List<Box> boxes, int which, StringBuilder result)protected voidexportPageBoxText(RenderingContext c, Writer writer, int yPos)voidexportText(RenderingContext c, Writer writer)Boxfind(CssContext cssCtx, int absX, int absY, boolean findAnonymous)BoxfindAncestor(Predicate<Box> predicate)Walks up the ancestor tree to the root testing ancestors agains the predicate.voidfindColumnBreakOpportunities(FlowingColumnContainerBox.ColumnBreakStore store)Recursive method to find column break opportunities.voidforcePageBreakAfter(LayoutContext c, IdentValue pageBreakValue)intforcePageBreakBefore(LayoutContext c, IdentValue pageBreakValue, boolean pendingPageName)intforcePageBreakBefore(LayoutContext c, IdentValue pageBreakValue, boolean pendingPageName, int absY)AreagetAbsoluteClipBox(CssContext c)Returns the absolute (ie transformed if needed) clip area for this box.intgetAbsX()intgetAbsY()ObjectgetAccessibilityObject()BorderPropertySetgetBorder(CssContext cssCtx)RectanglegetBorderBox(CssContext c)Only to be called after layout, due to double use of getHeight().protected intgetBorderBoxHeight(CssContext c)intgetBorderBoxWidth(CssContext c)RectanglegetBorderEdge(int left, int top, CssContext cssCtx)intgetBorderSides()BoxDimensionsgetBoxDimensions()BoxgetChild(int i)intgetChildCount()Iterator<Box>getChildIterator()<T> Iterator<T>getChildIteratorOfType(Class<T> type)Returns an iterator of boxes cast to type.List<Box>getChildren()RectanglegetChildrenClipEdge(CssContext c)RectanglegetClipBox(RenderingContext c, Layer layer)Gets the combined clip of this box relative to the containing layer.BoxgetContainingBlock()protected intgetContainingBlockWidth()LayergetContainingLayer()RectanglegetContentAreaEdge(int left, int top, CssContext cssCtx)intgetContentWidth()BoxgetDocumentParent()FSColorgetEffBackgroundColor(RenderingContext c)intgetEffectiveWidth()ElementgetElement()List<Box>getElementBoxes(Element elem)intgetHeight()Uh oh! This refers to content height during layout but total height after layout!protected intgetIndex()LayergetLayer()intgetLeftMBP()RectPropertySetgetMargin(CssContext cssContext)intgetMarginBorderPadding(CssContext cssCtx, int which)RectanglegetMarginEdge(int left, int top, CssContext cssCtx, int tx, int ty)RectanglegetMarginEdge(CssContext cssCtx, int tx, int ty)protected BoxgetNext(Box child)BoxgetNextSibling()RectPropertySetgetPadding(CssContext cssCtx)RectanglegetPaddingEdge(int left, int top, CssContext cssCtx)protected intgetPaddingWidth(CssContext cssCtx)RectanglegetPaintingBorderEdge(CssContext cssCtx)RectanglegetPaintingClipEdge(CssContext cssCtx)PaintingInfogetPaintingInfo()RectanglegetPaintingPaddingEdge(CssContext cssCtx)BoxgetParent()RectanglegetParentClipBox(RenderingContext c, Layer layer)Gets the layer relative clip for the parent box.protected BoxgetPrevious(Box child)BoxgetPreviousSibling()StringgetPseudoElementOrClass()DimensiongetRelativeOffset()BoxgetRestyleTarget()intgetRightMBP()intgetState()CalculatedStylegetStyle()protected RectPropertySetgetStyleMargin(CssContext cssContext)protected RectPropertySetgetStyleMargin(CssContext cssContext, boolean useCache)intgetTx()intgetTy()intgetWidth()intgetX()intgetY()booleanhasNonTextContent(CssContext c)booleanhasRootElementBackground(RenderingContext c)If the html or body box have a background return true.voidinitContainingLayer(LayoutContext c)booleanintersects(CssContext cssCtx, Shape clip)NOTE: This method does not consider any children of this box but does consider the transformation matrix of the containing layer.booleanisAnonymous()booleanisBody()booleanisContainedInMarginBox()booleanisFirstChild()Is this box the first child of its parent?booleanisInDocumentFlow()protected booleanisInitialContainingBlock()protected booleanisInlineBlock()protected booleanisMarginAreaRoot()booleanisRoot()booleanisStyled()booleanisTerminalColumnBreak()Is this box unbreakable in regards to column break opportunities?protected voidmoveIfGreater(Dimension result, Dimension test)voidpaintBackground(RenderingContext c)voidpaintBorder(RenderingContext c)voidpaintRootElementBackground(RenderingContext c)DimensionpositionRelative(CssContext cssCtx)voidremoveAllChildren()voidremoveChild(int i)voidremoveChild(Box target)voidreset(LayoutContext c)protected voidresetChildren(LayoutContext c)voidresetChildren(LayoutContext c, int start, int end)protected voidresetTopMargin(CssContext cssContext)voidrestyle(LayoutContext c)protected voidrestyleChildren(LayoutContext c)BoxrootBox()Returns the highest ancestor box.voidsetAbsX(int absX)voidsetAbsY(int absY)voidsetAccessiblityObject(Object object)voidsetAnonymous(boolean anonymous)protected voidsetBorderBoxHeight(CssContext c, int h)voidsetBorderBoxWidth(CssContext c, int borderBoxWidth)voidsetBoxDimensions(BoxDimensions dimensions)voidsetContainingBlock(Box containingBlock)voidsetContainingLayer(Layer containingLayer)voidsetContentWidth(int contentWidth)voidsetElement(Element element)voidsetHeight(int height)Uh oh! This refers to content height during layout but total height after layout!protected voidsetIndex(int index)voidsetLayer(Layer layer)voidsetLeftMBP(int leftMBP)voidsetMarginBottom(CssContext cssContext, int marginBottom)voidsetMarginLeft(CssContext cssContext, int marginLeft)voidsetMarginRight(CssContext cssContext, int marginRight)voidsetMarginTop(CssContext cssContext, int marginTop)voidsetParent(Box box)voidsetPseudoElementOrClass(String pseudoElementOrClass)voidsetRelativeOffset(Dimension relativeOffset)voidsetRightMBP(int rightMBP)voidsetState(int state)voidsetStyle(CalculatedStyle style)voidsetTx(int tx)voidsetTy(int ty)voidsetX(int x)voidsetY(int y)static StringstateToString(int state)StringtoString()
-
Field Details
-
LINE_SEPARATOR
-
NOTHING
public static final int NOTHING- See Also:
- Constant Field Values
-
FLUX
public static final int FLUX- See Also:
- Constant Field Values
-
CHILDREN_FLUX
public static final int CHILDREN_FLUX- See Also:
- Constant Field Values
-
DONE
public static final int DONE- See Also:
- Constant Field Values
-
DUMP_RENDER
public static final int DUMP_RENDER- See Also:
- Constant Field Values
-
DUMP_LAYOUT
public static final int DUMP_LAYOUT- See Also:
- Constant Field Values
-
-
Constructor Details
-
Box
protected Box()
-
-
Method Details
-
getClipBox
Gets the combined clip of this box relative to the containing layer. The returned clip is in document coordinate space (not transformed in any way). For example, if we have the following nesting: overflow hidden := transformed box := overflow hidden := overflow hidden := overflow visible this function called on the overflow visible box will return the combined clip of its two immediate ancestors in document coordinate space. It stops at the transformed box because the transform triggers a layer. Currently this method is used for getting the clip to apply to a float, which are nested in layers but taken out of the default block list and therefore clip stack. Since it is only used for floats, the result is not cached. Revisit this decision if using for every box. There are several other clip methods available: +getChildrenClipEdge(CssContext)- gets the local clip for a single box. +getParentClipBox(RenderingContext, Layer)- gets the layer relative clip for the parent box. +getAbsoluteClipBox(CssContext)- gets the absolute clip box in document coordinates -
getParentClipBox
Gets the layer relative clip for the parent box. -
getAbsoluteClipBox
Returns the absolute (ie transformed if needed) clip area for this box. Cached as this will be needed on every box to check if the clip area is inside a page. -
dump
-
dumpBoxes
protected void dumpBoxes(LayoutContext c, String indent, List<Box> boxes, int which, StringBuilder result) -
getWidth
public int getWidth() -
toString
-
addChildForLayout
-
addChild
-
addAllChildren
-
removeAllChildren
public void removeAllChildren() -
removeChild
-
getPreviousSibling
-
getNextSibling
-
getPrevious
-
getNext
-
removeChild
public void removeChild(int i) -
setParent
-
getParent
-
getDocumentParent
-
getChildCount
public int getChildCount() -
getChild
-
getChildIterator
-
getChildren
-
getChildIteratorOfType
Returns an iterator of boxes cast to type. If a box is not of type, an error will be logged and null will be returned for that box. Therefore, this method should only be used when it is certain all children are of a particular type. Eg: TableBox has children only of type TableSectionBox. -
getState
public int getState() -
setState
public void setState(int state) -
stateToString
-
getStyle
-
setStyle
-
getContainingBlock
-
setContainingBlock
-
getMarginEdge
-
getMarginEdge
-
getPaintingBorderEdge
-
getPaintingPaddingEdge
-
getPaintingClipEdge
-
getChildrenClipEdge
-
intersects
NOTE: This method does not consider any children of this box but does consider the transformation matrix of the containing layer. -
getBorderEdge
-
getPaddingEdge
-
getPaddingWidth
-
getContentAreaEdge
-
getLayer
-
setLayer
-
positionRelative
-
isInlineBlock
protected boolean isInlineBlock() -
setAbsY
public void setAbsY(int absY) -
getAbsY
public int getAbsY() -
setAbsX
public void setAbsX(int absX) -
getAbsX
public int getAbsX() -
isStyled
public boolean isStyled() -
getBorderSides
public int getBorderSides() -
paintBorder
-
paintBackground
-
hasNonTextContent
-
setAccessiblityObject
-
getAccessibilityObject
-
paintRootElementBackground
-
hasRootElementBackground
If the html or body box have a background return true. -
getContainingLayer
-
setContainingLayer
-
initContainingLayer
-
connectChildrenToCurrentLayer
-
getElementBoxes
-
reset
-
detach
-
resetChildren
-
resetChildren
-
calcCanvasLocation
public abstract void calcCanvasLocation() -
calcChildLocations
public void calcChildLocations() -
forcePageBreakBefore
public int forcePageBreakBefore(LayoutContext c, IdentValue pageBreakValue, boolean pendingPageName) -
forcePageBreakBefore
public int forcePageBreakBefore(LayoutContext c, IdentValue pageBreakValue, boolean pendingPageName, int absY) -
forcePageBreakAfter
-
crossesPageBreak
-
getRelativeOffset
-
setRelativeOffset
-
find
-
isRoot
public boolean isRoot() -
isBody
public boolean isBody() -
getElement
- Specified by:
getElementin interfaceStyleable
-
setElement
- Specified by:
setElementin interfaceStyleable
-
setMarginTop
-
setMarginBottom
-
setMarginLeft
-
setMarginRight
-
getMargin
-
getStyleMargin
-
getStyleMargin
-
getPadding
-
getBorder
-
getContainingBlockWidth
protected int getContainingBlockWidth() -
resetTopMargin
-
calcPaintingInfo
-
calcChildPaintingInfo
-
getMarginBorderPadding
-
moveIfGreater
-
restyle
-
restyleChildren
-
getRestyleTarget
-
getIndex
protected int getIndex() -
setIndex
protected void setIndex(int index) -
getPseudoElementOrClass
- Specified by:
getPseudoElementOrClassin interfaceStyleable
-
setPseudoElementOrClass
-
setX
public void setX(int x) -
getX
public int getX() -
setY
public void setY(int y) -
getY
public int getY() -
setTy
public void setTy(int ty) -
getTy
public int getTy() -
setTx
public void setTx(int tx) -
getTx
public int getTx() -
setRightMBP
public void setRightMBP(int rightMBP) -
getRightMBP
public int getRightMBP() -
setLeftMBP
public void setLeftMBP(int leftMBP) -
getLeftMBP
public int getLeftMBP() -
setHeight
public void setHeight(int height)Uh oh! This refers to content height during layout but total height after layout! -
getHeight
public int getHeight()Uh oh! This refers to content height during layout but total height after layout! -
setBorderBoxHeight
-
getBorderBoxHeight
-
getBorderBox
Only to be called after layout, due to double use of getHeight(). -
setContentWidth
public void setContentWidth(int contentWidth) -
getContentWidth
public int getContentWidth() -
getBorderBoxWidth
-
setBorderBoxWidth
-
getPaintingInfo
-
isAnonymous
public boolean isAnonymous() -
setAnonymous
public void setAnonymous(boolean anonymous) -
getBoxDimensions
-
setBoxDimensions
-
collectText
-
exportText
- Throws:
IOException
-
exportPageBoxText
- Throws:
IOException
-
isInDocumentFlow
public boolean isInDocumentFlow() -
analyzePageBreaks
-
getEffBackgroundColor
-
isMarginAreaRoot
protected boolean isMarginAreaRoot() -
isContainedInMarginBox
public boolean isContainedInMarginBox() -
getEffectiveWidth
public int getEffectiveWidth() -
isInitialContainingBlock
protected boolean isInitialContainingBlock() -
isFirstChild
public boolean isFirstChild()Is this box the first child of its parent? -
isTerminalColumnBreak
public boolean isTerminalColumnBreak()Is this box unbreakable in regards to column break opportunities? -
ancestorsWhile
Creates a list of ancestors by walking up the chain of parent, grandparent, etc. Stops when the provided predicate returns false or the root box otherwise. -
ancestors
Get all ancestors, up until the root box. -
findAncestor
Walks up the ancestor tree to the root testing ancestors agains the predicate. NOTE: Does not test against the current box (this).- Returns:
- the box for which predicate returned true or null if none found.
-
rootBox
Returns the highest ancestor box. May be current box (this). -
findColumnBreakOpportunities
Recursive method to find column break opportunities.- Parameters:
store- - use to report break opportunities.
-