AbstractBox

Extends: module:AWT.Rectangle

Source: AbstractBox.js:44

Modifiers: abstract

This abstract class is the base for most graphic components of JClic. It describes an area
(by default an module:AWT.Rectangle) with some special properties that determine how it must
be drawn on screen.

Some types of boxes can act as containers for other boxes, establishing a hierarchy of dependences.


Constructor

new AbstractBox( parent: module:AbstractBox, container: module:AWT.Container, boxBase: module:BoxBase, ): AbstractBox

AbstractBox constructor

Parameters

  • parent (module:AbstractBox) — The AbstractBox to which this one belongs
  • container (module:AWT.Container) — The container where this box is placed.
  • boxBase (module:BoxBase) — The object where colors, fonts, border and other graphic properties
    of this box are defined.

Instance Methods

setParent(parent: module:boxes/AbstractBox.AbstractBox)

Setter method for parent

Parameters

getParent(): module:boxes/AbstractBox.AbstractBox

Gets the current parent of this box

Returns

end()

Finisher method

setContainer(newContainer: module:AWT.Container)

Setter method for container

Parameters

getContainerX(): module:AWT.Container

Gets the container attribute of this box, without checking its parent

Returns

getContainerResolve(): module:AWT.Container

Gets the container associated to this box, asking its parents when null.

Returns

invalidate(rect: module:AWT.Rectangle)

Invalidates the zone corresponding to this box in the associated module:AWT.Container, if any.

Parameters

  • rect (module:AWT.Rectangle) — The rectangle to be invalidated. When null, it's the full
    container area.

setBoxBase(boxBase: module:boxes/BoxBase.BoxBase)

Sets the BoxBase of this box

Parameters

getBoxBaseResolve(): module:boxes/BoxBase.BoxBase

Gets the real BoxBase associated to this box, scanning down parent relationships.

Returns

setShape(sh: module:AWT.Shape)

Sets the shape used to draw the content of this box

Parameters

getShape(): module:AWT.Shape

Overrides: module:AWT.Rectangle#getShape

Gets the current shape used in this box

Returns

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

Check if this box contains the specified point

Parameters

Returns

  • boolean

setBounds( rect: AWT.Rectangle | number, y?: number, w?: number, h?: number, )

Sets a new size and/or dimension to this box

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

moveTo(newPos: AWT.Point | number, y?: number)

Overrides: module:AWT.Rectangle#moveTo

Sets a new location for this box. In JClic this method was named setLocation

Parameters

  • newPos (AWT.Point | number) — A point or the x coordinate of a new point.
  • y (number, optional) — The y coordinate of a new point.

moveBy(dx: number, dy: number)

Overrides: module:AWT.Rectangle#moveBy

Sets a new location to this box. In JClic this method was named translate.

Parameters

  • dx (number) — The displacement on the X axis
  • dy (number) — The displacement on the Y axis

setSize(width: number, height: number)

Changes the size of this box

Parameters

  • width (number)
  • height (number)

hasBorder(): boolean

Checks if this box has border

Returns

  • boolean

setBorder(newVal: boolean)

Sets/unsets a border to this box

Parameters

  • newVal (boolean) — true to set a border.

isVisible(): boolean

Checks if this box is fully visible

Returns

  • boolean

setVisible(newVal: boolean)

Sets this box visible or invisible

Parameters

  • newVal (boolean) — true for visible

setHostedComponentVisible()

Makes module:boxes/AbstractBox.AbstractBox#$hostedComponent visible or invisible, based on the value of
the AbstractBox visible flag.

isTemporaryHidden(): boolean

Checks if this box is temporary hidden

Returns

  • boolean

setTemporaryHidden(newVal: boolean)

Makes this box temporary hidden (newVal true) or resets its original state (newVal false)

Parameters

  • newVal (boolean)

isInactive(): boolean

Checks if this box is currently inactive.

Returns

  • boolean

setInactive(newVal: boolean)

Makes this box active (false) or inactive (true)

Parameters

  • newVal (boolean)

isInverted(): boolean

Checks if this box is in inverted state.

Returns

  • boolean

setInverted(newVal: boolean)

Puts this box in inverted mode or restores its original state.

Parameters

  • newVal (boolean)

isMarked(): boolean

Checks if this box is marked

Returns

  • boolean

setMarked(newVal: boolean)

Sets this box in marked mode, or restores its original state.

Parameters

  • newVal (boolean)

isFocused(): boolean

Checks if this box has the input focus

Returns

  • boolean

setFocused(newVal: boolean)

Sets or unsets the input focus to this box.

Parameters

  • newVal (boolean)

isAlternative(): boolean

Checks if this box is in alternative state.

Returns

  • boolean

setAlternative(newVal: boolean)

Sets this box in alternative mode, or restores its original state.

Parameters

  • newVal (boolean)

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

Draws the content of this box on an HTML canvas element. At this level, only background
and border are painted/stroked. Derived classes should implement specific drawing tasks in
module:boxes/AbstractBox.AbstractBox#updateContent.

Parameters

updateContent( _ctx: external:CanvasRenderingContext2D, _dirtyRegion?: module:AWT.Rectangle, )

Here is where classes derived from AbstractBox should implement the drawing of its
content. Background and border are already painted in module:boxes/AbstractBox.AbstractBox#update.

Parameters

drawBorder(ctx: external:CanvasRenderingContext2D)

Draws the box border

Parameters

getBorderBounds(): module:AWT.Rectangle

Returns the enclosing Rectangle of this box including its border (if any)

Returns

setHostedComponent($hc: external:jQuery)

Sets the $hostedComponent member.

Parameters

getHostedComponent(): external:jQuery

Gets the current $hostedComponent member

Returns

setHostedComponentColors()

Sets $hostedComponent colors and other css properties
based on the current BoxBase of this box.

setHostedComponentBorder()

Sets the $hostedComponent border, based on the current
BoxBase of this box.

setHostedComponentBounds(_sizeChanged: boolean)

Places and resizes $hostedComponent, based on the size
and position of this box.

Parameters

  • _sizeChanged (boolean) — true when this ActiveBox has changed its size

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: AWT.Rectangle | number, y?: number, w?: number, h?: number, ): module:AWT.Rectangle

Inherited from module:boxes/AbstractBox.AbstractBox#setBounds

Overrides: module:AWT.Rectangle#setBounds

Sets a new size and/or dimension to this box

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

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

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

Inherited from module:AWT.Shape#contains

Overrides: module:AWT.Rectangle#contains

Check if this box contains the specified point

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

setBounds( rect: AWT.Rectangle | number, y?: number, w?: number, h?: number, ): module:AWT.Rectangle

Inherited from module:boxes/AbstractBox.AbstractBox#setBounds

Overrides: module:AWT.Rectangle#setBounds

Sets a new size and/or dimension to this box

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

Returns

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

Inherited from module:AWT.Shape#contains

Overrides: module:AWT.Rectangle#contains

Check if this box contains the specified point

Parameters

Returns

  • boolean

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

parent: module:boxes/AbstractBox.AbstractBox

The parent AbstractBox (can be null)

container: module:AWT.Container

The Container to which this AbstractBox belongs

boxBase: module:boxes/BoxBase.BoxBase

The BoxBase related to this AbstractBox. When null, the parent can provide an
alternative one.

border: boolean

Whether this box has a border or not

shape: module:AWT.Shape

The shape of this box (the box Rectangle or a special Shape, if set)

specialShape: boolean

Whether this box has a shape that is not a rectangle

visible: boolean

Whether this box is visible or not

temporaryHidden: boolean

Used to temporary hide a box while other drawing operations are done

tmpTrans: boolean

Cells with this attribute will be transparent but with painted border

inactive: boolean

Whether this box is active or inactive

inverted: boolean

Whether this box must be displayed with inverted or regular colors

alternative: boolean

Whether this box must be displayed with alternative or regular color and font settings

marked: boolean

Whether this box is marked (selected) or not

focused: boolean

Whether this box holds the input focus

accessibleText: string

Text to be used in accessible contexts

role: string

Describes the main role of this box on the activity. Useful in wai-aria descriptions.

$accessibleElement: external:jQuery

DOM element used to display this cell content in wai-aria contexts

accessibleAlwaysActive: boolean

Flag indicating that $accessibleElement should be always active

$hostedComponent: external:jQuery

An external JQuery DOM element hosted by this box

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