de.infinityloop.util.style
Class CSSValue

java.lang.Object
  extended by de.infinityloop.util.style.CSSValue

public class CSSValue
extends java.lang.Object

Class representing a CSS property's value.


Field Summary
static int kAutoValue
           
static double kDefaultFontSizeInHp
           
static int kLengthUnit_auto
           
static int kLengthUnit_cm
           
static int kLengthUnit_em
           
static int kLengthUnit_emu
           
static int kLengthUnit_ex
           
static int kLengthUnit_hp
           
static int kLengthUnit_ident
           
static int kLengthUnit_in
           
static int kLengthUnit_inherit
           
static int kLengthUnit_int
           
static int kLengthUnit_mm
           
static int kLengthUnit_NotALengthError
           
static int kLengthUnit_pc
           
static int kLengthUnit_percent
           
static int kLengthUnit_pt
           
static int kLengthUnit_px
           
static int kLengthUnit_RelativeUnitError
           
static int kLengthUnit_string
           
static int kLengthUnit_tw
           
static int kLengthUnit_UnsupportedError
           
static java.lang.String kPropref
          prefix string for having a property take the computed value of the property name following the prefix.
static java.util.Hashtable unitConstantsMapping
          Map from CSSValue's unit constants to UnitConverter's unit constants
 
Constructor Summary
CSSValue()
          creator for a CSSValue standing for "inherit".
CSSValue(double v, int unit)
           
CSSValue(int v)
          creator for integer type
CSSValue(org.w3c.css.sac.LexicalUnit origUnit)
          creator.
CSSValue(java.lang.String propValue)
          Constructor that processes one single property value
CSSValue(java.lang.String v, int unit)
          creator for text or string type values
 
Method Summary
 int getInt()
          gets the integer value
 double getLengthAbs(int destUnit)
          returns a length, converted from the original unit to the desired unit
 double getLengthAbsFromRelative(int destUnit, CSSValue baseComputed, CSSValue fontSize, double dpi)
          returns a length, converted from the original unit to the desired unit, with providing base values for relative calculations.
 org.w3c.css.sac.LexicalUnit getOriginalLexicalUnit()
          retrieves the original LexicalUnit.
 int getParsedUnit()
          retrieves the original parsed unit
 double getReal()
          gets the real value
 int getReferencedProperty()
          retrieves the 'referenced' property id of this property value.
 java.lang.String getText()
          retrieves the value as text.
 int getUnit()
          gets the unit/dimension
static int getUnitId(java.lang.String u, int def)
          converts an ASCII unit string to its respective unit id
 boolean isLength()
          returns whether this unit is a length
 boolean isRelative()
          returns whether this unit is a relatively specified unit (=true) or an absolutely specified unit (=false).
 boolean isText()
          returns whether this unit is a textual string (=true) or a length.
static java.lang.String makeCSSUnit(java.lang.String s, java.lang.String defaultUnit)
          makes a CSS-parseable length unit string from the value passed here.
 java.lang.String toPrettyString(int precision)
          returns this property value as it would be written in a stylesheet
 java.lang.String toString()
          String representation for debugging
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

kAutoValue

public static final int kAutoValue
See Also:
Constant Field Values

kPropref

public static final java.lang.String kPropref
prefix string for having a property take the computed value of the property name following the prefix. We can think of it as an "inherit, but from a different property"

See Also:
Constant Field Values

kLengthUnit_em

public static final int kLengthUnit_em
See Also:
Constant Field Values

kLengthUnit_ex

public static final int kLengthUnit_ex
See Also:
Constant Field Values

kLengthUnit_px

public static final int kLengthUnit_px
See Also:
Constant Field Values

kLengthUnit_percent

public static final int kLengthUnit_percent
See Also:
Constant Field Values

kLengthUnit_in

public static final int kLengthUnit_in
See Also:
Constant Field Values

kLengthUnit_cm

public static final int kLengthUnit_cm
See Also:
Constant Field Values

kLengthUnit_mm

public static final int kLengthUnit_mm
See Also:
Constant Field Values

kLengthUnit_pt

public static final int kLengthUnit_pt
See Also:
Constant Field Values

kLengthUnit_pc

public static final int kLengthUnit_pc
See Also:
Constant Field Values

kLengthUnit_int

public static final int kLengthUnit_int
See Also:
Constant Field Values

kLengthUnit_string

public static final int kLengthUnit_string
See Also:
Constant Field Values

kLengthUnit_ident

public static final int kLengthUnit_ident
See Also:
Constant Field Values

kLengthUnit_inherit

public static final int kLengthUnit_inherit
See Also:
Constant Field Values

kLengthUnit_hp

public static final int kLengthUnit_hp
See Also:
Constant Field Values

kLengthUnit_tw

public static final int kLengthUnit_tw
See Also:
Constant Field Values

kLengthUnit_emu

public static final int kLengthUnit_emu
See Also:
Constant Field Values

kLengthUnit_auto

public static final int kLengthUnit_auto
See Also:
Constant Field Values

kLengthUnit_UnsupportedError

public static final int kLengthUnit_UnsupportedError
See Also:
Constant Field Values

kLengthUnit_NotALengthError

public static final int kLengthUnit_NotALengthError
See Also:
Constant Field Values

kLengthUnit_RelativeUnitError

public static final int kLengthUnit_RelativeUnitError
See Also:
Constant Field Values

kDefaultFontSizeInHp

public static final double kDefaultFontSizeInHp
See Also:
Constant Field Values

unitConstantsMapping

public static java.util.Hashtable unitConstantsMapping
Map from CSSValue's unit constants to UnitConverter's unit constants

Constructor Detail

CSSValue

public CSSValue(org.w3c.css.sac.LexicalUnit origUnit)
creator. Expects value to be a valid CSS length description string.


CSSValue

public CSSValue(int v)
creator for integer type


CSSValue

public CSSValue(double v,
                int unit)

CSSValue

public CSSValue(java.lang.String v,
                int unit)
creator for text or string type values


CSSValue

public CSSValue()
creator for a CSSValue standing for "inherit".


CSSValue

public CSSValue(java.lang.String propValue)
Constructor that processes one single property value

Method Detail

getInt

public int getInt()
gets the integer value


getReal

public double getReal()
gets the real value


getUnit

public int getUnit()
gets the unit/dimension


isLength

public boolean isLength()
returns whether this unit is a length


isRelative

public boolean isRelative()
returns whether this unit is a relatively specified unit (=true) or an absolutely specified unit (=false).


isText

public boolean isText()
returns whether this unit is a textual string (=true) or a length.


getLengthAbsFromRelative

public double getLengthAbsFromRelative(int destUnit,
                                       CSSValue baseComputed,
                                       CSSValue fontSize,
                                       double dpi)
                                throws java.lang.Exception
returns a length, converted from the original unit to the desired unit, with providing base values for relative calculations.

Throws:
java.lang.Exception

getLengthAbs

public double getLengthAbs(int destUnit)
                    throws java.lang.Exception
returns a length, converted from the original unit to the desired unit

Throws:
java.lang.Exception

getOriginalLexicalUnit

public org.w3c.css.sac.LexicalUnit getOriginalLexicalUnit()
retrieves the original LexicalUnit.


makeCSSUnit

public static java.lang.String makeCSSUnit(java.lang.String s,
                                           java.lang.String defaultUnit)
makes a CSS-parseable length unit string from the value passed here.


getReferencedProperty

public int getReferencedProperty()
retrieves the 'referenced' property id of this property value. Returns -1 when it is a final value, otherwise the id of the property whose value should this property take instead.


getUnitId

public static int getUnitId(java.lang.String u,
                            int def)
converts an ASCII unit string to its respective unit id


getParsedUnit

public int getParsedUnit()
retrieves the original parsed unit


getText

public java.lang.String getText()
retrieves the value as text.


toString

public java.lang.String toString()
String representation for debugging

Overrides:
toString in class java.lang.Object

toPrettyString

public java.lang.String toPrettyString(int precision)
returns this property value as it would be written in a stylesheet