Interface UnitConverter

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 Details

  • 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

      default double getFactor(String unit)
    • 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

      default double convert(double value, String inputUnit, String outputUnit)
      Converts the specified value from input unit to output unit.
      Parameters:
      value - a value
      inputUnit - the units of the value
      outputUnit - the desired output unit
      Returns:
      converted value
    • convertSize

      default CssSize convertSize(double value, String inputUnit, String outputUnit)
    • convert

      default double convert(CssSize value, String outputUnit)
      Converts the specified value from input unit to output unit.
      Parameters:
      value - a value
      outputUnit - the desired output unit
      Returns:
      converted value
    • convertSize

      default CssSize convertSize(CssSize value, String outputUnit)