org.jrabbit.base.graphics.transforms
Class GLGroupTransform

java.lang.Object
  extended by org.jrabbit.base.graphics.transforms.GLGroupTransform
All Implemented Interfaces:
GLTransform

public class GLGroupTransform
extends java.lang.Object
implements GLTransform

A GLGroupTransform is an object that performs a series of operations on the OpenGL Modelview Matrix. It has a dynamic list of the operations it needs to perform. The class contains an internal array that holds the transforms to execute. This resizes when needed to contain additional transforms.

Author:
Chris Molini

Field Summary
protected  int size
          The number of transforms currently in the list.
private static int TRANSFORM_BUFFER
          The "increment" value for resizing the list of transforms.
protected  GLTransform[] transforms
          The array of all transforms, in order of their execution.
 
Constructor Summary
GLGroupTransform()
          Creates an empty GLGroupTransform.
GLGroupTransform(GLTransform... transforms)
          Creates a GLGroupTransform with the indicated transforms added to the list.
 
Method Summary
 void add(GLTransform... transforms)
          Places a series of transforms after those already in the list.
 int add(GLTransform transform)
          Places a transform after those already in the list.
 void allocate(int size)
          Expands the internal array to hold at least as many transforms as requested.
 void bind()
          Applies every operation in the list, in order.
 void clear()
          Removes all transforms.
 GLTransform get(int place)
          Attempts to retrieve the desired transform.
 void release()
          Re-iterates through the list of transforms, undoing each one in the reverse order they were applied in.
 boolean remove(GLTransform transform)
          Attempts to remove the indicated transform from the list.
 GLTransform remove(int place)
          Attempts to remove the indicated transform from the list.
 boolean replace(int place, GLTransform newTransform)
          Attempts to replace the GLTransform at the indicated position with the one supplied.
 int size()
          Learns the size of the group transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSFORM_BUFFER

private static final int TRANSFORM_BUFFER
The "increment" value for resizing the list of transforms.

See Also:
Constant Field Values

transforms

protected GLTransform[] transforms
The array of all transforms, in order of their execution.


size

protected int size
The number of transforms currently in the list.

Constructor Detail

GLGroupTransform

public GLGroupTransform()
Creates an empty GLGroupTransform.


GLGroupTransform

public GLGroupTransform(GLTransform... transforms)
Creates a GLGroupTransform with the indicated transforms added to the list.

Parameters:
transforms - The GLTransforms for the GLGroupTransform to begin with.
Method Detail

bind

public void bind()
Applies every operation in the list, in order.

Specified by:
bind in interface GLTransform

release

public void release()
Re-iterates through the list of transforms, undoing each one in the reverse order they were applied in.

Specified by:
release in interface GLTransform

allocate

public void allocate(int size)
Expands the internal array to hold at least as many transforms as requested. If the array is already at least as large as the indicated size, no changes occur.

Parameters:
size - The minimum number of transforms to contain in the list.

add

public int add(GLTransform transform)
Places a transform after those already in the list.

Parameters:
transform - The object that will cause a change in OpenGL's state to affect rendering.

add

public void add(GLTransform... transforms)
Places a series of transforms after those already in the list.

Parameters:
transforms - The object that will cause a change in OpenGL's state to affect rendering.

get

public GLTransform get(int place)
Attempts to retrieve the desired transform.

Parameters:
place - The location of the transform in the internal array.
Returns:
The transform at the indicated position.

remove

public GLTransform remove(int place)
Attempts to remove the indicated transform from the list.

Parameters:
key - The String that identifies which transform to remove.
Returns:
If a transform was removed, returns that transform. If not, null is returned.

remove

public boolean remove(GLTransform transform)
Attempts to remove the indicated transform from the list. The GroupTransform searches through the list for an equivalent GLTransform (via equals()) and removes it if found.

Parameters:
transform - The transform (or one equivalent to it) to remove.
Returns:
If a transform was removed, returns true, otherwise false.

replace

public boolean replace(int place,
                       GLTransform newTransform)
Attempts to replace the GLTransform at the indicated position with the one supplied.

Parameters:
place - The position to replace.
newTransform - The new transform to place in the list.
Returns:
True if the operation succeeded, false if not.

size

public int size()
Learns the size of the group transform.

Returns:
The number of transforms currently used by the GroupTransform.

clear

public void clear()
Removes all transforms.