org.geotools.graph.build
Class LineGraphBuilder

java.lang.Object
  extended byorg.geotools.graph.build.LineGraphBuilder
All Implemented Interfaces:
GraphBuilder
Direct Known Subclasses:
NetworkBuilder

public class LineGraphBuilder
extends java.lang.Object
implements GraphBuilder

Implentation of GraphBuilder that builds graphs from linear features.

In this type of graph, Features are represented by the edges, and relationships by the nodes. A feature is related to another feature when one of its enpoints is shared with one of the endpoints of another feature.


Constructor Summary
LineGraphBuilder()
          Creates a new LineGraphBuilder object.
 
Method Summary
 GraphComponent add(org.geotools.feature.Feature feature)
          Adds feature to the graph.
protected  void addEdge(Edge newEdge)
          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, com.vividsolutions.jts.geom.Coordinate coordinate)
          DOCUMENT ME!
protected  Node createNode(org.geotools.feature.Feature feature, com.vividsolutions.jts.geom.Coordinate coordinate)
          DOCUMENT ME!
protected  java.util.Collection getEdges()
          DOCUMENT ME!
 Graph getGraph()
          Returns the graph built by the builder.
 Node getNode(com.vividsolutions.jts.geom.Coordinate coord)
          Returns a node that has been built at a specific coordinate.
protected  java.util.Map getNodes()
          DOCUMENT ME!
 boolean isDirected()
          Indicates wether or not the graph is directed.
 boolean isReversed()
          Determines if the relationships in the graph are reversed.
 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 setDirected(boolean directed)
          Sets the graph to be directed/undirected.
 void setReversed(boolean reversed)
          Sets the relationships in the graph to be reversed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineGraphBuilder

public LineGraphBuilder()
Creates a new LineGraphBuilder object.

Method Detail

setReversed

public void setReversed(boolean reversed)
Sets the relationships in the graph to be reversed.

Parameters:
reversed - True for reversed, false for normal.

isReversed

public boolean isReversed()
Determines if the relationships in the graph are reversed.

Returns:
True is reversed, otherwise false.

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()

add

public GraphComponent add(org.geotools.feature.Feature feature)
Adds feature to the graph.

This is a custom implementaiton in which only the end points of the feature are considered (LineString geometry is required ).

Specified by:
add in interface GraphBuilder
Parameters:
feature - Feature with LineString geometry
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)

removeEdge

public void removeEdge(Edge edge)
Removes an edge from the graph.

Specified by:
removeEdge in interface GraphBuilder
Parameters:
edge - DOCUMENT ME!

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()

getNode

public Node getNode(com.vividsolutions.jts.geom.Coordinate coord)
Returns a node that has been built at a specific coordinate.

Parameters:
coord - DOCUMENT ME!
Returns:
DOCUMENT ME!

addEdge

protected void addEdge(Edge newEdge)
DOCUMENT ME!

Parameters:
newEdge - DOCUMENT ME!

getNodes

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

Returns:
DOCUMENT ME!

getEdges

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

Returns:
DOCUMENT ME!

createNode

protected Node createNode(org.geotools.feature.Feature feature,
                          com.vividsolutions.jts.geom.Coordinate coordinate)
DOCUMENT ME!

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

buildNode

protected Node buildNode(org.geotools.feature.Feature feature,
                         com.vividsolutions.jts.geom.Coordinate coordinate)
DOCUMENT ME!

Parameters:
feature - DOCUMENT ME!
coordinate - DOCUMENT ME!
Returns:
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!