Class: SelectionModel

SelectionModel

new SelectionModel()

We represent selections as a list of rectangles because large areas can be represented and tested against quickly with a minimal amount of memory usage. Also we need to maintain the selection rectangles flattened counter parts so we can test for single dimension contains. This is how we know to highlight the fixed regions on the edges of the grid.

Members

allRowsSelected :boolean

Type:
  • boolean

columnSelectionModel :RangeSelectionModel

The selection rectangles.

Created as a new RangeSelectionModel upon instantiation by the constructor.

Type:
  • RangeSelectionModel

flattenedX :Array.<Rectangle>

The selection rectangles flattened in the horizontal direction (no width).

Created as an empty array upon instantiation by the constructor.

Type:

flattenedY :Array.<Rectangle>

The selection rectangles flattened in the vertical direction (no height).

Created as an empty array upon instantiation by the constructor.

Type:

rowSelectionModel :RangeSelectionModel

The selection rectangles.

Created as a new RangeSelectionModel upon instantiation by the constructor.

Type:
  • RangeSelectionModel

selections :Array.<Rectangle>

The selection rectangles.

Created as an empty array upon instantiation by the constructor.

Type:

Methods

clear()

empty out all our state

clearMostRecentColumnSelection()

clearMostRecentRowSelection()

clearMostRecentSelection()

Remove the last selection that was created.

clearRowSelection()

deselectColumn(x1, x2)

Parameters:
Name Type Description
x1
x2

deselectRow(y1, y2)

Parameters:
Name Type Description
y1
y2

getFlattenedYs() → {Array}

Returns:
Type
Array

getLastSelection() → {*}

Returns:
Type
*

getLastSelectionType() → {*}

Returns:
Type
*

getSelectedColumns() → {*|Array.Array.number}

Returns:
Type
* | Array.Array.number

getSelectedRows() → {*}

Returns:
Type
*

getSelections() → {*}

Returns:
Type
*

hasColumnSelections() → {boolean}

Returns:
Type
boolean

hasRowSelections() → {boolean}

Returns:
Type
boolean

hasSelections() → {boolean}

Returns:

There are active selection(s).

Type
boolean

isCellSelected(x, y) → {*}

Parameters:
Name Type Description
x
y
Returns:
Type
*

isCellSelectedInColumn(x)

Parameters:
Name Type Description
x number
Returns:

Selection covers a specific row.

isCellSelectedInRow(y) → {boolean}

Parameters:
Name Type Description
y number
Returns:

Selection covers a specific column.

Type
boolean

isColumnOrRowSelected() → {boolean}

Returns:
Type
boolean

isColumnSelected(x) → {*}

Parameters:
Name Type Description
x
Returns:
Type
*

isInCurrentSelectionRectangle(x, y) → {*}

Parameters:
Name Type Description
x
y
Returns:
Type
*

isRectangleSelected(ox, oy, ex, ey) → {boolean}

Parameters:
Name Type Description
ox number

origin x coordinate

oy number

origin y coordinate

ex number

extent x coordinate

ey number

extent y coordinate

Returns:
Type
boolean

isRowSelected(y) → {boolean|*}

Parameters:
Name Type Description
y
Returns:
Type
boolean | *

isSelected(selections, x, y) → {boolean}

Selection query function.

Parameters:
Name Type Description
selections Array.<Rectangle>

Selection rectangles to search through.

x number
y number
Returns:

The given cell is selected (part of an active selection).

Type
boolean

rectangleContains(rect, x, y) → {boolean}

Parameters:
Name Type Description
rect
x
y
Returns:
Type
boolean

select(ox, oy, ex, ey, silent)

Select the region described by the given coordinates.

Parameters:
Name Type Description
ox number

origin x coordinate

oy number

origin y coordinate

ex number

extent x coordinate

ey number

extent y coordinate

silent boolean

whether to fire selection changed event

selectAllRows()

selectColumn(x1, x2)

Parameters:
Name Type Description
x1
x2

selectColumnsFromCells(offset)

Parameters:
Name Type Description
offset

selectRow(y1, y2)

Parameters:
Name Type Description
y1
y2

selectRowsFromCells(offset)

Parameters:
Name Type Description
offset

setAllRowsSelected() → {boolean}

Returns:
Type
boolean

setLastSelectionType(type)

Parameters:
Name Type Description
type

toggleSelect(ox, oy, ex, ey)

Parameters:
Name Type Description
ox number

origin x coordinate

oy number

origin y coordinate

ex number

extent x coordinate

ey number

extent y coordinate