Class NumberValue
java.lang.Object
io.sf.carte.doc.style.css.property.StyleValue
io.sf.carte.doc.style.css.property.PrimitiveValue
io.sf.carte.doc.style.css.property.TypedValue
io.sf.carte.doc.style.css.property.NumberValue
- All Implemented Interfaces:
CSSPrimitiveValue,CSSTypedValue,CSSValue,Serializable,Cloneable
- Direct Known Subclasses:
PercentageValue
Number-specific value.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a copy of this object.static NumberValuecreateCSSNumberValue(short unit, float floatValue) booleanstatic floatfloatValueConversion(float fvalue, short declType, short unitType) Converts a float value, expressed indeclTypeunits, tounitTypeunits.Get a string representation of the current value.Gives the text representation of the dimension unit, if this value represents a dimension.floatgetFloatValue(short unitType) Gets a float value in a specified unit.getMinifiedCssText(String propertyName) Gives a minified version of the css text of the property.shortIf this is a numeric value, get its unit type.inthashCode()booleanTest whether this is a numeric value that was the result of acalc()expression.booleanTest whether this is a numeric value that is less than zero.booleanIs this value a number set to a value of zero, or an absolute value less than 1e-5 ?minifyAbsolute(String propertyName) voidserializeAbsolute(io.sf.carte.util.SimpleWriter wri) voidSet that the value that this number represents was originally specified as a calculation or as a relative unit, but comes from being either calculated or absolutized.voidsetCssText(String cssText) Attempts to change this value to match the supplied css text.voidThis value is expected to contain an integer.voidsetFloatValue(short unitType, float floatValue) If this value is numeric, set a float value with the given unit.voidsetFloatValuePt(float floatValue) voidsetIntegerValue(int intValue) voidwriteCssText(io.sf.carte.util.SimpleWriter wri) Serialize this value to aSimpleWriter.Methods inherited from class io.sf.carte.doc.style.css.property.TypedValue
getComponent, getCssValueType, getStringValue, setComponent, setStringValue, toRGBColorMethods inherited from class io.sf.carte.doc.style.css.property.PrimitiveValue
getPrimitiveType, isPrimitiveValue, isSubproperty, setSubpropertyMethods inherited from class io.sf.carte.doc.style.css.property.StyleValue
isSystemDefault, matches, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSTypedValue
toRGBColorValueMethods inherited from interface io.sf.carte.doc.style.css.CSSValue
getPrimitiveType, matches
-
Field Details
-
realvalue
protected float realvalue
-
-
Constructor Details
-
NumberValue
public NumberValue() -
NumberValue
-
-
Method Details
-
getUnitType
public short getUnitType()Description copied from interface:CSSPrimitiveValueIf this is a numeric value, get its unit type.- Returns:
- the unit type,
CSS_INVALIDif the unit or type are not valid.
-
getCssText
Description copied from class:StyleValueGet a string representation of the current value.- Specified by:
getCssTextin interfaceCSSValue- Specified by:
getCssTextin classStyleValue- Returns:
- the css text representing the value of this property.
-
writeCssText
Description copied from interface:CSSValueSerialize this value to aSimpleWriter.- Parameters:
wri- the SimpleWriter.- Throws:
IOException- if an error happened while writing.
-
serializeAbsolute
- Throws:
IOException
-
getMinifiedCssText
Description copied from interface:CSSValueGives a minified version of the css text of the property.It may be customized for the given property name.
- Specified by:
getMinifiedCssTextin interfaceCSSValue- Overrides:
getMinifiedCssTextin classStyleValue- Parameters:
propertyName- the property name.- Returns:
- the minified css text.
-
minifyAbsolute
-
setFloatValue
Description copied from interface:CSSTypedValueIf this value is numeric, set a float value with the given unit.- Specified by:
setFloatValuein interfaceCSSTypedValue- Overrides:
setFloatValuein classTypedValue- Parameters:
unitType- the unit type according toCSSUnit.floatValue- the float value.- Throws:
DOMException- INVALID_ACCESS_ERR if the unit is not aCSSUnitone, or this value is not a number.
NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
-
setFloatValuePt
public void setFloatValuePt(float floatValue) -
setIntegerValue
public void setIntegerValue(int intValue) -
setExpectInteger
public void setExpectInteger()Description copied from interface:CSSPrimitiveValueThis value is expected to contain an integer.If this value is a non-integer number, an exception will be thrown immediately.
If this value is a
calc()that ever produces a non-integer number, the value shall be rounded to the nearest integer.If the value is a proxy that ever produces other than an integer number (without
calc()involvement), an exception should be thrown later.- Specified by:
setExpectIntegerin interfaceCSSPrimitiveValue- Overrides:
setExpectIntegerin classPrimitiveValue
-
setCssText
Description copied from class:StyleValueAttempts to change this value to match the supplied css text.In css4j, it is not recommended to set property values using this method.
- Specified by:
setCssTextin interfaceCSSValue- Overrides:
setCssTextin classStyleValue- Parameters:
cssText- the text value.- Throws:
DOMException- SYNTAX_ERR: Raised if the specified CSS string value has a syntax error (according to the attached property) or is unparsable.
INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of values than the values allowed by the CSS property.
NO_MODIFICATION_ALLOWED_ERR: Raised if this value is read-only.
-
isCalculatedNumber
public boolean isCalculatedNumber()Description copied from interface:CSSTypedValueTest whether this is a numeric value that was the result of acalc()expression.- Specified by:
isCalculatedNumberin interfaceCSSTypedValue- Overrides:
isCalculatedNumberin classTypedValue- Returns:
trueif this is a numeric value, and it was produced as the output of a calculation (instead of declared as a plain, constant numeric value).
-
setAbsolutizedUnit
public void setAbsolutizedUnit()Set that the value that this number represents was originally specified as a calculation or as a relative unit, but comes from being either calculated or absolutized.This has consequences as to how the number is serialized.
-
isNegativeNumber
public boolean isNegativeNumber()Description copied from interface:CSSPrimitiveValueTest whether this is a numeric value that is less than zero.- Returns:
trueif this is a numeric value and its value is negative.
-
isNumberZero
public boolean isNumberZero()Description copied from class:TypedValueIs this value a number set to a value of zero, or an absolute value less than 1e-5 ?- Specified by:
isNumberZeroin interfaceCSSTypedValue- Overrides:
isNumberZeroin classTypedValue- Returns:
trueif this is a number and is set to zero (or equivalently small value).
-
getFloatValue
Gets a float value in a specified unit.- Specified by:
getFloatValuein interfaceCSSTypedValue- Overrides:
getFloatValuein classTypedValue- Parameters:
unitType- A unit code to get the float value, likeCSS_NUMBER,CSS_PERCENTAGE,CSS_PTorCSS_EX. If the type isCSS_OTHER, the value shall be returned as is, regardless of the unit that was set with.- Returns:
- The float value in the specified unit.
- Throws:
DOMException- INVALID_ACCESS_ERR if the CSS value can't be converted into the specified unit.
-
floatValueConversion
public static float floatValueConversion(float fvalue, short declType, short unitType) throws DOMException Converts a float value, expressed indeclTypeunits, tounitTypeunits.- Parameters:
fvalue- the float value to convert.declType- the declared type of the value.unitType- the desired unit type.- Returns:
- the value converted to the
unitTypeunit. - Throws:
DOMException- if the unit conversion could not be done.
-
getDimensionUnitText
Gives the text representation of the dimension unit, if this value represents a dimension.- Returns:
- the text representation of the dimension unit, or the empty string if this value does not represent a dimension.
-
hashCode
public int hashCode()- Overrides:
hashCodein classPrimitiveValue
-
equals
- Overrides:
equalsin classPrimitiveValue
-
clone
Description copied from class:TypedValueCreates and returns a copy of this object.The object will be the same except for the
subpropertyflag, that will be disabled in the clone object.- Specified by:
clonein interfaceCSSValue- Specified by:
clonein classTypedValue- Returns:
- a copy of this object.
-
createCSSNumberValue
-