info.informatica.doc.style.css.visual.box
Class AbstractCSSBox

java.lang.Object
  extended by info.informatica.doc.style.css.visual.box.AbstractCSSBox
All Implemented Interfaces:
CSSBox
Direct Known Subclasses:
AbstractBlockBox, AbstractInlineBox, AbstractReplacedBox, FloatingBox, ListItemBox.ListItemMarkerBox, TableRowBox

public abstract class AbstractCSSBox
extends Object
implements CSSBox

Abstract CSS box.

Author:
Carlos Amengual (amengual at informatica.info)

Constructor Summary
AbstractCSSBox(CSS2ComputedProperties style)
           
 
Method Summary
protected  float computeNumberOrZero(org.w3c.dom.css.CSSPrimitiveValue cssValue)
          Computes the float value of a number, or returns zero if finds a non-numeric value.
protected  float computeNumberOrZero(String property)
           
 CSSPoint getBackgroundPosition()
          Gets the position for the background image, if any.
 org.w3c.dom.css.CSSPrimitiveValue getBorderBottomColor()
           
 float getBorderBottomWidth()
           
 org.w3c.dom.css.CSSPrimitiveValue getBorderLeftColor()
           
 float getBorderLeftWidth()
           
 org.w3c.dom.css.CSSPrimitiveValue getBorderRightColor()
           
 float getBorderRightWidth()
           
 org.w3c.dom.css.CSSPrimitiveValue getBorderTopColor()
           
 float getBorderTopWidth()
           
 CSS2ComputedProperties getComputedStyle()
          Gets the computed style for the element that generated this box.
protected  float getContainerWidth()
           
 CSSContainerBox getContainingBlock()
          Gets the 'containing block' for thid box, as defined by the CSS specification.
protected  org.w3c.dom.css.CSSPrimitiveValue getCSSValue(String property)
           
protected  CSSErrorHandler getErrorHandler()
           
 String getFontFamily()
          Gets the 'used' value for the font-family property.
 int getFontSize()
          Gets the computed value of the font-size property.
 String getFontWeight()
          Gets the computed font weight.
 CSSBox getGeneratedSibling()
          Gets the box generated by the element that generated this box.
protected abstract  float getHeight()
          Gets the height of this box.
 float getLeading()
           
 float getLeading(float defval)
           
 float getLeft()
           
 float getLineHeight()
           
 float getLineHeight(float defval)
           
 org.w3c.dom.css.CSSValue getLineHeightCSSValue()
           
 float getMarginBottom()
          Gets the value of the margin-bottom property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getMarginLeft()
          Gets the value of the margin-left property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getMarginRight()
          Gets the value of the margin-right property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getMarginTop()
          Gets the value of the margin-top property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getPaddingBottom()
          Gets the value of the padding-bottom property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getPaddingLeft()
          Gets the value of the padding-left property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getPaddingRight()
          Gets the value of the padding-right property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
protected  float getPaddingSubproperty(String subpropertyName)
           
 float getPaddingTop()
          Gets the value of the padding-top property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.
 float getRight()
           
protected abstract  float getWidth()
          Gets the width of this box.
protected  boolean isContainerHeightAuto()
           
protected  boolean isHeightAuto()
           
protected  boolean isWidthAuto()
           
protected  boolean overflowsWithScroll()
           
 void setContainingBlock(CSSContainerBox enclosingBlock)
           
 void setErrorHandler(CSSErrorHandler errorHandler)
          Sets the CSS error handler.
protected  float shrinkToFit(float preferredMinimum, float available, float preferred)
          Performs a shrink-to-fit computation as defined by the CSS specification, paragraph 10.3.5.
protected  float textLengthToNaturalUnit(int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCSSBox

public AbstractCSSBox(CSS2ComputedProperties style)
Method Detail

getComputedStyle

public CSS2ComputedProperties getComputedStyle()
Description copied from interface: CSSBox
Gets the computed style for the element that generated this box.

Specified by:
getComputedStyle in interface CSSBox
Returns:
the computed style.

getCSSValue

protected org.w3c.dom.css.CSSPrimitiveValue getCSSValue(String property)

getContainingBlock

public CSSContainerBox getContainingBlock()
Description copied from interface: CSSBox
Gets the 'containing block' for thid box, as defined by the CSS specification.

Specified by:
getContainingBlock in interface CSSBox
Returns:
the block box corresponding to the 'containing block', or null if it is the topmost box.

setContainingBlock

public void setContainingBlock(CSSContainerBox enclosingBlock)

getErrorHandler

protected CSSErrorHandler getErrorHandler()

setErrorHandler

public void setErrorHandler(CSSErrorHandler errorHandler)
Description copied from interface: CSSBox
Sets the CSS error handler.

Specified by:
setErrorHandler in interface CSSBox
Parameters:
errorHandler - the error handler.

getGeneratedSibling

public CSSBox getGeneratedSibling()
Description copied from interface: CSSBox
Gets the box generated by the element that generated this box.

Specified by:
getGeneratedSibling in interface CSSBox
Returns:
the next box generated by the element, or null if this box does not generate content.

computeNumberOrZero

protected float computeNumberOrZero(String property)

computeNumberOrZero

protected float computeNumberOrZero(org.w3c.dom.css.CSSPrimitiveValue cssValue)
Computes the float value of a number, or returns zero if finds a non-numeric value.

The container width is used as the base for percentages.

Parameters:
cssValue - the CSS object value.
Returns:
the float value, or zero.

getWidth

protected abstract float getWidth()
Gets the width of this box.

This is defined to be the value of the width property, for boxes where it is defined, or the content width otherwise.

Returns:
the width of this box.

getHeight

protected abstract float getHeight()
Gets the height of this box.

This is defined to be the value of the height property, for boxes where it is defined, or the content height otherwise.

Returns:
the height of this box.

isWidthAuto

protected boolean isWidthAuto()

isHeightAuto

protected boolean isHeightAuto()

getContainerWidth

protected float getContainerWidth()

isContainerHeightAuto

protected boolean isContainerHeightAuto()

shrinkToFit

protected float shrinkToFit(float preferredMinimum,
                            float available,
                            float preferred)
Performs a shrink-to-fit computation as defined by the CSS specification, paragraph 10.3.5.

Parameters:
preferredMinimum -
available -
preferred -
Returns:
the shrinked-to-fit value.

overflowsWithScroll

protected boolean overflowsWithScroll()

textLengthToNaturalUnit

protected float textLengthToNaturalUnit(int length)

getLeft

public float getLeft()
Specified by:
getLeft in interface CSSBox

getRight

public float getRight()
Specified by:
getRight in interface CSSBox

getBorderTopWidth

public float getBorderTopWidth()
Specified by:
getBorderTopWidth in interface CSSBox

getBorderRightWidth

public float getBorderRightWidth()
Specified by:
getBorderRightWidth in interface CSSBox

getBorderBottomWidth

public float getBorderBottomWidth()
Specified by:
getBorderBottomWidth in interface CSSBox

getBorderLeftWidth

public float getBorderLeftWidth()
Specified by:
getBorderLeftWidth in interface CSSBox

getMarginTop

public float getMarginTop()
Gets the value of the margin-top property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getMarginTop in interface CSSBox
Returns:
the value of the margin-top property.

getMarginBottom

public float getMarginBottom()
Gets the value of the margin-bottom property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getMarginBottom in interface CSSBox
Returns:
the value of the margin-bottom property.

getMarginRight

public float getMarginRight()
Gets the value of the margin-right property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getMarginRight in interface CSSBox
Returns:
the value of the margin-right property.

getMarginLeft

public float getMarginLeft()
Gets the value of the margin-left property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getMarginLeft in interface CSSBox
Returns:
the value of the margin-left property.

getPaddingTop

public float getPaddingTop()
Description copied from interface: CSSBox
Gets the value of the padding-top property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getPaddingTop in interface CSSBox
Returns:
the value of the padding-top property.

getPaddingRight

public float getPaddingRight()
Description copied from interface: CSSBox
Gets the value of the padding-right property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getPaddingRight in interface CSSBox
Returns:
the value of the padding-right property.

getPaddingBottom

public float getPaddingBottom()
Description copied from interface: CSSBox
Gets the value of the padding-bottom property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getPaddingBottom in interface CSSBox
Returns:
the value of the padding-bottom property.

getPaddingLeft

public float getPaddingLeft()
Description copied from interface: CSSBox
Gets the value of the padding-left property, expressed in the unit given by the StyleDatabase.getNaturalUnit() method.

Specified by:
getPaddingLeft in interface CSSBox
Returns:
the value of the padding-left property.

getPaddingSubproperty

protected float getPaddingSubproperty(String subpropertyName)

getFontFamily

public String getFontFamily()
Gets the 'used' value for the font-family property.

This method requires a style database.

Returns:
the value of the font-family property.
Throws:
IllegalStateException - if the style database has not been set.

getFontWeight

public String getFontWeight()
Gets the computed font weight.

Returns:
the font weight.

getFontSize

public int getFontSize()
Gets the computed value of the font-size property.

May require a style database to work.

Returns:
the value of the font-size property, in typographic points.

getLineHeight

public float getLineHeight()

getLineHeight

public float getLineHeight(float defval)

getLeading

public float getLeading()

getLeading

public float getLeading(float defval)

getLineHeightCSSValue

public org.w3c.dom.css.CSSValue getLineHeightCSSValue()

getBorderTopColor

public org.w3c.dom.css.CSSPrimitiveValue getBorderTopColor()
Specified by:
getBorderTopColor in interface CSSBox

getBorderRightColor

public org.w3c.dom.css.CSSPrimitiveValue getBorderRightColor()
Specified by:
getBorderRightColor in interface CSSBox

getBorderBottomColor

public org.w3c.dom.css.CSSPrimitiveValue getBorderBottomColor()
Specified by:
getBorderBottomColor in interface CSSBox

getBorderLeftColor

public org.w3c.dom.css.CSSPrimitiveValue getBorderLeftColor()
Specified by:
getBorderLeftColor in interface CSSBox

getBackgroundPosition

public CSSPoint getBackgroundPosition()
Description copied from interface: CSSBox
Gets the position for the background image, if any.

Specified by:
getBackgroundPosition in interface CSSBox
Returns:
the position for the background image.


Copyright © 2011 informatica.info. All Rights Reserved.