Interface Box

    • 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 by Concatenators.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 be null 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 interface ContentRect
        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 at startPos and ending at endPos.
        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 are class or href.
        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 are class or href.
        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