Package org.cip4.jdflib.datatypes
Class JDFNumList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.Object>
-
- org.cip4.jdflib.datatypes.JDFNumList
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.Object>,java.util.Collection<java.lang.Object>,java.util.List<java.lang.Object>,java.util.RandomAccess,JDFBaseDataTypes
- Direct Known Subclasses:
JDFCMYKColor,JDFIntegerList,JDFLabColor,JDFMatrix,JDFNumberList,JDFRectangle,JDFRGBColor,JDFShape,JDFTransferFunction,JDFXYPair
public abstract class JDFNumList extends java.util.Vector<java.lang.Object> implements JDFBaseDataTypes, java.lang.Cloneable
This abstract class is the representation of a number list (Integer and Double object). Intern these objects are collected in a vector and there are several methods to provide an access to the data.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJDFNumList.NormComparatorstatic classJDFNumList.VolumeComparator-
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
Constructors Constructor Description JDFNumList()constructs an empty number listJDFNumList(double[] array)constructor - constructs a number list with the given size and sets all values set to 0.0 DoubleJDFNumList(int size)constructor - constructs a number list with the given size and sets all values set to 0.0 DoubleJDFNumList(int[] array)constructor - constructs a number list with the given size and sets all values set to 0.0 DoubleJDFNumList(java.lang.String sl)constructor - constructs a number list with the given String; if the sub class is of type JDFIntegerList all object will be Integer in all other cases the object will be a DoubleJDFNumList(java.util.Vector v)Deprecated.use typesafe constructorsJDFNumList(JDFNumList nl)constructor - constructs a number list with a given JDFNumList
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JDFNumListabs()modify numlist to absolute valuesJDFNumListclone()booleancontains(JDFNumList l)return true if this contains at least one element from lbooleancontainsAll(JDFNumList l)return true if this contains all elements from ljava.util.Vector<java.lang.Object>copyNumList()Deprecated.use clone()doubledoubleAt(int i)getElementAt - returns the element at the ith positionjava.lang.ObjectelementAt(int i)getElementAt - returns the element at the ith positionbooleanequals(java.lang.Object other)equals - compares two JDFNumList elementsjava.lang.DoublegetDouble(int i)double[]getDoubleList()get the list of values as doublesjava.util.Vector<java.lang.Double>getDoubleVector()get the list of values as doublesint[]getIntArray()getIntArray - returns this integer list as an int arrayjava.lang.StringgetString()Deprecated.060418 - use toStringjava.lang.StringgetString(int precision)getString - returns the JDFNumList as a StringinthashCode()hashCode complements equals() to fulfill the equals/hashCode contractintintAt(int i)getElementAt - returns the element at the ith positionabstract booleanisValid()isValid - true if all instances are Double or Integer typesbooleanisValidString(java.lang.String st)isValidString - true if all instances are Double or Integer typesbooleanmatches(JDFNumList other, double delta)are all values within +/- delta?doublemax()return the absolute norm (sqrt of sum of values)doublemin()return the absolute norm (sqrt of sum of values)doublenorm()return the absolute norm (sqrt of sum of values)voidremoveElementAt(int i)removeElementAt - removes the element at the given positionbooleanreplaceElementAt(java.lang.Object obj, int i)replaceElementAt - replaces the element at the given position with the given objectJDFNumListscale(double factor)scale all values of this by factorJDFNumListscale(double factor, int precision)scale all values of this by factorJDFNumListscaleFromCM()scale all values of this to points from centimetersJDFNumListscaleFromCM(int precision)scale all values of this to points from centimetersJDFNumListscaleFromMM()scale all values of this to points from millimetersJDFNumListscaleFromMM(int precision)scale all values of this to points from millimetersJDFNumListscaleToCM()scale all values of this to points from centimetersJDFNumListscaleToCM(int precision)scale all values of this to points from centimetersJDFNumListscaleToMM()scale all values of this to points from millimetersJDFNumListscaleToMM(int precision)scale all values of this to points from millimetersvoidset(int pos, double d)JDFNumListsetString(java.lang.String string)sets this to the value specified in stringJDFNumListsetX(int pos, double d)JDFNumListshift(double x)return the absolute norm (sqrt of sum of values)voidsort()JDFNumListsubtract(JDFNumList l)subtract l from this,java.lang.StringtoString()toString - returns the JDFNumList as a Stringvoidunify()ensure that each instance exists only oncedoublevolume()return the n dimensional volume (product of all values)-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elements, ensureCapacity, firstElement, forEach, get, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
JDFNumList
public JDFNumList()
constructs an empty number list
-
JDFNumList
public JDFNumList(int size)
constructor - constructs a number list with the given size and sets all values set to 0.0 Double- Parameters:
size- the given size
-
JDFNumList
public JDFNumList(int[] array)
constructor - constructs a number list with the given size and sets all values set to 0.0 Double- Parameters:
size- the given size
-
JDFNumList
public JDFNumList(double[] array)
constructor - constructs a number list with the given size and sets all values set to 0.0 Double- Parameters:
size- the given size
-
JDFNumList
@Deprecated public JDFNumList(java.util.Vector v) throws java.util.zip.DataFormatExceptionDeprecated.use typesafe constructorsconstructor - constructs a number list with the given vector- Parameters:
v- a vector with number list objects- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFNumList
public JDFNumList(java.lang.String sl) throws java.util.zip.DataFormatExceptionconstructor - constructs a number list with the given String; if the sub class is of type JDFIntegerList all object will be Integer in all other cases the object will be a Double- Parameters:
sl- the given String- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFNumList
public JDFNumList(JDFNumList nl) throws java.util.zip.DataFormatException
constructor - constructs a number list with a given JDFNumList- Parameters:
nl- the given number list- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
-
Method Detail
-
set
public void set(int pos, double d)- Parameters:
pos-d-
-
setX
public JDFNumList setX(int pos, double d)
- Parameters:
pos-d-
-
setString
public JDFNumList setString(java.lang.String string) throws java.util.zip.DataFormatException
sets this to the value specified in string- Parameters:
string-- Throws:
java.util.zip.DataFormatException
-
getString
@Deprecated public java.lang.String getString()
Deprecated.060418 - use toStringgetString - returns all values whitespace separated in a String- Returns:
- String
-
getDoubleList
public double[] getDoubleList()
get the list of values as doubles- Returns:
-
getDoubleVector
public java.util.Vector<java.lang.Double> getDoubleVector()
get the list of values as doubles- Returns:
-
toString
public java.lang.String toString()
toString - returns the JDFNumList as a String- Overrides:
toStringin classjava.util.Vector<java.lang.Object>- Returns:
- String - the JDFNumList as a String
-
getString
public java.lang.String getString(int precision)
getString - returns the JDFNumList as a String- Parameters:
precision- # of digits to print- Returns:
- String - the JDFNumList as a String
-
equals
public boolean equals(java.lang.Object other)
equals - compares two JDFNumList elements- Specified by:
equalsin interfacejava.util.Collection<java.lang.Object>- Specified by:
equalsin interfacejava.util.List<java.lang.Object>- Overrides:
equalsin classjava.util.Vector<java.lang.Object>- Returns:
- boolean - true if equal otherwise false
-
hashCode
public int hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract- Specified by:
hashCodein interfacejava.util.Collection<java.lang.Object>- Specified by:
hashCodein interfacejava.util.List<java.lang.Object>- Overrides:
hashCodein classjava.util.Vector<java.lang.Object>
-
elementAt
public java.lang.Object elementAt(int i)
getElementAt - returns the element at the ith position- Overrides:
elementAtin classjava.util.Vector<java.lang.Object>- Parameters:
i- the index- Returns:
- Object - the range object at the given position, null if i is out of range
-
doubleAt
public double doubleAt(int i)
getElementAt - returns the element at the ith position- Parameters:
i- the index- Returns:
- double - the double value given position, 0.0 if out of range
-
intAt
public int intAt(int i)
getElementAt - returns the element at the ith position- Parameters:
i- the index- Returns:
- double - the double value given position, 0.0 if out of range
-
copyNumList
@Deprecated public java.util.Vector<java.lang.Object> copyNumList()
Deprecated.use clone()copyNumList - returns a clone of the numList vector- Returns:
- Vector - the clone of the numList vector
-
removeElementAt
public void removeElementAt(int i)
removeElementAt - removes the element at the given position- Overrides:
removeElementAtin classjava.util.Vector<java.lang.Object>- Parameters:
i- the position from where to remove the element
-
replaceElementAt
public boolean replaceElementAt(java.lang.Object obj, int i)replaceElementAt - replaces the element at the given position with the given object- Parameters:
obj- the objecti- the given position- Returns:
- boolean - true if successful otherwise false
-
isValid
public abstract boolean isValid() throws java.util.zip.DataFormatExceptionisValid - true if all instances are Double or Integer types- Returns:
- boolean - true if all instances are Double or Integer types
- Throws:
java.util.zip.DataFormatException
-
isValidString
public boolean isValidString(java.lang.String st)
isValidString - true if all instances are Double or Integer types- Parameters:
st- the string to check- Returns:
- boolean - true if all instances are Double or Integer types
-
scaleFromMM
public JDFNumList scaleFromMM()
scale all values of this to points from millimeters- Returns:
-
scaleFromMM
public JDFNumList scaleFromMM(int precision)
scale all values of this to points from millimeters- Returns:
-
scaleFromCM
public JDFNumList scaleFromCM()
scale all values of this to points from centimeters- Returns:
-
scaleFromCM
public JDFNumList scaleFromCM(int precision)
scale all values of this to points from centimeters- Returns:
-
scaleToMM
public JDFNumList scaleToMM()
scale all values of this to points from millimeters- Returns:
-
scaleToMM
public JDFNumList scaleToMM(int precision)
scale all values of this to points from millimeters- Returns:
-
scaleToCM
public JDFNumList scaleToCM()
scale all values of this to points from centimeters- Returns:
-
scaleToCM
public JDFNumList scaleToCM(int precision)
scale all values of this to points from centimeters- Returns:
-
scale
public JDFNumList scale(double factor)
scale all values of this by factor- Parameters:
factor-- Returns:
-
scale
public JDFNumList scale(double factor, int precision)
scale all values of this by factor- Parameters:
factor-- Returns:
-
abs
public JDFNumList abs()
modify numlist to absolute values- Returns:
- See Also:
Math.abs(int)
-
clone
public JDFNumList clone()
- Overrides:
clonein classjava.util.Vector<java.lang.Object>- See Also:
Vector.clone()
-
matches
public boolean matches(JDFNumList other, double delta)
are all values within +/- delta?- Parameters:
other-delta-- Returns:
- See Also:
Math.abs(int)
-
subtract
public JDFNumList subtract(JDFNumList l)
subtract l from this,- Parameters:
l- the list to subtract from this- Throws:
java.lang.IllegalArgumentException- if sizes don't match
-
unify
public void unify()
ensure that each instance exists only once
-
getIntArray
public int[] getIntArray()
getIntArray - returns this integer list as an int array- Returns:
- int[] - the int array
-
getDouble
public java.lang.Double getDouble(int i)
- Parameters:
i-- Returns:
- the Double object
-
sort
public void sort()
-
contains
public boolean contains(JDFNumList l)
return true if this contains at least one element from l- Parameters:
l- the list to check for- Returns:
-
norm
public double norm()
return the absolute norm (sqrt of sum of values)- Returns:
-
min
public double min()
return the absolute norm (sqrt of sum of values)- Returns:
-
shift
public JDFNumList shift(double x)
return the absolute norm (sqrt of sum of values)- Returns:
-
max
public double max()
return the absolute norm (sqrt of sum of values)- Returns:
-
volume
public double volume()
return the n dimensional volume (product of all values)- Returns:
-
containsAll
public boolean containsAll(JDFNumList l)
return true if this contains all elements from l- Parameters:
l- the list to check for- Returns:
-
-