- All Known Implementing Classes:
DefaultUnitConverter
public interface UnitConverter
UnitConverter.
References:
- CSS Values and Units Module Level 3. § 5.1.1 Font-relative lengths: the em, ex, ch, rem units
- w3.org
- CSS Values and Units Module Level 3. § 5.1.2 Viewport-percentage lengths: the vw, vh, vmin, vmax units
- w3.org
- CSS Values and Units Module Level 3. § 5.2 Absolute lengths: the cm, mm, Q, in, pt, pc, px units
- w3.org
- Author:
- Werner Randelshofer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringDefault unit.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptiondefault doubleConverts the specified value from input unit to output unit.default doubleConverts the specified value from input unit to output unit.convertSize(double value, @NonNull String inputUnit, @NonNull String outputUnit) convertSize(@NonNull CssSize value, @NonNull String outputUnit) default doublegetDpi()Gets the resolution in dots per inch.default doubledefault doubleGets the font size;default doubleGets the x-height of the font size.default doubleGets the factor for percentage values.default doubleGets the viewport height.default doubleGets the viewport width.
-
Field Details
-
DEFAULT
Default unit.- See Also:
-
CENTIMETERS
- See Also:
-
DEGREES
- See Also:
-
EM
- See Also:
-
EX
- See Also:
-
INCH
- See Also:
-
MILLIMETERS
- See Also:
-
QUARTER_MILLIMETERS
- See Also:
-
PERCENTAGE
- See Also:
-
PICAS
- See Also:
-
PIXELS
- See Also:
-
POINTS
- See Also:
-
VIEWPORT_WIDTH_PERCENTAGE
- See Also:
-
VIEWPORT_HEIGHT_PERCENTAGE
- See Also:
-
VIEWPORT_MIN_PERCENTAGE
- See Also:
-
VIEWPORT_MAX_PERCENTAGE
- See Also:
-
-
Method Details
-
getDpi
default double getDpi()Gets the resolution in dots per inch.- Returns:
- dpi, default value: 96.0.
-
getViewportWidth
default double getViewportWidth()Gets the viewport width.- Returns:
- viewport width, default value: 1024.0.
-
getViewportHeight
default double getViewportHeight()Gets the viewport height.- Returns:
- viewport height, default value: 768.0.
-
getPercentageFactor
default double getPercentageFactor()Gets the factor for percentage values.- Returns:
- percentageFactor, for example 100.
-
getFactor
-
getFontSize
default double getFontSize()Gets the font size;- Returns:
- em
-
getFontXHeight
default double getFontXHeight()Gets the x-height of the font size.- Returns:
- ex
-
convert
Converts the specified value from input unit to output unit.- Parameters:
value- a valueinputUnit- the units of the valueoutputUnit- the desired output unit- Returns:
- converted value
-
convertSize
-
convert
Converts the specified value from input unit to output unit.- Parameters:
value- a valueoutputUnit- the desired output unit- Returns:
- converted value
-
convertSize
-