Class PagedBoxCollector
- java.lang.Object
-
- com.openhtmltopdf.render.displaylist.PagedBoxCollector
-
public class PagedBoxCollector extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPagedBoxCollector.AddBlockToShadowPageprivate static classPagedBoxCollector.AddFloatToShadowPageprivate static classPagedBoxCollector.AddInlineToShadowPageprivate static interfacePagedBoxCollector.AddToShadowPageThe joys of lambda style programming in Java 6! Provides a method to add a box to a shadow page if it is determined to sit on a particular shadow page.private static classPagedBoxCollector.FourPointstatic classPagedBoxCollector.PageFinderstatic classPagedBoxCollector.PageInfostatic classPagedBoxCollector.PageResult
-
Field Summary
Fields Modifier and Type Field Description private PagedBoxCollector.PageFinderfinderstatic intPAGE_ALLAdd collected boxes to all pages, including inserted shadow pages.static intPAGE_BASE_ONLYAdd collected items to base page only, ignoring inserted shadow pages.private java.util.List<PageBox>pagesprivate java.util.List<PagedBoxCollector.PageResult>resultprivate intstartPage
-
Constructor Summary
Constructors Constructor Description PagedBoxCollector(java.util.List<PageBox> pages, int minPage, int maxPage)A more efficient paged box collector that can only find boxes on pages minPage to maxPage inclusive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddBlock(Box container, PagedBoxCollector.PageResult pageResult)Adds block box to appropriate flat box lists.private voidaddBlockToAll(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, boolean includeShadowPages)private voidaddBlockToShadowPage(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, int shadowPageNumber)private voidaddBoxToShadowPages(CssContext c, Box container, int pageNumber, PagedBoxCollector.PageResult pageResult, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, Layer layer, PagedBoxCollector.AddToShadowPage addToMethod)Adds box to inserted shadow pages as needed.private voidaddLineBoxToAll(CssContext c, Layer layer, LineBox container, int basePageNumber, boolean includeShadowPages)Adds a line box to the base page if needed and any shadow pages as needed.private voidaddLineBoxToShadowPage(CssContext c, Layer layer, LineBox container, int basePageNumber, int shadowPageNumber)private voidaddTableHeaderFooter(CssContext c, Layer layer, Box container, int shadowPageNumber)private static java.awt.RectangleapplyOverflowClip(java.awt.Rectangle bounds, java.awt.geom.Area overflowClip)private booleanboxIntersects(CssContext c, java.awt.Shape clip, Box box, java.awt.Rectangle boxBounds)voidcollect(CssContext c, Layer layer)voidcollect(CssContext c, Layer layer, Box container, int shadowPageNumber)The main box collection method.voidcollect(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, int shadowPageNumber)voidcollectFloats(CssContext c, Layer layer)private voidcollectInline(CssContext c, Layer layer)static java.awt.RectanglefindAdjustedBoundsForBorderBox(CssContext c, Box container, java.util.List<PageBox> pages)Finds the document coordinates border box bounds of a box adjusted for transform and clipped according to overflow hidden.static java.awt.RectanglefindAdjustedBoundsForContentBox(CssContext c, Box container)Finds the document coordinates content box bounds of a box adjusted for transform and clipped according to overflow hidden.protected intfindEndPage(CssContext c, Box container, java.awt.geom.AffineTransform transform)static intfindEndPage(CssContext c, Box container, java.util.List<PageBox> pages)protected intfindEndPage(CssContext c, java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)static java.util.List<PagedBoxCollector.PageInfo>findLayerPages(CssContext c, Layer layer, java.util.List<PageBox> pages)Returns the pages a layer appears on including inserted overflow pages.static java.awt.RectanglefindLayerRect(CssContext c, Layer layer)static intfindPageForY(CssContext c, double y, java.util.List<PageBox> pages)protected intfindStartPage(CssContext c, Box container, java.awt.geom.AffineTransform transform)static intfindStartPage(CssContext c, Box container, java.util.List<PageBox> pages)protected intfindStartPage(CssContext c, java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)private static java.awt.RectanglegetBoxRect(CssContext c, Box container)private static PagedBoxCollector.FourPointgetCornersFromTransformedBounds(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)protected intgetMaxPageNumber()private static doublegetMaxX(PagedBoxCollector.FourPoint corners)private static doublegetMaxXFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect.private static doublegetMaxY(PagedBoxCollector.FourPoint corners)private static doublegetMaxYFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect, we have to apply it to the box bounds before checking what page(s) it sits on.protected intgetMinPageNumber()private static doublegetMinX(PagedBoxCollector.FourPoint corners)private static doublegetMinY(PagedBoxCollector.FourPoint corners)private static doublegetMinYFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect, we have to apply it to the box bounds before checking what page(s) it sits on.private PagedBoxCollector.PageResultgetOrCreateShadowPage(PagedBoxCollector.PageResult basePage, int shadowPageNumber)Inserts shadow pages as needed.protected PageBoxgetPageBox(int pageNo)protected PagedBoxCollector.PageResultgetPageResult(int pageNo)static intgetShadowPageForBounds(CssContext c, java.awt.Rectangle bounds, PageBox page)protected intgetValidMaxPageNumber(int pageNo)protected intgetValidMinPageNumber(int pageNo)private booleanintersectsAggregateBounds(CssContext c, java.awt.Shape clip, Box box)private booleanintersectsAny(CssContext c, java.awt.Shape clip, Box master, Box container)private booleanintersectsBorderBoxBounds(CssContext c, java.awt.Shape clip, Box box)Returns whether a box (out to the outside edge of border) is partially or fully in a clip shape.private static voidtransformBounds(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)
-
-
-
Field Detail
-
result
private final java.util.List<PagedBoxCollector.PageResult> result
-
pages
private final java.util.List<PageBox> pages
-
finder
private final PagedBoxCollector.PageFinder finder
-
startPage
private final int startPage
-
PAGE_BASE_ONLY
public static final int PAGE_BASE_ONLY
Add collected items to base page only, ignoring inserted shadow pages.- See Also:
- Constant Field Values
-
PAGE_ALL
public static final int PAGE_ALL
Add collected boxes to all pages, including inserted shadow pages.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PagedBoxCollector
public PagedBoxCollector(java.util.List<PageBox> pages, int minPage, int maxPage)
A more efficient paged box collector that can only find boxes on pages minPage to maxPage inclusive.
-
-
Method Detail
-
collect
public void collect(CssContext c, Layer layer)
-
collectInline
private void collectInline(CssContext c, Layer layer)
-
collectFloats
public void collectFloats(CssContext c, Layer layer)
-
collect
public void collect(CssContext c, Layer layer, Box container, int shadowPageNumber)
The main box collection method. This method works recursively to add all the boxes (inlines and blocks separately) owned by this layer to their respective flat page display lists. It also adds clip and setClip operations where needed to clip content inoverflow:hiddenblocks.- Parameters:
c-layer-container-
-
collect
public void collect(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, int shadowPageNumber)
-
addBlockToAll
private void addBlockToAll(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, boolean includeShadowPages)
-
addBlockToShadowPage
private void addBlockToShadowPage(CssContext c, Layer layer, Box container, int pgStart, int pgEnd, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, int shadowPageNumber)
-
addLineBoxToShadowPage
private void addLineBoxToShadowPage(CssContext c, Layer layer, LineBox container, int basePageNumber, int shadowPageNumber)
-
addLineBoxToAll
private void addLineBoxToAll(CssContext c, Layer layer, LineBox container, int basePageNumber, boolean includeShadowPages)
Adds a line box to the base page if needed and any shadow pages as needed.
-
getOrCreateShadowPage
private PagedBoxCollector.PageResult getOrCreateShadowPage(PagedBoxCollector.PageResult basePage, int shadowPageNumber)
Inserts shadow pages as needed.
-
addBoxToShadowPages
private void addBoxToShadowPages(CssContext c, Box container, int pageNumber, PagedBoxCollector.PageResult pageResult, java.awt.Shape ourClip, java.util.List<PagedBoxCollector.PageResult> clipPages, Layer layer, PagedBoxCollector.AddToShadowPage addToMethod)
Adds box to inserted shadow pages as needed.
-
addTableHeaderFooter
private void addTableHeaderFooter(CssContext c, Layer layer, Box container, int shadowPageNumber)
-
addBlock
private void addBlock(Box container, PagedBoxCollector.PageResult pageResult)
Adds block box to appropriate flat box lists.
-
intersectsAggregateBounds
private boolean intersectsAggregateBounds(CssContext c, java.awt.Shape clip, Box box)
-
intersectsBorderBoxBounds
private boolean intersectsBorderBoxBounds(CssContext c, java.awt.Shape clip, Box box)
Returns whether a box (out to the outside edge of border) is partially or fully in a clip shape. This should give us the painting bounds of the box itself, although child boxes can overflow.
-
boxIntersects
private boolean boxIntersects(CssContext c, java.awt.Shape clip, Box box, java.awt.Rectangle boxBounds)
-
intersectsAny
private boolean intersectsAny(CssContext c, java.awt.Shape clip, Box master, Box container)
-
getCornersFromTransformedBounds
private static PagedBoxCollector.FourPoint getCornersFromTransformedBounds(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)
-
getMinYFromTransformedBox
private static double getMinYFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect, we have to apply it to the box bounds before checking what page(s) it sits on. To do this we transform the four corners of the box.
-
getMaxYFromTransformedBox
private static double getMaxYFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect, we have to apply it to the box bounds before checking what page(s) it sits on. To do this we transform the four corners of the box.
-
getMaxXFromTransformedBox
private static double getMaxXFromTransformedBox(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)There is a matrix in effect. We need the max x to see how many shadow pages need creating.
-
findPageForY
public static int findPageForY(CssContext c, double y, java.util.List<PageBox> pages)
-
getShadowPageForBounds
public static int getShadowPageForBounds(CssContext c, java.awt.Rectangle bounds, PageBox page)
-
findAdjustedBoundsForBorderBox
public static java.awt.Rectangle findAdjustedBoundsForBorderBox(CssContext c, Box container, java.util.List<PageBox> pages)
Finds the document coordinates border box bounds of a box adjusted for transform and clipped according to overflow hidden.
-
findAdjustedBoundsForContentBox
public static java.awt.Rectangle findAdjustedBoundsForContentBox(CssContext c, Box container)
Finds the document coordinates content box bounds of a box adjusted for transform and clipped according to overflow hidden.
-
findStartPage
protected int findStartPage(CssContext c, java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)
-
findEndPage
protected int findEndPage(CssContext c, java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)
-
findStartPage
protected int findStartPage(CssContext c, Box container, java.awt.geom.AffineTransform transform)
-
findEndPage
protected int findEndPage(CssContext c, Box container, java.awt.geom.AffineTransform transform)
-
getPageResult
protected PagedBoxCollector.PageResult getPageResult(int pageNo)
-
getMaxPageNumber
protected int getMaxPageNumber()
-
getMinPageNumber
protected int getMinPageNumber()
-
getValidMinPageNumber
protected int getValidMinPageNumber(int pageNo)
-
getValidMaxPageNumber
protected int getValidMaxPageNumber(int pageNo)
-
getPageBox
protected PageBox getPageBox(int pageNo)
-
getBoxRect
private static java.awt.Rectangle getBoxRect(CssContext c, Box container)
-
findLayerRect
public static java.awt.Rectangle findLayerRect(CssContext c, Layer layer)
-
getMinY
private static double getMinY(PagedBoxCollector.FourPoint corners)
-
getMinX
private static double getMinX(PagedBoxCollector.FourPoint corners)
-
getMaxY
private static double getMaxY(PagedBoxCollector.FourPoint corners)
-
getMaxX
private static double getMaxX(PagedBoxCollector.FourPoint corners)
-
transformBounds
private static void transformBounds(java.awt.Rectangle bounds, java.awt.geom.AffineTransform transform)
-
applyOverflowClip
private static java.awt.Rectangle applyOverflowClip(java.awt.Rectangle bounds, java.awt.geom.Area overflowClip)
-
findLayerPages
public static java.util.List<PagedBoxCollector.PageInfo> findLayerPages(CssContext c, Layer layer, java.util.List<PageBox> pages)
Returns the pages a layer appears on including inserted overflow pages. Takes into account any transform and overflow hidden clipping.
-
findStartPage
public static int findStartPage(CssContext c, Box container, java.util.List<PageBox> pages)
- Returns:
- 0 based page number of start of container paint area (including overflow)
-
findEndPage
public static int findEndPage(CssContext c, Box container, java.util.List<PageBox> pages)
- Returns:
- 0 based page number of end of container paint area (including overflow)
-
-