TextGrid
Extends: module:boxes/AbstractBox.AbstractBox
Source: TextGrid.js:67
This class is a special type of AbstractBox that displays a grid of single
characters.
It's used CrossWord and WordSearch activities.
Constructor
new TextGrid(
parent: module:boxes/AbstractBox.AbstractBox,
container: module:AWT.Container,
boxBase: module:boxes/BoxBase.BoxBase,
x: number,
y: number,
ncw: number,
nch: number,
cellW: number,
cellH: number,
border: boolean,
): TextGridTextGrid constructor
Parameters
parent(module:boxes/AbstractBox.AbstractBox) — The AbstractBox to which this text grid belongscontainer(module:AWT.Container) — The container where this text grid is placed.boxBase(module:boxes/BoxBase.BoxBase) — The object where colors, fonts, border and other graphic propertiesx(number) —Xcoordinate of the upper left corner of this gridy(number) —Ycoordinate of the upper left corner of this gridncw(number) — Number of columns of the gridnch(number) — Nomber of rows of the gridcellW(number) — Width of the cellscellH(number) — Height of the cellsborder(boolean) — Whentrue, a border must be drawn between the cells
Instance Methods
setChars(text: string)
Sets the characters to be placed in the cells of this TextGrid
Parameters
text(string)
randomize()
Substitutes the current content of all cells with wildcards with a randomly generated char.
- See:
- TextGridContent#randomChars
setCellAttributes(lockWild: boolean, clearChars: boolean)
Clears or sets global attributes to all cells
Parameters
lockWild(boolean) — Whentrue, the wildcard cells will be marked with special
attributes (used in CrossWords to mark black cells)clearChars(boolean) — Whentrue, the current content of cells will be erased.
setCellLocked(px: number, py: number, locked: boolean)
Sets or unsets the locked properties (black cell) to a specific cell.
Parameters
px(number) — The logical 'X' coordinate of the cellpy(number) — The logical 'Y' coordinate of the celllocked(boolean) — When true, thelockedattribute will be on.
getItemFor(rx: number, ry: number): module:AWT.Point
For a specific cell located at column rx and row ry, finds the number of words delimited
by wildchars located behind its current position and in the same row and column. Used in
CrossWord activities to find the definition for a specific cell.
The result is returned as 'x' and 'y' properties of a logical point.
Parameters
rx(number) — The 'X' position of the cellry(number) — The 'Y' position of the cell
Returns
setCursorEnabled(status: boolean)
Whether the blinking cursor must be enabled or disabled.
Parameters
status(boolean)
startCursorBlink()
Starts the module:AWT.Timer that makes the cursor blink.
stopCursorBlink()
Stops the module:AWT.Timer that makes the cursor blink.
moveCursor(dx: number, dy: number, skipLocked: boolean)
Moves the cursor in the specified x and y directions.
Parameters
dx(number) — Amount to move in the 'X' axisdy(number) — Amount to move in the 'Y' axisskipLocked(boolean) — Skip locked cells (wildcards in CrossWord)
findFreeCell(
from: module:AWT.Point,
dx: number,
dy: number,
): module:AWT.Point
Finds the coordinates of the nearest non-locked cell (non-wildcard) moving on the indicated
'X' and 'Y' directions.
Parameters
from(module:AWT.Point) — Logical coordinates of the starting pointdx(number) — 0 means no movement, 1 go right, -1 go left.dy(number) — 0 means no movement, 1 go down, -1 go up.
Returns
findNextCellWithAttr(
startX: number,
startY: number,
attr: number,
dx: number,
dy: number,
attrState: boolean,
): module:AWT.Point
Finds the first cell with the specified attributes at the specified state, starting
at specified point.
Parameters
startX(number) — Starting X coordinatestartY(number) — Starting Y coordinateattr(number) — Attribute to check. See module:boxes/TextGrid.TextGrid.flags.dx(number) — 0 means no movement, 1 go right, -1 go left.dy(number) — 0 means no movement, 1 go down, -1 go up.attrState(boolean) — Desired state (enabled or disabled) ofattr
Returns
setCursorAt(px: number, py: number, skipLocked: boolean)
Sets the blinking cursor at a specific point
Parameters
px(number) — X coordinatepy(number) — Y coordinateskipLocked(boolean) — Skip locked (wildcard) cells
setUseCursor(value: boolean)
Sets the useCursor property of this text grid
Parameters
value(boolean)
getCursor(): module:AWT.Point
Gets the current position of the blinking cursor
Returns
countCharsLike(ch: string): number
Counts the number of cells of this grid with the specified character
Parameters
ch(string)
Returns
number
getNumCells(): number
Gets the number of cells of this grid
Returns
number
countCoincidences(checkCase: boolean): number
Counts the number of coincidences between the answers array and the current content of this grid
Parameters
checkCase(boolean) — Make comparisions case-sensitive
Returns
number
isCellOk(px: number, py: number, checkCase: boolean): boolean
Checks if a specific cell is equivalent to the content of answers at its position
Parameters
px(number) — X coordinatepy(number) — Y coordinatecheckCase(boolean) — Make comparisions case-sensitive
Returns
boolean
getLogicalCoords(
devicePoint: module:AWT.Point,
): module:AWT.Point
Gets the logical coordinates (in 'cell' units) of a device point into the grid
Parameters
devicePoint(module:AWT.Point)
Returns
isValidCell(px: number, py: number): boolean
Checks if the specified logical coordinates are inside the valid bounds of the grid.
Parameters
px(number) — 'X' coordinatepy(number) — 'Y' coordinate
Returns
boolean
setCharAt(px: number, py: number, ch: string)
Sets the specified character as a content of the cell at specified coordinates
Parameters
px(number) — 'X' coordinatepy(number) — 'Y' coordinatech(string) — The character to set.
getCharAt(px: number, py: number): string
Gets the character of the cell at the specified coordinates
Parameters
px(number) — 'X' coordinatepy(number) — 'Y' coordinate
Returns
string
getStringBetween(
x0: number,
y0: number,
x1: number,
y1: number,
): string
Gets the text formed by the letters between two cells that share a straight line on the grid.
The text can be formed horizontally, vertically and diagonal, both in left-to-right or
right-to-left direction.
Parameters
x0(number) — 'X' coordinate of the first celly0(number) — 'Y' coordinate of the first cellx1(number) — 'X' coordinate of the second celly1(number) — 'Y' coordinate of the second cell
Returns
string
setAttributeBetween(
x0: number,
y0: number,
x1: number,
y1: number,
attribute: number,
value: boolean,
)
Sets a specific attribute to all cells forming a straight line between two cells on the grid.
Parameters
x0(number) — 'X' coordinate of the first celly0(number) — 'Y' coordinate of the first cellx1(number) — 'X' coordinate of the second celly1(number) — 'Y' coordinate of the second cellattribute(number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.value(boolean) — Whether to set or unset the attribute.
setAttribute(
px: number,
py: number,
attribute: number,
state: boolean,
)
Sets or unsets a specifi attrobut to a cell.
Parameters
px(number) — The 'X' coordinate of the cellpy(number) — The 'Y' coordinate of the cellattribute(number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.state(boolean) — Whether to set or unset the attribute.
setAllCellsAttribute(attribute: number, state: boolean)
Sets the specified attribute to all cells.
Parameters
attribute(number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.state(boolean) — Whether to set or unset the attribute.
getCellAttribute(
px: number,
py: number,
attribute: number,
): boolean
Gets the specified attribute of a cell
Parameters
px(number) — The 'X' coordinate of the cellpy(number) — The 'Y' coordinate of the cellattribute(number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.
Returns
boolean
getCellRect(px: number, py: number): module:AWT.Rectangle
Gets the rectangle enclosing a specific cell
Parameters
px(number) — The 'X' coordinate of the cellpy(number) — The 'Y' coordinate of the cell
Returns
getCellBorderBounds(
px: number,
py: number,
): module:AWT.Rectangle
Gets the rectangle enclosing a specific cell, including the border thick.
Parameters
px(number) — The 'X' coordinate of the cellpy(number) — The 'Y' coordinate of the cell
Returns
repaintCell(px: number, py: number)
Repaints a cell
Parameters
px(number) — The 'X' coordinate of the cellpy(number) — The 'Y' coordinate of the cell
getPreferredSize(): module:AWT.Dimension
Gets the preferred size of this grid
Returns
getMinimumSize(): module:AWT.Dimension
Gets the minimum size of this grid
Returns
getScaledSize(scale: number): module:AWT.Dimension
Scales the grid to a new size
Parameters
scale(number) — The factor used to multiply all coordinates and sizes
Returns
setBounds(
rect: AWT.Rectangle | number,
y?: number,
w?: number,
h?: number,
)
Overrides module:boxes/AbstractBox.AbstractBox#setBounds
Parameters
rect(AWT.Rectangle | number) — An AWT.Rectangle object, or thexcoordinate of the
upper-left corner of a new rectangle.y(number, optional) —ycoordinate 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.
updateContent(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
)
Overrides module:boxes/AbstractBox.AbstractBox#updateContent
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas rendering context used to draw the
grid.dirtyRegion(module:AWT.Rectangle, optional) — The area that must be repainted.nullrefers to the whole box.
blink(status: boolean)
Makes the cursor blink, alternating between two states. This method should be called only by
module:boxes/TextGrid.TextGrid#cursorTimer
Parameters
status(boolean)
end()
Overrides: module:boxes/AbstractBox.AbstractBox#end
Stops the cursor timer if not null and active
setParent(parent: module:boxes/AbstractBox.AbstractBox)
Inherited from module:boxes/AbstractBox.AbstractBox#setParent
Overrides: module:boxes/AbstractBox.AbstractBox#setParent
Setter method for parent
Parameters
parent(module:boxes/AbstractBox.AbstractBox) — The new parent of this box
getParent(): module:boxes/AbstractBox.AbstractBox
Inherited from module:boxes/AbstractBox.AbstractBox#getParent
Overrides: module:boxes/AbstractBox.AbstractBox#getParent
Gets the current parent of this box
Returns
setContainer(newContainer: module:AWT.Container)
Inherited from module:boxes/AbstractBox.AbstractBox#setContainer
Overrides: module:boxes/AbstractBox.AbstractBox#setContainer
Setter method for container
Parameters
newContainer(module:AWT.Container) — The new Container assigned to this box
getContainerX(): module:AWT.Container
Inherited from module:boxes/AbstractBox.AbstractBox#getContainerX
Overrides: module:boxes/AbstractBox.AbstractBox#getContainerX
Gets the container attribute of this box, without checking its parent
Returns
getContainerResolve(): module:AWT.Container
Inherited from module:boxes/AbstractBox.AbstractBox#getContainerResolve
Overrides: module:boxes/AbstractBox.AbstractBox#getContainerResolve
Gets the container associated to this box, asking its parents when null.
Returns
invalidate(rect: module:AWT.Rectangle)
Inherited from module:boxes/AbstractBox.AbstractBox#invalidate
Overrides: module:boxes/AbstractBox.AbstractBox#invalidate
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. Whennull, it's the full
container area.
setBoxBase(boxBase: module:boxes/BoxBase.BoxBase)
Inherited from module:boxes/AbstractBox.AbstractBox#setBoxBase
Overrides: module:boxes/AbstractBox.AbstractBox#setBoxBase
Sets the BoxBase of this box
Parameters
boxBase(module:boxes/BoxBase.BoxBase) — The new BoxBase
getBoxBaseResolve(): module:boxes/BoxBase.BoxBase
Inherited from module:boxes/AbstractBox.AbstractBox#getBoxBaseResolve
Overrides: module:boxes/AbstractBox.AbstractBox#getBoxBaseResolve
Gets the real BoxBase associated to this box, scanning down parent relationships.
Returns
setShape(sh: module:AWT.Shape)
Inherited from module:boxes/AbstractBox.AbstractBox#setShape
Overrides: module:boxes/AbstractBox.AbstractBox#setShape
Sets the shape used to draw the content of this box
Parameters
sh(module:AWT.Shape) — The shape to be set
getShape(): module:AWT.Shape
Inherited from module:boxes/AbstractBox.AbstractBox#getShape
Overrides: module:boxes/AbstractBox.AbstractBox#getShape
Gets the current shape used in this box
Returns
contains(p: module:AWT.Point): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#contains
Check if this box contains the specified point
Parameters
p(module:AWT.Point) — The point to be checked
Returns
boolean
setBounds(
rect: AWT.Rectangle | number,
y?: number,
w?: number,
h?: number,
): module:AWT.Rectangle
Inherited from module:boxes/TextGrid.TextGrid#setBounds
Overrides: module:boxes/AbstractBox.AbstractBox#setBounds
Overrides module:boxes/AbstractBox.AbstractBox#setBounds
Parameters
rect(AWT.Rectangle | number) — An AWT.Rectangle object, or thexcoordinate of the
upper-left corner of a new rectangle.y(number, optional) —ycoordinate 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
moveTo(newPos: AWT.Point | number, y?: number)
Inherited from module:boxes/AbstractBox.AbstractBox#moveTo
Overrides: module:boxes/AbstractBox.AbstractBox#moveTo
Sets a new location for this box. In JClic this method was named setLocation
Parameters
newPos(AWT.Point | number) — A point or thexcoordinate of a new point.y(number, optional) — Theycoordinate of a new point.
moveBy(dx: number, dy: number)
Inherited from module:boxes/AbstractBox.AbstractBox#moveBy
Overrides: module:boxes/AbstractBox.AbstractBox#moveBy
Sets a new location to this box. In JClic this method was named translate.
Parameters
dx(number) — The displacement on the X axisdy(number) — The displacement on the Y axis
setSize(width: number, height: number)
Inherited from module:boxes/AbstractBox.AbstractBox#setSize
Overrides: module:boxes/AbstractBox.AbstractBox#setSize
Changes the size of this box
Parameters
width(number)height(number)
hasBorder(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#hasBorder
Overrides: module:boxes/AbstractBox.AbstractBox#hasBorder
Checks if this box has border
Returns
boolean
setBorder(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setBorder
Overrides: module:boxes/AbstractBox.AbstractBox#setBorder
Sets/unsets a border to this box
Parameters
newVal(boolean) —trueto set a border.
isVisible(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isVisible
Overrides: module:boxes/AbstractBox.AbstractBox#isVisible
Checks if this box is fully visible
Returns
boolean
setVisible(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setVisible
Overrides: module:boxes/AbstractBox.AbstractBox#setVisible
Sets this box visible or invisible
Parameters
newVal(boolean) —truefor visible
setHostedComponentVisible()
Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentVisible
Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentVisible
Makes module:boxes/AbstractBox.AbstractBox#$hostedComponent visible or invisible, based on the value of
the AbstractBox visible flag.
isTemporaryHidden(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isTemporaryHidden
Overrides: module:boxes/AbstractBox.AbstractBox#isTemporaryHidden
Checks if this box is temporary hidden
Returns
boolean
setTemporaryHidden(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setTemporaryHidden
Overrides: module:boxes/AbstractBox.AbstractBox#setTemporaryHidden
Makes this box temporary hidden (newVal true) or resets its original state (newVal false)
Parameters
newVal(boolean)
isInactive(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isInactive
Overrides: module:boxes/AbstractBox.AbstractBox#isInactive
Checks if this box is currently inactive.
Returns
boolean
setInactive(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setInactive
Overrides: module:boxes/AbstractBox.AbstractBox#setInactive
Makes this box active (false) or inactive (true)
Parameters
newVal(boolean)
isInverted(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isInverted
Overrides: module:boxes/AbstractBox.AbstractBox#isInverted
Checks if this box is in inverted state.
Returns
boolean
setInverted(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setInverted
Overrides: module:boxes/AbstractBox.AbstractBox#setInverted
Puts this box in inverted mode or restores its original state.
Parameters
newVal(boolean)
isMarked(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isMarked
Overrides: module:boxes/AbstractBox.AbstractBox#isMarked
Checks if this box is marked
Returns
boolean
setMarked(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setMarked
Overrides: module:boxes/AbstractBox.AbstractBox#setMarked
Sets this box in marked mode, or restores its original state.
Parameters
newVal(boolean)
isFocused(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isFocused
Overrides: module:boxes/AbstractBox.AbstractBox#isFocused
Checks if this box has the input focus
Returns
boolean
setFocused(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setFocused
Overrides: module:boxes/AbstractBox.AbstractBox#setFocused
Sets or unsets the input focus to this box.
Parameters
newVal(boolean)
isAlternative(): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#isAlternative
Overrides: module:boxes/AbstractBox.AbstractBox#isAlternative
Checks if this box is in alternative state.
Returns
boolean
setAlternative(newVal: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setAlternative
Overrides: module:boxes/AbstractBox.AbstractBox#setAlternative
Sets this box in alternative mode, or restores its original state.
Parameters
newVal(boolean)
update(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
)
Inherited from module:boxes/AbstractBox.AbstractBox#update
Overrides: module:boxes/AbstractBox.AbstractBox#update
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
ctx(external:CanvasRenderingContext2D) — The canvas rendering context used to draw the
box content.dirtyRegion(module:AWT.Rectangle, optional, default: null) — The area that must be repainted.nullrefers to the whole box.
updateContent(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
)
Inherited from module:boxes/TextGrid.TextGrid#updateContent
Overrides: module:boxes/AbstractBox.AbstractBox#updateContent
Overrides module:boxes/AbstractBox.AbstractBox#updateContent
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas rendering context used to draw the
grid.dirtyRegion(module:AWT.Rectangle, optional) — The area that must be repainted.nullrefers to the whole box.
drawBorder(ctx: external:CanvasRenderingContext2D)
Inherited from module:boxes/AbstractBox.AbstractBox#drawBorder
Overrides: module:boxes/AbstractBox.AbstractBox#drawBorder
Draws the box border
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas rendering context where the border
will be drawn.
getBorderBounds(): module:AWT.Rectangle
Inherited from module:boxes/AbstractBox.AbstractBox#getBorderBounds
Overrides: module:boxes/AbstractBox.AbstractBox#getBorderBounds
Returns the enclosing Rectangle of this box including its border (if any)
Returns
setHostedComponent($hc: external:jQuery)
Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponent
Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponent
Sets the $hostedComponent member.
Parameters
$hc(external:jQuery) — The jQuery DOM component hosted by this box.
getHostedComponent(): external:jQuery
Inherited from module:boxes/AbstractBox.AbstractBox#getHostedComponent
Overrides: module:boxes/AbstractBox.AbstractBox#getHostedComponent
Gets the current $hostedComponent member
Returns
setHostedComponentColors()
Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentColors
Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentColors
Sets $hostedComponent colors and other css properties
based on the current BoxBase of this box.
setHostedComponentBorder()
Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentBorder
Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentBorder
Sets the $hostedComponent border, based on the current
BoxBase of this box.
setHostedComponentBounds(_sizeChanged: boolean)
Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentBounds
Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentBounds
Places and resizes $hostedComponent, based on the size
and position of this box.
Parameters
_sizeChanged(boolean) —truewhen this ActiveBox has changed its size
getBounds(): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#getBounds
Overrides: module:boxes/AbstractBox.AbstractBox#getBounds
Gets the enclosing Rectangle of this Shape.
Returns
equals(r: module:AWT.Shape): boolean
Inherited from module:AWT.Rectangle#equals
Overrides: module:boxes/AbstractBox.AbstractBox#equals
Checks if two shapes are equivalent.
Parameters
r(module:AWT.Shape) — The Shape to compare against
Returns
boolean
clone(): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#clone
Overrides: module:boxes/AbstractBox.AbstractBox#clone
Clones this Rectangle
Returns
scaleBy(delta: Point | Dimension): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#scaleBy
Overrides: module:boxes/AbstractBox.AbstractBox#scaleBy
Multiplies the dimension of the Shape by the specified delta amount.
Parameters
Returns
grow(dx: number, dy: number): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#grow
Overrides: module:boxes/AbstractBox.AbstractBox#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 directiondy(number) — The amount to grow (or decrease) in vertical direction
Returns
getOppositeVertex(): module:AWT.Point
Inherited from module:AWT.Rectangle#getOppositeVertex
Overrides: module:boxes/AbstractBox.AbstractBox#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:boxes/AbstractBox.AbstractBox#add
Adds the boundaries of another shape to the current one
Parameters
shape(module:AWT.Shape) — The module:AWT.Shape to be added
Returns
getCoords(): string
Inherited from module:AWT.Rectangle#getCoords
Overrides: module:boxes/AbstractBox.AbstractBox#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:boxes/AbstractBox.AbstractBox#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:boxes/AbstractBox.AbstractBox#setAttributes
Reads the properties of this Rectangle from a data object
Parameters
data(object) — The data object to be parsed
Returns
intersects(_r: module:AWT.Rectangle): boolean
Inherited from module:AWT.Shape#intersects
Overrides: module:boxes/AbstractBox.AbstractBox#intersects
Checks if the provided Rectangle r intersects with this shape.
Parameters
_r(module:AWT.Rectangle)
Returns
boolean
fill(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#fill
Overrides: module:boxes/AbstractBox.AbstractBox#fill
Fills the Shape with the current style in the provided HTML canvas context
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas 2D rendering context where to fill this shape.dirtyRegion(module:AWT.Rectangle, optional) — The context region to be updated. Used as clipping
region when drawing.
Returns
stroke(
ctx: external:CanvasRenderingContext2D,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#stroke
Overrides: module:boxes/AbstractBox.AbstractBox#stroke
Draws this shape in the provided HTML canvas 2D rendering context.
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas 2D rendering context where to draw the shape.
Returns
preparePath(
ctx: external:CanvasRenderingContext2D,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#preparePath
Overrides: module:boxes/AbstractBox.AbstractBox#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:boxes/AbstractBox.AbstractBox#clip
Creates a clipping region on the specified HTML canvas 2D rendering context
Parameters
ctx(external:CanvasRenderingContext2D) — The rendering contextfillRule(string, optional, default: "'nonzero'") — Can be 'nonzero' (default when not set) or 'evenodd'
Returns
isRect(): boolean
Inherited from module:AWT.Shape#isRect
Overrides: module:boxes/AbstractBox.AbstractBox#isRect
Shorthand method for determining if a Shape is an Rectangle
Returns
boolean
toString(): string
Inherited from module:AWT.Shape#toString
Overrides: module:boxes/AbstractBox.AbstractBox#toString
Overwrites the original 'Object.toString' method with a more descriptive text
Returns
string
contains(p: module:AWT.Point): boolean
Inherited from module:boxes/AbstractBox.AbstractBox#contains
Check if this box contains the specified point
Parameters
p(module:AWT.Point) — The point to be checked
Returns
boolean
setBounds(
rect: AWT.Rectangle | number,
y?: number,
w?: number,
h?: number,
): module:AWT.Rectangle
Inherited from module:boxes/TextGrid.TextGrid#setBounds
Overrides: module:boxes/AbstractBox.AbstractBox#setBounds
Overrides module:boxes/AbstractBox.AbstractBox#setBounds
Parameters
rect(AWT.Rectangle | number) — An AWT.Rectangle object, or thexcoordinate of the
upper-left corner of a new rectangle.y(number, optional) —ycoordinate 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
updateContent(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
)
Inherited from module:boxes/TextGrid.TextGrid#updateContent
Overrides: module:boxes/AbstractBox.AbstractBox#updateContent
Overrides module:boxes/AbstractBox.AbstractBox#updateContent
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas rendering context used to draw the
grid.dirtyRegion(module:AWT.Rectangle, optional) — The area that must be repainted.nullrefers to the whole box.
Static Methods
createEmptyGrid(
parent: module:boxes/AbstractBox.AbstractBox,
container: module:AWT.Container,
x: number,
y: number,
tgc: module:boxes/TextGridContent.TextGridContent,
wildTransparent: boolean,
): module:boxes/TextGrid.TextGrid
Factory constructor that creates an empty grid based on a TextGridContent
Parameters
parent(module:boxes/AbstractBox.AbstractBox) — The AbstractBox to which the text grid belongscontainer(module:AWT.Container) — The container where the text grid will be placed.x(number) —Xcoordinate of the upper left corner of the gridy(number) —Ycoordinate of the upper left corner of the gridtgc(module:boxes/TextGridContent.TextGridContent) — Object with the content and other settings of the gridwildTransparent(boolean) — Whentrue, the wildcard character will be transparent
Returns
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
nRows: number
Number of rows
nCols: number
Number of columns
chars: Array.<Array.<string>>
Two-dimension array of characters
answers: Array.<Array.<string>>
Two-dimension array with the expected characters, used to check user's answers.
attributes: Array.<Array.<number>>
Two-dimension array of bytes used as containers of boolean attributes
- See:
- TextGrid.flags
cellWidth: number
The cell width, in pixels
cellHeight: number
The cell height, in pixels
preferredBounds: module:AWT.Rectangle
The preferred bounds of this grid
wild: string
The character to be used as wildcard
randomChars: string
Characters that can be used when randomizing the content of this grid
- See:
- TextGridContent#randomChars
cursorEnabled: boolean
Whether the blinking cursor is enabled or disabled
useCursor: boolean
Whether this grid uses a blinking cursor or not
cursor: module:AWT.Point
The current position of the cursor
cursorBlink: boolean
true when the cursor is "blinking" (cell drawn with BoxBase inverse attributes)
cursorTimer: module:AWT.Timer
Controls the blinking of the cursor
wildTransparent: boolean
Whether the wildcard character is transparent or opaque
parent: module:boxes/AbstractBox.AbstractBox
Inherited from module:boxes/AbstractBox.AbstractBox#parent
Overrides: module:boxes/AbstractBox.AbstractBox#parent
The parent AbstractBox (can be null)
container: module:AWT.Container
Inherited from module:boxes/AbstractBox.AbstractBox#container
Overrides: module:boxes/AbstractBox.AbstractBox#container
The Container to which this AbstractBox belongs
boxBase: module:boxes/BoxBase.BoxBase
Inherited from module:boxes/AbstractBox.AbstractBox#boxBase
Overrides: module:boxes/AbstractBox.AbstractBox#boxBase
The BoxBase related to this AbstractBox. When null, the parent can provide an
alternative one.
border: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#border
Overrides: module:boxes/AbstractBox.AbstractBox#border
Whether this box has a border or not
shape: module:AWT.Shape
Inherited from module:boxes/AbstractBox.AbstractBox#shape
Overrides: module:boxes/AbstractBox.AbstractBox#shape
The shape of this box (the box Rectangle or a special Shape, if set)
specialShape: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#specialShape
Overrides: module:boxes/AbstractBox.AbstractBox#specialShape
Whether this box has a shape that is not a rectangle
visible: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#visible
Overrides: module:boxes/AbstractBox.AbstractBox#visible
Whether this box is visible or not
temporaryHidden: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#temporaryHidden
Overrides: module:boxes/AbstractBox.AbstractBox#temporaryHidden
Used to temporary hide a box while other drawing operations are done
tmpTrans: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#tmpTrans
Overrides: module:boxes/AbstractBox.AbstractBox#tmpTrans
Cells with this attribute will be transparent but with painted border
inactive: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#inactive
Overrides: module:boxes/AbstractBox.AbstractBox#inactive
Whether this box is active or inactive
inverted: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#inverted
Overrides: module:boxes/AbstractBox.AbstractBox#inverted
Whether this box must be displayed with inverted or regular colors
alternative: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#alternative
Overrides: module:boxes/AbstractBox.AbstractBox#alternative
Whether this box must be displayed with alternative or regular color and font settings
marked: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#marked
Overrides: module:boxes/AbstractBox.AbstractBox#marked
Whether this box is marked (selected) or not
focused: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#focused
Overrides: module:boxes/AbstractBox.AbstractBox#focused
Whether this box holds the input focus
accessibleText: string
Inherited from module:boxes/AbstractBox.AbstractBox#accessibleText
Overrides: module:boxes/AbstractBox.AbstractBox#accessibleText
Text to be used in accessible contexts
role: string
Inherited from module:boxes/AbstractBox.AbstractBox#role
Overrides: module:boxes/AbstractBox.AbstractBox#role
Describes the main role of this box on the activity. Useful in wai-aria descriptions.
$accessibleElement: external:jQuery
Inherited from module:boxes/AbstractBox.AbstractBox#$accessibleElement
Overrides: module:boxes/AbstractBox.AbstractBox#$accessibleElement
DOM element used to display this cell content in wai-aria contexts
accessibleAlwaysActive: boolean
Inherited from module:boxes/AbstractBox.AbstractBox#accessibleAlwaysActive
Overrides: module:boxes/AbstractBox.AbstractBox#accessibleAlwaysActive
Flag indicating that $accessibleElement should be always active
$hostedComponent: external:jQuery
Inherited from module:boxes/AbstractBox.AbstractBox#$hostedComponent
Overrides: module:boxes/AbstractBox.AbstractBox#$hostedComponent
An external JQuery DOM element hosted by this box
type: string
Inherited from module:AWT.Rectangle#type
Overrides: module:boxes/AbstractBox.AbstractBox#type
Shape type id
dim: module:AWT.Dimension
Inherited from module:AWT.Rectangle#dim
Overrides: module:boxes/AbstractBox.AbstractBox#dim
The Dimension of the Rectangle
pos: module:AWT.Point
Inherited from module:AWT.Shape#pos
Overrides: module:boxes/AbstractBox.AbstractBox#pos
The current position of the shape
Other
defaults: object
TextGrid default values
flags: object
Binary flags used to mark status