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 classBox.DisplayTypeCSS Display Typestatic classBox.TypeThe 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 StringgetAttribute(String name)Obtains a value of an additional attribute.Map<String,String>getAttributes()Obtains the names and values of all the box attributes.RectangulargetBounds()Returns the logical bounds of the box.ColorgetColor()Obtains the box text color.RectangulargetContentBounds()Returns the content bounds.ContentObjectgetContentObject()Obtains the content object contained in this box.Box.DisplayTypegetDisplayType()Obtains the display type of the element according to the CSS display: property.StringgetFontFamily()Obtains the font family name used by the box.BoxgetIntrinsicParent()Gets the parent box of this box as obtained from the renderer.intgetOrder()Gets the order of precedence of the box in the page.StringgetOwnText()Obtains the text contained directly in this box without considering its child boxes.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.StringgetText()Obtains the complete text contained in this box.StringgetText(BoxConcatenator concatenator)Obtains the complete text contained in this box.Box.TypegetType()Resurns the type of the box.RectangulargetVisualBounds()Returns the bounds of the box as they visually appear to the user.booleanisVisible()Checks whether the box is visible.booleanisVisuallySeparated()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.voidsetContentBounds(Rectangular contentBounds)Sets the content bounds of the box.voidsetVisualBounds(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,
nullfor non-leaf boxes
-
getContentObject
ContentObject getContentObject()
Obtains the content object contained in this box.- Returns:
- the content object or
nullwhen there is no object contained.
-
getIntrinsicParent
Box getIntrinsicParent()
Gets the parent box of this box as obtained from the renderer. The renturned value may benullwhen 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:
getBoundsin 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 atstartPosand 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
nullwhen there is no own text contained in the box
-
isVisible
boolean isVisible()
Checks whether the box is visible.- Returns:
truewhen 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:
trueif 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
nullfor 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 areclassorhref.- Parameters:
name- the attribute name- Returns:
- the attribute value or
nullif 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 areclassorhref.- 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
-
-