net.sourceforge.fluxion.graph
Class AbstractGraph

java.lang.Object
  extended by net.sourceforge.fluxion.graph.AbstractGraph
All Implemented Interfaces:
Graph
Direct Known Subclasses:
DefaultGraph

public abstract class AbstractGraph
extends java.lang.Object
implements Graph

Javadocs go here.

Version:
1.0
Author:
Tony Burdett

Constructor Summary
AbstractGraph()
          Constructs a new DefaultGraph.
 
Method Summary
 void accept(GraphVisitor visitor)
          Accept a visit from a GraphVisitor.
 void add(Edge edge)
          Adds the Edge to this graph.
 void add(Node node)
          Adds the Node to this graph
 void addGraphListener(GraphListener listener)
          Add a GraphListener to report on changes to the Graph.
 void cascadeChanges()
          Cascades any changes made to this graph down to the underlying object model.
 boolean contains(Edge edge)
          Returns true if this graph contains the given edge, or false otherwise
 boolean contains(Node node)
          Returns true if this graph contains the given Node, or false otherwise
 java.util.Set<Node> getAllNodes()
          Returns every Node present within this graph
 java.util.Collection<Edge> getLeadingEdges(Node node)
          Returns the set of edges leading into a given node.
 java.lang.String getName()
          Gets the name of this graph
 Node getNode(java.lang.String name)
          Returns the Node with the given name present within this graph.
 java.util.Set<Node> getRootNodes()
          Returns all the nodes which are "root" nodes of this graph.
 java.util.Set<Edge> getTailingEdges(Node node)
          Returns the set of edges which lead out of the given node.
 void remove(Edge edge)
          Removes this Edge from the graph.
 void remove(Node node)
          Removes the Node from this graph.
 void removeAll()
          Removes all Nodes and Edges from this graph
 void removeGraphListener(GraphListener listener)
          Remove a GraphListener from the Graph
 void setAsRoot(Node node)
          Sets this node as the root.
 void setName(java.lang.String name)
          Sets the name of this graph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGraph

public AbstractGraph()
Constructs a new DefaultGraph.

Method Detail

getName

public java.lang.String getName()
Description copied from interface: Graph
Gets the name of this graph

Specified by:
getName in interface Graph
Returns:
the graph name

setName

public void setName(java.lang.String name)
Description copied from interface: Graph
Sets the name of this graph

Specified by:
setName in interface Graph
Parameters:
name - the name of the graph

add

public void add(Node node)
Description copied from interface: Graph
Adds the Node to this graph

Specified by:
add in interface Graph
Parameters:
node - the Node to be added

remove

public void remove(Node node)
Description copied from interface: Graph
Removes the Node from this graph.

Specified by:
remove in interface Graph
Parameters:
node - the Node to be removed

add

public void add(Edge edge)
Description copied from interface: Graph
Adds the Edge to this graph. In order to be sucessfully added, the parent and child Nodes of the given Edge should already be present in the graph.

Specified by:
add in interface Graph
Parameters:
edge - the Edge to be added

remove

public void remove(Edge edge)
Description copied from interface: Graph
Removes this Edge from the graph. If these leaves any Nodes without a leading edge, the positional information of this Node will be lost.

Specified by:
remove in interface Graph
Parameters:
edge - the Edge to be removed

removeAll

public void removeAll()
Description copied from interface: Graph
Removes all Nodes and Edges from this graph

Specified by:
removeAll in interface Graph

contains

public boolean contains(Node node)
Description copied from interface: Graph
Returns true if this graph contains the given Node, or false otherwise

Specified by:
contains in interface Graph
Parameters:
node - check if this Node exists in the graph
Returns:
true if the graph contains this node

contains

public boolean contains(Edge edge)
Description copied from interface: Graph
Returns true if this graph contains the given edge, or false otherwise

Specified by:
contains in interface Graph
Parameters:
edge - check if this Edge exists in the graph
Returns:
returns true if this edge is present in the graph, false otherwise

setAsRoot

public void setAsRoot(Node node)
Description copied from interface: Graph
Sets this node as the root. Multiple roots are allowed.

Specified by:
setAsRoot in interface Graph
Parameters:
node - the Node to set as a root node.

getRootNodes

public java.util.Set<Node> getRootNodes()
Description copied from interface: Graph
Returns all the nodes which are "root" nodes of this graph. In other words, the nodes which aren't attached to the tail of an edge.

Specified by:
getRootNodes in interface Graph
Returns:
the root nodes

getLeadingEdges

public java.util.Collection<Edge> getLeadingEdges(Node node)
Description copied from interface: Graph
Returns the set of edges leading into a given node. Normally, it makes sense for there to be only one edge leading into a node, but this is not compulsory. This is a convenience method to allow easy retrieval of the "parent" edges on a node.

Specified by:
getLeadingEdges in interface Graph
Parameters:
node - all edges leading into a node
Returns:
the leading edges

getTailingEdges

public java.util.Set<Edge> getTailingEdges(Node node)
Description copied from interface: Graph
Returns the set of edges which lead out of the given node. This is a convenience method to allow easy retrieval of the "child" edges leading out of any node.

Specified by:
getTailingEdges in interface Graph
Parameters:
node - gets all tailing edges leading out of this Node
Returns:
the tailing edges

getNode

public Node getNode(java.lang.String name)
Description copied from interface: Graph
Returns the Node with the given name present within this graph. If no such node is present, this method will return null.

Specified by:
getNode in interface Graph
Parameters:
name - the node name
Returns:
the node with the given name

getAllNodes

public java.util.Set<Node> getAllNodes()
Description copied from interface: Graph
Returns every Node present within this graph

Specified by:
getAllNodes in interface Graph
Returns:
all nodes in this graph

cascadeChanges

public void cascadeChanges()
Description copied from interface: Graph
Cascades any changes made to this graph down to the underlying object model. This allows the graph model to be changed independently from the underlying object model, and changes only cacaded down when the user is happy with these changes.

Specified by:
cascadeChanges in interface Graph

accept

public void accept(GraphVisitor visitor)
Description copied from interface: Graph
Accept a visit from a GraphVisitor.

Specified by:
accept in interface Graph
Parameters:
visitor - the GraphVisitor visiting this graph

addGraphListener

public void addGraphListener(GraphListener listener)
Description copied from interface: Graph
Add a GraphListener to report on changes to the Graph.

Specified by:
addGraphListener in interface Graph
Parameters:
listener - the listener to add

removeGraphListener

public void removeGraphListener(GraphListener listener)
Description copied from interface: Graph
Remove a GraphListener from the Graph

Specified by:
removeGraphListener in interface Graph
Parameters:
listener - the listener to remove


Copyright © 2010. All Rights Reserved.