Class TransferFunction

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class TransferFunction
    extends ModelSerialCloneable

    Title: TransferFunction

    Description:

    Simple class to hold an array of points that describe a transfer function.

    Version:
    1.0
    Author:
    not attributable
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int capacity
      The total capacity of the 2D point array.
      private int endPtr
      Points to the next available storage location for the point.
      private WildMagic.LibFoundation.Mathematics.Vector2f[] pts
      The array of 2D points that define the line.
      private static long serialVersionUID
      Use serialVersionUID for interoperability.
      private float[] slopes
      The array of pre-calculated slope values.
    • Constructor Summary

      Constructors 
      Constructor Description
      TransferFunction()
      Simple class to hold an array of points that describe a transfer function.
      TransferFunction​(TransferFunction kTransfer)
      Copies the object that extends this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPoint​(float x, float y)
      Adds a point to the function at the end.
      void addPoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt)
      Adds a point to the function at the end.
      private void checkSize()
      Checks the size of the point array to make sure it is big enough.
      java.lang.Object clone()
      Copies the object that extends this class.
      void exportArrays​(float[] x, float[] y)
      Exports the float arrays of the points of the curve.
      protected void finalize()
      Cleans up memory.
      WildMagic.LibFoundation.Mathematics.Vector2f[] getFunction()
      Gets the points that describe the function.
      WildMagic.LibFoundation.Mathematics.Vector2f getPoint​(int index)
      Get the point at the specified index.
      float getRemappedValue​(float inputValue, int height)
      Method to remapped a value using the transfer function.
      void importArrays​(float[] x, float[] y, int n)
      Import points into the contour.
      void insertPoint​(float x, float y, int index)
      Inserts a point to the transfer function at the specified index.
      void insertPoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt, int index)
      Inserts a point to the transfer function at the specified index.
      boolean isEndpoint​(int index)
      Decides whether parameter 'index' is an endpoint of this transfer function.
      private void recalculateSlopes()
      DOCUMENT ME!
      WildMagic.LibFoundation.Mathematics.Vector2f[] removeAll()
      Removes all points from the funcitons.
      WildMagic.LibFoundation.Mathematics.Vector2f removePoint​(int index)
      Removes a point in the function at the specified index.
      void replacePoint​(float x, float y, int index)
      Replaces the point at param index with point of params x and y.
      void replacePoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt, int index)
      Replaces the point at param index with point of pt.
      int size()
      Indicated the number of points in the function.
      java.lang.String toString()  
      int whichEnd​(int index)
      returns -1 if not an endpoint returns 0 if starting point returns 1 if end point
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • capacity

        private int capacity
        The total capacity of the 2D point array. Initial capacity = 10
      • endPtr

        private int endPtr
        Points to the next available storage location for the point.
      • pts

        private WildMagic.LibFoundation.Mathematics.Vector2f[] pts
        The array of 2D points that define the line.
      • slopes

        private float[] slopes
        The array of pre-calculated slope values.
    • Constructor Detail

      • TransferFunction

        public TransferFunction()
        Simple class to hold an array of points that describe a transfer function.
      • TransferFunction

        public TransferFunction​(TransferFunction kTransfer)
        Copies the object that extends this class.
    • Method Detail

      • addPoint

        public void addPoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt)
        Adds a point to the function at the end.
        Parameters:
        pt - DOCUMENT ME!
      • addPoint

        public void addPoint​(float x,
                             float y)
        Adds a point to the function at the end.
        Parameters:
        x - the x coordinate of point to be added
        y - the y coordinate of point to be added
      • clone

        public java.lang.Object clone()
        Copies the object that extends this class.
        Overrides:
        clone in class ModelSerialCloneable
        Returns:
        An exact copy of this class.
      • exportArrays

        public void exportArrays​(float[] x,
                                 float[] y)
        Exports the float arrays of the points of the curve.
        Parameters:
        x - array of x coordinates
        y - array of y coordinates
      • getFunction

        public WildMagic.LibFoundation.Mathematics.Vector2f[] getFunction()
        Gets the points that describe the function.
        Returns:
        the 2D point array of floats
      • getPoint

        public WildMagic.LibFoundation.Mathematics.Vector2f getPoint​(int index)
        Get the point at the specified index.
        Parameters:
        index - the index of the point to be returned.
        Returns:
        the 2D point
      • getRemappedValue

        public final float getRemappedValue​(float inputValue,
                                            int height)
        Method to remapped a value using the transfer function.
        Parameters:
        inputValue - the value to be remapped
        height - return range max of the remapped value
        Returns:
        the remapped value
      • importArrays

        public void importArrays​(float[] x,
                                 float[] y,
                                 int n)
        Import points into the contour.
        Parameters:
        x - array of x points
        y - array of y points
        n - number of points in the array
      • insertPoint

        public void insertPoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt,
                                int index)
        Inserts a point to the transfer function at the specified index.
        Parameters:
        pt - the 2D point to be added to the function.
        index - the index the point is to be inserted.
      • insertPoint

        public void insertPoint​(float x,
                                float y,
                                int index)
        Inserts a point to the transfer function at the specified index.
        Parameters:
        x - the x coordinate of the 2D point to be added to the function.
        y - the y coordinate of the 2D point to be added to the function.
        index - the index the point is to be inserted.
      • isEndpoint

        public boolean isEndpoint​(int index)
        Decides whether parameter 'index' is an endpoint of this transfer function.
        Parameters:
        index - int The index to test whether or not it is an endpoint
        Returns:
        boolean
      • whichEnd

        public int whichEnd​(int index)
        returns -1 if not an endpoint returns 0 if starting point returns 1 if end point
        Parameters:
        index - The index to test
        Returns:
        int
      • removeAll

        public WildMagic.LibFoundation.Mathematics.Vector2f[] removeAll()
        Removes all points from the funcitons.
      • removePoint

        public WildMagic.LibFoundation.Mathematics.Vector2f removePoint​(int index)
        Removes a point in the function at the specified index.
        Parameters:
        index - the index where the point is to be removed
      • replacePoint

        public void replacePoint​(WildMagic.LibFoundation.Mathematics.Vector2f pt,
                                 int index)
        Replaces the point at param index with point of pt.
        Parameters:
        pt - Vector2f the new point
        index - int the index of the point to be replaced
      • replacePoint

        public void replacePoint​(float x,
                                 float y,
                                 int index)
        Replaces the point at param index with point of params x and y.
        Parameters:
        x - float the x-coordinate of the new point
        y - float the y-coordinate of the new point
        index - int the index of the point to be replaced
      • size

        public int size()
        Indicated the number of points in the function.
        Returns:
        the number of points in the function.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • finalize

        protected void finalize()
        Cleans up memory.
        Overrides:
        finalize in class java.lang.Object
      • checkSize

        private void checkSize()
        Checks the size of the point array to make sure it is big enough. If not the Points buffer is reallocated to a larger size.
      • recalculateSlopes

        private void recalculateSlopes()
        DOCUMENT ME!