org.cip4.jdflib.datatypes
Class JDFNumList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<Object>
              extended by org.cip4.jdflib.datatypes.JDFNumList
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, JDFBaseDataTypes
Direct Known Subclasses:
JDFCMYKColor, JDFIntegerList, JDFLabColor, JDFMatrix, JDFNumberList, JDFRectangle, JDFRGBColor, JDFShape, JDFTransferFunction, JDFXYPair

public abstract class JDFNumList
extends Vector<Object>
implements JDFBaseDataTypes, 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/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
 
Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
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
JDFNumList()
          constructs an empty number list
JDFNumList(int size)
          constructor - constructs a number list with the given size and sets all values set to 0.0 Double
JDFNumList(JDFNumList nl)
          constructor - constructs a number list with a given JDFNumList
JDFNumList(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 Double
JDFNumList(Vector v)
          Deprecated. use typesafe constructors
 
Method Summary
 JDFNumList abs()
          modify numlist to absolute values
 JDFNumList clone()
           
 boolean contains(JDFNumList l)
          return true if this contains at least one element from l
 boolean containsAll(JDFNumList l)
          return true if this contains all elements from l
 Vector<Object> copyNumList()
          Deprecated. use clone()
 double doubleAt(int i)
          getElementAt - returns the element at the ith position
 Object elementAt(int i)
          getElementAt - returns the element at the ith position
 boolean equals(Object other)
          equals - compares two JDFNumList elements
 double[] getDoubleList()
          get the list of values as doubles
 int[] getIntArray()
          getIntArray - returns this integer list as an int array
 String getString()
          Deprecated. 060418 - use toString
 String getString(int precision)
          getString - returns the JDFNumList as a String
 int hashCode()
          hashCode complements equals() to fulfill the equals/hashCode contract
abstract  boolean isValid()
          isValid - true if all instances are Double or Integer types
 boolean isValidString(String st)
          isValidString - true if all instances are Double or Integer types
 boolean matches(JDFNumList other, double delta)
          are all values within +/- delta?
 void removeElementAt(int i)
          removeElementAt - removes the element at the given position
 boolean replaceElementAt(Object obj, int i)
          replaceElementAt - replaces the element at the given position with the given object
 JDFNumList scale(double factor)
          scale all values of this by factor
 JDFNumList scaleFromCM()
          scale all values of this to points from centimeters
 JDFNumList scaleFromMM()
          scale all values of this to points from millimeters
 JDFNumList scaleToCM()
          scale all values of this to points from centimeters
 JDFNumList scaleToMM()
          scale all values of this to points from millimeters
 void set(int pos, double d)
           
 void setString(String string)
          sets this to the value specified in string
 void subtract(JDFNumList l)
          subtract l from this,
 String toString()
          toString - returns the JDFNumList as a String
 void unify()
          ensure that each instance exists only once
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elements, ensureCapacity, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

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

@Deprecated
public JDFNumList(Vector v)
           throws DataFormatException
Deprecated. use typesafe constructors

constructor - constructs a number list with the given vector

Parameters:
v - a vector with number list objects
Throws:
DataFormatException - - if the Vector has not a valid format

JDFNumList

public JDFNumList(String sl)
           throws DataFormatException
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 Double

Parameters:
sl - the given String
Throws:
DataFormatException - - if the String has not a valid format

JDFNumList

public JDFNumList(JDFNumList nl)
           throws DataFormatException
constructor - constructs a number list with a given JDFNumList

Parameters:
nl - the given number list
Throws:
DataFormatException - - if the String has not a valid format
Method Detail

set

public void set(int pos,
                double d)
Parameters:
pos -
d -

setString

public void setString(String string)
               throws DataFormatException
sets this to the value specified in string

Parameters:
string -
Throws:
DataFormatException

getString

@Deprecated
public String getString()
Deprecated. 060418 - use toString

getString - returns all values whitespace separated in a String

Returns:
String

getDoubleList

public double[] getDoubleList()
get the list of values as doubles

Returns:

toString

public String toString()
toString - returns the JDFNumList as a String

Overrides:
toString in class Vector<Object>
Returns:
String - the JDFNumList as a String

getString

public 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(Object other)
equals - compares two JDFNumList elements

Specified by:
equals in interface Collection<Object>
Specified by:
equals in interface List<Object>
Overrides:
equals in class Vector<Object>
Returns:
boolean - true if equal otherwise false

hashCode

public int hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract

Specified by:
hashCode in interface Collection<Object>
Specified by:
hashCode in interface List<Object>
Overrides:
hashCode in class Vector<Object>

elementAt

public Object elementAt(int i)
getElementAt - returns the element at the ith position

Overrides:
elementAt in class Vector<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

copyNumList

@Deprecated
public Vector<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:
removeElementAt in class Vector<Object>
Parameters:
i - the position from where to remove the element

replaceElementAt

public boolean replaceElementAt(Object obj,
                                int i)
replaceElementAt - replaces the element at the given position with the given object

Parameters:
obj - the object
i - the given position
Returns:
boolean - true if successful otherwise false

isValid

public abstract boolean isValid()
                         throws DataFormatException
isValid - true if all instances are Double or Integer types

Returns:
boolean - true if all instances are Double or Integer types
Throws:
DataFormatException

isValidString

public boolean isValidString(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:

scaleFromCM

public JDFNumList scaleFromCM()
scale all values of this to points from centimeters

Returns:

scaleToMM

public JDFNumList scaleToMM()
scale all values of this to points from millimeters

Returns:

scaleToCM

public JDFNumList scaleToCM()
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:

abs

public JDFNumList abs()
modify numlist to absolute values

Returns:
See Also:
Math.abs(int)

clone

public JDFNumList clone()
Overrides:
clone in class Vector<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 void subtract(JDFNumList l)
subtract l from this,

Parameters:
l - the list to subtract from this
Throws:
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

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:

containsAll

public boolean containsAll(JDFNumList l)
return true if this contains all elements from l

Parameters:
l - the list to check for
Returns:


Copyright © 2013. All Rights Reserved.