org.geotools.graph.build.line
Class BasicLineGraphGenerator

java.lang.Object
  extended byorg.geotools.graph.build.line.BasicLineGraphGenerator
All Implemented Interfaces:
GraphGenerator, LineGraphGenerator
Direct Known Subclasses:
BasicDirectedLineGraphGenerator, LineStringGraphGenerator

public class BasicLineGraphGenerator
extends java.lang.Object
implements LineGraphGenerator

An implementation of GraphGenerator used to generate a graph representing a line network. Graphs are generated by supplying the generator with objects of type LineSegment via the add(Object) method.

For each line segment added, an edge in the graph is created. The builder records the end coordinates of each line added, and maintains a map of coordinates to nodes, creating nodes when neccessary.

Edges created by the generator are of type BasicEdge and contain an object of type LineSegment.
Nodes created by the generator are of type BasicXYNode and contain an object of type Coordinate.

Author:
Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
See Also:
BasicXYNode, BasicEdge, LineSegment, Coordinate

Constructor Summary
BasicLineGraphGenerator()
          Constructs a new BasicLineGraphGenerator.
 
Method Summary
 Graphable add(java.lang.Object obj)
          Adds a line to the graph.
 Graphable get(java.lang.Object obj)
          Returns the edge which represents a line.
 Edge getEdge(com.vividsolutions.jts.geom.Coordinate c1, com.vividsolutions.jts.geom.Coordinate c2)
           
 Graph getGraph()
          Returns the graph being generated.
 GraphBuilder getGraphBuilder()
          Returns the underlying builder.
 Node getNode(com.vividsolutions.jts.geom.Coordinate c)
           
 java.util.Map getNodeMap()
          Returns the coordinate to node map used to build nodes representing line endpoint coordinates.
 Graphable remove(java.lang.Object obj)
          Removes the edge from the graph that represents a line.
 void setGraphBuilder(GraphBuilder builder)
          Sets the underlying builder used to physically construct the graph.
protected  void setObject(Edge e, java.lang.Object obj)
           
protected  void setObject(Node n, java.lang.Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLineGraphGenerator

public BasicLineGraphGenerator()
Constructs a new BasicLineGraphGenerator.

Method Detail

add

public Graphable add(java.lang.Object obj)
Adds a line to the graph.

Specified by:
add in interface GraphGenerator
Parameters:
obj - An instance of LineSegment.
Returns:
A BasicEdge.
See Also:
LineSegment, GraphGenerator.add(Object)

get

public Graphable get(java.lang.Object obj)
Returns the edge which represents a line. Note that if the exact same line has been added to the graph multiple times, then only one of the edges that represents it will be returned. It is undefined which edge will be returned.

Specified by:
get in interface GraphGenerator
Parameters:
obj - An instance of LineSegment.
Returns:
Edge that represents the line.
See Also:
GraphGenerator.get(Object)

remove

public Graphable remove(java.lang.Object obj)
Removes the edge from the graph that represents a line.

Specified by:
remove in interface GraphGenerator
Parameters:
obj - The object modelled by the component.
Returns:
Edge that represents the line.
See Also:
GraphGenerator.remove(Object)

setGraphBuilder

public void setGraphBuilder(GraphBuilder builder)
Description copied from interface: GraphGenerator
Sets the underlying builder used to physically construct the graph.

Specified by:
setGraphBuilder in interface GraphGenerator
Parameters:
builder - The new underlying GraphBuilder.
See Also:
GraphGenerator.setGraphBuilder(GraphBuilder)

getGraphBuilder

public GraphBuilder getGraphBuilder()
Description copied from interface: GraphGenerator
Returns the underlying builder.

Specified by:
getGraphBuilder in interface GraphGenerator
Returns:
The underyling builder.
See Also:
GraphGenerator.getGraphBuilder()

getGraph

public Graph getGraph()
Description copied from interface: GraphGenerator
Returns the graph being generated.

Specified by:
getGraph in interface GraphGenerator
Returns:
The generated graph.
See Also:
GraphGenerator.getGraph()

getNodeMap

public java.util.Map getNodeMap()
Returns the coordinate to node map used to build nodes representing line endpoint coordinates.

Returns:
coordinate to ndoe map.

getNode

public Node getNode(com.vividsolutions.jts.geom.Coordinate c)
Specified by:
getNode in interface LineGraphGenerator

getEdge

public Edge getEdge(com.vividsolutions.jts.geom.Coordinate c1,
                    com.vividsolutions.jts.geom.Coordinate c2)
Specified by:
getEdge in interface LineGraphGenerator

setObject

protected void setObject(Edge e,
                         java.lang.Object obj)

setObject

protected void setObject(Node n,
                         java.lang.Object obj)


Copyright © GeoTools. All Rights Reserved.