Package cz.vutbr.fit.layout.cssbox.impl
Class BoxNode
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultTreeNode<T>
-
- cz.vutbr.fit.layout.impl.DefaultTreeContentRect<Box>
-
- cz.vutbr.fit.layout.impl.DefaultBox
-
- cz.vutbr.fit.layout.cssbox.impl.BoxNode
-
- All Implemented Interfaces:
Box
,ContentRect
,GenericTreeNode<Box>
,Rect
public class BoxNode extends DefaultBox
A node of a tree of visual blocks.- Author:
- burgetr
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cz.vutbr.fit.layout.model.Box
Box.DisplayType, Box.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected org.fit.cssbox.layout.Box
box
The CSSBox box that forms this nodeprotected BoxTransform
transform
The transformation that should be applied to the box-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Constructor Summary
Constructors Constructor Description BoxNode(org.fit.cssbox.layout.Box box, org.eclipse.rdf4j.model.IRI pageIri, float zoom)
Creates a new node containing a box with a transparent background.BoxNode(org.fit.cssbox.layout.Box box, org.eclipse.rdf4j.model.IRI pageIri, Color bgColor, float zoom)
Creates a new node containing a box with a computed background.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
protected String
getAncestorAttribute(Node node, String elementName, String attrName)
String
getAttribute(String name)
Obtains a value of an additional attribute.Map<String,String>
getAttributes()
Obtains the names and values of all the box attributes.org.fit.cssbox.layout.Box
getBox()
Box.DisplayType
getDisplayType()
Obtains the display type of the element according to the CSS display: property.Node
getDOMNode()
protected String
getElementAttribute(Node node, String attrName)
Border
getIntrinsicBorderStyle(Border.Side side)
int
getIntrinsicBottomBorder()
Rectangular
getIntrinsicBounds()
Gets the original bounds of a box as provided by CSSBox.Color
getIntrinsicColor()
ContentObject
getIntrinsicContentObject()
String
getIntrinsicFontFamily()
float
getIntrinsicFontSize()
float
getIntrinsicFontStyle()
float
getIntrinsicFontWeight()
int
getIntrinsicLeftBorder()
float
getIntrinsicLineThrough()
int
getIntrinsicRightBorder()
int
getIntrinsicTopBorder()
Box.Type
getIntrinsicType()
float
getIntrinsicUnderline()
String
getSourceNodeId()
Obtains a unique identification of the box source (e.g. the source DOM node).Rectangular
getSubstringBounds(int startPos, int endPos)
Returns the bounds of a substring of the own text of the box starting atstartPos
and ending atendPos
.String
getTagName()
When the box is generated by a DOM element, obtains the corresponding tag name.protected void
recomputeTextStyle()
Recomputes the text style after the style of some children has changed.String
toString()
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultBox
getColor, getContentBounds, getContentObject, getFontFamily, getHeight, getIntrinsicParent, getOrder, getOwnText, getText, getText, getType, getVisualBounds, getWidth, getX1, getX2, getY1, getY2, isVisible, isVisuallySeparated, move, removeAttribute, setAttribute, setColor, setContentBounds, setContentObject, setDisplayType, setFontFamily, setIntrinsicParent, setOrder, setOwnText, setSourceNodeId, setTagName, setType, setVisible, setVisualBounds
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultTreeContentRect
addUserAttribute, getBackgroundColor, getBackgroundImagePng, getBorderCount, getBorderStyle, getBottomBorder, getBounds, getId, getLeftBorder, getLine, getPageIri, getRightBorder, getTextStyle, getTopBorder, getUserAttribute, hasBackground, hasBottomBorder, hashCode, hasLeftBorder, hasRightBorder, hasTopBorder, childrenChanged, isBackgroundSeparated, setBackgroundColor, setBackgroundImagePng, setBackgroundSeparated, setBorderStyle, setBounds, setId, setLine, setPageIri, setTextStyle
-
Methods inherited from class cz.vutbr.fit.layout.impl.DefaultTreeNode
appendChild, appendChildren, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSibling, getParent, getPreviousSibling, getRoot, insertChild, isLeaf, isRoot, removeAllChildren, removeChild, removeChild, setParent, setRoot
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cz.vutbr.fit.layout.model.ContentRect
addUserAttribute, getBackgroundColor, getBackgroundImagePng, getBorderCount, getBorderStyle, getBottomBorder, getId, getLeftBorder, getLine, getPageIri, getRightBorder, getTextStyle, getTopBorder, getUserAttribute, hasBackground, hasBottomBorder, hasLeftBorder, hasRightBorder, hasTopBorder, isBackgroundSeparated, setBackgroundSeparated, setBounds, setLine
-
Methods inherited from interface cz.vutbr.fit.layout.model.GenericTreeNode
appendChild, appendChildren, getDepth, getChildAt, getChildCount, getChildren, getIndex, getLeafCount, getNextSibling, getParent, getPreviousSibling, getRoot, childrenChanged, insertChild, isLeaf, isRoot, removeAllChildren, removeChild, removeChild, setParent, setRoot
-
-
-
-
Field Detail
-
box
protected org.fit.cssbox.layout.Box box
The CSSBox box that forms this node
-
transform
protected BoxTransform transform
The transformation that should be applied to the box
-
-
Constructor Detail
-
BoxNode
public BoxNode(org.fit.cssbox.layout.Box box, org.eclipse.rdf4j.model.IRI pageIri, float zoom)
Creates a new node containing a box with a transparent background.- Parameters:
box
- the contained boxpageIri
- containing page IRIzoom
- zoom factor to apply
-
BoxNode
public BoxNode(org.fit.cssbox.layout.Box box, org.eclipse.rdf4j.model.IRI pageIri, Color bgColor, float zoom)
Creates a new node containing a box with a computed background. The background is computed separately when creating the nodes because the Viewport (and some table elements) are treated in a special way.- Parameters:
box
- the contained boxpageIri
- containing page IRIbgColor
- computed backgound color to be used for the boxzoom
- zoom factor to apply
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classDefaultBox
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classDefaultTreeContentRect<Box>
-
getIntrinsicBounds
public Rectangular getIntrinsicBounds()
Gets the original bounds of a box as provided by CSSBox.- Returns:
- the intrinsic bounds
-
getIntrinsicTopBorder
public int getIntrinsicTopBorder()
-
getIntrinsicBottomBorder
public int getIntrinsicBottomBorder()
-
getIntrinsicLeftBorder
public int getIntrinsicLeftBorder()
-
getIntrinsicRightBorder
public int getIntrinsicRightBorder()
-
getIntrinsicBorderStyle
public Border getIntrinsicBorderStyle(Border.Side side)
-
getBox
public org.fit.cssbox.layout.Box getBox()
- Returns:
- the contained box
-
recomputeTextStyle
protected void recomputeTextStyle()
Description copied from class:DefaultTreeContentRect
Recomputes the text style after the style of some children has changed.- Overrides:
recomputeTextStyle
in classDefaultBox
-
getIntrinsicFontSize
public float getIntrinsicFontSize()
-
getIntrinsicFontStyle
public float getIntrinsicFontStyle()
-
getIntrinsicFontWeight
public float getIntrinsicFontWeight()
-
getIntrinsicUnderline
public float getIntrinsicUnderline()
-
getIntrinsicLineThrough
public float getIntrinsicLineThrough()
-
getIntrinsicColor
public Color getIntrinsicColor()
-
getIntrinsicFontFamily
public String getIntrinsicFontFamily()
-
getIntrinsicContentObject
public ContentObject getIntrinsicContentObject()
-
getIntrinsicType
public Box.Type getIntrinsicType()
-
getDOMNode
public Node getDOMNode()
-
getSourceNodeId
public String getSourceNodeId()
Description copied from interface:Box
Obtains a unique identification of the box source (e.g. the source DOM node). This may be used for recognizing the boxes generated by the same DOM node.- Specified by:
getSourceNodeId
in interfaceBox
- Overrides:
getSourceNodeId
in classDefaultBox
-
getTagName
public String getTagName()
Description copied from interface:Box
When the box is generated by a DOM element, obtains the corresponding tag name.- Specified by:
getTagName
in interfaceBox
- Overrides:
getTagName
in classDefaultBox
- Returns:
- the tag name or
null
for boxes that do not correspond to a DOM element.
-
getAttribute
public String getAttribute(String name)
Description copied from interface:Box
Obtains a value of an additional attribute. The existing attribute names depend on the box implementation; they may correspond to HTML (DOM) attributes or they may be purely virtual. The typical attributes to be implemented areclass
orhref
.- Specified by:
getAttribute
in interfaceBox
- Overrides:
getAttribute
in classDefaultBox
- Parameters:
name
- the attribute name- Returns:
- the attribute value or
null
if the value is not specified.
-
getAttributes
public Map<String,String> getAttributes()
Description copied from interface:Box
Obtains the names and values of all the box attributes. The existing attribute names depend on the box implementation; they may correspond to HTML (DOM) attributes or they may be purely virtual. The typical attributes to be implemented areclass
orhref
.- Specified by:
getAttributes
in interfaceBox
- Overrides:
getAttributes
in classDefaultBox
- Returns:
- A map assigning values to the individual attribute names. An empty map is returned when no attributes are defined.
-
getAncestorAttribute
protected String getAncestorAttribute(Node node, String elementName, String attrName)
-
getDisplayType
public Box.DisplayType getDisplayType()
Description copied from interface:Box
Obtains the display type of the element according to the CSS display: property.- Specified by:
getDisplayType
in interfaceBox
- Overrides:
getDisplayType
in classDefaultBox
- Returns:
- The display type of NULL if the box does not correspond to an element
-
getSubstringBounds
public Rectangular getSubstringBounds(int startPos, int endPos)
Description copied from interface:Box
Returns the bounds of a substring of the own text of the box starting atstartPos
and ending atendPos
.- Specified by:
getSubstringBounds
in interfaceBox
- Overrides:
getSubstringBounds
in classDefaultBox
- Parameters:
startPos
- the starting position in the own text of the box (as obtained by )endPos
- the ending position in the own text of the box- Returns:
- the visual bounds in pixels or
null
when there is no own text contained in the box
-
-