Package com.helger.css
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>
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 Summary
Enum Constants Enum Constant Description ANGLE_DEGDegrees.ANGLE_GRADGradians, also known as "gons" or "grades".ANGLE_RADRadians.ANGLE_TURNTurns.CHwidth of the "0" glyph in the element's fontDPCMDots per CSS centimeterDPIDots per CSS inchDPPXDots per pixel centimeterEMfont size of the elementEXx-height of the element's fontFRFlexible length or flexFREQ_HZHertz.FREQ_KHZKilohertz.LENGTH_CMcentimetersLENGTH_INinches; 1in is equal to 2.54cmLENGTH_MMmillimeters; 10 millimeters = 1 centimeterLENGTH_PCpicas; 1pc is equal to 12ptLENGTH_PTpoints; 1pt is equal to 1/72nd of 1inLENGTH_Qquarter millimeters; 40 quarter-millimeters = 1 centimeterPERCENTAGEpercentagePXpixels; 1px is equal to 1/96th of 1inREMfont size of the root elementTIME_MSMilliseconds.TIME_SSeconds.VHEqual to 1% of the height of the initial containing block.VMAXEqual to the larger of 'vw' or 'vh'.VMINEqual to the smaller of 'vw' or 'vh'.VWEqual to 1% of the width of the initial containing block.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Stringch(double dValue)static Stringch(int nValue)static Stringch(BigDecimal aValue)static Stringcm(double dValue)static Stringcm(int nValue)static Stringcm(BigDecimal aValue)static Stringdeg(double dValue)static Stringdeg(int nValue)static Stringdeg(BigDecimal aValue)static Stringdpcm(double dValue)static Stringdpcm(int nValue)static Stringdpcm(BigDecimal aValue)static Stringdpi(double dValue)static Stringdpi(int nValue)static Stringdpi(BigDecimal aValue)static Stringdppx(double dValue)static Stringdppx(int nValue)static Stringdppx(BigDecimal aValue)static Stringem(double dValue)static Stringem(int nValue)static Stringem(BigDecimal aValue)static Stringex(double dValue)static Stringex(int nValue)static Stringex(BigDecimal aValue)Stringformat(double dValue)Get the passed value formatted with this unit.Stringformat(int nValue)Get the passed value formatted with this unitStringformat(long nValue)Get the passed value formatted with this unitStringformat(BigDecimal aValue)Get the passed value formatted with this unit.static Stringfr(double dValue)static Stringfr(int nValue)static Stringfr(BigDecimal aValue)static ECSSUnitgetFromNameOrDefault(String sName, ECSSUnit eDefault)static ECSSUnitgetFromNameOrNull(String sName)ECSSMetaUnitgetMetaUnit()ECSSVersiongetMinimumCSSVersion()StringgetName()static Stringgrad(double dValue)static Stringgrad(int nValue)static Stringgrad(BigDecimal aValue)static Stringhz(double dValue)static Stringhz(int nValue)static Stringhz(BigDecimal aValue)static Stringin(double dValue)static Stringin(int nValue)static Stringin(BigDecimal aValue)static Stringkhz(double dValue)static Stringkhz(int nValue)static Stringkhz(BigDecimal aValue)static Stringmm(double dValue)static Stringmm(int nValue)static Stringmm(BigDecimal aValue)static Stringms(double dValue)static Stringms(int nValue)static Stringms(BigDecimal aValue)static Stringpc(double dValue)static Stringpc(int nValue)static Stringpc(BigDecimal aValue)static Stringperc(double dValue)static Stringperc(int nValue)static Stringperc(BigDecimal aValue)static Stringpt(double dValue)static Stringpt(int nValue)static Stringpt(BigDecimal aValue)static Stringpx(double dValue)static Stringpx(int nValue)static Stringpx(BigDecimal aValue)static Stringq(double dValue)static Stringq(int nValue)static Stringq(BigDecimal aValue)static Stringrad(double dValue)static Stringrad(int nValue)static Stringrad(BigDecimal aValue)static Stringrem(double dValue)static Stringrem(int nValue)static Stringrem(BigDecimal aValue)static Strings(double dValue)static Strings(int nValue)static Strings(BigDecimal aValue)static Stringturn(double dValue)static Stringturn(int nValue)static Stringturn(BigDecimal aValue)static ECSSUnitvalueOf(String name)Returns the enum constant of this type with the specified name.static ECSSUnit[]values()Returns an array containing the constants of this enum type, in the order they are declared.static Stringvh(double dValue)static Stringvh(int nValue)static Stringvh(BigDecimal aValue)static Stringvmax(double dValue)static Stringvmax(int nValue)static Stringvmax(BigDecimal aValue)static Stringvmin(double dValue)static Stringvmin(int nValue)static Stringvmin(BigDecimal aValue)static Stringvw(double dValue)static Stringvw(int nValue)static Stringvw(BigDecimal aValue)static Stringzero()
-
-
-
Enum Constant Detail
-
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 Detail
-
LENGTH_PX
public static final ECSSUnit LENGTH_PX
Length in pixel
-
-
Method Detail
-
values
public static ECSSUnit[] 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 (ECSSUnit c : ECSSUnit.values()) System.out.println(c);
- 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 nameNullPointerException- if the argument is null
-
getName
@Nonnull @Nonempty public String getName()
- Specified by:
getNamein interfacecom.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:
getMinimumCSSVersionin interfaceICSSVersionAware- 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 benull.- Returns:
value + getName()- Since:
- 3.7.3
-
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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- 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 benull.- Returns:
value + "fr"- Since:
- 5.0.4
-
-