Home Reference Source Test Repository
public class | source

Label

Data representation of text objects. Not called Text due to JavaScript already having a Text class.

Constructor Summary

Public Constructor
public

constructor(x: number, y: number, parentObject: Node | Edge)

Constructs a Label instance.

Member Summary

Public Members
public get

Returns the font properties concatenated to match the CanvasRenderingContext2D.font property.

public
public
public

x: *

public

y: *

Method Summary

Public Methods
public

Check if the label contains the given point.

public

Draw the label on the given canvas context.

public

Draw a box around the label's selection area on the given canvas context.

public

setPos(x: number, y: number)

Update the label's position.

Public Constructors

public constructor(x: number, y: number, parentObject: Node | Edge) source

Constructs a Label instance.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the label.

y number

y-coordinate of the label.

parentObject Node | Edge

Node or Edge associated with the Label.

Public Members

public get font: string: string source

Returns the font properties concatenated to match the CanvasRenderingContext2D.font property.

Return:

string

String that can be used to set the canvas font property.

public parentObject: * source

public textMetric: * source

public x: * source

public y: * source

Public Methods

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

Check if the label contains the given point.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Return:

boolean

Whether or not the label contains the point.

public draw(context: CanvasRenderingContext2D) source

Draw the label on the given canvas context.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

public drawBox(context: CanvasRenderingContext2D) source

Draw a box around the label's selection area on the given canvas context.

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D

Canvas 2D context.

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

Update the label's position.

Params:

NameTypeAttributeDescription
x number

The new x-coordinate.

y number

The new y-coordinate.