Package org.cip4.jdflib.datatypes
Class JDFTransferFunction
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.Object>
-
- org.cip4.jdflib.datatypes.JDFNumList
-
- org.cip4.jdflib.datatypes.JDFTransferFunction
-
- 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
public class JDFTransferFunction extends JDFNumList
This class is a representation of a whitespace separated list of numbers representing a set of XY coordinates of a transfer function. The total number of x y values must be even because of the pairs.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cip4.jdflib.datatypes.JDFNumList
JDFNumList.NormComparator, JDFNumList.VolumeComparator
-
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringUNIT-
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 JDFTransferFunction()constructs a xy pair with all values set to 0.0 DoubleJDFTransferFunction(java.lang.String s)constructs a number list with the given string the number of tokens must be evenJDFTransferFunction(java.util.Vector v)Deprecated.use typesafe constructorsJDFTransferFunction(JDFNumList nl)constructs a number list with the given number listJDFTransferFunction(JDFTransferFunction tf)copy constructor
constructs a number list with the given transfer function
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double x, double y)add - adds a x and a y coordinate to the vectorvoidadd(java.lang.Double x, java.lang.Double y)add - adds a x and a y coordinate to the vectorbooleanadd(java.lang.Object e)voidadd(java.lang.String s)add - adds a x and a y coordinate to the vectorvoidadd(JDFTransferFunction tf)add - adds a complete transfer function to the vectorvoidadd(JDFXYPair xy)add - adds a xy coordinate to the vectorbooleanaddAll(java.util.Collection<? extends java.lang.Object> c)voidclear()static JDFTransferFunctioncreateTransferFunction(java.lang.String s)factory for JDFTransferFunction that silently returns null in case of illegal stringsdoublegetFastValue(double x)get the Y value at x-value x - we interpolate linearly from a cachestatic JDFTransferFunctiongetUnit()doublegetValue(double x)get the Y value at x-value x - we interpolate linearlydoublegetX(int index)get the x value at index note that each index consumes 2 elements (the x and y value)JDFXYPairgetXRange()get the min and max value of XdoublegetY(int index)get the Y value at index ibooleanisUnit()isUnit - true if we are 0 0 1 1booleanisValid()isValid - true if the size of the vector is even and all instances are Double typesvoidmultiply(JDFTransferFunction tf)multiplies a complete transfer function to the vector only useful for 0-1 ranged transfer functionsstatic JDFTransferFunctionmultiply(JDFTransferFunction tf1, JDFTransferFunction tf2)returns the multiplied tf - in case one of thr arguments is null or unit, the other argument is returned unmodifiedintnumPoints()voidresetCache()voidset(double x0, double dx, java.util.Vector<java.lang.Double> v)sets a vector of y coordinates with a common distance between points-
Methods inherited from class org.cip4.jdflib.datatypes.JDFNumList
abs, clone, contains, containsAll, copyNumList, doubleAt, elementAt, equals, getDouble, getDoubleList, getDoubleVector, getIntArray, getString, getString, hashCode, intAt, isValidString, matches, max, min, norm, removeElementAt, replaceElementAt, scale, scale, scaleFromCM, scaleFromCM, scaleFromMM, scaleFromMM, scaleToCM, scaleToCM, scaleToMM, scaleToMM, set, setString, setX, shift, sort, subtract, toString, unify, volume
-
Methods inherited from class java.util.Vector
add, addAll, addElement, capacity, 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
-
-
-
-
Field Detail
-
UNIT
public static final java.lang.String UNIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JDFTransferFunction
public JDFTransferFunction()
constructs a xy pair with all values set to 0.0 Double
-
JDFTransferFunction
public JDFTransferFunction(java.lang.String s) throws java.util.zip.DataFormatExceptionconstructs a number list with the given string the number of tokens must be even- Parameters:
s- the given String in number list format- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFTransferFunction
@Deprecated public JDFTransferFunction(java.util.Vector v) throws java.util.zip.DataFormatExceptionDeprecated.use typesafe constructorsconstructs a number list with the given vector the number of elements must be even- Parameters:
v- the number list as a vector- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFTransferFunction
public JDFTransferFunction(JDFNumList nl) throws java.util.zip.DataFormatException
constructs a number list with the given number list- Parameters:
nl- the given number list- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFTransferFunction
public JDFTransferFunction(JDFTransferFunction tf)
copy constructor
constructs a number list with the given transfer function- Parameters:
tf- the given number list- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
-
Method Detail
-
getUnit
public static JDFTransferFunction getUnit()
-
createTransferFunction
public static JDFTransferFunction createTransferFunction(java.lang.String s)
factory for JDFTransferFunction that silently returns null in case of illegal strings- Parameters:
s- the string to parse- Returns:
- the JDFTransferFunction, null if s is not compatible
-
isValid
public boolean isValid() throws java.util.zip.DataFormatExceptionisValid - true if the size of the vector is even and all instances are Double types- Specified by:
isValidin classJDFNumList- Returns:
- boolean - true if all instances are Double or Integer types
- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
isUnit
public boolean isUnit()
isUnit - true if we are 0 0 1 1
-
add
public void add(JDFXYPair xy)
add - adds a xy coordinate to the vector- Parameters:
xy- the xy coordinate to add
-
add
public void add(java.lang.Double x, java.lang.Double y)add - adds a x and a y coordinate to the vector- Parameters:
x- the x coordinate to addy- the y coordinate to add
-
add
public void add(double x, double y)add - adds a x and a y coordinate to the vector- Parameters:
x- the x coordinate to addy- the y coordinate to add
-
set
public void set(double x0, double dx, java.util.Vector<java.lang.Double> v)sets a vector of y coordinates with a common distance between points- Parameters:
x0-dx-v-
-
getX
public double getX(int index)
get the x value at index note that each index consumes 2 elements (the x and y value)- Parameters:
index-- Returns:
-
getXRange
public JDFXYPair getXRange()
get the min and max value of X- Parameters:
index-- Returns:
-
getY
public double getY(int index)
get the Y value at index i- Parameters:
index-- Returns:
-
getFastValue
public double getFastValue(double x)
get the Y value at x-value x - we interpolate linearly from a cache- Parameters:
index-- Returns:
-
getValue
public double getValue(double x)
get the Y value at x-value x - we interpolate linearly- Parameters:
index-- Returns:
-
numPoints
public int numPoints()
- Returns:
- the number of points
-
add
public void add(java.lang.String s) throws java.util.zip.DataFormatExceptionadd - adds a x and a y coordinate to the vector- Parameters:
s- a string with the x and y coordinate to add- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
add
public void add(JDFTransferFunction tf)
add - adds a complete transfer function to the vector- Parameters:
tf- the given transfer function to add
-
add
public boolean add(java.lang.Object e)
- Specified by:
addin interfacejava.util.Collection<java.lang.Object>- Specified by:
addin interfacejava.util.List<java.lang.Object>- Overrides:
addin classjava.util.Vector<java.lang.Object>- See Also:
Vector.add(java.lang.Object)
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.Object> c)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.Object>- Specified by:
addAllin interfacejava.util.List<java.lang.Object>- Overrides:
addAllin classjava.util.Vector<java.lang.Object>- See Also:
Vector.addAll(java.util.Collection)
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<java.lang.Object>- Specified by:
clearin interfacejava.util.List<java.lang.Object>- Overrides:
clearin classjava.util.Vector<java.lang.Object>- See Also:
Vector.clear()
-
resetCache
public void resetCache()
-
multiply
public static JDFTransferFunction multiply(JDFTransferFunction tf1, JDFTransferFunction tf2)
returns the multiplied tf - in case one of thr arguments is null or unit, the other argument is returned unmodified- Parameters:
tf1-tf2-- Returns:
-
multiply
public void multiply(JDFTransferFunction tf)
multiplies a complete transfer function to the vector only useful for 0-1 ranged transfer functions- Parameters:
tf- the given transfer function to add
-
-