org.geotools.graph
Class Edge

java.lang.Object
  extended byorg.geotools.graph.GraphComponent
      extended byorg.geotools.graph.Edge
All Implemented Interfaces:
org.geotools.feature.Feature
Direct Known Subclasses:
NetworkEdge

public class Edge
extends GraphComponent

An Edge connects two nodes in the graph.


Nested Class Summary
 
Nested classes inherited from class org.geotools.feature.Feature
org.geotools.feature.Feature.NULL
 
Constructor Summary
Edge(org.geotools.feature.Feature feature, Node nodeA, Node nodeB)
          Creates an edge.
 
Method Summary
 com.vividsolutions.jts.geom.Geometry buildGeometry()
          Builds a Geometry object to represent the edge spatially.
 boolean endpointEquals(Edge other)
          Compares the nodes of the edge with the nodes of another edge.
 boolean endpointEqualsReverse(Edge other)
          Compares the nodes of the edge with the nodes of another edge in reverse order.
 boolean equals(Edge other)
          Determines equality between two edges.
 boolean equals(java.lang.Object other)
          Calls equals(Edge).
 boolean equalsReverse(Edge other)
          Determines equality between two edges in reverse.
 java.util.Collection getAdjacentElements()
          Returns the edges adjacent to this edge.
 Node getNodeA()
          Returns the node at the source of the Edge.
 Node getNodeB()
          Returns the node at the destination of the edge.
 Node getOtherNode(Node node)
          Returns the node of the edge opposite of the specified node.
 void reverse(boolean deep)
          Reverses the direction of the edge by swapping the two nodes.
 java.lang.String toString()
          Returns the string representation of the edge.
 
Methods inherited from class org.geotools.graph.GraphComponent
compareTo, getAttribute, getAttribute, getAttributes, getBounds, getCount, getDefaultGeometry, getFeature, getFeatureType, getID, getNumberOfAttributes, getParent, getSchema, isVisited, schema, setAttribute, setAttribute, setAttributes, setCount, setDefaultGeometry, setParent, setVisited
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Edge

public Edge(org.geotools.feature.Feature feature,
            Node nodeA,
            Node nodeB)
Creates an edge.

Parameters:
feature - Underlying Feature represented by the edge.
nodeA - Node at the source of the edge.
nodeB - Node at the destination of the edge.
See Also:
Node, Feature
Method Detail

getNodeA

public Node getNodeA()
Returns the node at the source of the Edge.

Returns:
Node

getNodeB

public Node getNodeB()
Returns the node at the destination of the edge.

Returns:

getOtherNode

public Node getOtherNode(Node node)
Returns the node of the edge opposite of the specified node.

Parameters:
node - The node opposite of the desired node to be returned.
Returns:
If the specified node is the source node, the destination node is returned, and vice versa.

getAdjacentElements

public java.util.Collection getAdjacentElements()
Returns the edges adjacent to this edge. More specifically, edges adjacent to the source and destination node, minus this edge, are returned.

Specified by:
getAdjacentElements in class GraphComponent
Returns:
Collection

reverse

public void reverse(boolean deep)
Reverses the direction of the edge by swapping the two nodes. As well, the geometry used to represent the edge spatially is also reversed.

Parameters:
deep - Indicates wether the geometry of the underlying feature represented by the edge should be reversed.

endpointEquals

public boolean endpointEquals(Edge other)
Compares the nodes of the edge with the nodes of another edge.

Parameters:
other - Edge to be compared.
Returns:
True if the two sets of nodes are equal in correct order. That is that both A nodes are equals, and both B nodes are equal.

endpointEqualsReverse

public boolean endpointEqualsReverse(Edge other)
Compares the nodes of the edge with the nodes of another edge in reverse order.

Parameters:
other - Edge to be compared to in reverse.
Returns:
True if the nodes in both pairs of A,B nodes are equal.

equals

public boolean equals(java.lang.Object other)
Calls equals(Edge).

See Also:
Object.equals(Object)

equals

public boolean equals(Edge other)
Determines equality between two edges.

Parameters:
other - Edge to be compared.
Returns:
True if the two nodes of the edges are equal in correct order and if the geometries used to represent the edges are equal, otherwise false.

equalsReverse

public boolean equalsReverse(Edge other)
Determines equality between two edges in reverse.

Parameters:
other - Edge to be compared.
Returns:
True if the two nodes of the edges are equal in reverse order and if the geomtries used to represent the edges spatially are the reverse of each other, otherwise false is returned.

buildGeometry

public com.vividsolutions.jts.geom.Geometry buildGeometry()
Builds a Geometry object to represent the edge spatially.

Specified by:
buildGeometry in class GraphComponent
Returns:
Geometry
See Also:
Geometry

toString

public java.lang.String toString()
Returns the string representation of the edge.

See Also:
Object.toString()