Container

Extends: module:AWT.Rectangle

Source: AWT.js:1978

Logic object that takes care of an "invalidated" rectangle that will be repainted
at the next update of a 2D object, usually an HTML Canvas.
Container has the same constructor options as Rectangle


Constructor

new Container( pos: Point | Rectangle | number | Array.<number>, dim?: Dimension | number, w?: number, h?: number, ): Container

Container constructor

Parameters

  • pos (Point | Rectangle | number | Array.<number>)
  • dim (Dimension | number, optional)
  • w (number, optional)
  • h (number, optional)

Instance Methods

invalidate(rect: module:AWT.Rectangle)

Adds the provided rectangle to the invalidated area.

Parameters

update()

Updates the invalidated area

updateContent(_dirtyRegion: module:AWT.Shape)

Containers should implement this method to update its graphic contents. It should
be called from module:AWT.Container#update

Parameters

  • _dirtyRegion (module:AWT.Shape) — Specifies the area to be updated. When null, it's the whole
    Container.

getBounds(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#getBounds

Overrides: module:AWT.Rectangle#getBounds

Gets the enclosing Rectangle of this Shape.

Returns

setBounds(rect: module:AWT.Rectangle): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#setBounds

Overrides: module:AWT.Rectangle#setBounds

Sets this Rectangle the position and dimension of another one

Parameters

Returns

equals(r: module:AWT.Shape): boolean

Inherited from module:AWT.Rectangle#equals

Overrides: module:AWT.Rectangle#equals

Checks if two shapes are equivalent.

Parameters

Returns

  • boolean

clone(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#clone

Overrides: module:AWT.Rectangle#clone

Clones this Rectangle

Returns

scaleBy(delta: Point | Dimension): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#scaleBy

Overrides: module:AWT.Rectangle#scaleBy

Multiplies the dimension of the Shape by the specified delta amount.

Parameters

  • delta (Point | Dimension) — Object containing the X and Y ratio to be scaled.

Returns

grow(dx: number, dy: number): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#grow

Overrides: module:AWT.Rectangle#grow

Expands the boundaries of this shape. This affects the current position and dimension.

Parameters

  • dx (number) — The amount to grow (or decrease) in horizontal direction
  • dy (number) — The amount to grow (or decrease) in vertical direction

Returns

getOppositeVertex(): module:AWT.Point

Inherited from module:AWT.Rectangle#getOppositeVertex

Overrides: module:AWT.Rectangle#getOppositeVertex

Gets the module:AWT.Point corresponding to the lower-right vertex of the Rectangle.

Returns

add(shape: module:AWT.Shape): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#add

Overrides: module:AWT.Rectangle#add

Adds the boundaries of another shape to the current one

Parameters

Returns

getCoords(): string

Inherited from module:AWT.Rectangle#getCoords

Overrides: module:AWT.Rectangle#getCoords

Gets a string with the co-ordinates of the upper-left and lower-right vertexs of this rectangle,
(with values rounded to int)

Returns

  • string

getAttributes(): object

Inherited from module:AWT.Rectangle#getAttributes

Overrides: module:AWT.Rectangle#getAttributes

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns

  • object

setAttributes(data: object): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#setAttributes

Overrides: module:AWT.Rectangle#setAttributes

Reads the properties of this Rectangle from a data object

Parameters

  • data (object) — The data object to be parsed

Returns

moveBy(delta: Point | Dimension): module:AWT.Shape

Inherited from module:AWT.Shape#moveBy

Overrides: module:AWT.Rectangle#moveBy

Shifts the shape a specified amount in horizontal and vertical directions

Parameters

Returns

moveTo(newPos: module:AWT.Point): module:AWT.Shape

Inherited from module:AWT.Shape#moveTo

Overrides: module:AWT.Rectangle#moveTo

Moves this shape to a new position

Parameters

Returns

getShape(rect: module:AWT.Rectangle): module:AWT.Shape

Inherited from module:AWT.Shape#getShape

Overrides: module:AWT.Rectangle#getShape

Gets a clone of this shape moved to the pos component of the rectangle and scaled
by its dim value.

Parameters

  • rect (module:AWT.Rectangle) — The rectangle to be taken as a base for moving and scaling
    this shape.

Returns

contains(_p: module:AWT.Point): boolean

Inherited from module:AWT.Shape#contains

Overrides: module:AWT.Rectangle#contains

Checks if the provided module:AWT.Point is inside this shape.

Parameters

Returns

  • boolean

intersects(_r: module:AWT.Rectangle): boolean

Inherited from module:AWT.Shape#intersects

Overrides: module:AWT.Rectangle#intersects

Checks if the provided Rectangle r intersects with this shape.

Parameters

Returns

  • boolean

fill( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#fill

Overrides: module:AWT.Rectangle#fill

Fills the Shape with the current style in the provided HTML canvas context

Parameters

Returns

stroke( ctx: external:CanvasRenderingContext2D, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#stroke

Overrides: module:AWT.Rectangle#stroke

Draws this shape in the provided HTML canvas 2D rendering context.

Parameters

Returns

preparePath( ctx: external:CanvasRenderingContext2D, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#preparePath

Overrides: module:AWT.Rectangle#preparePath

Prepares an HTML canvas 2D rendering context with a path that can be used to stroke a line,
to fill a surface or to define a clipping region.

Parameters

Returns

clip( ctx: external:CanvasRenderingContext2D, fillRule?: string, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#clip

Overrides: module:AWT.Rectangle#clip

Creates a clipping region on the specified HTML canvas 2D rendering context

Parameters

  • ctx (external:CanvasRenderingContext2D) — The rendering context
  • fillRule (string, optional, default: "'nonzero'") — Can be 'nonzero' (default when not set) or 'evenodd'

Returns

isRect(): boolean

Inherited from module:AWT.Shape#isRect

Overrides: module:AWT.Rectangle#isRect

Shorthand method for determining if a Shape is an Rectangle

Returns

  • boolean

toString(): string

Inherited from module:AWT.Shape#toString

Overrides: module:AWT.Rectangle#toString

Overwrites the original 'Object.toString' method with a more descriptive text

Returns

  • string

Static Methods

buildShape(data: object): module:AWT.Shape

Inherited from module:AWT.Shape

Builds a shape based on the provided data object.
Data should contain a 'type' member, specifying the type of shape requested ('rect', 'ellipse', 'rectangle' or 'path')

Parameters

  • data (object) — Specific data for this shape

Returns

Instance Fields

invalidatedRect: module:AWT.Rectangle

The currently "invalidated" area

type: string

Inherited from module:AWT.Rectangle#type

Overrides: module:AWT.Rectangle#type

Shape type id

dim: module:AWT.Dimension

Inherited from module:AWT.Rectangle#dim

Overrides: module:AWT.Rectangle#dim

The Dimension of the Rectangle

pos: module:AWT.Point

Inherited from module:AWT.Shape#pos

Overrides: module:AWT.Rectangle#pos

The current position of the shape