Package cz.vutbr.fit.layout.impl
Class BaseBoxTreeBuilder
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.BaseBoxTreeBuilder
-
- Direct Known Subclasses:
BoxTreeBuilder,CSSBoxTreeBuilder,PageBoxTreeBuilder,PDFBoxTreeBuilder
public abstract class BaseBoxTreeBuilder extends Object
This class implements building the box tree using the default FitLayout box nesting algorithms.- Author:
- burgetr
-
-
Field Summary
Fields Modifier and Type Field Description protected StringpageTitleprotected URLpageUrlprotected booleanpreserveAuxPreserve auxiliary boxes that have no actual visual resultprotected booleanuseVisualBoundsUse real visual bounds instead of the element content bounds for building the box hierarchy
-
Constructor Summary
Constructors Constructor Description BaseBoxTreeBuilder(boolean useVisualBounds, boolean preserveAux)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected BoxbuildTree(List<Box> boxlist, Color bgColor)protected voidcomputeBackgrounds(Box root, Color currentbg)Computes efficient background color for all the nodes in the treeprotected RectangularcomputeVisualBounds(Box box)protected booleancontentEncloses(Box parent, Box child)protected RectangulargetMinimalVisualBounds(Box box)Returns the minimal bounds of the box for enclosing all the contained boxes.abstract PagegetPage()The resulting page model.voidmarkChildNodes(Box parent, List<Box> list, List<Box> parents)Takes a list of nodes and selects the nodes whose parent box is identical to this node's box.protected voidmarkNodesInside(Box parent, List<Box> list, boolean useVisualBounds, List<Box> parents)Takes a list of nodes and selects the nodes that are located directly inside of this node's box.voidrecomputeBounds(Box root, boolean useVisualBounds)Recomputes the total bounds of the whole subtree.protected voidrecomputeVisualBounds(Box root)Recomputes the visual bounds of the whole subtree.protected voidrecomputeVisualBounds(List<Box> boxes)Recomputes the visual bounds for a list of boxes.protected voidtakeChildren(Box parent, List<Box> list, List<Box> parents)Goes through the parent's children, takes all the nodes that are inside of this node and makes them the children of this node.protected booleanvisuallyEncloses(Box parent, Box child)
-
-
-
Field Detail
-
pageUrl
protected URL pageUrl
-
pageTitle
protected String pageTitle
-
useVisualBounds
protected boolean useVisualBounds
Use real visual bounds instead of the element content bounds for building the box hierarchy
-
preserveAux
protected boolean preserveAux
Preserve auxiliary boxes that have no actual visual result
-
-
Method Detail
-
getPage
public abstract Page getPage()
The resulting page model.- Returns:
- the page
-
markChildNodes
public void markChildNodes(Box parent, List<Box> list, List<Box> parents)
Takes a list of nodes and selects the nodes whose parent box is identical to this node's box. ThenearestParentof the selected boxes is set to this box node.- Parameters:
list- the list of nodes to test
-
markNodesInside
protected void markNodesInside(Box parent, List<Box> list, boolean useVisualBounds, List<Box> parents)
Takes a list of nodes and selects the nodes that are located directly inside of this node's box. The corresponding positions in the destination list of parents is set to the parent box.- Parameters:
parent- the parent node to considerlist- the list of nodes to testuseVisualBounds- when set totrue, only the boxes within the visual bounds are considered. Otherwise, all the nodes within the box content bounds are considered.parents- the list of parent boxes where the parent nodes are marked. The list must have the same size aslist.
-
takeChildren
protected void takeChildren(Box parent, List<Box> list, List<Box> parents)
Goes through the parent's children, takes all the nodes that are inside of this node and makes them the children of this node. Then, recursively calls the children to take their nodes.
-
computeBackgrounds
protected void computeBackgrounds(Box root, Color currentbg)
Computes efficient background color for all the nodes in the tree
-
recomputeBounds
public void recomputeBounds(Box root, boolean useVisualBounds)
Recomputes the total bounds of the whole subtree. The bounds of each box will correspond to its visual bounds. If the child boxes exceed the parent box, the parent box bounds will be expanded accordingly.- Parameters:
root- the root node of the subtreeuseVisualBounds- use the visual bounds instead of the content bounds
-
recomputeVisualBounds
protected void recomputeVisualBounds(List<Box> boxes)
Recomputes the visual bounds for a list of boxes.- Parameters:
boxes-
-
recomputeVisualBounds
protected void recomputeVisualBounds(Box root)
Recomputes the visual bounds of the whole subtree.- Parameters:
root- the root node of the subtree
-
computeVisualBounds
protected Rectangular computeVisualBounds(Box box)
-
getMinimalVisualBounds
protected Rectangular getMinimalVisualBounds(Box box)
Returns the minimal bounds of the box for enclosing all the contained boxes.- Returns:
- the minimal visual bounds
-
-