Home Reference Source Test Repository
public class | source

Node

Direct Subclass:

CircleNode, PolygonNode

Data representation of a graph node.

Constructor Summary

Public Constructor
public

Constructs a Node instance.

Member Summary

Public Members
public

x: *

public

y: *

Method Summary

Public Methods
public abstract

Check if the node contains the given point.

public abstract

Find the distance from the node's coordinates to a given point.

public abstract

Draw the node on the given canvas context.

public

Draw the Label object associated with this node.

public abstract

Find the point on the edge of the node in the direction of the given point.

public abstract

Get the point on the edge of the node at the given angle.

public

setPos(x: number, y: number)

Update the node position.

Public Constructors

public constructor(x: number, y: number) source

Constructs a Node instance. Should not be called directly.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the node.

y number

y-coordinate of the node.

Public Members

public x: * source

public y: * source

Public Methods

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

Check if the node contains the given point.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Throw:

Error

Throws error if called.

public abstract distanceToPoint(x: number, y: number) source

Find the distance from the node's coordinates to a given point.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Throw:

Error

Throws error if called.

public abstract draw(context: CanvasRenderingContext2D) source

Draw the node on the given canvas context.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

Throw:

Error

Throws error if called.

public drawLabel(context: CanvasRenderingContext2D) source

Draw the Label object associated with this node.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

public abstract edgePointInDirection(x: number, y: number) source

Find the point on the edge of the node in the direction of the given point.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Throw:

Error

Throws error if called.

public abstract getAnglePoint(angle: number) source

Get the point on the edge of the node at the given angle.

Params:

NameTypeAttributeDescription
angle number

The angle (clockwise from +x axis).

Throw:

Error

Throws error if called.

public setPos(x: number, y: number) source

Update the node position.

Params:

NameTypeAttributeDescription
x number

The new x-coordinate.

y number

The new y-coordinate.