Constructor
new ActiveBoxBag(parentopt, containeropt, boxBaseopt)
ActiveBoxBag constructor
Name | Type | Attributes | Description |
---|---|---|---|
parent | module:boxes/AbstractBox. | <optional> | The AbstractBox to which this box bag belongs |
container | module:AWT. | <optional> | The container where this box bag is placed. |
boxBase | module:boxes/BoxBase. | <optional> | The object where colors, fonts, border and other graphic properties |
- Source
Extends
Members
$accessibleDiv :external:jQuery
div
containing the accessible elements associated to this ActiveBoxBag
- Source
$accessibleElement :external:jQuery
DOM element used to display this cell content in wai-aria contexts
- Source
$hostedComponent :external:jQuery
An external JQuery DOM element hosted by this box
- Source
accessibleAlwaysActive :boolean
Flag indicating that $accessibleElement should be always active
- boolean
- Source
accessibleText :string
Text to be used in accessible contexts
- string
- Source
alternative :boolean
Whether this box must be displayed with alternative or regular color and font settings
- boolean
- Source
backgroundBox :module:boxes/AbstractBox.AbstractBox
An optional box used as a background by this BoxBag
- Source
border :boolean
Whether this box has a border or not
- boolean
- Overrides
- Source
boxBase :module:boxes/BoxBase.BoxBase
The BoxBase
related to this AbstractBox. When null
, the parent can provide an
alternative one.
- Overrides
- Source
cells :Array.<module:boxes/AbstractBox.AbstractBox>
The array of cells
- Overrides
- Source
container :module:AWT.Container
The Container to which this AbstractBox belongs
- Overrides
- Source
dim :module:AWT.Dimension
The Dimension
of the Rectangle
- Overrides
focused :boolean
Whether this box holds the input focus
- boolean
- Overrides
- Source
inactive :boolean
Whether this box is active or inactive
- boolean
- Overrides
- Source
inverted :boolean
Whether this box must be displayed with inverted or regular colors
- boolean
- Overrides
- Source
marked :boolean
Whether this box is marked (selected) or not
- boolean
- Overrides
- Source
parent :module:boxes/AbstractBox.AbstractBox
The parent AbstractBox (can be null
)
- Overrides
- Source
pos :module:AWT.Point
The current position of the shape
- Overrides
preferredBounds :module:AWT.Rectangle
Rectangle containing the preferred bounds of the BoxBag
- Source
role :string
Describes the main role of this box on the activity. Useful in wai-aria descriptions.
- string
- Overrides
- Source
shape :module:AWT.Shape
The shape of this box (the box Rectangle or a special Shape, if set)
- Overrides
- Source
specialShape :boolean
Whether this box has a shape that is not a rectangle
- boolean
- Source
temporaryHidden :boolean
Used to temporary hide a box while other drawing operations are done
- boolean
- Source
tmpTrans :boolean
Cells with this attribute will be transparent but with painted border
- boolean
- Overrides
- Source
type :string
Shape type id
- string
- Overrides
visible :boolean
Whether this box is visible or not
- boolean
- Overrides
- Source
Methods
add(shape) → {module:AWT.Rectangle}
Adds the boundaries of another shape to the current one
Name | Type | Description |
---|---|---|
shape | module:AWT. | The |
- Overrides
- Type:
- module:AWT.
Rectangle
addActiveBox(bx)
Adds an ActiveBox
to this bag
Name | Type | Description |
---|---|---|
bx | module:boxes/ActiveBox. | The ActiveBox to be added to this bag |
- Source
addBox(bx)
Adds an AbstractBox
to the collection of cells
Name | Type | Description |
---|---|---|
bx | module:boxes/AbstractBox. | The box to add |
- Overrides
- Source
boxIndex(bx) → {number}
Returns the index of a specific box in the cells
array
Name | Type | Description |
---|---|---|
bx | module:boxes/AbstractBox. |
- Overrides
- Source
- Type:
- number
buildAccessibleElements($canvas, $clickReceiver, eventTypeopt) → {external:jQuery}
Builds a group of hidden buton
elements that will act as a accessible objects associated
to the canvas area of this ActiveBoxBag.
The buttons will only be created when CanvasRenderingContext2D
has a method named addHitRegion
.
See https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility
for more information and supported browsers.
Name | Type | Attributes | Description |
---|---|---|---|
$canvas | external:jQuery | The | |
$clickReceiver | external:jQuery | The DOM element that will be notified when a button is clicked. | |
eventType | string | <optional> | Type of event sent to $clickReceiver. Default is |
- Source
- The $accessibleDiv member, containing the accessible elements associated to this ActiveBoxBag.
- Type:
- external:jQuery
cellIsAtEquivalentPlace(bx, checkCase) → {boolean}
Checks if the place occupied by a cell corresponds to a cell with equivalent content.
Name | Type | Description |
---|---|---|
bx | module:boxes/ActiveBox. | The box to check |
checkCase | boolean | If |
- Source
- Type:
- boolean
clearAll()
Clears the content of all boxes and background box
- Source
clearAllBoxes()
Clears the content of all boxes
- Source
clip(ctx, fillRuleopt) → {external:CanvasRenderingContext2D}
Creates a clipping region on the specified HTML canvas 2D rendering context
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ctx | external:CanvasRenderingContext2D | The rendering context | ||
fillRule | string | <optional> | 'nonzero' | Can be 'nonzero' (default when not set) or 'evenodd' |
- Overrides
- The provided rendering context
clone() → {module:AWT.Rectangle}
Clones this Rectangle
- Overrides
- Type:
- module:AWT.
Rectangle
countCellsAtEquivalentPlace(checkCase) → {number}
Count the number of cells that are at its original place or equivalent
Name | Type | Description |
---|---|---|
checkCase | boolean |
|
- Source
- Type:
- number
countCellsAtPlace() → {number}
Count the number of cells that are at its original place
- Source
- Type:
- number
countCellsWithIdAss(idAss) → {number}
Counts the number of cells that have the provided idAss
attribute
Name | Type | Description |
---|---|---|
idAss | number | The |
- Source
- Type:
- number
countInactiveCells() → {number}
Count the number of cells of this BoxBag that are in "inactive" state
- Source
- Type:
- number
drawBorder(ctx)
Draws the box border
Name | Type | Description |
---|---|---|
ctx | external:CanvasRenderingContext2D | The canvas rendering context where the border |
- Source
end()
Finisher method
- Overrides
- Source
equals(r) → {boolean}
Checks if two shapes are equivalent.
Name | Type | Description |
---|---|---|
r | module:AWT. | The Shape to compare against |
- Overrides
- Type:
- boolean
fill(ctx, dirtyRegionopt) → {external:CanvasRenderingContext2D}
Fills the Shape with the current style in the provided HTML canvas context
Name | Type | Attributes | Description |
---|---|---|---|
ctx | external:CanvasRenderingContext2D | The canvas 2D rendering context where to fill this shape. | |
dirtyRegion | module:AWT. | <optional> | The context region to be updated. Used as clipping |
- Overrides
- The provided rendering context
findActiveBox(point) → {module:boxes/ActiveBox.ActiveBox}
Finds an ActiveBox by location
Name | Type | Description |
---|---|---|
point | module:AWT. | The location to search for |
- Source
findBox(p) → {module:boxes/AbstractBox.AbstractBox}
Finds the first visible AbstractBox
located under the specified point
Name | Type | Description |
---|---|---|
p | module:AWT. |
- Overrides
- Source
fitCellsInArea(boxes)
Fits cells inside the ActiveBoxBag area. Useful when non-rectangular cells exchange its positions.
Name | Type | Description |
---|---|---|
boxes | Array.<module:boxes/ActiveBox.ActiveBox> | The boxes to be checked |
- Source
getActiveBox(idLoc) → {module:boxes/ActiveBox.ActiveBox}
Finds an ActiveBox by its relative location (idLoc
field)
Name | Type | Description |
---|---|---|
idLoc | number |
- Source
getActiveBoxWithIdLoc(idLoc) → {module:boxes/ActiveBox.ActiveBox}
Finds the ActiveBox
that has the specified idLoc
attribute
Name | Type | Description |
---|---|---|
idLoc | number | The idLoc to search for |
- Source
getAttributes() → {object}
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.
- The resulting object, with minimal attrributes
- Type:
- object
getBackgroundActiveBox() → {module:boxes/ActiveBox.ActiveBox}
Gets the background box
- Source
getBackgroundBox() → {module:boxes/AbstractBox.AbstractBox}
Gets the background box
- Source
getBorderBounds() → {module:AWT.Rectangle}
Returns the enclosing Rectangle of this box including its border (if any)
- Source
- Type:
- module:AWT.
Rectangle
getBounds() → {module:AWT.Rectangle}
Gets the enclosing Rectangle
of this Shape.
- Overrides
- Type:
- module:AWT.
Rectangle
getBox(n) → {module:boxes/AbstractBox.AbstractBox}
Returns the box at a specific index in the cells
array
Name | Type | Description |
---|---|---|
n | number | The index |
- Overrides
- Source
getBoxBaseResolve() → {module:boxes/BoxBase.BoxBase}
Gets the real BoxBase
associated to this box, scanning down parent relationships.
- Source
getContainerResolve() → {module:AWT.Container}
Gets the container associated to this box, asking its parents when null
.
- Source
- Type:
- module:AWT.
Container
getContainerX() → {module:AWT.Container}
Gets the container
attribute of this box, without checking its parent
- Source
- Type:
- module:AWT.
Container
getCoords() → {string}
Gets a string with the co-ordinates of the upper-left and lower-right vertexs of this rectangle,
(with values rounded to int)
- Overrides
- Type:
- string
getHostedComponent() → {external:jQuery}
Gets the current $hostedComponent
member
- Source
- Type:
- external:jQuery
getMinimumSize() → {module:AWT.Dimension}
Gets the minimum size requested by this BoxBag
- Source
- Type:
- module:AWT.
Dimension
getNextItem(currentItem, idAssValidopt) → {number}
Gets the index of box located in the cells
array after the provided index, having the
provided idAssValid
value as idAss
attribute.
When idAssValid
is null
or undefined
, search for the next cell with idAss>0
Name | Type | Attributes | Description |
---|---|---|---|
currentItem | number | The index after to which start scanning | |
idAssValid | string | <optional> | The |
- Source
- Type:
- number
getNumCells() → {number}
Returns the number of cells stored in this BoxBag
- Source
- Type:
- number
getOppositeVertex() → {module:AWT.Point}
Gets the module:AWT.Point
corresponding to the lower-right vertex of the Rectangle.
- Type:
- module:AWT.
Point
getParent() → {module:boxes/AbstractBox.AbstractBox}
Gets the current parent of this box
- Overrides
- Source
getPreferredSize() → {module:AWT.Dimension}
Gets the preferred size of this BoxBag
- Source
- Type:
- module:AWT.
Dimension
getScaledSize(scale) → {module:AWT.Dimension}
Scales the current size of this box bag, multiplying all values by a specific factor
Name | Type | Description |
---|---|---|
scale | number | The scale factor |
- Source
- Type:
- module:AWT.
Dimension
getShape() → {module:AWT.Shape}
Gets the current shape used in this box
- Overrides
- Source
- Type:
- module:AWT.
Shape
grow(dx, dy) → {module:AWT.Rectangle}
Expands the boundaries of this shape. This affects the current position and dimension.
Name | Type | Description |
---|---|---|
dx | number | The amount to grow (or decrease) in horizontal direction |
dy | number | The amount to grow (or decrease) in vertical direction |
- Overrides
- Type:
- module:AWT.
Rectangle
hasBorder() → {boolean}
Checks if this box has border
- Overrides
- Source
- Type:
- boolean
intersects(_r) → {boolean}
Checks if the provided Rectangle
r
intersects with this shape.
Name | Type | Description |
---|---|---|
_r | module:AWT. |
- Type:
- boolean
invalidate(rect)
Invalidates the zone corresponding to this box in the associated module:AWT.Container
, if any.
Name | Type | Description |
---|---|---|
rect | module:AWT. | The rectangle to be invalidated. When |
- Source
isAlternative() → {boolean}
Checks if this box is in alternative
state.
- Source
- Type:
- boolean
isFocused() → {boolean}
Checks if this box has the input focus
- Overrides
- Source
- Type:
- boolean
isInactive() → {boolean}
Checks if this box is currently inactive.
- Source
- Type:
- boolean
isInverted() → {boolean}
Checks if this box is in inverted
state.
- Source
- Type:
- boolean
isMarked() → {boolean}
Checks if this box is marked
- Overrides
- Source
- Type:
- boolean
isRect() → {boolean}
Shorthand method for determining if a Shape is an Rectangle
- Overrides
- Type:
- boolean
isTemporaryHidden() → {boolean}
Checks if this box is temporary hidden
- Source
- Type:
- boolean
isVisible() → {boolean}
Checks if this box is fully visible
- Overrides
- Source
- Type:
- boolean
moveBy(dx, dy)
Sets a new location to this box. In JClic this method was named translate
.
Name | Type | Description |
---|---|---|
dx | number | The displacement on the X axis |
dy | number | The displacement on the Y axis |
- Overrides
- Source
moveTo(newPos, yopt)
Sets a new location for this box. In JClic this method was named setLocation
Name | Type | Attributes | Description |
---|---|---|---|
newPos | AWT. | A point or the | |
y | number | <optional> | The |
- Overrides
- Source
preparePath(ctx) → {external:CanvasRenderingContext2D}
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.
Name | Type | Description |
---|---|---|
ctx | external:CanvasRenderingContext2D |
- The provided rendering context
recalcSize()
Recalculates the total size of this BoxBag (useful after direct additions o deletions of
elements in the cells
array).
Updates preferredBounds
and the current position and size of the box bag.
- Source
resetIds()
Resets the IDs of all cells
- Source
scaleBy(delta) → {module:AWT.Rectangle}
Multiplies the dimension of the Shape by the specified delta
amount.
Name | Type | Description |
---|---|---|
delta | Point | | Object containing the X and Y ratio to be scaled. |
- Overrides
- Type:
- module:AWT.
Rectangle
setAttributes(data) → {module:AWT.Rectangle}
Reads the properties of this Rectangle from a data object
Name | Type | Description |
---|---|---|
data | object | The data object to be parsed |
- Type:
- module:AWT.
Rectangle
setBackgroundBox(bx)
Sets the background box
Name | Type | Description |
---|---|---|
bx | module:boxes/AbstractBox. |
- Source
setBoxBase(boxBase)
Sets the BoxBase
of this box
Name | Type | Description |
---|---|---|
boxBase | module:boxes/BoxBase. | The new BoxBase |
- Source
setCellAttr(key, value)
Sets the specified key - value pair to all cells of this bag.
Name | Type | Description |
---|---|---|
key | string | The key to be established |
value | any | The value, of any type |
- Source
setContainer(newContainer)
Setter method for container
Name | Type | Description |
---|---|---|
newContainer | module:AWT. | The new Container assigned to this box |
- Source
setContent(abc, altAbcopt, fromIndexopt, toCellopt, numCellsopt)
Sets the content of members of this ActiveBoxBag, based on one or more ActiveBagContent
objects.
Name | Type | Attributes | Description |
---|---|---|---|
abc | module:boxes/ActiveBagContent. | The main bag of content | |
altAbc | module:boxes/ActiveBagContent. | <optional> | The alternative bag of content |
fromIndex | number | <optional> | Starts taking the cell content located at this position on the bag |
toCell | number | <optional> | Starts filling the box located at this position on the ActiveBoxBag |
numCells | number | <optional> | Acts only with a limited number of elements. |
- Source
setDefaultIdAss()
Resets the default idAss
attribute on all cells
- Source
setFocused(newVal)
Sets or unsets the input focus to this box.
Name | Type | Description |
---|---|---|
newVal | boolean |
- Source
setHostedComponent($hc)
Sets the $hostedComponent
member.
Name | Type | Description |
---|---|---|
$hc | external:jQuery | The jQuery DOM component hosted by this box. |
- Source
setHostedComponentBorder()
Sets the $hostedComponent
border, based on the currentBoxBase
of this box.
- Source
setHostedComponentBounds(_sizeChanged)
Places and resizes $hostedComponent
, based on the size
and position of this box.
Name | Type | Description |
---|---|---|
_sizeChanged | boolean |
|
- Source
setHostedComponentColors()
Sets $hostedComponent
colors and other css properties
based on the current BoxBase
of this box.
- Source
setHostedComponentVisible()
Makes module:boxes/AbstractBox.AbstractBox#$hostedComponent
visible or invisible, based on the value of
the AbstractBox visible
flag.
- Source
setInactive(newVal)
Makes this box active (false
) or inactive (true
)
Name | Type | Description |
---|---|---|
newVal | boolean |
- Source
setInverted(newVal)
Puts this box in inverted
mode or restores its original state.
Name | Type | Description |
---|---|---|
newVal | boolean |
- Source
setMarked(newVal)
Sets this box in marked
mode, or restores its original state.
Name | Type | Description |
---|---|---|
newVal | boolean |
- Overrides
- Source
setParent(parent)
Setter method for parent
Name | Type | Description |
---|---|---|
parent | module:boxes/AbstractBox. | The new parent of this box |
- Overrides
- Source
setShape(sh)
Sets the shape used to draw the content of this box
Name | Type | Description |
---|---|---|
sh | module:AWT. | The shape to be set |
- Overrides
- Source
setSize(width, height)
Changes the size of this box
Name | Type | Description |
---|---|---|
width | number | |
height | number |
- Overrides
- Source
setTemporaryHidden(newVal)
Makes this box temporary hidden (newVal true
) or resets its original state (newVal false
)
Name | Type | Description |
---|---|---|
newVal | boolean |
- Source
shuffleCells(times, fitInArea)
Shuffles the cells
Name | Type | Description |
---|---|---|
times | number | Number of times to shuffle |
fitInArea | boolean | Ensure that all cells are inside the bag rectangle |
- Source
stroke(ctx) → {external:CanvasRenderingContext2D}
Draws this shape in the provided HTML canvas 2D rendering context.
Name | Type | Description |
---|---|---|
ctx | external:CanvasRenderingContext2D | The canvas 2D rendering context where to draw the shape. |
- Overrides
- The provided rendering context
swapCellPositions(bxa, bxb, fitInArea)
Exchange the positions of two cells inside the ActiveBoxBag area.
Name | Type | Description |
---|---|---|
bxa | module:boxes/ActiveBox. | The first box |
bxb | module:boxes/ActiveBox. | The second box |
fitInArea | boolean | Ensure that all cells are inside the bag rectangle |
- Source
toString() → {string}
Overwrites the original 'Object.toString' method with a more descriptive text
- Overrides
- Type:
- string
updateContent(_ctx, _dirtyRegionopt)
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
.
Name | Type | Attributes | Description |
---|---|---|---|
_ctx | external:CanvasRenderingContext2D | The canvas rendering context used to draw the | |
_dirtyRegion | module:AWT. | <optional> | The area that must be repainted. |
- Source