All Implemented Interfaces:
io.sf.carte.doc.style.css.CSSNumberValue, io.sf.carte.doc.style.css.CSSPrimitiveValue, io.sf.carte.doc.style.css.CSSTypedValue, io.sf.carte.doc.style.css.CSSValue, CSSVal, TypedValue, Value, Serializable, Cloneable, CSSNumericValue, CSSStyleValue, CSSUnitValue

public class FloatValue extends NumericValue implements io.sf.carte.doc.style.css.CSSNumberValue, CSSUnitValue
This class represents float values.
See Also:
  • Constructor Details

    • FloatValue

      public FloatValue(short unitType, float floatValue)
      Creates a new value.
      Parameters:
      unitType - the unit.
      floatValue - the value expressed in that unit.
  • Method Details

    • getCssText

      public static String getCssText(short unit, float value)
      Returns the CSS text associated with the given type/value pair.
    • createConstant

      public static FloatValue createConstant(short unit, float value)
      Create a constant with the given unit and value.

      If you want to have a modifiable copy of the returned value, clone it.

      Parameters:
      unit - the unit.
      value - the value expressed in that unit.
      Returns:
      the immutable value.
    • getPrimitiveType

      public io.sf.carte.doc.style.css.CSSValue.Type getPrimitiveType()
      The type of the value.
      Specified by:
      getPrimitiveType in interface io.sf.carte.doc.style.css.CSSValue
    • getUnitType

      public short getUnitType()
      Description copied from interface: Value
      Gets the css unit as in CSS4J's CSSUnit.

      If the value has no valid CSS unit, returns CSSUnit.CSS_INVALID.

      Specified by:
      getUnitType in interface io.sf.carte.doc.style.css.CSSPrimitiveValue
      Specified by:
      getUnitType in interface TypedValue
      Specified by:
      getUnitType in interface Value
      Returns:
      the css unit as in CSS4J's CSSUnit.
    • getFloatValue

      public float getFloatValue()
      Returns the float value.
      Specified by:
      getFloatValue in interface io.sf.carte.doc.style.css.CSSTypedValue
      Specified by:
      getFloatValue in interface CSSVal
      Specified by:
      getFloatValue in interface TypedValue
      Overrides:
      getFloatValue in class AbstractValue
      Returns:
      the float value.
    • getValue

      public double getValue()
      Description copied from interface: CSSUnitValue
      Gets the numeric value in the units represented by this object.
      Specified by:
      getValue in interface CSSUnitValue
      Returns:
      the numeric value.
    • setValue

      public void setValue(double value)
      Description copied from interface: CSSUnitValue
      Set the numeric value in the units represented by this object.
      Specified by:
      setValue in interface CSSUnitValue
      Parameters:
      value - the numeric value.
    • setValue

      public void setValue(String cssText) throws DOMException
      Throws:
      DOMException
    • getUnit

      public String getUnit()
      Description copied from interface: CSSUnitValue
      Gets the unit string.
      Specified by:
      getUnit in interface CSSUnitValue
      Returns:
      the unit string.
    • getCssText

      public String getCssText()
      A string representation of the current value.
      Specified by:
      getCssText in interface io.sf.carte.doc.style.css.CSSValue
    • setCssText

      public void setCssText(String cssText) throws DOMException
      Specified by:
      setCssText in interface io.sf.carte.doc.style.css.CSSValue
      Overrides:
      setCssText in class AbstractValue
      Throws:
      DOMException
    • isCalculatedNumber

      public boolean isCalculatedNumber()
      Specified by:
      isCalculatedNumber in interface io.sf.carte.doc.style.css.CSSTypedValue
      Specified by:
      isCalculatedNumber in interface TypedValue
    • setCalculatedNumber

      public void setCalculatedNumber(boolean calculated)
      Sets whether this number is the result of a calculation.
      Specified by:
      setCalculatedNumber in interface io.sf.carte.doc.style.css.CSSNumberValue
      Parameters:
      calculated - true if this number was calculated.
    • setExpectInteger

      public void setExpectInteger() throws DOMException
      Specified by:
      setExpectInteger in interface io.sf.carte.doc.style.css.CSSPrimitiveValue
      Specified by:
      setExpectInteger in interface TypedValue
      Throws:
      DOMException
    • roundToInteger

      public void roundToInteger() throws DOMException
      Specified by:
      roundToInteger in interface io.sf.carte.doc.style.css.CSSNumberValue
      Throws:
      DOMException
    • isNegativeNumber

      public boolean isNegativeNumber()
      Specified by:
      isNegativeNumber in interface io.sf.carte.doc.style.css.CSSPrimitiveValue
    • isNumberZero

      public boolean isNumberZero()
      Specified by:
      isNumberZero in interface io.sf.carte.doc.style.css.CSSTypedValue
      Specified by:
      isNumberZero in interface TypedValue
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractValue
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class AbstractValue
    • to

      public CSSUnitValue to(String unit)
      Description copied from interface: CSSNumericValue
      Converts this value into one in the given unit.
      Specified by:
      to in interface CSSNumericValue
      Parameters:
      unit - the unit.
      Returns:
      the new converted value,
    • clone

      public FloatValue clone()
      Description copied from interface: Value
      Create and return a copy of this object.

      If this object is unmodifiable, the clone will be modifiable.

      Specified by:
      clone in interface io.sf.carte.doc.style.css.CSSTypedValue
      Specified by:
      clone in interface CSSVal
      Specified by:
      clone in interface io.sf.carte.doc.style.css.CSSValue
      Specified by:
      clone in interface TypedValue
      Specified by:
      clone in interface Value
      Overrides:
      clone in class NumericValue
      Returns:
      a modifiable copy of this object.