Package com.vaadin.flow.component
Enum Unit
- java.lang.Object
-
- java.lang.Enum<Unit>
-
- com.vaadin.flow.component.Unit
-
- All Implemented Interfaces:
Serializable,Comparable<Unit>
public enum Unit extends Enum<Unit>
Enum of supported units in Css sizes.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CHUnit code representing the width of the "0" (zero).CMUnit code representing centimeters.EMUnit code representing the font-size of the relevant font.EXUnit code representing the x-height of the relevant font.INCHUnit code representing inches.MMUnit code representing millimeters.PERCENTAGEUnit code representing in percentage of the containing element defined by terminal.PICASUnit code representing picas (12 points).PIXELSUnit code representing pixels.POINTSUnit code representing points (1/72nd of an inch).REMUnit code representing the font-size of the root font.VHUnit code representing the viewport's height.VMAXUnit code representing the viewport's larger dimension.VMINUnit code representing the viewport's smaller dimension.VWUnit code representing the viewport's width.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static floatgetSize(String cssSize)Gives size component as float of the css string representing a size.StringgetSymbol()static Optional<Unit>getUnit(String cssSize)Gives size unit of the css string representing a size.static UnitgetUnitFromSymbol(String symbol)Convert unit string symbol to Unit.StringtoString()static UnitvalueOf(String name)Returns the enum constant of this type with the specified name.static Unit[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 Detail
-
values
public static Unit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Unit c : Unit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Unit 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 nameNullPointerException- if the argument is null
-
getSymbol
public String getSymbol()
-
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.
-
-