public class BoxNode extends GenericTreeNode implements Box
Box.DisplayType, Box.Type| Modifier and Type | Field and Description |
|---|---|
protected boolean |
backgroundSeparated
Is the box separated by background
|
protected Rectangular |
bounds
The total bounds of the box node.
|
protected org.fit.cssbox.layout.Box |
box
The CSSBox box that forms this node
|
protected Rectangular |
content
The total content bounds of the node.
|
protected java.awt.Color |
efficientBackground
Efficient background color
|
BoxNode |
nearestParent
Potential nearest parent node in the box tree
|
protected int |
order
Order in the box tree.
|
protected Page |
page
The page this box belongs to.
|
protected Rectangular |
visual
Visual bounds of the node.
|
| Constructor and Description |
|---|
BoxNode(org.fit.cssbox.layout.Box box,
Page page)
Creates a new node containing a box.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsVisibleTextString()
Checks if the box text is visible (it does not contain spaces only).
|
boolean |
contentEncloses(BoxNode childNode)
Checks if another node is fully located inside the content bounds of this box.
|
boolean |
equals(java.lang.Object obj) |
void |
expandToEnclose(BoxNode child)
Expands the box node in order to fully enclose another box
|
protected java.lang.String |
getAncestorAttribute(org.w3c.dom.Node node,
java.lang.String elementName,
java.lang.String attrName) |
java.lang.String |
getAttribute(java.lang.String name)
Obtains a value of an additional attribute.
|
java.awt.Color |
getBackgroundColor()
Returns the declared background color of the element or null when transparent.
|
int |
getBorderCount()
Obtains the number of defined borders for the box.
|
Border |
getBorderStyle(Border.Side side)
Obtains the properties of the box border at the given side.
|
int |
getBottomBorder()
Obtains the bottom border of the box
|
Rectangular |
getBounds()
Returns the logical bounds of the box node.
|
org.fit.cssbox.layout.Box |
getBox() |
java.awt.Color |
getColor()
Obtains the box text color.
|
Rectangular |
getContentBounds()
Returns the content bounds.
|
ContentObject |
getContentObject()
Obtains the content object contained in this box.
|
Box.DisplayType |
getDisplayType()
Obtains the display type of the element according to the CSS display: property.
|
org.w3c.dom.Node |
getDOMNode() |
java.awt.Color |
getEfficientBackground() |
java.lang.String |
getEfficientColor()
Get the effective text color.
|
protected java.lang.String |
getElementAttribute(org.w3c.dom.Node node,
java.lang.String attrName) |
java.lang.String |
getFontFamily()
Obtains the font family name used by the box.
|
float |
getFontSize()
Obtains an average font size in the are in pixels.
|
float |
getFontStyle()
Obtains the average font style. 0 means no text in italics, 1 means all the text in italics.
|
float |
getFontWeight()
Obtains the average font style. 0 means no text is bold, 1 means all the text is bold
|
int |
getHeight() |
BoxNode |
getChildBox(int index)
Returns a specified child box.
|
int |
getId()
Obtains a unique ID of the area within the page.
|
int |
getLeftBorder()
Obtains the left border of the box
|
float |
getLineThrough()
Obtains the amount of line-through text. 0 means no underlined text, 1 means all the text is underlined.
|
int |
getOrder() |
Page |
getPage()
Obtains the page this block belongs to.
|
BoxNode |
getParentBox()
Obtains the parent box of this box.
|
int |
getRightBorder()
Obtains the right border of the box
|
java.awt.Color |
getStartColor()
Obtains the text color of the first box in the area.
|
java.lang.String |
getTagName()
When the box is generated by a DOM element, obtains the corresponding tag name.
|
java.lang.String |
getText()
Obtains the complete text contained in this box.
|
int |
getTopBorder()
Obtains the top border of the box
|
Box.Type |
getType()
Resurns the type of the box.
|
float |
getUnderline()
Obtains the amount of underlined text. 0 means no underlined text, 1 means all the text is underlined.
|
Rectangular |
getVisualBounds()
Returns the bounds of the box as they visually appear to the user.
|
int |
getWidth() |
int |
getX1() |
int |
getX2() |
int |
getY1() |
int |
getY2() |
boolean |
hasBottomBorder()
Checks whether the box has the bottom border defined.
|
boolean |
hasLeftBorder()
Checks whether the box has the left border defined.
|
boolean |
hasRightBorder()
Checks whether the box has right top border defined.
|
boolean |
hasTopBorder()
Checks whether the box has the top border defined.
|
boolean |
isBackgroundSeparated()
Checks whether the box is separated by background, i.e. its background color is not transparent
and it is different from the ancestor background.
|
boolean |
isRootNode() |
boolean |
isVisible()
Checks whether the box is inside of the visible area and the text is visible and its color is different from the background
|
boolean |
isVisuallySeparated() |
void |
markNodesInside(java.util.Vector<BoxNode> list,
boolean full)
Takes a list of nodes and selects the nodes that are located directly inside
of this node's box.
|
void |
recomputeBounds()
Recomputes the total bounds of the whole subtree.
|
void |
recomputeVisualBounds()
Re-computes the visual bounds of the whole subtree.
|
void |
removeFromTree()
Removes the node from the tree.
|
void |
setBackgroundSeparated(boolean backgroundSeparated) |
void |
setEfficientBackground(java.awt.Color bgcolor) |
void |
setOrder(int order) |
void |
takeChildren(java.util.Vector<BoxNode> list)
Goes through the parent's children, takes all the nodes that are inside of this node
and makes them the children of this node.
|
java.lang.String |
toString() |
boolean |
visuallyEncloses(BoxNode childNode)
Checks if another node is located inside the visual bounds of this box.
|
boolean |
visuallyEncloses1(BoxNode childNode)
Checks if another node is fully located inside the content bounds of this box.
|
add, addAttribute, getAttribute, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSiblingNode, getParent, getPreviousSiblingNode, getRoot, insert, isLeaf, isRoot, remove, remove, removeAllChildrenclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetChildCountprotected org.fit.cssbox.layout.Box box
protected Page page
protected int order
protected Rectangular bounds
protected Rectangular content
protected Rectangular visual
protected boolean backgroundSeparated
protected java.awt.Color efficientBackground
public BoxNode nearestParent
public BoxNode(org.fit.cssbox.layout.Box box,
Page page)
box - the contained boxpublic int getId()
ContentRectgetId in interface ContentRectpublic int getOrder()
public void setOrder(int order)
order - the display tree order to setpublic boolean isRootNode()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean isBackgroundSeparated()
ContentRectisBackgroundSeparated in interface ContentRecttrue for background-separated boxespublic void setBackgroundSeparated(boolean backgroundSeparated)
public java.awt.Color getEfficientBackground()
public void setEfficientBackground(java.awt.Color bgcolor)
bgcolor - the efficientBackground to setpublic boolean isVisuallySeparated()
true if the box is visually separated by a border or
a different background color.public Rectangular getVisualBounds()
getVisualBounds in interface Boxpublic void recomputeVisualBounds()
public void recomputeBounds()
public int getBorderCount()
ContentRectgetBorderCount in interface ContentRectpublic boolean hasTopBorder()
ContentRecthasTopBorder in interface ContentRecttrue if the box has a top borderpublic int getTopBorder()
getTopBorder in interface ContentRectpublic boolean hasBottomBorder()
ContentRecthasBottomBorder in interface ContentRecttrue if the box has a bottom borderpublic int getBottomBorder()
getBottomBorder in interface ContentRectpublic boolean hasLeftBorder()
ContentRecthasLeftBorder in interface ContentRecttrue if the box has a left borderpublic int getLeftBorder()
getLeftBorder in interface ContentRectpublic boolean hasRightBorder()
ContentRecthasRightBorder in interface ContentRecttrue if the box has a right borderpublic int getRightBorder()
getRightBorder in interface ContentRectpublic Border getBorderStyle(Border.Side side)
BoxgetBorderStyle in interface Boxside - the border side.public java.lang.String getEfficientColor()
public java.awt.Color getStartColor()
public boolean containsVisibleTextString()
public boolean isVisible()
public java.awt.Color getBackgroundColor()
getBackgroundColor in interface ContentRectnull for transparent backgroundpublic org.fit.cssbox.layout.Box getBox()
public BoxNode getParentBox()
BoxgetParentBox in interface Boxpublic BoxNode getChildBox(int index)
getChildBox in interface Boxindex - the child indexpublic Rectangular getBounds()
BoxgetBounds in interface BoxgetBounds in interface ContentRectpublic Rectangular getContentBounds()
BoxgetContentBounds in interface Boxpublic boolean visuallyEncloses(BoxNode childNode)
childNode - the node to checktrue if the child node is completely inside this node, false otherwisepublic boolean visuallyEncloses1(BoxNode childNode)
childNode - the node to checktrue if the child node is completely inside this node, false otherwisepublic boolean contentEncloses(BoxNode childNode)
childNode - the node to checktrue if the child node is completely inside this node, false otherwisepublic void expandToEnclose(BoxNode child)
public void markNodesInside(java.util.Vector<BoxNode> list, boolean full)
list - the list of nodes to testfull - when set to true, all the nodes within the box content bounds are considered.
Otherwise, only the boxes within the visual bounds are considered.public void takeChildren(java.util.Vector<BoxNode> list)
public void removeFromTree()
public java.lang.String getText()
Boxpublic Page getPage()
ContentRectgetPage in interface ContentRectpublic float getUnderline()
ContentRectgetUnderline in interface ContentRectpublic float getLineThrough()
ContentRectgetLineThrough in interface ContentRectpublic float getFontSize()
ContentRectgetFontSize in interface ContentRectpublic float getFontStyle()
ContentRectgetFontStyle in interface ContentRectpublic float getFontWeight()
ContentRectgetFontWeight in interface ContentRectpublic java.awt.Color getColor()
Boxpublic java.lang.String getFontFamily()
BoxgetFontFamily in interface Boxpublic ContentObject getContentObject()
BoxgetContentObject in interface Boxnull when there is no object contained.public Box.Type getType()
Boxpublic org.w3c.dom.Node getDOMNode()
public java.lang.String getTagName()
BoxgetTagName in interface Boxnull for boxes that do not correspond to a DOM element.public java.lang.String getAttribute(java.lang.String name)
Boxclass or href.getAttribute in interface Boxname - the attribute namenull if the value is not specified.protected java.lang.String getElementAttribute(org.w3c.dom.Node node,
java.lang.String attrName)
protected java.lang.String getAncestorAttribute(org.w3c.dom.Node node,
java.lang.String elementName,
java.lang.String attrName)
public Box.DisplayType getDisplayType()
BoxgetDisplayType in interface Box