org.fit.cssbox.layout
Class ElementBox

java.lang.Object
  extended by org.fit.cssbox.layout.Box
      extended by org.fit.cssbox.layout.ElementBox
Direct Known Subclasses:
BlockBox, InlineBox

public abstract class ElementBox
extends Box

An abstract class representing a box formed by a DOM element. There are two possible subclases: an inline box and a block box. The element box can contain an arbitrary number of sub-boxes. Since the box can be split to several parts, only a continuous part of the list is considered for rendering.

Author:
radek

Nested Class Summary
 
Nested classes/interfaces inherited from class org.fit.cssbox.layout.Box
Box.DrawStage
 
Field Summary
protected  Color bgcolor
          Background color or null when transparent
protected  Vector<BackgroundImage> bgimages
          Background images or null when there are no background images
protected  LengthSet border
          Padding widths
protected  boolean bottomset
          The top position coordinate is set explicitely
protected  Dimension content
          Content sizes
protected  LengthSet coords
          Position coordinates
protected  org.fit.cssbox.layout.BoxTreeCreationStatus curstat
          Current DOM child during the tree creation
protected  cz.vutbr.web.css.CSSProperty.Display display
          The display property value
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_ANY
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_BLOCK
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_BLOCK
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_TABLE
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_LIST_ITEM
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_NONE
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_RUN_IN
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CAPTION
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CELL
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN_GROUP
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_FOOTER_GROUP
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_HEADER_GROUP
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW
           
static cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW_GROUP
           
protected  Element el
          Assigned element
protected  LengthSet emargin
          Effective top and bottom margins (after collapsing with the contained boxes)
protected  int endChild
          Last valid child (excl)
protected  int firstDOMChild
          First DOM child node index covered by this box (inclusive)
protected  int lastDOMChild
          First DOM child node index covered by this box (exclusive)
protected  boolean leftset
          The top position coordinate is set explicitely
protected  int lineHeight
          the computed value of line-height
protected  LengthSet margin
          Margin widths
protected  Rectangle minAbsBounds
          Minimal absolute bounds.
protected  Vector<Box> nested
          A list of nested boxes (possibly empty).
protected  ElementBox nextTwin
          Next copy of the same box if the box has been split
protected  LengthSet padding
          Border widths
static cz.vutbr.web.css.CSSProperty.Position POS_ABSOLUTE
           
static cz.vutbr.web.css.CSSProperty.Position POS_FIXED
           
static cz.vutbr.web.css.CSSProperty.Position POS_RELATIVE
           
static cz.vutbr.web.css.CSSProperty.Position POS_STATIC
           
protected  cz.vutbr.web.css.CSSProperty.Position position
          Position property
protected  Vector<Box> postadd
          Other boxes to be added to the tree after this one.
protected  Box preadd
          Pre-created box to be added to this box before the DOM nodes are processed.
protected  ElementBox previousTwin
          Previous copy of the same box if the box has been split
protected  Map<cz.vutbr.web.css.Selector.PseudoDeclaration,ElementBox> pseudoElements
          The map of related pseudo-elements (if any)
protected  Map<cz.vutbr.web.css.Selector.PseudoDeclaration,cz.vutbr.web.css.NodeData> pseudoStyle
          Efficient styles for the pseudo classes
protected  boolean rightset
          The top position coordinate is set explicitely
protected  StackingContext scontext
          Corresponding stacking context if this box creates one.
protected  int startChild
          First valid child
protected  cz.vutbr.web.css.NodeData style
          The style of the node (for element nodes only) with no pseudo classes
protected  boolean textonly
          Set to true when the element box contains only text boxes
protected  boolean topset
          The top position coordinate is set explicitely
protected  cz.vutbr.web.css.CSSProperty.WhiteSpace whitespace
          The white-space property value
static cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NORMAL
           
static cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NOWRAP
           
static cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE
           
static cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_LINE
           
static cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_WRAP
           
protected  int zIndex
          the z-index value when set
protected  boolean zset
          the z-index flag: true when z-index is different from auto
 
Fields inherited from class org.fit.cssbox.layout.Box
absbounds, availwidth, base, bounds, cblock, clipblock, ctx, displayed, g, isblock, isempty, node, order, parent, rest, rootelem, splitid, splitted, stackingParent, sticky, viewport, visible
 
Constructor Summary
ElementBox(Element n, Graphics2D g, VisualContext ctx)
          Creates a new element box from a DOM element
 
Method Summary
 void addSubBox(Box box)
          Adds a new sub box to the end of the sub box list.
 void adoptChildren()
          Sets the parent of the valid children to this (used while splitting the boxes)
 boolean affectsDisplay()
           
 boolean allowsWrapping()
          Checks whether this box allows line wrapping on whitespaces according to the whit-space setting.
protected  boolean borderVisible(String dir)
           
 boolean collapsesSpaces()
          Checks whether the whitespaces should be collapsed within in the element according to its style.
abstract  void computeEfficientMargins()
          Computes efficient top and bottom margins for collapsing.
 boolean containsMixedContent()
          Checks if the element contains the mix of text boxes and elements
 boolean containsTextOnly()
          Checks if the element contains only text boxes (no nested elements)
abstract  ElementBox copyBox()
          Create a new box from the same DOM node in the same context
 void copyValues(ElementBox src)
          Copy the values from another element box.
 void drawBackground(Graphics2D g)
          Draw the background and border of this box (no subboxes).
protected  void drawBorders(Graphics2D g, int bx1, int by1, int bx2, int by2)
           
 void drawExtent(Graphics2D g)
          Draw the bounds of the box (for visualisation).
protected  void drawChildContexts(int zindex)
          Draws child stacking contexts of the given z-index.
protected  void drawChildren(Box.DrawStage turn)
          Draws all the sub-boxes in the given stage.
 void drawStackingContext(boolean include)
          Draws the subtree as if this was a stacking context root.
 boolean formsStackingContext()
          Check whether the element forms a new stacking context.
 Rectangle getAbsoluteBackgroundBounds()
           
 Rectangle getAbsoluteBorderBounds()
           
 int getAbsoluteContentX()
           
 int getAbsoluteContentY()
           
 int getAvailableContentWidth()
           
 List<BackgroundImage> getBackgroundImages()
          Obtains the list of background images of the element.
 Color getBgcolor()
           
 LengthSet getBorder()
           
 int getBorderWidth(CSSDecoder dec, String property)
          Reads the value of a border width specified by a CSS property.
 Dimension getContent()
           
 int getContentHeight()
           
 int getContentOffsetX()
          Computes the distance of the content from the left edge of the whole box (a convenience function for margin + border + padding).
 int getContentOffsetY()
          Computes the distance of the content from the top edge of the whole box.
 int getContentWidth()
           
 int getContentX()
           
 int getContentY()
           
 LengthSet getCoords()
          Obtains the position coordinates (top, left, bottom, right properties)
 cz.vutbr.web.css.CSSProperty.Display getDisplay()
          Returns the value of the display property
 String getDisplayString()
           
 Element getElement()
           
 LengthSet getEMargin()
           
 int getEndChild()
           
 cz.vutbr.web.css.TermLengthOrPercent getLengthValue(String name)
          Reads a CSS length value of a style property of the box.
 int getLineHeight()
          Obtains the computed value of the declared line height of the element.
 LengthSet getMargin()
           
 Rectangle getMinimalAbsoluteBounds()
          Determines the minimal bounds of the really displayed content.
 LengthSet getPadding()
           
 String getPositionString()
          Obtains the string value of the position: property
 ElementBox getPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
          Gets the list of related pseudo-element boxes
 StackingContext getStackingContext()
          Obtains the stacking context if this box creates one.
 int getStartChild()
           
 cz.vutbr.web.css.NodeData getStyle()
          Returns the style of the DOM node that forms this box.
 String getStylePropertyValue(String property)
          Reads the string value of the specified property of the element style.
 String getStyleString()
          Obtains the string representation of the current style of the box in the CSS syntax.
 Box getSubBox(int index)
           
 List<Box> getSubBoxList()
           
 int getSubBoxNumber()
           
 String getText()
           
 cz.vutbr.web.css.CSSProperty.WhiteSpace getWhiteSpace()
          Returns the value of the white-space property
 int getZIndex()
          Obtains the declared z-index for this element.
 boolean hasPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
          Checks whether the element box has a related pseudo-element box
 boolean hasZIndex()
          Checks whether the z-index is non-auto for this box.
 void initSubtree()
          Provides the initialization of the box and the corresponding subtree (if any).
 void insertSubBox(int index, Box what)
          Inserts a new sub box at a specified index
 void insertSubBoxAfter(Box where, Box what)
          Inserts a new sub box after a specified sub box
 void insertSubBoxBefore(Box where, Box what)
          Inserts a new sub box before a specified sub box
 boolean isVisible()
          Checks if this box is visible, i.e. it has not visibility:hidden and it is at least partially contained in the clipping region.
 boolean isWhitespace()
           
protected  void loadBackground()
          Loads the background information from the style
protected  Vector<BackgroundImage> loadBackgroundImages(cz.vutbr.web.css.NodeData style)
          Loads background images from style.
protected  void loadBasicStyle()
          Load the basic style from the CSS properties.
protected  void loadBorders(CSSDecoder dec, int contw)
          Loads the border sizes from the style.
protected  void loadPosition()
          Loads the top, left, bottom and right coordinates from the style
protected abstract  void loadSizes()
          Load the box sizes from the CSS properties.
abstract  boolean marginsAdjoin()
          Checks if the element's own top and bottom margins are adjoining according to the CSS specifiaction.
abstract  boolean mayContainBlocks()
           
 boolean preservesLineBreaks()
          Checks whether this element should preserve the line breaks according to its style.
 void removeAllSubBoxes()
          Removes all sub boxes from the subbox list
 void removeSubBox(Box box)
          Removes a sub box from the subbox list
 void setBgcolor(Color bgcolor)
           
 void setEndChild(int index)
           
 void setPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo, ElementBox box)
          Sets related pseudo-element boxes
 void setStartChild(int index)
           
 void setStyle(cz.vutbr.web.css.NodeData s)
          Assign a new style to this box
 int totalWidth()
           
 void updateChildSizes()
          Re-calculates the sizes of all the child block boxes recursively.
abstract  void updateSizes()
          Update the box sizes according to the new parent size.
protected  void updateStackingContexts()
          Updates the stacking parent values and registers the z-index for this parent.
 
Methods inherited from class org.fit.cssbox.layout.Box
absolutePositions, adoptParent, applyClip, canSplitAfter, canSplitBefore, canSplitInside, clipAbsoluteBounds, containsFlow, copyValues, doLayout, draw, endsWithWhitespace, equals, getAbsoluteBounds, getAbsoluteContentBounds, getAvailableWidth, getBase, getBounds, getClipBlock, getClippedBounds, getClippedContentBounds, getContainingBlock, getContentBounds, getGraphics, getHeight, getMaximalWidth, getMinimalWidth, getNode, getOrder, getParent, getRest, getSplitId, getStackingParent, getViewport, getVisualContext, getWidth, hasFixedHeight, hasFixedWidth, hashCode, initBox, isBlock, isDeclaredVisible, isDisplayed, isEmpty, isInFlow, isReplaced, isRootElement, isSticky, makeRoot, moveDown, moveRight, setAvailableWidth, setBase, setClipBlock, setContainingBlock, setIgnoreInitialWhitespace, setOrder, setParent, setPosition, setSize, setStackingParent, setSticky, setViewport, startsWithWhitespace, totalHeight
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_ANY

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_ANY

DISPLAY_NONE

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_NONE

DISPLAY_INLINE

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE

DISPLAY_BLOCK

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_BLOCK

DISPLAY_LIST_ITEM

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_LIST_ITEM

DISPLAY_RUN_IN

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_RUN_IN

DISPLAY_INLINE_BLOCK

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_BLOCK

DISPLAY_TABLE

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE

DISPLAY_INLINE_TABLE

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_TABLE

DISPLAY_TABLE_ROW_GROUP

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW_GROUP

DISPLAY_TABLE_HEADER_GROUP

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_HEADER_GROUP

DISPLAY_TABLE_FOOTER_GROUP

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_FOOTER_GROUP

DISPLAY_TABLE_ROW

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW

DISPLAY_TABLE_COLUMN_GROUP

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN_GROUP

DISPLAY_TABLE_COLUMN

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN

DISPLAY_TABLE_CELL

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CELL

DISPLAY_TABLE_CAPTION

public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CAPTION

POS_STATIC

public static final cz.vutbr.web.css.CSSProperty.Position POS_STATIC

POS_RELATIVE

public static final cz.vutbr.web.css.CSSProperty.Position POS_RELATIVE

POS_ABSOLUTE

public static final cz.vutbr.web.css.CSSProperty.Position POS_ABSOLUTE

POS_FIXED

public static final cz.vutbr.web.css.CSSProperty.Position POS_FIXED

WHITESPACE_NORMAL

public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NORMAL

WHITESPACE_PRE

public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE

WHITESPACE_NOWRAP

public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NOWRAP

WHITESPACE_PRE_WRAP

public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_WRAP

WHITESPACE_PRE_LINE

public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_LINE

el

protected Element el
Assigned element


firstDOMChild

protected int firstDOMChild
First DOM child node index covered by this box (inclusive)


lastDOMChild

protected int lastDOMChild
First DOM child node index covered by this box (exclusive)


preadd

protected Box preadd
Pre-created box to be added to this box before the DOM nodes are processed. Used during the box tree creation only.


postadd

protected Vector<Box> postadd
Other boxes to be added to the tree after this one. Used during the box tree creation only.


curstat

protected org.fit.cssbox.layout.BoxTreeCreationStatus curstat
Current DOM child during the tree creation


previousTwin

protected ElementBox previousTwin
Previous copy of the same box if the box has been split


nextTwin

protected ElementBox nextTwin
Next copy of the same box if the box has been split


style

protected cz.vutbr.web.css.NodeData style
The style of the node (for element nodes only) with no pseudo classes


pseudoStyle

protected Map<cz.vutbr.web.css.Selector.PseudoDeclaration,cz.vutbr.web.css.NodeData> pseudoStyle
Efficient styles for the pseudo classes


bgimages

protected Vector<BackgroundImage> bgimages
Background images or null when there are no background images


textonly

protected boolean textonly
Set to true when the element box contains only text boxes


pseudoElements

protected Map<cz.vutbr.web.css.Selector.PseudoDeclaration,ElementBox> pseudoElements
The map of related pseudo-elements (if any)


display

protected cz.vutbr.web.css.CSSProperty.Display display
The display property value


position

protected cz.vutbr.web.css.CSSProperty.Position position
Position property


coords

protected LengthSet coords
Position coordinates


topset

protected boolean topset
The top position coordinate is set explicitely


leftset

protected boolean leftset
The top position coordinate is set explicitely


bottomset

protected boolean bottomset
The top position coordinate is set explicitely


rightset

protected boolean rightset
The top position coordinate is set explicitely


whitespace

protected cz.vutbr.web.css.CSSProperty.WhiteSpace whitespace
The white-space property value


bgcolor

protected Color bgcolor
Background color or null when transparent


margin

protected LengthSet margin
Margin widths


emargin

protected LengthSet emargin
Effective top and bottom margins (after collapsing with the contained boxes)


border

protected LengthSet border
Padding widths


padding

protected LengthSet padding
Border widths


content

protected Dimension content
Content sizes


minAbsBounds

protected Rectangle minAbsBounds
Minimal absolute bounds.


lineHeight

protected int lineHeight
the computed value of line-height


zset

protected boolean zset
the z-index flag: true when z-index is different from auto


zIndex

protected int zIndex
the z-index value when set


startChild

protected int startChild
First valid child


endChild

protected int endChild
Last valid child (excl)


nested

protected Vector<Box> nested
A list of nested boxes (possibly empty). The box can contain either only block boxes or only inline boxes. The inline boxes can only contain inline boxes


scontext

protected StackingContext scontext
Corresponding stacking context if this box creates one.

Constructor Detail

ElementBox

public ElementBox(Element n,
                  Graphics2D g,
                  VisualContext ctx)
Creates a new element box from a DOM element

Parameters:
n - the DOM element
g - current graphics context
ctx - current visual context
Method Detail

copyValues

public void copyValues(ElementBox src)
Copy the values from another element box.

Parameters:
src - source element box

copyBox

public abstract ElementBox copyBox()
Create a new box from the same DOM node in the same context


initSubtree

public void initSubtree()
Description copied from class: Box
Provides the initialization of the box and the corresponding subtree (if any). Loads the basic CSS properties and computes the sizes.

Overrides:
initSubtree in class Box

getElement

public Element getElement()
Returns:
the corresponding DOM element

setStyle

public void setStyle(cz.vutbr.web.css.NodeData s)
Assign a new style to this box

Parameters:
s - the new style declaration

getStyle

public cz.vutbr.web.css.NodeData getStyle()
Returns the style of the DOM node that forms this box.

Returns:
the style declaration

getStyleString

public String getStyleString()
Obtains the string representation of the current style of the box in the CSS syntax.

Returns:
The style string representation.

getPositionString

public String getPositionString()
Obtains the string value of the position: property

Returns:
The string like "static", "absolute", "relative" or "fixed"

getStylePropertyValue

public String getStylePropertyValue(String property)
Reads the string value of the specified property of the element style.

Parameters:
property - the property name
Returns:
the property value

getLengthValue

public cz.vutbr.web.css.TermLengthOrPercent getLengthValue(String name)
Reads a CSS length value of a style property of the box.

Parameters:
name - property name
Returns:
the length value

getBorderWidth

public int getBorderWidth(CSSDecoder dec,
                          String property)
Reads the value of a border width specified by a CSS property.

Parameters:
dec - a CSS decoder used for converting the values
property - the property name, e.g. "border-top-width"
Returns:
the border width in pixels

getDisplay

public cz.vutbr.web.css.CSSProperty.Display getDisplay()
Returns the value of the display property

Returns:
One of the ElementBox.DISPLAY_XXX constants

getDisplayString

public String getDisplayString()

getWhiteSpace

public cz.vutbr.web.css.CSSProperty.WhiteSpace getWhiteSpace()
Returns the value of the white-space property

Returns:
one of the ElementBox.WHITESPACE_XXX constants

collapsesSpaces

public boolean collapsesSpaces()
Checks whether the whitespaces should be collapsed within in the element according to its style.

Specified by:
collapsesSpaces in class Box
Returns:
true if the whitespace sequences should be collapsed.

preservesLineBreaks

public boolean preservesLineBreaks()
Checks whether this element should preserve the line breaks according to its style.

Specified by:
preservesLineBreaks in class Box
Returns:
true when the line breaks should be preserved

allowsWrapping

public boolean allowsWrapping()
Checks whether this box allows line wrapping on whitespaces according to the whit-space setting.

Specified by:
allowsWrapping in class Box
Returns:
true when line wrapping is allowed

getBgcolor

public Color getBgcolor()
Returns:
the background color or null when transparent

getBackgroundImages

public List<BackgroundImage> getBackgroundImages()
Obtains the list of background images of the element.

Returns:
a list of the background images

setBgcolor

public void setBgcolor(Color bgcolor)
Parameters:
bgcolor - the background color

getSubBoxNumber

public int getSubBoxNumber()
Returns:
the number of subboxes in this box

getSubBoxList

public List<Box> getSubBoxList()
Returns:
list of all the subboxes

getSubBox

public Box getSubBox(int index)
Parameters:
index - the sub box index in the range from 0 to n-1
Returns:
the appropriate sub box

addSubBox

public void addSubBox(Box box)
Adds a new sub box to the end of the sub box list.

Parameters:
box - the new sub box to add

removeSubBox

public void removeSubBox(Box box)
Removes a sub box from the subbox list

Parameters:
box - the new sub box to add

removeAllSubBoxes

public void removeAllSubBoxes()
Removes all sub boxes from the subbox list


insertSubBoxBefore

public void insertSubBoxBefore(Box where,
                               Box what)
Inserts a new sub box before a specified sub box

Parameters:
where - the box already existing in the list
what - the new box to add

insertSubBoxAfter

public void insertSubBoxAfter(Box where,
                              Box what)
Inserts a new sub box after a specified sub box

Parameters:
where - the box already existing in the list
what - the new box to add

insertSubBox

public void insertSubBox(int index,
                         Box what)
Inserts a new sub box at a specified index

Parameters:
index - the index where the new box will be placed
what - the new box to add

getStackingContext

public StackingContext getStackingContext()
Obtains the stacking context if this box creates one.


setPseudoElement

public void setPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo,
                             ElementBox box)
Sets related pseudo-element boxes

Parameters:
pseudo - the name of the pseudo-element
box - the corresponding pseudo-element box

getPseudoElement

public ElementBox getPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
Gets the list of related pseudo-element boxes

Parameters:
pseudo - the name of the pseudo-element
Returns:
the related box

hasPseudoElement

public boolean hasPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
Checks whether the element box has a related pseudo-element box

Parameters:
pseudo - the name of the pseudo-element
Returns:
the related box

getContentWidth

public int getContentWidth()
Specified by:
getContentWidth in class Box
Returns:
the width of the content without any margins and borders

getContentHeight

public int getContentHeight()
Specified by:
getContentHeight in class Box
Returns:
the height of the content without any margins and borders

getLineHeight

public int getLineHeight()
Obtains the computed value of the declared line height of the element.

Returns:
the line height in pixels

getMargin

public LengthSet getMargin()
Returns:
the margin sizes

getEMargin

public LengthSet getEMargin()
Returns:
the effective margin sizes (after collapsing)

getCoords

public LengthSet getCoords()
Obtains the position coordinates (top, left, bottom, right properties)

Returns:
the set of coordinates

getBorder

public LengthSet getBorder()
Returns:
the border sizes (0 when no border is displayed)

getPadding

public LengthSet getPadding()
Returns:
the padding sizes

getContent

public Dimension getContent()
Returns:
the content sizes

hasZIndex

public boolean hasZIndex()
Checks whether the z-index is non-auto for this box.

Returns:
true when z-index has a value different form auto.

getZIndex

public int getZIndex()
Obtains the declared z-index for this element.

Returns:
the z-index value

formsStackingContext

public boolean formsStackingContext()
Check whether the element forms a new stacking context.

Returns:
true when the element creates a new stacking context.

getStartChild

public int getStartChild()
Returns:
the first child from the list that is considered for rendering

setStartChild

public void setStartChild(int index)
Parameters:
index - the index of the first child from the list that is considered for rendering

getEndChild

public int getEndChild()
Returns:
the last child from the list that is considered for rendering (not included)

setEndChild

public void setEndChild(int index)
Parameters:
index - the index of the last child from the list that is considered for rendering

adoptChildren

public void adoptChildren()
Sets the parent of the valid children to this (used while splitting the boxes)


getContentOffsetX

public int getContentOffsetX()
Computes the distance of the content from the left edge of the whole box (a convenience function for margin + border + padding).

Returns:
the distance

getContentOffsetY

public int getContentOffsetY()
Computes the distance of the content from the top edge of the whole box. (a convenience function for margin + border + padding).

Returns:
the distance

getContentX

public int getContentX()
Specified by:
getContentX in class Box
Returns:
the X coordinate of the content box top left corner

getContentY

public int getContentY()
Specified by:
getContentY in class Box
Returns:
the Y coordinate of the content box top left corner

getAbsoluteContentX

public int getAbsoluteContentX()
Specified by:
getAbsoluteContentX in class Box
Returns:
the absolute X coordinate of the content box top left corner

getAbsoluteContentY

public int getAbsoluteContentY()
Specified by:
getAbsoluteContentY in class Box
Returns:
the Y coordinate of the content box top left corner

totalWidth

public int totalWidth()
Specified by:
totalWidth in class Box
Returns:
the expected width of the box according to the CSS property values

getAvailableContentWidth

public int getAvailableContentWidth()
Specified by:
getAvailableContentWidth in class Box
Returns:
maximal available width of the content during the layout

getMinimalAbsoluteBounds

public Rectangle getMinimalAbsoluteBounds()
Description copied from class: Box
Determines the minimal bounds of the really displayed content.

Specified by:
getMinimalAbsoluteBounds in class Box
Returns:
the minimal bounds

affectsDisplay

public boolean affectsDisplay()
Specified by:
affectsDisplay in class Box
Returns:
true, if the element displays at least something (some content, or borders)

isVisible

public boolean isVisible()
Description copied from class: Box
Checks if this box is visible, i.e. it has not visibility:hidden and it is at least partially contained in the clipping region.

Overrides:
isVisible in class Box
Returns:
true if the box is visible

getAbsoluteBackgroundBounds

public Rectangle getAbsoluteBackgroundBounds()
Returns:
the bounds of the background - the content and padding

getAbsoluteBorderBounds

public Rectangle getAbsoluteBorderBounds()
Returns:
the bounds of the border - the content, padding and border

getText

public String getText()
Specified by:
getText in class Box
Returns:
all the text contained in this box and its subboxes

isWhitespace

public boolean isWhitespace()
Specified by:
isWhitespace in class Box
Returns:
true if the box only contains whitespaces

containsTextOnly

public boolean containsTextOnly()
Checks if the element contains only text boxes (no nested elements)

Returns:
true when only text boxes are contained in this element

containsMixedContent

public boolean containsMixedContent()
Checks if the element contains the mix of text boxes and elements

Returns:
true when both text boxes and elements are directly contained in this element

drawStackingContext

public void drawStackingContext(boolean include)
Draws the subtree as if this was a stacking context root.

Parameters:
g - The graphic context to be used for painting.
include - include new stacking contexts to this context (currently unused)

drawChildren

protected void drawChildren(Box.DrawStage turn)
Draws all the sub-boxes in the given stage.

Parameters:
g - The graphic context to be used for painting.
turn - The current drawing stage.

drawChildContexts

protected void drawChildContexts(int zindex)
Draws child stacking contexts of the given z-index.

Parameters:
g - The graphic context to be used for painting.
zindex - The z-index of the contexts to draw. Only the child contexts with the given z-index will be drawn.

drawBackground

public void drawBackground(Graphics2D g)
Draw the background and border of this box (no subboxes). This method is normally called automatically from Box#draw(Graphics2D, DrawStage).

Parameters:
g - the graphics context used for drawing

drawBorders

protected void drawBorders(Graphics2D g,
                           int bx1,
                           int by1,
                           int bx2,
                           int by2)

drawExtent

public void drawExtent(Graphics2D g)
Description copied from class: Box
Draw the bounds of the box (for visualisation).

Specified by:
drawExtent in class Box

mayContainBlocks

public abstract boolean mayContainBlocks()
Returns:
true when this box may contain block boxes (it may be a containing-block)

loadSizes

protected abstract void loadSizes()
Load the box sizes from the CSS properties.


updateSizes

public abstract void updateSizes()
Update the box sizes according to the new parent size. Should be called when the parent has been resized.


updateChildSizes

public void updateChildSizes()
Re-calculates the sizes of all the child block boxes recursively.


computeEfficientMargins

public abstract void computeEfficientMargins()
Computes efficient top and bottom margins for collapsing.


marginsAdjoin

public abstract boolean marginsAdjoin()
Checks if the element's own top and bottom margins are adjoining according to the CSS specifiaction.

Returns:
true if the margins are adjoining

borderVisible

protected boolean borderVisible(String dir)
Returns:
true if the box has a visible border around

loadBorders

protected void loadBorders(CSSDecoder dec,
                           int contw)
Loads the border sizes from the style.

Parameters:
dec - CSS decoder used for decoding the style
contw - containing block width for decoding percentages

loadBasicStyle

protected void loadBasicStyle()
Load the basic style from the CSS properties. This includes the display properties, floating, positioning, color and font properties.


loadBackground

protected void loadBackground()
Loads the background information from the style


loadBackgroundImages

protected Vector<BackgroundImage> loadBackgroundImages(cz.vutbr.web.css.NodeData style)
Loads background images from style. Considers their positions, repetition, etc. Currently, only a single background image is supported (CSS2).

Parameters:
style - the style containing the image specifiations
Returns:
a list of images

loadPosition

protected void loadPosition()
Loads the top, left, bottom and right coordinates from the style


updateStackingContexts

protected void updateStackingContexts()
Updates the stacking parent values and registers the z-index for this parent.

Overrides:
updateStackingContexts in class Box


Copyright © 2014. All rights reserved.