Class PercentageEvaluator

java.lang.Object
io.sf.carte.doc.style.css.property.Evaluator
io.sf.carte.doc.style.css.property.PercentageEvaluator

public class PercentageEvaluator extends Evaluator
Evaluates expressions with only percentages and plain numbers.
  • Constructor Details

    • PercentageEvaluator

      public PercentageEvaluator()
  • Method Details

    • evaluateExpression

      public CSSNumberValue evaluateExpression(CSSExpressionValue calc) throws DOMException
      Description copied from class: Evaluator
      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).

      Overrides:
      evaluateExpression in class Evaluator
      Parameters:
      calc - the expression value to evaluate.
      Returns:
      the result from evaluating the expression.
      Throws:
      DOMException - if a problem was found evaluating the expression.
    • evaluateFunction

      public CSSNumberValue evaluateFunction(CSSMathFunctionValue function) throws DOMException
      Description copied from class: Evaluator
      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).

      Overrides:
      evaluateFunction in class Evaluator
      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.
    • percentage

      protected float percentage(CSSNumberValue value, short resultType) throws DOMException
      Obtain the float value (in the requested absolute unit) corresponding to the given percentage value.
      Overrides:
      percentage in class Evaluator
      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.