Class DirectedEdge

Hierarchy: Object , GraphComponent, DirectedEdge
All Implemented Interfaces: Comparable
Direct Known Subclasses: LineMergeDirectedEdge, PolygonizeDirectedEdge
public class DirectedEdge
extends GraphComponent
implements Comparable
Represents a directed edge in a PlanarGraph. A DirectedEdge may or may not have a reference to a parent Edge (some applications of planar graphs may not require explicit Edge objects to be created). Usually a client using a PlanarGraph will subclass DirectedEdge to add its own application-specific data and methods.

Other

  • version: 1.7
public DirectedEdge(Node from, Node to, Coordinate directionPt, boolean edgeDirection)
Constructs a DirectedEdge connecting the from node to the to node.
Parameters:
directionPt - directionPt specifies this DirectedEdge's direction vector (determined by the vector from the from node to directionPt)
edgeDirection - edgeDirection whether this DirectedEdge's direction is the same as or opposite to that of the parent Edge (if any)
public static List toEdges(Collection dirEdges)
Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.
public Edge getEdge()
Returns this DirectedEdge's parent Edge, or null if it has none.
public void setEdge(Edge parentEdge)
Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
public int getQuadrant()
Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
public Coordinate getDirectionPt()
Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's orientation.
public boolean getEdgeDirection()
Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.
public Node getFromNode()
Returns the node from which this DirectedEdge leaves.
public Node getToNode()
Returns the node to which this DirectedEdge goes.
public Coordinate getCoordinate()
Returns the coordinate of the from-node.
public double getAngle()
Returns the angle that the start of this DirectedEdge makes with the positive x-axis, in radians.
public DirectedEdge getSym()
Returns the symmetric DirectedEdge -- the other DirectedEdge associated with this DirectedEdge's parent Edge.
public void setSym(DirectedEdge sym)
Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
public boolean isRemoved()
Tests whether this directed edge has been removed from its containing graph
Returns:
true if this directed edge is removed
public int compareTo(Object obj)
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.

Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:

public int compareDirection(DirectedEdge e)
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.

Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:

public void print(PrintStream out)
Prints a detailed string representation of this DirectedEdge to the given PrintStream.