Class JDFTransferFunction

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, 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:
  • Field Details

  • Constructor Details

    • JDFTransferFunction

      public JDFTransferFunction()
      constructs a xy pair with all values set to 0.0 Double
    • JDFTransferFunction

      public JDFTransferFunction(String s) throws 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:
      DataFormatException - - if the String has not a valid format
    • JDFTransferFunction

      @Deprecated public JDFTransferFunction(Vector v) throws 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:
      DataFormatException - - if the Vector has not a valid format
    • JDFTransferFunction

      public JDFTransferFunction(JDFNumList nl) throws DataFormatException
      constructs a number list with the given number list
      Parameters:
      nl - the given number list
      Throws:
      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:
      DataFormatException - - if the String has not a valid format
  • Method Details

    • getUnit

      public static JDFTransferFunction getUnit()
    • createTransferFunction

      public static JDFTransferFunction createTransferFunction(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 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:
      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(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
    • 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, Vector<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(String s) throws 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:
      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(Object e)
      Specified by:
      add in interface Collection<Object>
      Specified by:
      add in interface List<Object>
      Overrides:
      add in class Vector<Object>
      See Also:
    • addAll

      public boolean addAll(Collection<? extends Object> c)
      Specified by:
      addAll in interface Collection<Object>
      Specified by:
      addAll in interface List<Object>
      Overrides:
      addAll in class Vector<Object>
      See Also:
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<Object>
      Specified by:
      clear in interface List<Object>
      Overrides:
      clear in class Vector<Object>
      See Also:
    • 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