- Direct Known Subclasses:
PercentageEvaluator
Evaluates calc()
expressions as well as functions like
min()
, clamp()
or cos()
.
To support percentages within calc()
expressions, it must be
subclassed by something that supports a box model implementation, overriding
the percentage(CSSTypedValue, short)
method.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CSSValue
absoluteProxyValue
(CSSPrimitiveValue partialValue) protected CSSTypedValue
absoluteTypedValue
(CSSTypedValue partialValue) protected CSSTypedValue
absoluteValue
(CSSPrimitiveValue partialValue) Obtain an absolute (numeric) value, starting from a primitive value.protected CSSNumberValue
createNumberValue
(short unit, float valueInSpecifiedUnit, boolean calculated) Create aCSSNumberValue
in the desired implementation.Evaluate the given expression.evaluateFunction
(CSSMathFunctionValue function) Evaluate the given mathematical function.protected float
percentage
(CSSTypedValue value, short resultType) Obtain the float value (in the requested absolute unit) corresponding to the given percentage value.
-
Constructor Details
-
Evaluator
public Evaluator()Constructs an evaluator with a preferred unit of typographic points (pt
). -
Evaluator
public Evaluator(short preferredUnit) Constructs an evaluator with the given preferred unit.- Parameters:
preferredUnit
- the preferred unit according toCSSUnit
.
-
-
Method Details
-
evaluateFunction
Evaluate the given mathematical function.This method checks the result unit, assuming that the unit must match that of the returned primitive value (some functions may return values where the units are raised to a power greater than one, or lesser than zero).
- Parameters:
function
- the mathematical function to evaluate.- Returns:
- the result of evaluating the function, or the function itself if this class does not know how to evaluate it.
- Throws:
DOMException
- if a problem was found evaluating the function, or the resulting unit is not a valid CSS unit.
-
createNumberValue
protected CSSNumberValue createNumberValue(short unit, float valueInSpecifiedUnit, boolean calculated) Create aCSSNumberValue
in the desired implementation.- Parameters:
unit
- the unit.valueInSpecifiedUnit
- the value in the given unit.calculated
- whether the value was calculated. Implementations may ignore this parameter.- Returns:
- the number value.
-
evaluateExpression
Evaluate the given expression.This method checks the result unit, assuming that the unit must match that of the returned primitive value (some functions may return values where the units are raised to a power greater than one, or lesser than zero).
- Parameters:
calc
- the expression value to evaluate.- Returns:
- the result from evaluating the expression.
- Throws:
DOMException
- if a problem was found evaluating the expression.
-
absoluteValue
Obtain an absolute (numeric) value, starting from a primitive value.If the supplied value is already absolute, or it is not known how to express it in absolute units, return it.
- Parameters:
partialValue
- the value that has to be expressed in absolute units.- Returns:
- the value in absolute units.
- Throws:
DOMException
-
absoluteTypedValue
-
absoluteProxyValue
-
percentage
Obtain the float value (in the requested absolute unit) corresponding to the given percentage value.- Parameters:
value
- the percentage value.resultType
- the desired absolute result type.- Returns:
- the absolute float value in the requested unit.
- Throws:
DOMException
- if the percentage could not be converted to the requested unit.
-