org.geotools.graph.build
Class RelationshipGraphBuilder

java.lang.Object
  extended byorg.geotools.graph.build.RelationshipGraphBuilder
All Implemented Interfaces:
GraphBuilder

public class RelationshipGraphBuilder
extends java.lang.Object
implements GraphBuilder

General purpose graph builder based on user defined relationships.

In this type of graph, the features are represented by the nodes, and the relationships by the edges. Relationships are defined using the FeatureRelator interface as a Stratagy object (GOF Stratagy pattern).


Constructor Summary
RelationshipGraphBuilder(FeatureRelator relator)
          Creates a new RelationshipGraphBuilder object.
RelationshipGraphBuilder(FeatureRelator relator, com.vividsolutions.jts.index.SpatialIndex index)
          Creates a new RelationshipGraphBuilder object.
 
Method Summary
 GraphComponent add(org.geotools.feature.Feature feature)
          Adds a feature to the graph.
protected  void addEdge(Edge newEdge)
          DOCUMENT ME!
protected  void addNode(Node newNode)
          DOCUMENT ME!
 Graph build()
          Signals the builder to complete the graph build.
protected  Edge buildEdge(org.geotools.feature.Feature feature, Node n1, Node n2)
          DOCUMENT ME!
protected  Node buildNode(org.geotools.feature.Feature feature)
          DOCUMENT ME!
protected  java.util.Collection getEdges()
          DOCUMENT ME!
 Graph getGraph()
          Returns the graph built by the builder.
protected  java.util.Collection getNodes()
          DOCUMENT ME!
protected  FeatureRelator getRelator()
          DOCUMENT ME!
 boolean isDirected()
          Indicates wether or not the graph is directed.
protected  void relate(Node n1, Node n2)
          DOCUMENT ME!
 void removeEdge(Edge edge)
          Removes an edge from the graph.
 void removeEdges(java.util.Collection edges)
          Removes a collection of edges from the graph.
 void removeNode(Node node)
          Removes a node from the graph.
 void removeNodes(java.util.Collection nodes)
          Removes a collection of nodes from the graph.
 void setDirected(boolean directed)
          Sets the graph to be directed/undirected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationshipGraphBuilder

public RelationshipGraphBuilder(FeatureRelator relator,
                                com.vividsolutions.jts.index.SpatialIndex index)
Creates a new RelationshipGraphBuilder object.

Parameters:
relator - DOCUMENT ME!
index - DOCUMENT ME!

RelationshipGraphBuilder

public RelationshipGraphBuilder(FeatureRelator relator)
Creates a new RelationshipGraphBuilder object.

Parameters:
relator - DOCUMENT ME!
Method Detail

add

public GraphComponent add(org.geotools.feature.Feature feature)
Description copied from interface: GraphBuilder
Adds a feature to the graph.

Specified by:
add in interface GraphBuilder
Parameters:
feature - Feature to be added. The feature will be encapsulated with a GraphComponent, either a Node or a Edge. Which one is implentation dependant.
Returns:
The graph component that encapsulates the added feature.
See Also:
GraphBuilder.add(Feature)

removeNode

public void removeNode(Node node)
Description copied from interface: GraphBuilder
Removes a node from the graph.

Specified by:
removeNode in interface GraphBuilder
See Also:
GraphBuilder.removeNode(Node)

removeNodes

public void removeNodes(java.util.Collection nodes)
Removes a collection of nodes from the graph.

Parameters:
nodes - DOCUMENT ME!

removeEdge

public void removeEdge(Edge edge)
Description copied from interface: GraphBuilder
Removes an edge from the graph.

Specified by:
removeEdge in interface GraphBuilder
Parameters:
edge -
See Also:
GraphBuilder.removeEdge(Edge)

removeEdges

public void removeEdges(java.util.Collection edges)
Removes a collection of edges from the graph.

Parameters:
edges - DOCUMENT ME!

build

public Graph build()
Description copied from interface: GraphBuilder
Signals the builder to complete the graph build.

Specified by:
build in interface GraphBuilder
Returns:
The built Graph object.
See Also:
GraphBuilder.build()

getGraph

public Graph getGraph()
Description copied from interface: GraphBuilder
Returns the graph built by the builder.

Specified by:
getGraph in interface GraphBuilder
Returns:
Graph
See Also:
GraphBuilder.getGraph()

setDirected

public void setDirected(boolean directed)
Description copied from interface: GraphBuilder
Sets the graph to be directed/undirected.

Specified by:
setDirected in interface GraphBuilder
Parameters:
directed - True if directed, false if undirected.
See Also:
GraphBuilder.setDirected(boolean)

isDirected

public boolean isDirected()
Description copied from interface: GraphBuilder
Indicates wether or not the graph is directed.

Specified by:
isDirected in interface GraphBuilder
Returns:
True if directed, false if undirected.
See Also:
GraphBuilder.isDirected()

getNodes

protected java.util.Collection getNodes()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getEdges

protected java.util.Collection getEdges()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRelator

protected FeatureRelator getRelator()
DOCUMENT ME!

Returns:
DOCUMENT ME!

relate

protected void relate(Node n1,
                      Node n2)
DOCUMENT ME!

Parameters:
n1 - DOCUMENT ME!
n2 - DOCUMENT ME!

buildNode

protected Node buildNode(org.geotools.feature.Feature feature)
DOCUMENT ME!

Parameters:
feature - DOCUMENT ME!
Returns:
DOCUMENT ME!

addNode

protected void addNode(Node newNode)
DOCUMENT ME!

Parameters:
newNode - DOCUMENT ME!

buildEdge

protected Edge buildEdge(org.geotools.feature.Feature feature,
                         Node n1,
                         Node n2)
DOCUMENT ME!

Parameters:
feature - DOCUMENT ME!
n1 - DOCUMENT ME!
n2 - DOCUMENT ME!
Returns:
DOCUMENT ME!

addEdge

protected void addEdge(Edge newEdge)
DOCUMENT ME!

Parameters:
newEdge - DOCUMENT ME!