Module technology.sola.engine
Class StyleValue
java.lang.Object
technology.sola.engine.graphics.gui.style.property.StyleValue
StyleValue holds a numeric value that can be represented as an absolute value or a relative percentage value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StyleValue
StyleValue constant for the value of 100%.static final StyleValue
StyleValue constant for the value of 0. -
Constructor Summary
ConstructorsConstructorDescriptionStyleValue
(int pixelValue) Creates a StyleValue that is an absolute pixel value.StyleValue
(String value) Creates a StyleValue from a string that can be a pixel value or percentage. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
getValue
(int parentValue) Gets the resolved value based on a parent's dimension.int
hashCode()
boolean
static @Nullable StyleValue
Creates a StyleValue from the parsed String.
-
Field Details
-
ZERO
StyleValue constant for the value of 0. -
FULL
StyleValue constant for the value of 100%.
-
-
Constructor Details
-
StyleValue
public StyleValue(int pixelValue) Creates a StyleValue that is an absolute pixel value.- Parameters:
pixelValue
- the pixel value
-
StyleValue
Creates a StyleValue from a string that can be a pixel value or percentage.- ends with '%' - percentage
- ends with 'px' - pixel
- default - pixel
- Parameters:
value
- the value to parse into a StyleValue
-
-
Method Details
-
of
Creates a StyleValue from the parsed String. Returns null if value is null.- Parameters:
value
- the String to parse- Returns:
- the StyleValue or null
-
getValue
public int getValue(int parentValue) Gets the resolved value based on a parent's dimension.- Parameters:
parentValue
- the parent's value to be relative to if percentage- Returns:
- the resolved value
-
isPercentage
public boolean isPercentage()- Returns:
- true if this StyleValue is a relative percentage value
-
equals
-
hashCode
public int hashCode()
-