Home Reference Source
private class | source

Label

Extends:

WorldElement → Label

A Label Box allows for a pair of label and value to be displayed. It is often used to display results. A Label object is created by calling the method Box.addLabel on the parent Box.

Constructor Summary

Public Constructor
public

constructor(box: Box, width: number, height: number, opts: object)

Member Summary

Public Members
public

box: Box

Sets the parent box where te Label will be placed.

public

Sets the amount of decimal places displayed on the value.

public

Flag for fixing the decimal places to the amount set in Label.decPlaces.

public

Sets the height of the Label in pixels.

public

Click debouncing.

public

Sets the width that the name portion has.

public

Name of the label.

public

Callback for clicking the label.

public

Sets the units that the value will use.

public

Flag for automatically using the (k)ilo, (M)ega, (G)iga prefixes in order to shorten the length of the value.

public

Sets the formated value for the label.

public

Sets the width of the Label in pixels.

Method Summary

Public Methods
public

set(value: number | string)

Sets the value of the label.

Private Methods
private

debug()

Debug function used to draw a box around the dimensions of the label object.

private

draw()

Draw function for the Label called by the parent box.

private

Tests if the mouse is over the label.

Inherited Summary

From class WorldElement
public

Sets the color in HEX format of the element.

public

Sets the cursor style when the mouse is over the element.

public

Flag for enabling or diabling this element.

public

Flag set when the element is being dragged around.

public

Sets the font of the element.

public

Sets the current height of the element.

public

Flag for allowing the element to be dragged around.

public

Sets the move style of the element.

public

Flag set when the mouse is over the element.

public

Sets a callback function for when the element is dragged around.

public

Sets the position of the element.

public

Sets the renderer used for the element.

public

Sets the rotation of the element.

public

A copy of the z-index value is stored here.

public

Sets the drawing scale of the element.

public

Flag for determining if the element will be a top-most element when dragged around.

public

Flag used to determine if an object is a child of WorldElement.

public

Sets the current width of the element.

public

Sets the world where this element is found.

public

Sets the z-index of the element.

public

Adds the provided coordinates to the position.

public

Sets if the element is draggable.

public

Function called when the mouse moves to check if the pointer is over the element.

public

Sets the color in HEX format of the element.

public

Sets the position of the element.

public

Sets the scale of the element.

public

setZ(z: number)

Sets the z-index of the element.

private

resize()

Function called when the canvas gets resized.

private

setWorld(world: World)

Sets the world object where element will be drawn.

private

topmost(state: boolean)

Sets the element as a topmost element.

Public Constructors

public constructor(box: Box, width: number, height: number, opts: object) source

Override:

WorldElement#constructor

Params:

NameTypeAttributeDescription
box Box

Parent box.

width number

Width of the label in pixels.

height number

Height of the label in pixels.

opts object
  • optional

Object that contains valid Text properties with values. Their values will be assigned at the end of the constructor. If an invalid property is passed then the value will be ignored.

Public Members

public box: Box source

Sets the parent box where te Label will be placed.

public decPlaces: number source

Sets the amount of decimal places displayed on the value. Default value is 2.

public fixPlaces: boolean source

Flag for fixing the decimal places to the amount set in Label.decPlaces. Default value is false.

public height: number source

Sets the height of the Label in pixels. Default value is 14.

Override:

WorldElement#height

public isDown: boolean source

Click debouncing.

public labelWidth: number source

Sets the width that the name portion has. This also means that the value of the label is going to be displayed this amount of pixels to the left of it. Furthermore, the width of the label (Label.width) must be larger than this value. Default value is 75.

public name: string source

Name of the label. Default value is "".

public onClick: function source

Callback for clicking the label. Default value is undefined.

public units: string source

Sets the units that the value will use. Default value is "".

public usePrefixes: boolean source

Flag for automatically using the (k)ilo, (M)ega, (G)iga prefixes in order to shorten the length of the value. Default value is false.

public value: string source

Sets the formated value for the label. This is the value that is displayed along the name.

public width: number source

Sets the width of the Label in pixels.

Override:

WorldElement#width

Public Methods

public set(value: number | string) source

Sets the value of the label. Given any new value it is formated into a string with the provided settings in the object.

Params:

NameTypeAttributeDescription
value number | string

New value for the label.

Private Methods

private debug() source

Debug function used to draw a box around the dimensions of the label object. It is only drawn if the parent box has the flag Box.debug enabled.

private draw() source

Draw function for the Label called by the parent box.

private isMouseOver(): boolean source

Tests if the mouse is over the label.

Override:

WorldElement#isMouseOver

Return:

boolean

True if the mouse is over the label, false otherwise.