Package cz.vutbr.fit.layout.model
Interface Box
-
- All Superinterfaces:
ContentRect
,GenericTreeNode<Box>
,Rect
- All Known Implementing Classes:
BoxImpl
,BoxImpl
,BoxNode
,DefaultBox
,RDFBox
public interface Box extends ContentRect, GenericTreeNode<Box>
This class represents a box in the rendered page tree. It may contain a text or a content object (e.g. an image).- Author:
- burgetr
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Box.DisplayType
CSS Display Typestatic class
Box.Type
The type of the box.
-
Field Summary
-
Fields inherited from interface cz.vutbr.fit.layout.model.ContentRect
ATTR_SAME_AS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.Rectangular
getBounds()
Returns the logical bounds of the box.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.String
getFontFamily()
Obtains the font family name used by the box.Box
getIntrinsicParent()
Gets the parent box of this box as obtained from the renderer.int
getOrder()
Gets the order of precedence of the box in the page.String
getOwnText()
Obtains the text contained directly in this box without considering its child boxes.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.String
getText()
Obtains the complete text contained in this box.String
getText(BoxConcatenator concatenator)
Obtains the complete text contained in this box.Box.Type
getType()
Resurns the type of the box.Rectangular
getVisualBounds()
Returns the bounds of the box as they visually appear to the user.boolean
isVisible()
Checks whether the box is visible.boolean
isVisuallySeparated()
Checks if the box is separated from other contents by some visual means: a visible border at any side, visible background different from its parent or a visible content.void
setContentBounds(Rectangular contentBounds)
Sets the content bounds of the box.void
setVisualBounds(Rectangular visualBounds)
Sets the visual bounds of the box.-
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
-
-
-
-
Method Detail
-
getOrder
int getOrder()
Gets the order of precedence of the box in the page. A box that precedes another box in the page must have a lower order number.- Returns:
- the document order for the box
-
getColor
Color getColor()
Obtains the box text color.- Returns:
- the text color
-
getFontFamily
String getFontFamily()
Obtains the font family name used by the box.- Returns:
- The font family name.
-
getText
String getText()
Obtains the complete text contained in this box. For the leaf boxes, it returns the corresponding string. For non-leaft boxes, it returns the concatentaion of the leaf box strings using the default concatenator defined byConcatenators.getDefaultBoxConcatenator()
.- Returns:
- a text string (possibly empty)
-
getText
String getText(BoxConcatenator concatenator)
Obtains the complete text contained in this box. For the leaf boxes, it returns the corresponding string. For non-leaft boxes, it returns the concatentaion of the leaf box strings using a given concatenator.- Parameters:
concatenator
- The concatenator to be used to join the boxes.- Returns:
- a text string (possibly empty)
-
getOwnText
String getOwnText()
Obtains the text contained directly in this box without considering its child boxes.- Returns:
- a text string for leaf boxes,
null
for non-leaf boxes
-
getContentObject
ContentObject getContentObject()
Obtains the content object contained in this box.- Returns:
- the content object or
null
when there is no object contained.
-
getIntrinsicParent
Box getIntrinsicParent()
Gets the parent box of this box as obtained from the renderer. The renturned value may benull
when the box was not obtained by rendering (e.g. a box tree loaded from the storage).- Returns:
- the intrinsic parent box or
null
-
getBounds
Rectangular getBounds()
Returns the logical bounds of the box. Normally, the bounds are the same as the content bounds. However, the Box may be extended in order to enclose all the overlapping boxes.- Specified by:
getBounds
in interfaceContentRect
- Returns:
- the logical bounds of the box
-
getContentBounds
Rectangular getContentBounds()
Returns the content bounds. They correspond to the background bounds of the box; however, when a border is present, it is included in the contents. Moreover, the box is clipped by its clipping box.- Returns:
- the content bounds of the box
-
setContentBounds
void setContentBounds(Rectangular contentBounds)
Sets the content bounds of the box.- Parameters:
contentBounds
- the new content bounds.
-
getVisualBounds
Rectangular getVisualBounds()
Returns the bounds of the box as they visually appear to the user.- Returns:
- the visual bounds
-
setVisualBounds
void setVisualBounds(Rectangular visualBounds)
Sets the visual bounds of the box.- Parameters:
visualBounds
- the new visual bounds.
-
getSubstringBounds
Rectangular getSubstringBounds(int startPos, int endPos)
Returns the bounds of a substring of the own text of the box starting atstartPos
and ending atendPos
.- 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
-
isVisible
boolean isVisible()
Checks whether the box is visible.- Returns:
true
when the box is visible
-
isVisuallySeparated
boolean isVisuallySeparated()
Checks if the box is separated from other contents by some visual means: a visible border at any side, visible background different from its parent or a visible content.- Returns:
true
if the box is visually separated
-
getType
Box.Type getType()
Resurns the type of the box.- Returns:
- the box type
-
getSourceNodeId
String getSourceNodeId()
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.
-
getTagName
String getTagName()
When the box is generated by a DOM element, obtains the corresponding tag name.- Returns:
- the tag name or
null
for boxes that do not correspond to a DOM element.
-
getAttribute
String getAttribute(String name)
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
.- Parameters:
name
- the attribute name- Returns:
- the attribute value or
null
if the value is not specified.
-
getAttributes
Map<String,String> getAttributes()
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
.- Returns:
- A map assigning values to the individual attribute names. An empty map is returned when no attributes are defined.
-
getDisplayType
Box.DisplayType getDisplayType()
Obtains the display type of the element according to the CSS display: property.- Returns:
- The display type of NULL if the box does not correspond to an element
-
-