Class Layer
java.lang.Object
com.openhtmltopdf.layout.Layer
All positioned content as well as content with an overflow value other
than visible creates a layer. Layers which define stacking contexts
provide the entry for rendering the box tree to an output device. The main
purpose of this class is to provide an implementation of Appendix E of the
spec, but it also provides additional utility services including page
management and mapping boxes to coordinates (for e.g. links). When
rendering to a paged output device, the layer is also responsible for laying
out absolute content (which is layed out after its containing block has
completed layout).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AffineTransformprivate Boxprivate booleanprivate booleanprivate final booleanprivate booleanprivate booleanprivate PageBoxprivate Boxprivate Layerprivate booleanprivate Boxprivate intprivate intprivate Boxprivate intprivate intprivate booleanstatic final intstatic final intstatic final shortstatic final shortstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionLayer(Layer parent, Box master, CssContext c) Creates a child layer.Layer(Box master, CssContext c) Creates the root layer.Layer(Box master, CssContext c, boolean isolated) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddFloat(BlockBox floater, BlockFormattingContext bfc) voidvoidaddPageSequence(BlockBox start) private voidaddPagesUntilPosition(CssContext c, int position) voidaddRunningBlock(BlockBox block) protected List<AffineTransform> applyTranform(RenderingContext c, Box box) Deprecated.private voidapplyTransformFunctions(float flipFactor, List<PropertyValue> transformList, List<AffineTransform> resultTransforms) Deprecated.voidassignPagePaintingPositions(CssContext cssCtx, int mode, int additionalClearance) voidassignPagePaintingPositions(CssContext cssCtx, short mode) private PaintingInfoprivate Map<TableCellBox, List<CollapsedBorderSide>> collectCollapsedTableBorders(RenderingContext c, List<Box> blocks) Deprecated.collectLayers(int which) Called recusively to collect all descendant layers in a layer tree so they can be painted in correct order.private floatDeprecated.static PageBoxcreatePageBox(CssContext c, String pseudoPage) booleancrossesPageBreak(LayoutContext c, int top, int bottom) Returns whether the a box with the given top and bottom would cross a page break.voiddetach()voidensureHasPage(CssContext c, Box box) find(CssContext cssCtx, int absX, int absY, boolean findAnonymous) Deprecated.private Boxfind(CssContext cssCtx, int absX, int absY, List<Layer> layers, boolean findAnonymous) Deprecated.private BlockBoxfindPageSequence(List<BlockBox> sequences, int absY) findRoot()voidThe resulting list should not be modified.The document coordinates current transform, this is cumulative from layer to child layer.getEnd()getFirstPage(CssContext c, int absY) Returns the page box for a Y position.getFirstPage(CssContext c, Box box) getLastPage(CssContext c, Box box) private PageBoxintgetMaxPageWidth(CssContext cssCtx, int additionalClearance) getPage(CssContext c, int yOffset) Gets the page box for the given document y offset.getPages()getPages(CssContext c, int top, int bottom) Tries to return a list of pages that cover top to bottom.private intgetPageSequenceStart(RenderingContext c, List<BlockBox> sequences, PageBox page) intintintgetRelativePageNo(RenderingContext c, int absY) getRunningBlock(String identifer, PageBox page, PageElementPosition which) intintintintgetSortedLayers(int which) getStackingContextLayers(int which) intbooleanbooleanbooleanbooleanisInline()booleanbooleanisLastPage(PageBox pageBox) booleanbooleanbooleanbooleanprivate voidlayoutAbsoluteChild(LayoutContext c, Layer child) private voidvoidprivate voidmoveIfGreater(Dimension result, Dimension test) private SearchUtil.IntComparatorpageFinder(List<PageBox> pages, int yOffset, Predicate<PageBox> matcher) Returns a comparator that determines if the given pageBox is a match, too late or too early.pagePredicate(int yOffset) Returns a predicate that determines if yOffset sits on the given page.voidDeprecated.voidpaintAsLayer(RenderingContext c, BlockBox startingPoint) Deprecated.private voidpaintBackgroundsAndBorders(RenderingContext c, List<Box> blocks, Map<TableCellBox, List<CollapsedBorderSide>> collapsedTableBorders, BoxRangeLists rangeLists) Deprecated.private voidDeprecated.private voidDeprecated.private voidpaintInlineContent(RenderingContext c, List<Box> lines, BoxRangeLists rangeLists) Deprecated.private voidDeprecated.private voidpaintLayers(RenderingContext c, List<Layer> layers) Deprecated.private voidpaintListMarkers(RenderingContext c, List<Box> blocks, BoxRangeLists rangeLists) Deprecated.private voidpaintReplacedElement(RenderingContext c, BlockBox replaced) Deprecated.private voidpaintReplacedElements(RenderingContext c, List<Box> blocks, BoxRangeLists rangeLists) Deprecated.private voidpaintSelection(RenderingContext c, List<Box> lines) Deprecated.private voidvoidvoidvoidRecursively propagates the transformation matrix.private voidvoidremoveFloat(BlockBox floater) FIXME: Only used when we reset a box, so trying to remove at sometime in the future.voidvoidremoveRunningBlock(BlockBox block) voidvoidsetForDeletion(boolean forDeletion) voidsetInline(boolean inline) private voidsetIsolated(boolean b) private voidsetLastRequestedPage(PageBox lastRequestedPage) voidvoidsetRequiresLayout(boolean requiresLayout) voidsetSelectionEnd(Box selectionEnd) voidsetSelectionEndX(int selectionEndX) voidsetSelectionEndY(int selectionEndY) voidsetSelectionStart(Box selectionStart) voidsetSelectionStartX(int selectionStartX) voidsetSelectionStartY(int selectionStartY) voidsetStackingContext(boolean stackingContext) voidtrimEmptyPages(CssContext c, int maxYHeight) voidtrimPageCount(int newPageCount)
-
Field Details
-
PAGED_MODE_SCREEN
public static final short PAGED_MODE_SCREEN- See Also:
-
PAGED_MODE_PRINT
public static final short PAGED_MODE_PRINT- See Also:
-
_parent
-
_stackingContext
private boolean _stackingContext -
_children
-
_master
-
_end
-
_floats
-
_inline
private boolean _inline -
_requiresLayout
private boolean _requiresLayout -
_pages
-
_lastRequestedPage
-
_pageSequences
-
_sortedPageSequences
-
_runningBlocks
-
_selectionStart
-
_selectionEnd
-
_selectionStartX
private int _selectionStartX -
_selectionStartY
private int _selectionStartY -
_selectionEndX
private int _selectionEndX -
_selectionEndY
private int _selectionEndY -
_forDeletion
private boolean _forDeletion -
_hasFixedAncester
private boolean _hasFixedAncester -
_ctm
-
_hasLocalTransform
private final boolean _hasLocalTransform -
_isolated
private boolean _isolated -
POSITIVE
public static final int POSITIVE- See Also:
-
ZERO
public static final int ZERO- See Also:
-
NEGATIVE
public static final int NEGATIVE- See Also:
-
AUTO
public static final int AUTO- See Also:
-
-
Constructor Details
-
Layer
Creates the root layer. -
Layer
-
Layer
Creates a child layer.
-
-
Method Details
-
setIsolated
private void setIsolated(boolean b) -
propagateCurrentTransformationMatrix
Recursively propagates the transformation matrix. This must be done after layout of the master box and its children as this method relies on the box width and height for relative units in the transforms and transform origins. -
getCurrentTransformMatrix
The document coordinates current transform, this is cumulative from layer to child layer. May be null, if identity transform is in effect. Used to check if a box belonging to this layer sits on a particular page after the transform is applied. This method can only be used afterpropagateCurrentTransformationMatrix(CssContext)has been called on the root layer.- Returns:
- null or affine transform.
-
hasLocalTransform
public boolean hasLocalTransform() -
setForDeletion
public void setForDeletion(boolean forDeletion) -
isForDeletion
public boolean isForDeletion() -
hasFixedAncester
public boolean hasFixedAncester() -
getParent
-
isStackingContext
public boolean isStackingContext() -
setStackingContext
public void setStackingContext(boolean stackingContext) -
getZIndex
public int getZIndex() -
isZIndexAuto
public boolean isZIndexAuto() -
getMaster
-
addChild
-
createPageBox
-
removeFloat
FIXME: Only used when we reset a box, so trying to remove at sometime in the future. -
paintFloats
Deprecated. -
paintLayers
Deprecated. -
addFloat
-
collectLayers
-
getStackingContextLayers
-
getSortedLayers
-
paintBackgroundsAndBorders
@Deprecated private void paintBackgroundsAndBorders(RenderingContext c, List<Box> blocks, Map<TableCellBox, List<CollapsedBorderSide>> collapsedTableBorders, BoxRangeLists rangeLists) Deprecated. -
paintSelection
Deprecated. -
getPaintingDimension
-
paintInlineContent
@Deprecated private void paintInlineContent(RenderingContext c, List<Box> lines, BoxRangeLists rangeLists) Deprecated. -
paint
Deprecated. -
convertAngleToRadians
Deprecated. -
getFloats
-
applyTranform
Deprecated.Applies the transforms specified for the box and returns a list of inverse transforms that should be applied once the transformed element has been output. -
applyTransformFunctions
@Deprecated private void applyTransformFunctions(float flipFactor, List<PropertyValue> transformList, List<AffineTransform> resultTransforms) Deprecated. -
find
@Deprecated private Box find(CssContext cssCtx, int absX, int absY, List<Layer> layers, boolean findAnonymous) Deprecated. -
find
Deprecated. -
paintCollapsedTableBorders
@Deprecated private void paintCollapsedTableBorders(RenderingContext c, List<CollapsedBorderSide> borders) Deprecated. -
collectCollapsedTableBorders
@Deprecated private Map<TableCellBox, List<CollapsedBorderSide>> collectCollapsedTableBorders(RenderingContext c, List<Box> blocks) Deprecated. -
paintAsLayer
Deprecated. -
paintListMarkers
@Deprecated private void paintListMarkers(RenderingContext c, List<Box> blocks, BoxRangeLists rangeLists) Deprecated. -
paintReplacedElements
@Deprecated private void paintReplacedElements(RenderingContext c, List<Box> blocks, BoxRangeLists rangeLists) Deprecated. -
paintLayerBackgroundAndBorder
Deprecated. -
positionFixedLayer
-
isRootLayer
public boolean isRootLayer() -
moveIfGreater
-
paintReplacedElement
Deprecated. -
positionChildren
-
calcPaintingDimension
-
getChildren
-
remove
-
detach
public void detach() -
isInline
public boolean isInline() -
setInline
public void setInline(boolean inline) -
getEnd
-
setEnd
-
isRequiresLayout
public boolean isRequiresLayout() -
setRequiresLayout
public void setRequiresLayout(boolean requiresLayout) -
finish
-
layoutAbsoluteChildren
-
position
-
getPages
-
setPages
-
isLastPage
-
layoutAbsoluteChild
-
removeLastPage
public void removeLastPage() -
addPage
-
getFirstPage
Returns the page box for a Y position. If the y position is less than 0 then the first page will be returned if available. Only returns null if there are no pages available.
IMPORTANT: If absY is past the end of the last page, pages will be created as required to include absY and the last page will be returned. -
getFirstPage
-
getLastPage
-
ensureHasPage
-
getPages
Tries to return a list of pages that cover top to bottom. If top and bottom are less-than zero returns null.
IMPORTANT: If bottom is past the end of the last page, pages are created until bottom is included. -
pageFinder
private SearchUtil.IntComparator pageFinder(List<PageBox> pages, int yOffset, Predicate<PageBox> matcher) Returns a comparator that determines if the given pageBox is a match, too late or too early. For use withSearchUtil.intBinarySearch(IntComparator, int, int) -
pagePredicate
-
getPage
Gets the page box for the given document y offset. If y offset is less-than zero returns null.
IMPORTANT: If y offset is past the end of the last page, pages are created until y offset is included and the last page is returned. -
addPagesUntilPosition
-
trimEmptyPages
-
trimPageCount
public void trimPageCount(int newPageCount) -
assignPagePaintingPositions
-
assignPagePaintingPositions
-
getMaxPageWidth
-
getLastPage
-
crossesPageBreak
Returns whether the a box with the given top and bottom would cross a page break.
Requirements: top is >= 0.
Important: This method will take into account anyfloat: bottomcontent when used in in-flow content. For example, if the top/bottom pair overlaps the footnote area, returns true. It also takes into account space set aside for paginated table header/footer.
SeeCssContext.isInFloatBottom()LayoutContext.getExtraSpaceBottom() -
findRoot
-
addRunningBlock
-
removeRunningBlock
-
getRunningBlock
-
layoutPages
-
addPageSequence
-
getSortedPageSequences
-
getRelativePageNo
-
findPageSequence
-
getRelativePageNo
-
getRelativePageCount
-
getPageSequenceStart
-
getSelectionEnd
-
setSelectionEnd
-
getSelectionStart
-
setSelectionStart
-
getSelectionEndX
public int getSelectionEndX() -
setSelectionEndX
public void setSelectionEndX(int selectionEndX) -
getSelectionEndY
public int getSelectionEndY() -
setSelectionEndY
public void setSelectionEndY(int selectionEndY) -
getSelectionStartX
public int getSelectionStartX() -
setSelectionStartX
public void setSelectionStartX(int selectionStartX) -
getSelectionStartY
public int getSelectionStartY() -
setSelectionStartY
public void setSelectionStartY(int selectionStartY) -
getLastRequestedPage
-
setLastRequestedPage
-
isIsolated
public boolean isIsolated()
-