Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.grogra.graph
Interface Visitor

All Known Implementing Classes:
  DisplayVisitor, FluxLightVisitor, FluxSceneVisitor, GL20DisplayVisitor, GLDisplay.GLVisitor, GLSLUpdateCache, PickRayVisitor, SceneTree, SceneTreeWithShader, SceneVisitor, Tree, Visitor3D, VisitorImpl

    public interface Visitor

A `Visitor` is a callback-instance which is informed about the structure of a graph via invocation of `Graph.accept(Object, Visitor, ArrayPath)`. It follows the design pattern of hierarchical visitors: For every node and edge of the graph, the corresponding methods `visitEnter` and `visitLeave` are invoked. Invocations nested within such an invocation pair indicate the hierarchy. In any case, the invocation pairs are nested correctly. The `path` argument to the methods of this interface contain the path from the root to the current location, this path corresponds to the invocations of `visitEnter`-methods which have not yet been closed by invocations of `visitLeave`.

Author:
  Ole Kniemeyer

Field Summary
`static java.lang.Object` | `STOP` Return value for `visitEnter(de.grogra.graph.Path, boolean)` and `visitInstanceEnter()` to indicate that the hierarchical traversal of the graph must not go more deeply in the hierarchy at the current location.

Method Summary
`GraphState` | `getGraphState()` Returns the graph state within which the visitor is operating.
`java.lang.Object` | `visitEnter(Path path, boolean node)` Informs this visitor about a node or edge in the graph.
`java.lang.Object` | `visitInstanceEnter()` Informs this visitor about the beginning of an instantiation.
`boolean` | `visitInstanceLeave(java.lang.Object o)` Informs this visitor that an instantiation has been processed completely.
`boolean` | `visitLeave(java.lang.Object o, Path path, boolean node)` Informs this visitor that a node or an edge has been processed completely.

Field Detail

### STOP

    static final java.lang.Object STOP

  Return value for `visitEnter(de.grogra.graph.Path, boolean)` and `visitInstanceEnter()` to indicate that the hierarchical traversal of the graph must not go more deeply in the hierarchy at the current location.

Method Detail

### getGraphState

    GraphState getGraphState()

  Returns the graph state within which the visitor is operating.

  Returns:
    graph state of visitor

### visitEnter

    java.lang.Object visitEnter(Path path,
                                boolean node)

  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, `visitLeave(java.lang.Object, de.grogra.graph.Path, boolean)` will be invoked with the returned value of this invocation, `path` and `node` as arguments. If this method returns `STOP`, the corresponding `visitLeave`-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.

  Parameters:
    `path` - current path
    `node` - do we enter a node or an edge?
  Returns:
    value to pass to `visitLeave`, may be `STOP`

### visitInstanceEnter

    java.lang.Object visitInstanceEnter()

  Informs this visitor about the beginning of an instantiation. This method invokation is nested immediately within `visitEnter`/`visitLeave` of a node. Later on, `visitInstanceLeave(Object)` will be invoked with the returned value of this invocation as argument. If this method returns `STOP`, the `visitInstanceLeave`-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.

  Returns:
    value to pass to `visitInstanceLeave`, may be `STOP`

### visitInstanceLeave

    boolean visitInstanceLeave(java.lang.Object o)

  Informs this visitor that an instantiation has been processed completely. The value `o` is the return value of the corresponding invocation of `visitInstanceEnter()`. If this invocation returns `false`, no further instantiations or edges of the current level of hierarchy will be passed to this visitor, i.e., the `visitLeave` method for the enclosing node will be invoked immediately.

  Parameters:
    `o` - returned value of `visitInstanceEnter`
  Returns:
    `true` iff processing of current level shall be continued

### visitLeave

    boolean visitLeave(java.lang.Object o,
                       Path path,
                       boolean node)

  Informs this visitor that a node or an edge has been processed completely. The value `o` is the return value of the corresponding invocation of `visitEnter(de.grogra.graph.Path, boolean)`. In case of a node and if this invocation returns `false`, no further edges of the current level of hierarchy will be passed to this visitor, i.e., the `visitLeave` methods for the enclosing edge and node will be invoked immediately. Likewise, in case of an edge and a return value `false`, no further instantiations or edges of the current level of hierarchy will be passed to this visitor, i.e., the `visitLeave` method for the enclosing node will be invoked immediately.

  Parameters:
    `o` - returned value of `visitEnter`
    `path` - current path to `node`
    `node` - do we leave a node or an edge?
  Returns:
    `true` iff processing of current level shall be continued

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD