java.lang.Object
de.grogra.imp3d.objects.SceneTree
- Direct Known Subclasses:
SceneTreeWithShader
A
SceneTree
is a simplified image of a
Graph
designed for usage in the context
of 3D analysis (e.g., export). The nodes of such a tree are created
by invocation of createTree(boolean)
, this in turn uses the factory
methods createInnerNode()
and createLeaf(Object, boolean, long)
.- Author:
- Ole Kniemeyer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class represents an inner node of a scene tree.static class
This represents a leaf in aSceneTree
.static class
The abstract base class for nodes of aSceneTree
.static interface
AVisitor
is used to visit aSceneTree
. -
Field Summary
-
Constructor Summary
ConstructorDescriptionSceneTree
(GraphState gs, EdgePattern pattern) Creates a new scene tree instance.Creates a new scene tree instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(SceneTree.Visitor visitor) This method is invoked if one wants to inform thevisitor
of the complete set of nodes of this tree.protected abstract boolean
acceptLeaf
(Object object, boolean asNode) This method defines for which objects of the graph aSceneTree.Leaf
node shall be created.void
protected SceneTree.InnerNode
This factory method is used bycreateTree(boolean)
to create an inner node.protected abstract SceneTree.Leaf
createLeaf
(Object object, boolean asNode, long id) This factory method is used bycreateTree(boolean)
to create a leaf.createTree
(boolean simplify) createTree
(boolean simplify, boolean checkLayer) This method creates the nodes of this tree by traversing the original graph using the edge pattern which has been specified in the constructor.int
getChildCount
(Object parent) Returns the graph state within which the visitor is operating.int
getIndexOfChild
(Object parent, Object child) getRoot()
protected void
init
(SceneTree.Leaf leaf) This method has to be invoked whenever a newSceneTree.Leaf
is created as a leaf of this tree.boolean
void
void
valueForPathChanged
(TreePath path, Object newValue) visitEnter
(Path path, boolean node) Informs this visitor about a node or edge in the graph.Informs this visitor about the beginning of an instantiation.boolean
Informs this visitor that an instantiation has been processed completely.boolean
visitLeave
(Object o, Path path, boolean node) Informs this visitor that a node or an edge has been processed completely.
-
Field Details
-
state
-
-
Constructor Details
-
SceneTree
Creates a new scene tree instance. The nodes are not created by the constructor, this is done increateTree(boolean)
.- Parameters:
gs
- the graph state to use for attribute queriespattern
- the pattern which defines which edges span the tree as subgraph of the complete graph
-
SceneTree
Creates a new scene tree instance. This delegates toSceneTree(GraphState, EdgePattern)
, where the parameters are obtained from theview
.- Parameters:
view
- view for which the new scene tree is configured
-
-
Method Details
-
getGraphState
Description copied from interface:Visitor
Returns the graph state within which the visitor is operating.- Specified by:
getGraphState
in interfaceVisitor
- Returns:
- graph state of visitor
-
init
This method has to be invoked whenever a newSceneTree.Leaf
is created as a leaf of this tree. The tree may perform some initialization tasks on theleaf
.- Parameters:
leaf
- a newly createdLeaf
to be initialized
-
createTree
-
createTree
This method creates the nodes of this tree by traversing the original graph using the edge pattern which has been specified in the constructor. It collects all objects of the original graph as leaves for which the methodacceptLeaf(Object, boolean)
returnstrue
. The leaves are inserted into a hierarchy ofSceneTree.InnerNode
s corresponding to the hierarchy of the original graph.- Parameters:
simplify
- simplify structure (may destroy hierarchy)?- Returns:
- root node of the created tree
- See Also:
-
getRoot
-
visitEnter
Description copied from interface:Visitor
Informs this visitor about a node or edge in the graph.path
contains the path from the root up to and including the node or, in case an edge is visited, the edge and its terminal node. Later on,Visitor.visitLeave(java.lang.Object, de.grogra.graph.Path, boolean)
will be invoked with the returned value of this invocation,path
andnode
as arguments. If this method returnsVisitor.STOP
, the correspondingvisitLeave
-method will be invoked immediately after this method, i.e., the visitor does not dive more deeply in the hierarchy. Otherwise, if a node is visited and there are instantiations associated with or edges connected with it (regardless of their direction), their corresponding visitor methods will be invoked inbetween. Likewise, if an edge is visited, its indicent terminal node will be visited next.- Specified by:
visitEnter
in interfaceVisitor
- Parameters:
path
- current pathnode
- do we enter a node or an edge?- Returns:
- value to pass to
visitLeave
, may beVisitor.STOP
-
visitLeave
Description copied from interface:Visitor
Informs this visitor that a node or an edge has been processed completely. The valueo
is the return value of the corresponding invocation ofVisitor.visitEnter(de.grogra.graph.Path, boolean)
. In case of a node and if this invocation returnsfalse
, no further edges of the current level of hierarchy will be passed to this visitor, i.e., thevisitLeave
methods for the enclosing edge and node will be invoked immediately. Likewise, in case of an edge and a return valuefalse
, no further instantiations or edges of the current level of hierarchy will be passed to this visitor, i.e., thevisitLeave
method for the enclosing node will be invoked immediately.- Specified by:
visitLeave
in interfaceVisitor
- Parameters:
o
- returned value ofvisitEnter
path
- current path tonode
node
- do we leave a node or an edge?- Returns:
true
iff processing of current level shall be continued
-
visitInstanceEnter
Description copied from interface:Visitor
Informs this visitor about the beginning of an instantiation. This method invokation is nested immediately withinvisitEnter
/visitLeave
of a node. Later on,Visitor.visitInstanceLeave(Object)
will be invoked with the returned value of this invocation as argument. If this method returnsVisitor.STOP
, thevisitInstanceLeave
-method will be invoked immediately after this method, i.e., the visitor does not dive into the instantiation. Otherwise, the instantiation is performed, starting with an edge.- Specified by:
visitInstanceEnter
in interfaceVisitor
- Returns:
- value to pass to
visitInstanceLeave
, may beVisitor.STOP
-
visitInstanceLeave
Description copied from interface:Visitor
Informs this visitor that an instantiation has been processed completely. The valueo
is the return value of the corresponding invocation ofVisitor.visitInstanceEnter()
. If this invocation returnsfalse
, no further instantiations or edges of the current level of hierarchy will be passed to this visitor, i.e., thevisitLeave
method for the enclosing node will be invoked immediately.- Specified by:
visitInstanceLeave
in interfaceVisitor
- Parameters:
o
- returned value ofvisitInstanceEnter
- Returns:
true
iff processing of current level shall be continued
-
accept
This method is invoked if one wants to inform thevisitor
of the complete set of nodes of this tree.- Parameters:
visitor
- a visitor to visit the nodes of this tree
-
isLeaf
-
getChild
-
getChildCount
- Specified by:
getChildCount
in interfaceTreeModel
-
getIndexOfChild
- Specified by:
getIndexOfChild
in interfaceTreeModel
-
valueForPathChanged
- Specified by:
valueForPathChanged
in interfaceTreeModel
-
addTreeModelListener
- Specified by:
addTreeModelListener
in interfaceTreeModel
-
removeTreeModelListener
- Specified by:
removeTreeModelListener
in interfaceTreeModel
-
createInnerNode
This factory method is used bycreateTree(boolean)
to create an inner node.- Returns:
- newly created inner node
-
acceptLeaf
This method defines for which objects of the graph aSceneTree.Leaf
node shall be created.- Parameters:
object
- an object of the graphasNode
- is object a node or an edge?- Returns:
true
iff a leaf shall be created for the object
-
createLeaf
This factory method is used bycreateTree(boolean)
to create a leaf. Note that the implementation has to invokeinit(Leaf)
on the created leaf.- Parameters:
object
- object of leafasNode
- represents leaf a node or an edge?id
- id to pass to the leaf constructor- Returns:
- newly create leaf
-