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.BoxboxThe CSSBox box that forms this nodeprotected BoxTransformtransformThe 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 booleanequals(Object obj)protected StringgetAncestorAttribute(Node node, String elementName, String attrName)StringgetAttribute(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.BoxgetBox()Box.DisplayTypegetDisplayType()Obtains the display type of the element according to the CSS display: property.NodegetDOMNode()protected StringgetElementAttribute(Node node, String attrName)BordergetIntrinsicBorderStyle(Border.Side side)intgetIntrinsicBottomBorder()RectangulargetIntrinsicBounds()Gets the original bounds of a box as provided by CSSBox.ColorgetIntrinsicColor()ContentObjectgetIntrinsicContentObject()StringgetIntrinsicFontFamily()floatgetIntrinsicFontSize()floatgetIntrinsicFontStyle()floatgetIntrinsicFontWeight()intgetIntrinsicLeftBorder()floatgetIntrinsicLineThrough()intgetIntrinsicRightBorder()intgetIntrinsicTopBorder()Box.TypegetIntrinsicType()floatgetIntrinsicUnderline()StringgetSourceNodeId()Obtains a unique identification of the box source (e.g. the source DOM node).RectangulargetSubstringBounds(int startPos, int endPos)Returns the bounds of a substring of the own text of the box starting atstartPosand ending atendPos.StringgetTagName()When the box is generated by a DOM element, obtains the corresponding tag name.protected voidrecomputeTextStyle()Recomputes the text style after the style of some children has changed.StringtoString()-
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:
toStringin classDefaultBox
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin 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:DefaultTreeContentRectRecomputes the text style after the style of some children has changed.- Overrides:
recomputeTextStylein 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:BoxObtains 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:
getSourceNodeIdin interfaceBox- Overrides:
getSourceNodeIdin classDefaultBox
-
getTagName
public String getTagName()
Description copied from interface:BoxWhen the box is generated by a DOM element, obtains the corresponding tag name.- Specified by:
getTagNamein interfaceBox- Overrides:
getTagNamein classDefaultBox- Returns:
- the tag name or
nullfor boxes that do not correspond to a DOM element.
-
getAttribute
public String getAttribute(String name)
Description copied from interface:BoxObtains 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 areclassorhref.- Specified by:
getAttributein interfaceBox- Overrides:
getAttributein classDefaultBox- Parameters:
name- the attribute name- Returns:
- the attribute value or
nullif the value is not specified.
-
getAttributes
public Map<String,String> getAttributes()
Description copied from interface:BoxObtains 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 areclassorhref.- Specified by:
getAttributesin interfaceBox- Overrides:
getAttributesin 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:BoxObtains the display type of the element according to the CSS display: property.- Specified by:
getDisplayTypein interfaceBox- Overrides:
getDisplayTypein 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:BoxReturns the bounds of a substring of the own text of the box starting atstartPosand ending atendPos.- Specified by:
getSubstringBoundsin interfaceBox- Overrides:
getSubstringBoundsin 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
nullwhen there is no own text contained in the box
-
-