de.jreality.scene
Class SceneGraphPath

java.lang.Object
  extended by de.jreality.scene.SceneGraphPath
All Implemented Interfaces:
Cloneable

public class SceneGraphPath
extends Object
implements Cloneable

A SceneGraphPath represents a directed path between two nodes in the scene graph. Technically it begins with list of SceneGraphComponent's, but the final element may be a SceneGraphNode contained in the final SceneGraphComponent.

This allows addressing the sub-nodes contained as fields in the SceneGraphComponent (such as lights, camera, geometry, appearance). But it is not required that the path ends in such a SceneGraphNode; it can also end in a SceneGraphComponent.

There are methods for pushing and popping elements onto the path, useful for instances of SceneGraphVisitor.

There are methods for ascertaining the matrix transformation associated to the path (by multiplying the instances of Transformation occurring on the path. Note: This class takes no care of the elements being inserted. The method isValid() gives information if this path exists in the scenegraph

This class does not allow specifying a path that begins somewhere in a scene graph, goes up to the root, and then descends again. All paths go down from the root.

The methods equal() and hashCode() always represent the current state of the path, so make sure you do not change paths that are put into some sort of HashMap etc.!

Author:
Tim Hoffman, Charles Gunn, Steffen Weissmann

Constructor Summary
SceneGraphPath()
           
SceneGraphPath(SceneGraphComponent... nodes)
           
SceneGraphPath(SceneGraphPath path)
           
 
Method Summary
 void clear()
           
 Object clone()
          Deprecated. use SceneGraphPath(SceneGraphPath) instead
 boolean equals(Object p)
           
static SceneGraphPath fromList(List<SceneGraphNode> list)
           
 SceneGraphNode getFirstElement()
           
 double[] getInverseMatrix(double[] invMatrix)
           
 double[] getInverseMatrix(double[] invMatrix, int begin)
           
 double[] getInverseMatrix(double[] aMatrix, int begin, int end)
           
 SceneGraphComponent getLastComponent()
           
 SceneGraphNode getLastElement()
           
 int getLength()
          Gives the length of the path
 double[] getMatrix(double[] aMatrix)
          matrix calculations
 double[] getMatrix(double[] aMatrix, int begin)
           
 double[] getMatrix(double[] aMatrix, int begin, int end)
           
 int hashCode()
           
 void insertAfter(SceneGraphNode toInsert, SceneGraphNode exists)
           
 boolean isEqual(SceneGraphPath anotherPath)
           
 boolean isValid()
          Checks if the path is really an existing path in the scenegraph.
 ListIterator<SceneGraphNode> iterator()
           
 ListIterator<SceneGraphNode> iterator(int start)
           
 void pop()
           
 SceneGraphPath popNew()
          lets this path unchanged
 void push(SceneGraphNode c)
           
 SceneGraphPath pushNew(SceneGraphNode c)
          lets this path unchanged
 void replace(SceneGraphNode old, SceneGraphNode nnew)
           
 Iterator reverseIterator()
           
 Iterator<SceneGraphNode> reverseIterator(int start)
           
 boolean startsWith(SceneGraphPath potentialPrefix)
           
 List<SceneGraphNode> toList()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SceneGraphPath

public SceneGraphPath()

SceneGraphPath

public SceneGraphPath(SceneGraphPath path)

SceneGraphPath

public SceneGraphPath(SceneGraphComponent... nodes)
Method Detail

fromList

public static SceneGraphPath fromList(List<SceneGraphNode> list)

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Deprecated. use SceneGraphPath(SceneGraphPath) instead

Overrides:
clone in class Object

toList

public List<SceneGraphNode> toList()

iterator

public ListIterator<SceneGraphNode> iterator()

iterator

public ListIterator<SceneGraphNode> iterator(int start)

reverseIterator

public Iterator<SceneGraphNode> reverseIterator(int start)
Parameters:
start - how many nodes from the end of the path should we leave out? i.e.: p.reverseIterator(p.getLength()) gives the same result as p.reverseIterator()
Returns:
a reverse iterator from the given position

reverseIterator

public Iterator reverseIterator()

getLength

public int getLength()
Gives the length of the path

Returns:
int

push

public final void push(SceneGraphNode c)

pushNew

public final SceneGraphPath pushNew(SceneGraphNode c)
lets this path unchanged

Returns:
a new path that is equal to this path after calling path.push(c)

pop

public final void pop()

popNew

public final SceneGraphPath popNew()
lets this path unchanged

Returns:
a new path that is equal to this path after calling path.pop()

getFirstElement

public SceneGraphNode getFirstElement()

getLastElement

public SceneGraphNode getLastElement()

getLastComponent

public SceneGraphComponent getLastComponent()

clear

public void clear()

replace

public void replace(SceneGraphNode old,
                    SceneGraphNode nnew)

insertAfter

public void insertAfter(SceneGraphNode toInsert,
                        SceneGraphNode exists)

isValid

public boolean isValid()
Checks if the path is really an existing path in the scenegraph.

Returns:
true if the path exists

equals

public boolean equals(Object p)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEqual

public boolean isEqual(SceneGraphPath anotherPath)

startsWith

public boolean startsWith(SceneGraphPath potentialPrefix)

getMatrix

public double[] getMatrix(double[] aMatrix)
matrix calculations


getMatrix

public double[] getMatrix(double[] aMatrix,
                          int begin)

getInverseMatrix

public double[] getInverseMatrix(double[] invMatrix)

getInverseMatrix

public double[] getInverseMatrix(double[] invMatrix,
                                 int begin)

getMatrix

public double[] getMatrix(double[] aMatrix,
                          int begin,
                          int end)

getInverseMatrix

public double[] getInverseMatrix(double[] aMatrix,
                                 int begin,
                                 int end)