y25.base
Class LayeredGraph.IDAssigner

java.lang.Object
  extended byy25.base.LayeredGraph.IDAssigner
All Implemented Interfaces:
EventListener, GraphListener
Enclosing class:
LayeredGraph

protected class LayeredGraph.IDAssigner
extends Object
implements GraphListener

A GraphListener that is responsible for assigning new and unique IDs to newly created nodes and edges in graphs that belong to this LayeredGraph.


Constructor Summary
protected LayeredGraph.IDAssigner()
           
 
Method Summary
 void onGraphEvent(GraphEvent evt)
          This method is responsible for assigning new and unique IDs to nodes and edges whenever they are created and to remove IDs of nodes and edges whenever they are deleted from a graph.
 void removeEdgeID(Edge edge)
          Removes the edge ID of the passed edge from the set of used IDs.
 void removeIDs(Graph graph)
          Removes IDs of nodes and edges that occur in the passed graph from the set of used IDs.
 void removeNodeID(Node node)
          Removes the node ID of the passed node from the set of used IDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayeredGraph.IDAssigner

protected LayeredGraph.IDAssigner()
Method Detail

onGraphEvent

public void onGraphEvent(GraphEvent evt)
This method is responsible for assigning new and unique IDs to nodes and edges whenever they are created and to remove IDs of nodes and edges whenever they are deleted from a graph.

Special care is taken if a node or edge is removed that has an ID that is still assigned to some other node or edge. In this case, the ID is not removed from the set of used IDs.

If a node ID is removed, all other nodes that have that ID as their parent ID are visited and their parent ID is set to 0.

Specified by:
onGraphEvent in interface GraphListener
See Also:
GraphListener.onGraphEvent(y.base.GraphEvent)

removeIDs

public void removeIDs(Graph graph)
Removes IDs of nodes and edges that occur in the passed graph from the set of used IDs. The implementation of this method is very simple, since it only calls removeNodeID and removeEdgeID for every node and every edge in the passed graph. For details, consult the documentation of those methods.

It is irrelevant if the passed graph is still part of the LayeredGraph or if it has already been removed. It is only important that is still has all the structure information (node/parent/edge IDs).

Parameters:
graph - The graph that holds the nodes and edges whose IDs will be removed.

removeEdgeID

public void removeEdgeID(Edge edge)
Removes the edge ID of the passed edge from the set of used IDs. This will happen only if there is no other edge inside the LayeredGraph that has the same ID.

It is irrelevant if the passed edge is still part of the LayeredGraph or if it is already removed (together with its parent graph). It is only necessary that the edges parent graph still has structure information (node/parent/edge IDs).

Parameters:
edge - The edge whose ID will be removed.

removeNodeID

public void removeNodeID(Node node)
Removes the node ID of the passed node from the set of used IDs. This will happen only if there is no other node inside the LayeredGraph that has the same ID.

If the node ID is removed, all other nodes that have this ID as their parent ID will be visited and their parent ID will be set to 0.

It is irrelevant if the passed node is still part of the LayeredGraph or if it is already removed (together with its parent graph). It is only necessary that the nodes parent graph still has structure information (node/parent/edge IDs).

Parameters:
node - The node whose ID should be removed.