Enum ECSSUnit

java.lang.Object
java.lang.Enum<ECSSUnit>
com.helger.css.ECSSUnit
All Implemented Interfaces:
com.helger.commons.name.IHasName, ICSSVersionAware, Serializable, Comparable<ECSSUnit>, java.lang.constant.Constable

public enum ECSSUnit extends Enum<ECSSUnit> implements com.helger.commons.name.IHasName, ICSSVersionAware
Enumeration containing all predefined CSS units.
Source: http://www.w3.org/TR/css3-values/
Author:
Philip Helger
  • Enum Constant Details

    • EM

      public static final ECSSUnit EM
      font size of the element
    • EX

      public static final ECSSUnit EX
      x-height of the element's font
    • PX

      public static final ECSSUnit PX
      pixels; 1px is equal to 1/96th of 1in
    • CH

      public static final ECSSUnit CH
      width of the "0" glyph in the element's font
    • REM

      public static final ECSSUnit REM
      font size of the root element
    • VW

      public static final ECSSUnit VW
      Equal to 1% of the width of the initial containing block.
    • VH

      public static final ECSSUnit VH
      Equal to 1% of the height of the initial containing block.
    • VMIN

      public static final ECSSUnit VMIN
      Equal to the smaller of 'vw' or 'vh'.
    • VMAX

      public static final ECSSUnit VMAX
      Equal to the larger of 'vw' or 'vh'.
    • LENGTH_IN

      public static final ECSSUnit LENGTH_IN
      inches; 1in is equal to 2.54cm
    • LENGTH_CM

      public static final ECSSUnit LENGTH_CM
      centimeters
    • LENGTH_MM

      public static final ECSSUnit LENGTH_MM
      millimeters; 10 millimeters = 1 centimeter
    • LENGTH_Q

      public static final ECSSUnit LENGTH_Q
      quarter millimeters; 40 quarter-millimeters = 1 centimeter
    • LENGTH_PT

      public static final ECSSUnit LENGTH_PT
      points; 1pt is equal to 1/72nd of 1in
    • LENGTH_PC

      public static final ECSSUnit LENGTH_PC
      picas; 1pc is equal to 12pt
    • PERCENTAGE

      public static final ECSSUnit PERCENTAGE
      percentage
    • ANGLE_DEG

      public static final ECSSUnit ANGLE_DEG
      Degrees. There are 360 degrees in a full circle.
    • ANGLE_RAD

      public static final ECSSUnit ANGLE_RAD
      Radians. There are 2*pi radians in a full circle.
    • ANGLE_GRAD

      public static final ECSSUnit ANGLE_GRAD
      Gradians, also known as "gons" or "grades". There are 400 gradians in a full circle.
    • ANGLE_TURN

      public static final ECSSUnit ANGLE_TURN
      Turns. There is 1 turn in a full circle.
    • TIME_MS

      public static final ECSSUnit TIME_MS
      Milliseconds. There are 1000 milliseconds in a second.
    • TIME_S

      public static final ECSSUnit TIME_S
      Seconds.
    • FREQ_HZ

      public static final ECSSUnit FREQ_HZ
      Hertz. It represents the number of occurrences per second.
    • FREQ_KHZ

      public static final ECSSUnit FREQ_KHZ
      Kilohertz. A kiloHertz is 1000 Hertz.
    • DPI

      public static final ECSSUnit DPI
      Dots per CSS inch
    • DPCM

      public static final ECSSUnit DPCM
      Dots per CSS centimeter
    • DPPX

      public static final ECSSUnit DPPX
      Dots per pixel centimeter
    • FR

      public static final ECSSUnit FR
      Flexible length or flex
  • Field Details

    • LENGTH_PX

      public static final ECSSUnit LENGTH_PX
      Length in pixel
  • Method Details

    • values

      public static ECSSUnit[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ECSSUnit valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getName

      @Nonnull @Nonempty public String getName()
      Specified by:
      getName in interface com.helger.commons.name.IHasName
      Returns:
      The name of the unit as it should be used in CSS. E.g. "px"
    • getMetaUnit

      @Nonnull public ECSSMetaUnit getMetaUnit()
      Returns:
      The underlying meta unit. Never null.
    • getMinimumCSSVersion

      @Nonnull public ECSSVersion getMinimumCSSVersion()
      Specified by:
      getMinimumCSSVersion in interface ICSSVersionAware
      Returns:
      The minimum CSS version that is required to read or write this artifact. May not be null.
    • format

      @Nonnull @Nonempty public String format(int nValue)
      Get the passed value formatted with this unit
      Parameters:
      nValue - Value to format
      Returns:
      value + getName()
    • format

      @Nonnull @Nonempty public String format(long nValue)
      Get the passed value formatted with this unit
      Parameters:
      nValue - Value to format
      Returns:
      value + getName()
    • format

      @Nonnull @Nonempty public String format(double dValue)
      Get the passed value formatted with this unit. Always '.' is used as the separator.
      Parameters:
      dValue - Value to format
      Returns:
      value + getName()
    • format

      @Nonnull @Nonempty public String format(@Nonnull BigDecimal aValue)
      Get the passed value formatted with this unit. Always '.' is used as the separator.
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + getName()
      Since:
      3.7.3
    • getFromNameOrNull

      @Nullable public static ECSSUnit getFromNameOrNull(@Nullable String sName)
    • getFromNameOrDefault

      @Nullable public static ECSSUnit getFromNameOrDefault(@Nullable String sName, @Nullable ECSSUnit eDefault)
    • em

      @Nonnull @Nonempty public static String em(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "em"
    • em

      @Nonnull @Nonempty public static String em(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "em"
    • em

      @Nonnull @Nonempty public static String em(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "em"
      Since:
      3.7.3
    • ex

      @Nonnull @Nonempty public static String ex(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "ex"
    • ex

      @Nonnull @Nonempty public static String ex(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "ex"
    • ex

      @Nonnull @Nonempty public static String ex(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "ex"
      Since:
      3.7.3
    • px

      @Nonnull @Nonempty public static String px(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "px"
    • px

      @Nonnull @Nonempty public static String px(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "px"
    • px

      @Nonnull @Nonempty public static String px(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "px"
      Since:
      3.7.3
    • rem

      @Nonnull @Nonempty public static String rem(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "rem"
    • rem

      @Nonnull @Nonempty public static String rem(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "rem"
    • rem

      @Nonnull @Nonempty public static String rem(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "rem"
      Since:
      3.7.3
    • vw

      @Nonnull @Nonempty public static String vw(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "vw"
    • vw

      @Nonnull @Nonempty public static String vw(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "vw"
    • vw

      @Nonnull @Nonempty public static String vw(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "vw"
      Since:
      3.7.3
    • vh

      @Nonnull @Nonempty public static String vh(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "vh"
    • vh

      @Nonnull @Nonempty public static String vh(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "vh"
    • vh

      @Nonnull @Nonempty public static String vh(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "vh"
      Since:
      3.7.3
    • vmin

      @Nonnull @Nonempty public static String vmin(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "vmin"
    • vmin

      @Nonnull @Nonempty public static String vmin(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "vmin"
    • vmin

      @Nonnull @Nonempty public static String vmin(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "vmin"
      Since:
      3.7.3
    • vmax

      @Nonnull @Nonempty public static String vmax(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "vmax"
      Since:
      5.0.4
    • vmax

      @Nonnull @Nonempty public static String vmax(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "vmax"
      Since:
      5.0.4
    • vmax

      @Nonnull @Nonempty public static String vmax(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "vmax"
      Since:
      5.0.4
    • ch

      @Nonnull @Nonempty public static String ch(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "ch"
    • ch

      @Nonnull @Nonempty public static String ch(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "ch"
    • ch

      @Nonnull @Nonempty public static String ch(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "ch"
      Since:
      3.7.3
    • in

      @Nonnull @Nonempty public static String in(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "in"
    • in

      @Nonnull @Nonempty public static String in(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "in"
    • in

      @Nonnull @Nonempty public static String in(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "in"
      Since:
      3.7.3
    • cm

      @Nonnull @Nonempty public static String cm(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "cm"
    • cm

      @Nonnull @Nonempty public static String cm(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "cm"
    • cm

      @Nonnull @Nonempty public static String cm(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "cm"
      Since:
      3.7.3
    • mm

      @Nonnull @Nonempty public static String mm(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "mm"
    • mm

      @Nonnull @Nonempty public static String mm(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "mm"
    • mm

      @Nonnull @Nonempty public static String mm(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "mm"
      Since:
      3.7.3
    • q

      @Nonnull @Nonempty public static String q(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "q"
      Since:
      5.0.4
    • q

      @Nonnull @Nonempty public static String q(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "q"
      Since:
      5.0.4
    • q

      @Nonnull @Nonempty public static String q(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "q"
      Since:
      5.0.4
    • pt

      @Nonnull @Nonempty public static String pt(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "pt"
    • pt

      @Nonnull @Nonempty public static String pt(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "pt"
    • pt

      @Nonnull @Nonempty public static String pt(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "pt"
      Since:
      3.7.3
    • pc

      @Nonnull @Nonempty public static String pc(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "pc"
    • pc

      @Nonnull @Nonempty public static String pc(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "pc"
    • pc

      @Nonnull @Nonempty public static String pc(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "pc"
      Since:
      3.7.3
    • perc

      @Nonnull @Nonempty public static String perc(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "%"
    • perc

      @Nonnull @Nonempty public static String perc(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "%"
    • perc

      @Nonnull @Nonempty public static String perc(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "%"
      Since:
      3.7.3
    • deg

      @Nonnull @Nonempty public static String deg(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "deg"
    • deg

      @Nonnull @Nonempty public static String deg(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "deg"
    • deg

      @Nonnull @Nonempty public static String deg(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "deg"
      Since:
      3.7.3
    • rad

      @Nonnull @Nonempty public static String rad(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "rad"
    • rad

      @Nonnull @Nonempty public static String rad(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "rad"
    • rad

      @Nonnull @Nonempty public static String rad(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "rad"
      Since:
      3.7.3
    • grad

      @Nonnull @Nonempty public static String grad(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "grad"
    • grad

      @Nonnull @Nonempty public static String grad(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "grad"
    • grad

      @Nonnull @Nonempty public static String grad(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "grad"
      Since:
      3.7.3
    • turn

      @Nonnull @Nonempty public static String turn(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "turn"
    • turn

      @Nonnull @Nonempty public static String turn(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "turn"
    • turn

      @Nonnull @Nonempty public static String turn(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "turn"
      Since:
      3.7.3
    • ms

      @Nonnull @Nonempty public static String ms(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "ms"
    • ms

      @Nonnull @Nonempty public static String ms(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "ms"
    • ms

      @Nonnull @Nonempty public static String ms(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "ms"
      Since:
      3.7.3
    • s

      @Nonnull @Nonempty public static String s(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "s"
    • s

      @Nonnull @Nonempty public static String s(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "s"
    • s

      @Nonnull @Nonempty public static String s(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "s"
      Since:
      3.7.3
    • hz

      @Nonnull @Nonempty public static String hz(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "hz"
    • hz

      @Nonnull @Nonempty public static String hz(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "hz"
    • hz

      @Nonnull @Nonempty public static String hz(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "hz"
      Since:
      3.7.3
    • khz

      @Nonnull @Nonempty public static String khz(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "khz"
    • khz

      @Nonnull @Nonempty public static String khz(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "khz"
    • khz

      @Nonnull @Nonempty public static String khz(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "khz"
      Since:
      3.7.3
    • dpi

      @Nonnull @Nonempty public static String dpi(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "dpi"
    • dpi

      @Nonnull @Nonempty public static String dpi(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "dpi"
    • dpi

      @Nonnull @Nonempty public static String dpi(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "dpi"
      Since:
      3.7.3
    • dpcm

      @Nonnull @Nonempty public static String dpcm(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "dpcm"
    • dpcm

      @Nonnull @Nonempty public static String dpcm(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "dpcm"
    • dpcm

      @Nonnull @Nonempty public static String dpcm(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "dpcm"
      Since:
      3.7.3
    • dppx

      @Nonnull @Nonempty public static String dppx(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "dppx"
    • dppx

      @Nonnull @Nonempty public static String dppx(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "dppx"
    • dppx

      @Nonnull @Nonempty public static String dppx(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "dppx"
      Since:
      3.7.3
    • fr

      @Nonnull @Nonempty public static String fr(int nValue)
      Parameters:
      nValue - value to format
      Returns:
      value + "fr"
      Since:
      5.0.4
    • fr

      @Nonnull @Nonempty public static String fr(double dValue)
      Parameters:
      dValue - value to format
      Returns:
      value + "fr"
      Since:
      5.0.4
    • fr

      @Nonnull @Nonempty public static String fr(@Nonnull BigDecimal aValue)
      Parameters:
      aValue - Value to format. May not be null.
      Returns:
      value + "fr"
      Since:
      5.0.4
    • zero

      @Nonnull @Nonempty public static String zero()
      Returns:
      "0" without a unit