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:
- Array.<Rectangle>
flattenedY :Array.<Rectangle>
The selection rectangles flattened in the vertical direction (no height).
Created as an empty array upon instantiation by the constructor
.
Type:
- Array.<Rectangle>
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:
- Array.<Rectangle>
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() → {*}
The most recent selection type. This is the TOS of this.lastSelectionType
, the stack of unique selection types.
Note that in the case where the only remaining previous selection of type
was deselected, and setLastSelectionType
was called with reset
truthy, type
is removed from the stack. If it was previously TOS, the TOS will now be what was the 2nd most recently pushed type (or nothing if no other selections).
Returns empty string (''
) if there are no selections.
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, resetopt)
Set the most recent selection's type
. That is, push onto TOS of this.lastSelectionType
, the stack of unique selection types. If already in the stack, move it to the top.
If reset
is truthy, remove the given type
from the stack, regardless of where found therein (or not), thus "revealing" the 2nd most recently pushed type.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
string | One of: |
||
reset |
boolean |
<optional> |
false | Remove the given |
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 |