Package org.cip4.jdflib.datatypes
Class JDFNumberRange
java.lang.Object
org.cip4.jdflib.datatypes.JDFRange
org.cip4.jdflib.datatypes.JDFNumberRange
- All Implemented Interfaces:
JDFBaseDataTypes
This class represents a number range (JDFNumberRange). It is a whitespace separated list of 2 double values separated by a tilde "~", for example "1.23 ~ 1.45"
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue -
Field Summary
Fields inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
EPSILON, MAX_CMYK_COLOR, MAX_LAB_COLOR, MAX_MATRIX_DIMENSION, MAX_RECTANGLE_DIMENSION, MAX_RGB_COLOR, MAX_SHAPE_DIMENSION, MAX_XY_DIMENSION -
Constructor Summary
ConstructorsConstructorDescriptionconstructs an empty JDFNumberRangeJDFNumberRange(double x) constructs a JDFNumberRange, both values are equal ("from x to x")JDFNumberRange(double xmin, double xmax) constructor, creates a JDFNumberRange bounded by two double values ("from xmin to xmax")constructs a JDFNumberRange with the values of the given stringcopy constructor, creates a JDFNumberRange with the given JDFNumberRange -
Method Summary
Modifier and TypeMethodDescriptionstatic JDFNumberRangefactory for JDFNumberRange that silently returns null in case of illegal stringsbooleanequals - returns true if both JDFNumberRange are equal otherwise false, the difference must be smaller than EPSILONdoublegetLeft()getLeft - returns the left value of the rangeprotected Objectreturns the string representation of the left value of the rangegetLeftString(int precision) returns the string representation of the left value of the rangedoublegetLowerValue - returns the lower value of the bounds
for example 4.5~6.3 returns 4.5, 7.0~5.9 returns 5.9doublegetRight()getRight - returns the right value of the rangeprotected Objectreturns the string representation of the left value of the rangegetRightString(int precision) returns the string representation of the left value of the rangegetString(int precision) get a string with precision digits after each decimaldoublegetUpperValue - return the upper value of the bounds
for example 4.5~6.3 returns 6.3, 7.0~5.9 returns 7.0inthashCode()hashCode complements equals() to fulfill the equals/hashCode contractprotected voidinit(double xmin, double xmax) Initializationprotected booleaninObjectRange(Object other) booleaninRange(double x) inRange - returns true if (lower value >= x <= upper value)booleanisPartOfRange - is range 'r' within this range?booleanisValid - validate the given Stringvoidscale(double f) scale - scales both valuesvoidsetLeft(double x) setLeft - sets the left double objectvoidsetRight(double x) setRight - sets the right double objectMethods inherited from class org.cip4.jdflib.datatypes.JDFRange
getXJDFString, toString
-
Constructor Details
-
JDFNumberRange
public JDFNumberRange()constructs an empty JDFNumberRange -
JDFNumberRange
public JDFNumberRange(double x) constructs a JDFNumberRange, both values are equal ("from x to x")- Parameters:
x- the given double
-
JDFNumberRange
public JDFNumberRange(double xmin, double xmax) constructor, creates a JDFNumberRange bounded by two double values ("from xmin to xmax")- Parameters:
xmin- the given min valuexmax- the given max value
-
JDFNumberRange
copy constructor, creates a JDFNumberRange with the given JDFNumberRange- Parameters:
nr-
-
JDFNumberRange
constructs a JDFNumberRange with the values of the given string- Parameters:
s- the given string- Throws:
DataFormatException- - if the String has not a valid format
-
-
Method Details
-
createNumberRange
factory for JDFNumberRange that silently returns null in case of illegal strings- Parameters:
s- the string to parse- Returns:
- the JDFNumberRange, null if s is not compatible
-
init
protected void init(double xmin, double xmax) Initialization- Parameters:
xmin- left valuexmax- right value
-
isValid
isValid - validate the given String- Parameters:
s- the given string to validate- Returns:
- boolean - false if the String has not a valid format
-
equals
equals - returns true if both JDFNumberRange are equal otherwise false, the difference must be smaller than EPSILON -
hashCode
public int hashCode()hashCode complements equals() to fulfill the equals/hashCode contract -
getLeftString
returns the string representation of the left value of the range- Returns:
- the left value of the range
-
getLeft
public double getLeft()getLeft - returns the left value of the range- Returns:
- double - the left value of the range
-
getLeftString
returns the string representation of the left value of the range- Overrides:
getLeftStringin classJDFRange- Parameters:
precision-- Returns:
-
getRightString
returns the string representation of the left value of the range- Overrides:
getRightStringin classJDFRange- Parameters:
precision-- Returns:
-
getRightString
returns the string representation of the left value of the range- Returns:
- the left value of the range
-
getRight
public double getRight()getRight - returns the right value of the range- Returns:
- double - the right value of the range
-
setLeft
public void setLeft(double x) setLeft - sets the left double object- Parameters:
x- the left double object
-
setRight
public void setRight(double x) setRight - sets the right double object- Parameters:
x- the right double object
-
scale
public void scale(double f) scale - scales both values- Parameters:
f- the scaling factor
-
getLowerValue
public double getLowerValue()getLowerValue - returns the lower value of the bounds
for example 4.5~6.3 returns 4.5, 7.0~5.9 returns 5.9- Returns:
- double - the lower value of the range
-
getUpperValue
public double getUpperValue()getUpperValue - return the upper value of the bounds
for example 4.5~6.3 returns 6.3, 7.0~5.9 returns 7.0- Returns:
- double - the upper value of the range
-
inRange
public boolean inRange(double x) inRange - returns true if (lower value >= x <= upper value)- Parameters:
x- comparison value- Returns:
- boolean - true if x in range
-
isPartOfRange
isPartOfRange - is range 'r' within this range?- Specified by:
isPartOfRangein classJDFRange- Parameters:
r- the range to test- Returns:
- boolean - true if range 'r' is within this range, else false
-
getRightObject
- Specified by:
getRightObjectin classJDFRange
-
getLeftObject
- Specified by:
getLeftObjectin classJDFRange
-
inObjectRange
- Overrides:
inObjectRangein classJDFRange
-
getString
Description copied from class:JDFRangeget a string with precision digits after each decimal
-