Class 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
    • 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.DataFormatException
        constructs 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.DataFormatException
        Deprecated.
        use typesafe constructors
        constructs 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

      • 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.DataFormatException
        isValid - true if the size of the vector is even and all instances are Double types
        Specified by:
        isValid in class JDFNumList
        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 add
        y - 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 add
        y - 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.DataFormatException
        add - 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:
        add in interface java.util.Collection<java.lang.Object>
        Specified by:
        add in interface java.util.List<java.lang.Object>
        Overrides:
        add in class java.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:
        addAll in interface java.util.Collection<java.lang.Object>
        Specified by:
        addAll in interface java.util.List<java.lang.Object>
        Overrides:
        addAll in class java.util.Vector<java.lang.Object>
        See Also:
        Vector.addAll(java.util.Collection)
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.Object>
        Specified by:
        clear in interface java.util.List<java.lang.Object>
        Overrides:
        clear in class java.util.Vector<java.lang.Object>
        See Also:
        Vector.clear()
      • resetCache

        public void resetCache()
      • 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