Package gov.nih.mipav.model.structures
Class TransferFunction
- java.lang.Object
-
- gov.nih.mipav.model.structures.ModelSerialCloneable
-
- gov.nih.mipav.model.structures.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 intcapacityThe total capacity of the 2D point array.private intendPtrPoints to the next available storage location for the point.private WildMagic.LibFoundation.Mathematics.Vector2f[]ptsThe array of 2D points that define the line.private static longserialVersionUIDUse serialVersionUID for interoperability.private float[]slopesThe 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 voidaddPoint(float x, float y)Adds a point to the function at the end.voidaddPoint(WildMagic.LibFoundation.Mathematics.Vector2f pt)Adds a point to the function at the end.private voidcheckSize()Checks the size of the point array to make sure it is big enough.java.lang.Objectclone()Copies the object that extends this class.voidexportArrays(float[] x, float[] y)Exports the float arrays of the points of the curve.protected voidfinalize()Cleans up memory.WildMagic.LibFoundation.Mathematics.Vector2f[]getFunction()Gets the points that describe the function.WildMagic.LibFoundation.Mathematics.Vector2fgetPoint(int index)Get the point at the specified index.floatgetRemappedValue(float inputValue, int height)Method to remapped a value using the transfer function.voidimportArrays(float[] x, float[] y, int n)Import points into the contour.voidinsertPoint(float x, float y, int index)Inserts a point to the transfer function at the specified index.voidinsertPoint(WildMagic.LibFoundation.Mathematics.Vector2f pt, int index)Inserts a point to the transfer function at the specified index.booleanisEndpoint(int index)Decides whether parameter 'index' is an endpoint of this transfer function.private voidrecalculateSlopes()DOCUMENT ME!WildMagic.LibFoundation.Mathematics.Vector2f[]removeAll()Removes all points from the funcitons.WildMagic.LibFoundation.Mathematics.Vector2fremovePoint(int index)Removes a point in the function at the specified index.voidreplacePoint(float x, float y, int index)Replaces the point at param index with point of params x and y.voidreplacePoint(WildMagic.LibFoundation.Mathematics.Vector2f pt, int index)Replaces the point at param index with point of pt.intsize()Indicated the number of points in the function.java.lang.StringtoString()intwhichEnd(int index)returns -1 if not an endpoint returns 0 if starting point returns 1 if end point-
Methods inherited from class gov.nih.mipav.model.structures.ModelSerialCloneable
nativeClone
-
-
-
-
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 addedy- the y coordinate of point to be added
-
clone
public java.lang.Object clone()
Copies the object that extends this class.- Overrides:
clonein classModelSerialCloneable- 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 coordinatesy- 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 remappedheight- 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 pointsy- array of y pointsn- 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 pointindex- 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 pointy- float the y-coordinate of the new pointindex- 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:
toStringin classjava.lang.Object
-
finalize
protected void finalize()
Cleans up memory.- Overrides:
finalizein classjava.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!
-
-