Enum Class Unit

java.lang.Object
java.lang.Enum<Unit>
com.vaadin.flow.component.Unit
All Implemented Interfaces:
Serializable, Comparable<Unit>, Constable

public enum Unit extends Enum<Unit>
Enum of supported units in Css sizes.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Unit code representing the width of the "0" (zero).
    Unit code representing centimeters.
    Unit code representing the font-size of the relevant font.
    Unit code representing the x-height of the relevant font.
    Unit code representing inches.
    Unit code representing millimeters.
    Unit code representing in percentage of the containing element defined by terminal.
    Unit code representing picas (12 points).
    Unit code representing pixels.
    Unit code representing points (1/72nd of an inch).
    Unit code representing the font-size of the root font.
    Unit code representing the viewport's height.
    Unit code representing the viewport's larger dimension.
    Unit code representing the viewport's smaller dimension.
    Unit code representing the viewport's width.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    getSize(String cssSize)
    Gives size component as float of the css string representing a size.
     
    static Optional<Unit>
    getUnit(String cssSize)
    Gives size unit of the css string representing a size.
    static Unit
    Convert unit string symbol to Unit.
     
    static Unit
    Returns the enum constant of this class with the specified name.
    static Unit[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • PERCENTAGE

      public static final Unit PERCENTAGE
      Unit code representing in percentage of the containing element defined by terminal.
    • PIXELS

      public static final Unit PIXELS
      Unit code representing pixels.
    • REM

      public static final Unit REM
      Unit code representing the font-size of the root font.
    • EM

      public static final Unit EM
      Unit code representing the font-size of the relevant font.
    • VW

      public static final Unit VW
      Unit code representing the viewport's width.
    • VH

      public static final Unit VH
      Unit code representing the viewport's height.
    • VMIN

      public static final Unit VMIN
      Unit code representing the viewport's smaller dimension.
    • VMAX

      public static final Unit VMAX
      Unit code representing the viewport's larger dimension.
    • POINTS

      public static final Unit POINTS
      Unit code representing points (1/72nd of an inch).
    • PICAS

      public static final Unit PICAS
      Unit code representing picas (12 points).
    • EX

      public static final Unit EX
      Unit code representing the x-height of the relevant font.
    • MM

      public static final Unit MM
      Unit code representing millimeters.
    • CH

      public static final Unit CH
      Unit code representing the width of the "0" (zero).
    • CM

      public static final Unit CM
      Unit code representing centimeters.
    • INCH

      public static final Unit INCH
      Unit code representing inches.
  • Method Details

    • values

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

      public static Unit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • getSymbol

      public String getSymbol()
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Unit>
    • getUnit

      public static Optional<Unit> getUnit(String cssSize)
      Gives size unit of the css string representing a size.
      Parameters:
      cssSize - Css compliant size string such as "50px".
      Returns:
      A Optional unit.
    • getSize

      public static float getSize(String cssSize)
      Gives size component as float of the css string representing a size.
      Parameters:
      cssSize - Css compliant size string such as "50px".
      Returns:
      Size as float, 0 if string contained only the unit.
    • getUnitFromSymbol

      public static Unit getUnitFromSymbol(String symbol)
      Convert unit string symbol to Unit.
      Parameters:
      symbol - A String.
      Returns:
      A Unit, Unit.PIXELS if symbol was null or not matching.