|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.graph.build.polygon.PolygonGraphGenerator
An implementation of GraphGenerator used to build graphs from a set of polygons.
This graph generator takes Polygon
objects as input when constructing a graph. The following code constructs
a graph from a set of polygons.
//get some polygons
Polygon[] polygons = ...
//determine what the relationship will be
PolygonGraphGenerator rel = new PolygonGraphGenerator.PolygonRelationship() {
public boolean related(Polygon p1, Polygon p2) {
return p1.intersects(p2);
}
public boolean equal(Polygon p1, Polygon p2) {
return p1.equals(p2);
}
}
//create the generator
PolygonGraphGenerator gg = new PolygonGraphGenerator(new BasicGraphBuilder(),rel);
//start building
for (int i = 0; i < polygons.length; i++) {
gg.add(polygons[i]);
}
For each distinct polygon added to the graph, a node is created. If two
polygons are considered equal, only a single node is created. If two
polygons are considered related, the associated nodes share an edge. Equality
and relationship is determined by PolygonGraphGenerator.PolygonRelationship
interface. An instance of this interface is passed to the generator at construction.
Nested Class Summary | |
static interface |
PolygonGraphGenerator.PolygonRelationship
Determines the relationship among two polygons. |
Constructor Summary | |
PolygonGraphGenerator(GraphBuilder builder,
PolygonGraphGenerator.PolygonRelationship rel)
|
Method Summary | |
Graphable |
add(java.lang.Object obj)
Adds an object to the graph. |
protected Node |
find(com.vividsolutions.jts.geom.Polygon polygon)
|
Graphable |
get(java.lang.Object obj)
Retrieves a component of the graph. |
Graph |
getGraph()
Returns the graph being generated. |
GraphBuilder |
getGraphBuilder()
Returns the underlying builder. |
protected void |
relate(Node node)
|
Graphable |
remove(java.lang.Object obj)
Removes an object from the graph. |
void |
setGraphBuilder(GraphBuilder builder)
Sets the underlying builder used to physically construct the graph. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PolygonGraphGenerator(GraphBuilder builder, PolygonGraphGenerator.PolygonRelationship rel)
Method Detail |
public Graphable add(java.lang.Object obj)
GraphGenerator
add
in interface GraphGenerator
obj
- The object to be modelled in the graph.
public Graphable get(java.lang.Object obj)
GraphGenerator
get
in interface GraphGenerator
obj
- The object modelled by the component.
public Graphable remove(java.lang.Object obj)
GraphGenerator
remove
in interface GraphGenerator
obj
- The object modelled by the component.
public void setGraphBuilder(GraphBuilder builder)
GraphGenerator
setGraphBuilder
in interface GraphGenerator
builder
- The new underlying GraphBuilder.public GraphBuilder getGraphBuilder()
GraphGenerator
getGraphBuilder
in interface GraphGenerator
public Graph getGraph()
GraphGenerator
getGraph
in interface GraphGenerator
protected Node find(com.vividsolutions.jts.geom.Polygon polygon)
protected void relate(Node node)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |