Box
Extends:
A Box allows for a window like object to be displayed in the world. This window object has the possibility to display text, labels and graphs, completely isolated from the settings of the world. A box object does not have a width or a height. Instead, it takes the dimensions of the objects it contains.
Constructor Summary
Public Constructor | ||
public |
constructor(opts: object) |
Member Summary
Public Members | ||
public |
Sets the color of the Box. |
|
public |
Flag for displaying debug rectangles around the elements inside the Box. |
|
public |
Sets an array where all elements inside the Box are stored. |
|
public |
Sets the height of the Box in pixels. |
|
public |
Flag for allowing the Box to be dragged around. |
|
public |
Sets the move style of the Box to change by pixels rather than by units. |
|
public |
Sets the padding in pixels that the Box has. |
|
public |
Sets the title for the Box. |
|
public |
Sets the width of the Box in pixels. |
Method Summary
Public Methods | ||
public |
Adds a Graph to the Box. |
|
public |
Adds a Label to the Box. |
|
public |
Adds a Text to the Box. |
|
public |
Since the box takes the dimensions of the objects it contains, this function calculates these dimensions. |
|
public |
setPadding(top: number, right: number, bottom: number, left: number) Sets the padding of the Box object. |
Private Methods | ||
private |
draw() Main draw function for the Box called by the World automatically. |
|
private |
Tests if the mouse is over the box. |
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 |
addPosition(x: number, y: number) 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 |
setPosition(x: number, y: number) Sets the position of the element. |
|
public |
Sets the scale of the element. |
|
public |
Sets the z-index of the element. |
|
private |
resize() Function called when the canvas gets resized. |
|
private |
Sets the world object where element will be drawn. |
|
private |
Sets the element as a topmost element. |
Public Constructors
public constructor(opts: object) source
Override:
WorldElement#constructorParams:
Name | Type | Attribute | Description |
opts | object |
|
Object that contains valid Box 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 color: object source
Sets the color of the Box. The color must have the format as in BOX_COLORS. The default value is BOX_COLORS.BLUE.
Override:
WorldElement#colorpublic debug: boolean source
Flag for displaying debug rectangles around the elements inside the Box. Default value is false.
public elements: Label[] | Text[] | Graph[] source
Sets an array where all elements inside the Box are stored. Default value is []
public height: number source
Sets the height of the Box in pixels. Default value is 0.
Override:
WorldElement#heightpublic isDraggable: boolean source
Flag for allowing the Box to be dragged around. Default value is true.
Override:
WorldElement#isDraggablepublic mouseMoveStyle: string source
Sets the move style of the Box to change by pixels rather than by units. Default value is MOVE_STYLE.BY_PX.
Override:
WorldElement#mouseMoveStylepublic width: number source
Sets the width of the Box in pixels. Default value is 0.
Override:
WorldElement#widthPublic Methods
public addGraph(width: number, height: number, opts: object): Graph source
Adds a Graph to the Box.
Params:
Name | Type | Attribute | Description |
width | number | Width of the Graph in pixels. |
|
height | number | Height of the Graph in pixels. |
|
opts | object |
|
Object that contains valid Graph 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 addLabel(width: number, height: number, opts: object): Label source
Adds a Label to the Box.
Params:
Name | Type | Attribute | Description |
width | number | Width of the Label in pixels. |
|
height | number | Height of the Label in pixels. |
|
opts | object |
|
Object that contains valid Label 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 addText(width: number, height: number, opts: object): Text source
Adds a Text to the Box.
Params:
Name | Type | Attribute | Description |
width | number | Width of the Text in pixels. |
|
height | number | Height of the Text in pixels. |
|
opts | object |
|
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 calculateDimensions() source
Since the box takes the dimensions of the objects it contains, this function calculates these dimensions. The function must be called after setting the dimensions of the objects it contains.
public setPadding(top: number, right: number, bottom: number, left: number) source
Sets the padding of the Box object.
Private Methods
private isMouseOver(): boolean source
Tests if the mouse is over the box.