java.lang.Object
de.grogra.imp3d.Visitor3D
- All Implemented Interfaces:
Visitor
- Direct Known Subclasses:
DisplayVisitor
,PhysicsVisitor
,PickRayVisitor
,PickRayVisitor
,PickToolVisitor
This base implementation of the
Visitor
interface
tracks information about the current coordinate transformation
and layer of objects. Invocations of visit
methods
are forwarded to the abstract methods
visitEnterImpl(Object, boolean, Path)
and
visitLeaveImpl(Object, boolean, Path)
.- Author:
- Ole Kniemeyer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The current layer.protected int
The level of resolution the visitor go through the graph.protected GraphState
The graph state in which this visitor runs.protected Matrix4d
The current transformation from local coordinates to global coordinates. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the current affine transformation from local coordinates to global coordinates.Returns the graph state within which the visitor is operating.protected void
init
(GraphState gs, EdgePattern pattern, Matrix4d t) Initializes this visitor.setResolution
(int r) visitEnter
(Path path, boolean node) Informs this visitor about a node or edge in the graph.protected Object
visitEnter
(Object object, boolean asNode, Path path) protected abstract void
visitEnterImpl
(Object object, boolean asNode, Path path) This method has to be implemented by subclasses.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.protected abstract void
visitLeaveImpl
(Object object, boolean asNode, Path path) This method has to be implemented by subclasses.
-
Field Details
-
state
The graph state in which this visitor runs. -
transformation
The current transformation from local coordinates to global coordinates. -
layer
protected int layerThe current layer. -
resolution
protected int resolutionThe level of resolution the visitor go through the graph. If a node has a higher resolution than the visitor, it stops.
-
-
Constructor Details
-
Visitor3D
public Visitor3D()
-
-
Method Details
-
init
Initializes this visitor.- Parameters:
gs
- the graph state in which the visitor runspattern
- the pattern which is used to extract the scene tree to visit from the complete grapht
- the initial transformation from local to global coordinates
-
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
-
getCurrentTransformation
Returns the current affine transformation from local coordinates to global coordinates.- Returns:
- current coordinate transformation
-
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
-
visitEnter
-
visitEnterImpl
This method has to be implemented by subclasses. It is invoked whenobject
is entered.- Parameters:
object
- the object being enteredasNode
- isobject
a node or an edge?path
- the path toobject
ifobject
is a node, the path to the node whereobject
points to ifobject
is an edge
-
visitLeaveImpl
This method has to be implemented by subclasses. It is invoked whenobject
is left.- Parameters:
object
- the object being leftasNode
- isobject
a node or an edge?path
- the path toobject
ifobject
is a node, the path to the node whereobject
points to ifobject
is an edge
-
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
-
setResolution
-