|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fit.cssbox.layout.Box
org.fit.cssbox.layout.ElementBox
public abstract class ElementBox
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.
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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_ANY
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_NONE
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_BLOCK
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_LIST_ITEM
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_RUN_IN
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_BLOCK
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_INLINE_TABLE
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW_GROUP
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_HEADER_GROUP
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_FOOTER_GROUP
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_ROW
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN_GROUP
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_COLUMN
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CELL
public static final cz.vutbr.web.css.CSSProperty.Display DISPLAY_TABLE_CAPTION
public static final cz.vutbr.web.css.CSSProperty.Position POS_STATIC
public static final cz.vutbr.web.css.CSSProperty.Position POS_RELATIVE
public static final cz.vutbr.web.css.CSSProperty.Position POS_ABSOLUTE
public static final cz.vutbr.web.css.CSSProperty.Position POS_FIXED
public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NORMAL
public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE
public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_NOWRAP
public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_WRAP
public static final cz.vutbr.web.css.CSSProperty.WhiteSpace WHITESPACE_PRE_LINE
protected Element el
protected int firstDOMChild
protected int lastDOMChild
protected Box preadd
protected Vector<Box> postadd
protected org.fit.cssbox.layout.BoxTreeCreationStatus curstat
protected ElementBox previousTwin
protected ElementBox nextTwin
protected cz.vutbr.web.css.NodeData style
protected Map<cz.vutbr.web.css.Selector.PseudoDeclaration,cz.vutbr.web.css.NodeData> pseudoStyle
protected Vector<BackgroundImage> bgimages
protected boolean textonly
protected Map<cz.vutbr.web.css.Selector.PseudoDeclaration,ElementBox> pseudoElements
protected cz.vutbr.web.css.CSSProperty.Display display
protected cz.vutbr.web.css.CSSProperty.Position position
protected LengthSet coords
protected boolean topset
protected boolean leftset
protected boolean bottomset
protected boolean rightset
protected cz.vutbr.web.css.CSSProperty.WhiteSpace whitespace
protected Color bgcolor
protected LengthSet margin
protected LengthSet emargin
protected LengthSet border
protected LengthSet padding
protected Dimension content
protected Rectangle minAbsBounds
protected int lineHeight
protected boolean zset
auto
protected int zIndex
protected int startChild
protected int endChild
protected Vector<Box> nested
protected StackingContext scontext
Constructor Detail |
---|
public ElementBox(Element n, Graphics2D g, VisualContext ctx)
n
- the DOM elementg
- current graphics contextctx
- current visual contextMethod Detail |
---|
public void copyValues(ElementBox src)
src
- source element boxpublic abstract ElementBox copyBox()
public void initSubtree()
Box
initSubtree
in class Box
public Element getElement()
public void setStyle(cz.vutbr.web.css.NodeData s)
s
- the new style declarationpublic cz.vutbr.web.css.NodeData getStyle()
public String getStyleString()
public String getPositionString()
public String getStylePropertyValue(String property)
property
- the property name
public cz.vutbr.web.css.TermLengthOrPercent getLengthValue(String name)
name
- property name
public int getBorderWidth(CSSDecoder dec, String property)
dec
- a CSS decoder used for converting the valuesproperty
- the property name, e.g. "border-top-width"
public cz.vutbr.web.css.CSSProperty.Display getDisplay()
public String getDisplayString()
public cz.vutbr.web.css.CSSProperty.WhiteSpace getWhiteSpace()
public boolean collapsesSpaces()
collapsesSpaces
in class Box
true
if the whitespace sequences should be collapsed.public boolean preservesLineBreaks()
preservesLineBreaks
in class Box
true
when the line breaks should be preservedpublic boolean allowsWrapping()
allowsWrapping
in class Box
true
when line wrapping is allowedpublic Color getBgcolor()
public List<BackgroundImage> getBackgroundImages()
public void setBgcolor(Color bgcolor)
bgcolor
- the background colorpublic int getSubBoxNumber()
public List<Box> getSubBoxList()
public Box getSubBox(int index)
index
- the sub box index in the range from 0 to n-1
public void addSubBox(Box box)
box
- the new sub box to addpublic void removeSubBox(Box box)
box
- the new sub box to addpublic void removeAllSubBoxes()
public void insertSubBoxBefore(Box where, Box what)
where
- the box already existing in the listwhat
- the new box to addpublic void insertSubBoxAfter(Box where, Box what)
where
- the box already existing in the listwhat
- the new box to addpublic void insertSubBox(int index, Box what)
index
- the index where the new box will be placedwhat
- the new box to addpublic StackingContext getStackingContext()
public void setPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo, ElementBox box)
pseudo
- the name of the pseudo-elementbox
- the corresponding pseudo-element boxpublic ElementBox getPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
pseudo
- the name of the pseudo-element
public boolean hasPseudoElement(cz.vutbr.web.css.Selector.PseudoDeclaration pseudo)
pseudo
- the name of the pseudo-element
public int getContentWidth()
getContentWidth
in class Box
public int getContentHeight()
getContentHeight
in class Box
public int getLineHeight()
public LengthSet getMargin()
public LengthSet getEMargin()
public LengthSet getCoords()
public LengthSet getBorder()
public LengthSet getPadding()
public Dimension getContent()
public boolean hasZIndex()
true
when z-index has a value different form auto
.public int getZIndex()
public boolean formsStackingContext()
true
when the element creates a new stacking context.public int getStartChild()
public void setStartChild(int index)
index
- the index of the first child from the list that is considered for renderingpublic int getEndChild()
public void setEndChild(int index)
index
- the index of the last child from the list that is considered for renderingpublic void adoptChildren()
public int getContentOffsetX()
public int getContentOffsetY()
public int getContentX()
getContentX
in class Box
public int getContentY()
getContentY
in class Box
public int getAbsoluteContentX()
getAbsoluteContentX
in class Box
public int getAbsoluteContentY()
getAbsoluteContentY
in class Box
public int totalWidth()
totalWidth
in class Box
public int getAvailableContentWidth()
getAvailableContentWidth
in class Box
public Rectangle getMinimalAbsoluteBounds()
Box
getMinimalAbsoluteBounds
in class Box
public boolean affectsDisplay()
affectsDisplay
in class Box
public boolean isVisible()
Box
isVisible
in class Box
true
if the box is visiblepublic Rectangle getAbsoluteBackgroundBounds()
public Rectangle getAbsoluteBorderBounds()
public String getText()
getText
in class Box
public boolean isWhitespace()
isWhitespace
in class Box
true
if the box only contains whitespacespublic boolean containsTextOnly()
true
when only text boxes are contained in this elementpublic boolean containsMixedContent()
true
when both text boxes and elements are directly contained in this elementpublic void drawStackingContext(boolean include)
g
- The graphic context to be used for painting.include
- include new stacking contexts to this context (currently unused)protected void drawChildren(Box.DrawStage turn)
g
- The graphic context to be used for painting.turn
- The current drawing stage.protected void drawChildContexts(int zindex)
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.public void drawBackground(Graphics2D g)
Box#draw(Graphics2D, DrawStage)
.
g
- the graphics context used for drawingprotected void drawBorders(Graphics2D g, int bx1, int by1, int bx2, int by2)
public void drawExtent(Graphics2D g)
Box
drawExtent
in class Box
public abstract boolean mayContainBlocks()
true when this box may contain block boxes (it may be a containing-block)
protected abstract void loadSizes()
public abstract void updateSizes()
public void updateChildSizes()
public abstract void computeEfficientMargins()
public abstract boolean marginsAdjoin()
true
if the margins are adjoiningprotected boolean borderVisible(String dir)
true
if the box has a visible border aroundprotected void loadBorders(CSSDecoder dec, int contw)
dec
- CSS decoder used for decoding the stylecontw
- containing block width for decoding percentagesprotected void loadBasicStyle()
protected void loadBackground()
protected Vector<BackgroundImage> loadBackgroundImages(cz.vutbr.web.css.NodeData style)
style
- the style containing the image specifiations
protected void loadPosition()
protected void updateStackingContexts()
updateStackingContexts
in class Box
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |