eu.webtoolkit.jwt
Class WLength

java.lang.Object
  extended by eu.webtoolkit.jwt.WLength

public class WLength
extends java.lang.Object

A value class that describes a CSS length.

The class combines a value with a unit. There is a special value auto which has a different meaning depending on the context.


Nested Class Summary
static class WLength.Unit
          The unit.
 
Field Summary
static WLength Auto
          An 'auto' length.
 
Constructor Summary
WLength()
          Creates an 'auto' length.
WLength(double value)
          Creates a length with value and unit.
WLength(double value, WLength.Unit unit)
          Creates a length with value and unit.
WLength(int value)
          Creates a length with value and unit.
WLength(int value, WLength.Unit unit)
          Creates a length with value and unit.
WLength(long value)
          Creates a length with value and unit.
WLength(long value, WLength.Unit unit)
          Creates a length with value and unit.
WLength(java.lang.String s)
          Creates a length by parsing the argument as a css length string.
 
Method Summary
 boolean equals(WLength other)
          Indicates whether some other object is "equal to" this one.
 java.lang.String getCssText()
          Returns the CSS text.
 WLength.Unit getUnit()
          Returns the unit.
 double getValue()
          Returns the value.
 boolean isAuto()
          Returns whether the length is 'auto'.
 double toPixels()
          Returns the (approximate) length in pixels.
 double toPixels(double fontSize)
          Returns the (approximate) length in pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Auto

public static WLength Auto
An 'auto' length.

See Also:
WLength()
Constructor Detail

WLength

public WLength()
Creates an 'auto' length.

Specifies an 'auto' length.

See Also:
Auto

WLength

public WLength(java.lang.String s)
Creates a length by parsing the argument as a css length string.

This supports all CSS length formats that have an API counterpart.


WLength

public WLength(double value,
               WLength.Unit unit)
Creates a length with value and unit.

This constructor is also used for the implicit conversion of a double to a WLength, assuming a pixel unit.


WLength

public WLength(double value)
Creates a length with value and unit.

Calls this(value, WLength.Unit.Pixel)


WLength

public WLength(int value,
               WLength.Unit unit)
Creates a length with value and unit.

This constructor is also used for the implicit conversion of a int to a WLength, assuming a pixel unit.


WLength

public WLength(int value)
Creates a length with value and unit.

Calls this(value, WLength.Unit.Pixel)


WLength

public WLength(long value,
               WLength.Unit unit)
Creates a length with value and unit.

This constructor is also used for the implicit conversion of a long to a WLength, assuming a pixel unit.


WLength

public WLength(long value)
Creates a length with value and unit.

Calls this(value, WLength.Unit.Pixel)

Method Detail

isAuto

public boolean isAuto()
Returns whether the length is 'auto'.

See Also:
WLength(), Auto

getValue

public double getValue()
Returns the value.

See Also:
getUnit()

getUnit

public WLength.Unit getUnit()
Returns the unit.

See Also:
getValue()

getCssText

public java.lang.String getCssText()
Returns the CSS text.


equals

public boolean equals(WLength other)
Indicates whether some other object is "equal to" this one.


toPixels

public double toPixels(double fontSize)
Returns the (approximate) length in pixels.

When the length isAuto(), 0 is returned, otherwise the approximate length in pixels.


toPixels

public final double toPixels()
Returns the (approximate) length in pixels.

Returns toPixels(16.0)