info.informatica.doc.style.css.dom
Class ComputedCSSStyle

java.lang.Object
  extended by info.informatica.doc.style.css.dom.BaseCSSStyleDeclaration
      extended by info.informatica.doc.style.css.dom.ComputedCSSStyle
All Implemented Interfaces:
CSS2ComputedProperties, StyleDatabaseAware, Cloneable, org.w3c.dom.css.CSSStyleDeclaration
Direct Known Subclasses:
DOM4JCSSStyleDeclaration, DOMCSSStyleDeclaration

public abstract class ComputedCSSStyle
extends BaseCSSStyleDeclaration
implements CSS2ComputedProperties, StyleDatabaseAware

Style declaration that computes CSS properties.

See section 6.1 of the Document Object Model CSS spec.

Some of the methods require that a style database is set, for example to verify the availability of font families.

Author:
Carlos Amengual (amengual at informatica.info)

Nested Class Summary
 
Nested classes/interfaces inherited from class info.informatica.doc.style.css.dom.BaseCSSStyleDeclaration
BaseCSSStyleDeclaration.StyleDeclarationDocumentHandler
 
Constructor Summary
protected ComputedCSSStyle()
           
protected ComputedCSSStyle(BaseCSSStyleDeclaration copiedObject)
           
 
Method Summary
abstract  ComputedCSSStyle clone()
           
 float computeFloatValue(CSSNumberValue cssValue)
          Computes the value, in the device's natural unit, of the given number value.
 org.w3c.dom.css.CSSPrimitiveValue getBackgroundColor()
          Gets the primitive, computed value for the 'background-color' property.
 String getBackgroundImage()
          Gets the computed value for the 'background-image' property.
 URL getBaseURL()
          Gets the base URL that should be used to resolve relative URLs in property values.
 org.w3c.dom.css.CSSPrimitiveValue getColor()
          Gets the primitive, computed value for the 'color' property.
 org.w3c.dom.css.CSSValue getCSSValue(String property)
          Gets the absolute, primitive "computed" value for the given property.
 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.
protected  int getLargerFontSize(int defaultSize)
           
abstract  CSS2ComputedProperties getParentComputedStyle()
          Gets the computed style for the parent element.
protected  int getParentElementFontSize()
           
abstract  String getParentXPath()
           
 Node getPeerNode()
          Gets the peer node.
abstract  String getPeerXPath()
          Gets the XPath of the node to which this style applies.
protected  int getSmallerFontSize(int defaultSize)
           
abstract  String getText()
          Gets the (whitespace-trimmed) text content of the node associated to this style.
 void setPeerNode(Node node)
           
 
Methods inherited from class info.informatica.doc.style.css.dom.BaseCSSStyleDeclaration
addStyle, defaultPropertyValue, getCSS2Properties, getCssText, getDeclaredCSSValue, getLength, getParentRule, getPropertyCSSValue, getPropertyPriority, getPropertyValue, getStyleDatabase, item, prioritySplit, removeProperty, setCssText, setProperty, setProperty, setStyleDatabase, setSubproperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.informatica.doc.style.css.CSS2ComputedProperties
getPropertyCSSValue, getPropertyValue, getStyleDatabase
 
Methods inherited from interface info.informatica.doc.style.css.StyleDatabaseAware
getStyleDatabase, setStyleDatabase
 

Constructor Detail

ComputedCSSStyle

protected ComputedCSSStyle()

ComputedCSSStyle

protected ComputedCSSStyle(BaseCSSStyleDeclaration copiedObject)
Method Detail

setPeerNode

public void setPeerNode(Node node)

getPeerNode

public Node getPeerNode()
Description copied from interface: CSS2ComputedProperties
Gets the peer node.

Specified by:
getPeerNode in interface CSS2ComputedProperties
Returns:
the peer node.

getCSSValue

public org.w3c.dom.css.CSSValue getCSSValue(String property)
Gets the absolute, primitive "computed" value for the given property.

The rendering context is not taken into account for this method.

See paragraph 6.1.2 of the Document Object Model CSS specification for the definition of "computed" values.

Overrides:
getCSSValue in class BaseCSSStyleDeclaration
Parameters:
property - the property that we want to evaluate.
Returns:
the primitive value of the property, a CSSShorthandValue if the property is a shorthand, or null if the property is not known.

getColor

public org.w3c.dom.css.CSSPrimitiveValue getColor()
Description copied from interface: CSS2ComputedProperties
Gets the primitive, computed value for the 'color' property.

Specified by:
getColor in interface CSS2ComputedProperties
Overrides:
getColor in class BaseCSSStyleDeclaration
Returns:
the value for the 'color' property.

getBackgroundColor

public org.w3c.dom.css.CSSPrimitiveValue getBackgroundColor()
Description copied from interface: CSS2ComputedProperties
Gets the primitive, computed value for the 'background-color' property.

Specified by:
getBackgroundColor in interface CSS2ComputedProperties
Returns:
the value for the 'background-color' property.

getBackgroundImage

public String getBackgroundImage()
Description copied from interface: CSS2ComputedProperties
Gets the computed value for the 'background-image' property.

Specified by:
getBackgroundImage in interface CSS2ComputedProperties
Returns:
the value for the 'background-image' property, or null if no background image was set for the element.

getBaseURL

public URL getBaseURL()
Gets the base URL that should be used to resolve relative URLs in property values.

Specified by:
getBaseURL in interface CSS2ComputedProperties
Returns:
the base URL, or null if could not be determined.

getFontFamily

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

This method requires a style database.

Specified by:
getFontFamily in interface CSS2ComputedProperties
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.

Specified by:
getFontWeight in interface CSS2ComputedProperties
Returns:
the font weight.

getFontSize

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

May require a style database to work.

Specified by:
getFontSize in interface CSS2ComputedProperties
Returns:
the value of the font-size property, in typographic points.

getLargerFontSize

protected int getLargerFontSize(int defaultSize)
                         throws CSSPropertyException
Throws:
CSSPropertyException

getSmallerFontSize

protected int getSmallerFontSize(int defaultSize)
                          throws CSSPropertyException
Throws:
CSSPropertyException

getParentElementFontSize

protected int getParentElementFontSize()

computeFloatValue

public float computeFloatValue(CSSNumberValue cssValue)
Computes the value, in the device's natural unit, of the given number value.

Specified by:
computeFloatValue in interface CSS2ComputedProperties
Parameters:
cssValue - the CSS value representing a number.
Returns:
the float value in the device's natural unit, or the value of a percentage if the value is a percentage.

getPeerXPath

public abstract String getPeerXPath()
Description copied from interface: CSS2ComputedProperties
Gets the XPath of the node to which this style applies.

Specified by:
getPeerXPath in interface CSS2ComputedProperties
Returns:
the XPath of the node.

getParentXPath

public abstract String getParentXPath()

getParentComputedStyle

public abstract CSS2ComputedProperties getParentComputedStyle()
Gets the computed style for the parent element.

Specified by:
getParentComputedStyle in interface CSS2ComputedProperties
Returns:
the computed style for the parent element, or null if there is no parent element, or has no style associated.

getText

public abstract String getText()
Gets the (whitespace-trimmed) text content of the node associated to this style.

Returns:
the text content, or the empty string if the box has no text.

clone

public abstract ComputedCSSStyle clone()
Overrides:
clone in class BaseCSSStyleDeclaration


Copyright © 2011 informatica.info. All Rights Reserved.