Package eu.webtoolkit.jwt
Class WLength
java.lang.Object
eu.webtoolkit.jwt.WLength
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether some other object is "equal to" this one.Returns the CSS text.getUnit()
Returns the unit.double
getValue()
Returns the value.boolean
isAuto()
Returns whether the length is 'auto'.final double
toPixels()
Returns the (approximate) length in pixels.double
toPixels
(double fontSize) Returns the (approximate) length in pixels.
-
Field Details
-
Auto
An 'auto' length.- See Also:
-
-
Constructor Details
-
WLength
public WLength()Creates an 'auto' length.Specifies an 'auto' length.
- See Also:
-
WLength
Creates a length by parsing the argument as a css length string.This supports all CSS length formats that have an API counterpart.
-
WLength
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.
-
-
Method Details
-
isAuto
public boolean isAuto()Returns whether the length is 'auto'. -
getValue
public double getValue()Returns the value.- See Also:
-
getUnit
Returns the unit.- See Also:
-
getCssText
Returns the CSS text. -
equals
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.Note: For percentages (
LengthUnit.Percentage
), and units relative to viewport size (LengthUnit.ViewportWidth
,LengthUnit.ViewportHeight
,LengthUnit.ViewportMin
,LengthUnit.ViewportMax
), a percentage of the font size is used. -
toPixels
public final double toPixels()Returns the (approximate) length in pixels.Returns
toPixels(16.0)
-