Home Reference Source Test Repository
public class | source

Edge

Direct Subclass:

DashedEdge, SolidEdge

Data representation of a graph edge.

Constructor Summary

Public Constructor
public

constructor(startNode: Node, destNode: Node)

Constructs an Edge instance.

Member Summary

Public Members
public
public
public
public
public

label: *

public
public
public

Method Summary

Public Methods
public

Check if the edge contains a given point (within a distance threshold).

public

detach()

Remove the edge from all other graph objects associated with it.

public abstract

Draw the edge on the given canvas context.

public

Draw an arrow on the destination side of the edge on the given context.

public

Draw the Label object associated with this edge.

public

updateCurvedEdgeLabel(oldStartPoint2D: Point2D, oldBezierPoint2D: Point2D, oldDestPoint2D: Point2D, startPoint2D: Point2D, bezierPoint2D: Point2D, destPoint2D: Point2D)

Update the position of the Label for a curved edge.

public

Update the endpoints of the edge.

public

Update endpoints for a normal edge.

public

Update endpoints for a self-loop edge.

public

updateSelfLoopLabel(oldBezierPoint: Object)

Update the position of the Label for a self-loop edge.

public

updateStraightEdgeLabel(oldStartPoint2D: Point2D, oldBezierPoint2D: Point2D, oldDestPoint2D: Point2D, startPoint2D: Point2D, bezierPoint2D: Point2D, destPoint2D: Point2D)

Update the position of the Label for a straight edge.

Public Constructors

public constructor(startNode: Node, destNode: Node) source

Constructs an Edge instance. Should not be called directly.

Params:

NameTypeAttributeDescription
startNode Node

Start node of the edge.

destNode Node

Destination node of the edge.

Public Members

public bezierPoint: * source

public destNode: * source

public destPoint: * source

public isDirected: boolean source

public label: * source

public partners: * source

public startNode: * source

public startPoint: * source

Public Methods

public containsPoint(x: number, y: number): boolean source

Check if the edge contains a given point (within a distance threshold).

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Return:

boolean

Whether or not the edge contains the point.

public detach() source

Remove the edge from all other graph objects associated with it.

public abstract draw(context: CanvasRenderingContext2D) source

Draw the edge on the given canvas context.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

Throw:

Error

Throws error if called.

public drawArrow(context: CanvasRenderingContext2D) source

Draw an arrow on the destination side of the edge on the given context.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

public drawLabel(context: CanvasRenderingContext2D) source

Draw the Label object associated with this edge.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

public updateCurvedEdgeLabel(oldStartPoint2D: Point2D, oldBezierPoint2D: Point2D, oldDestPoint2D: Point2D, startPoint2D: Point2D, bezierPoint2D: Point2D, destPoint2D: Point2D) source

Update the position of the Label for a curved edge.

Params:

NameTypeAttributeDescription
oldStartPoint2D Point2D

The previous start point.

oldBezierPoint2D Point2D

The previous bezier point.

oldDestPoint2D Point2D

The previous destination point.

startPoint2D Point2D

The current start point.

bezierPoint2D Point2D

The current bezier point.

destPoint2D Point2D

The current destination point.

public updateEndpoints() source

Update the endpoints of the edge.

public updateNormalEdgeEndpoints() source

Update endpoints for a normal edge. Called by updateEndpoints().

public updateSelfLoopEndpoints() source

Update endpoints for a self-loop edge. Called by updateEndpoints().

public updateSelfLoopLabel(oldBezierPoint: Object) source

Update the position of the Label for a self-loop edge.

Params:

NameTypeAttributeDescription
oldBezierPoint Object

The previous bezier point location.

oldBezierPoint.x number

The x-coordinate of the bezier point.

oldBezierPoint.y number

The y-coordinate of the bezier point.

public updateStraightEdgeLabel(oldStartPoint2D: Point2D, oldBezierPoint2D: Point2D, oldDestPoint2D: Point2D, startPoint2D: Point2D, bezierPoint2D: Point2D, destPoint2D: Point2D) source

Update the position of the Label for a straight edge.

Params:

NameTypeAttributeDescription
oldStartPoint2D Point2D

The previous start point.

oldBezierPoint2D Point2D

The previous bezier point.

oldDestPoint2D Point2D

The previous destination point.

startPoint2D Point2D

The current start point.

bezierPoint2D Point2D

The current bezier point.

destPoint2D Point2D

The current destination point.