ActivityPanel

Extends: module:AWT.Container

Source: Activity.js:868

This object is responsible for rendering the contents of the activity on the screen and
managing user's interaction.
Each type of Activity must implement its own ActivityPanel.
In JClic, Activity.Panel
extends javax.swing.JPanel.
On this implementation, the JPanel will be replaced by an HTML div tag.


Constructor

new ActivityPanel( act: module:Activity.Activity, ps: module:JClicPlayer.JClicPlayer, $div?: external:jQuery, ): ActivityPanel

ActivityPanel constructor

Parameters


Instance Methods

setBounds(rect: module:AWT.Rectangle)

Overrides: module:AWT.Container#setBounds

Sets the size and position of this activity panel

Parameters

buildVisualComponents()

Prepares the visual components of the activity

updateContent(dirtyRegion: module:AWT.Rectangle)

Overrides: module:AWT.Container#updateContent

Activities should implement this method to update the graphic content of its panel. The method
will be called from module:AWT.Container#update when needed.

Parameters

  • dirtyRegion (module:AWT.Rectangle) — Specifies the area to be updated. When null,
    it's the whole panel.

playEvent(event: string)

Plays the specified event sound

Parameters

  • event (string) — The type of event to be performed

initActivity()

Basic initialization procedure, common to all activities.

startActivity()

Called when the activity starts playing

activityReady()

Called by JClicPlayer when this activity panel is fully visible, just after the
initialization process.

showHelp()

Displays help about the activity

setDimension( maxSize: module:AWT.Dimension, ): module:AWT.Dimension

Sets the real dimension of this ActivityPanel.

Parameters

Returns

attachEvents()

Attaches the events specified in the events member to the $div member

attachEvent($obj: external:jQuery, evt: string)

Attaches a single event to the specified object

Parameters

  • $obj (external:jQuery) — The object to which the event will be attached
  • evt (string) — The event name

processEvent(event: external:Event): boolean

Main handler used to process mouse, touch, keyboard and edit events.

Parameters

Returns

  • boolean

fitTo( proposed: module:AWT.Rectangle, bounds: module:AWT.Rectangle, )

Fits the panel within the proposed rectangle. The panel can occupy more space, but always
not surpassing the bounds rectangle.

Parameters

buildAccessibleComponents()

Builds the accessible components needed for this ActivityPanel
This method is called when all main elements are placed and visible, when the activity is ready
to start or when resized.

forceFinishActivity()

Forces the ending of the activity.

finishActivity(result: boolean)

Ordinary ending of the activity, usually called form processEvent

Parameters

  • result (boolean) — true if the activity was successfully completed, false otherwise

setAndPlayMsg(msgCode: string, eventSoundsCode?: string)

Sets the message to be displayed in the skin message box and optionally plays a sound event.

Parameters

  • msgCode (string) — Type of message (initial, final, finalError...)
  • eventSoundsCode (string, optional) — Optional name of the event sound to be played.

end()

Ends the activity

clear()

Miscellaneous cleaning operations

enableCounters( eTime: boolean, eScore: boolean, eActions: boolean, )

Enables or disables the three counters (time, score and actions)

Parameters

  • eTime (boolean) — Whether to enable or disable the time counter
  • eScore (boolean) — Whether to enable or disable the score counter
  • eActions (boolean) — Whether to enable or disable the actions counter

shuffle( bg: Array.<module:boxes/ActiveBoxBag.ActiveBoxBag>, visible: boolean, fitInArea: boolean, )

Shuffles the contents of the activity

Parameters

  • bg (Array.<module:boxes/ActiveBoxBag.ActiveBoxBag>) — The sets of boxes to be shuffled
  • visible (boolean) — The shuffle process must be animated on the screen (not yet implemented!)
  • fitInArea (boolean) — Shuffled pieces cannot go out of the current area

invalidate(rect: module:AWT.Rectangle)

Inherited from module:AWT.Container#invalidate

Overrides: module:AWT.Container#invalidate

Adds the provided rectangle to the invalidated area.

Parameters

update()

Inherited from module:AWT.Container#update

Overrides: module:AWT.Container#update

Updates the invalidated area

getBounds(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#getBounds

Overrides: module:AWT.Container#getBounds

Gets the enclosing Rectangle of this Shape.

Returns

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

Inherited from module:AWT.Rectangle#equals

Overrides: module:AWT.Container#equals

Checks if two shapes are equivalent.

Parameters

Returns

  • boolean

clone(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#clone

Overrides: module:AWT.Container#clone

Clones this Rectangle

Returns

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

Inherited from module:AWT.Rectangle#scaleBy

Overrides: module:AWT.Container#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.Container#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.Container#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.Container#add

Adds the boundaries of another shape to the current one

Parameters

Returns

getCoords(): string

Inherited from module:AWT.Rectangle#getCoords

Overrides: module:AWT.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#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.Container#isRect

Shorthand method for determining if a Shape is an Rectangle

Returns

  • boolean

toString(): string

Inherited from module:AWT.Shape#toString

Overrides: module:AWT.Container#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

act: module:Activity.Activity

The Activity this panel is related to

$div: external:jQuery

The jQuery div element used by this panel

$canvas: external:jQuery

The jQuery main canvas element used by this panel

accessibleCanvas: boolean

Always true, since canvas hit regions have been deprecated!
See: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility

skin: module:skins/Skin.Skin

The realized current Skin

$animatedBg: external:jQuery

Background element (currently a span) used to place animated GIFs when needed

$animatedBgB: external:jQuery

Additional background element for animated GIFs, used in associations

solved: boolean

true when the activity is solved, false otherwise

bgImage: external:HTMLImageElement

The realized image used as a background

playing: boolean

true while the activity is playing

firstRun: boolean

true if the activity is running for first time (not due to a click on the replay button)

currentItem: number

Currently selected item. Used in some types of activities.

bc: module:boxes/BoxConnector.BoxConnector

The object used to connect cells and other elements in some types of activity

ps: module:JClicPlayer.JClicPlayer

The PlayStation used to realize media objects and communicate with the player services
(usually a JClicPlayer

minimumSize: module:AWT.Dimension

The minimum size of this kind of ActivityPanel

preferredSize: module:AWT.Dimension

The preferred size of this kind of ActivityPanel

events: Array.<string>

List of events intercepted by this ActivityPanel. Current events are: 'keydown', 'keyup',
'keypress', 'mousedown', 'mouseup', 'click', 'dblclick', 'mousemove', 'mouseenter',
'mouseleave', 'mouseover', 'mouseout', 'touchstart', 'touchend', 'touchmove' and 'touchcancel'.

invalidatedRect: module:AWT.Rectangle

Inherited from module:AWT.Container#invalidatedRect

Overrides: module:AWT.Container#invalidatedRect

The currently "invalidated" area

type: string

Inherited from module:AWT.Rectangle#type

Overrides: module:AWT.Container#type

Shape type id

dim: module:AWT.Dimension

Inherited from module:AWT.Rectangle#dim

Overrides: module:AWT.Container#dim

The Dimension of the Rectangle

pos: module:AWT.Point

Inherited from module:AWT.Shape#pos

Overrides: module:AWT.Container#pos

The current position of the shape