API / geotoolkit / selection / Selector / Selector
Defines node selection. This class provides the logic to do shape selection using device coordinates.
It implements several algorithms to perform different types of selection:
- By point: At a given point with an optional radius
- By rect: In a given rectangle
- By polygon: In a given arbitrary polygon
- By ellipse: In a given arbitrary ellipse
Selection returns multiple objects in the current position. It can be Node or SelectedItem. SelectedItem usually is using when there is a composite object inside selected area like chart or curve. In this case SelectedItem contains info about samples inside area.
Example
// following code show how to get the names of the selected items.
// The method 'select' returns an array of selected objects. Also it has a radius of selection. In this code is 5 pixels.
import {Selector} from '@int/geotoolkit/selection/Selector';
import {isNode} from '@int/geotoolkit/scene/Node';
const radius = 5;
const select = Selector.select(widget, pt.x, pt.y, radius).filter(isNode);
if (select == null) return;
for (let i = 0; i < select.length; i++) {
console.log(select[i].getName());
}Example
// result can be filtered using predicates (https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
// embedded predicates or any custom predicate can be used
import {isSelectedItem} from '@int/geotoolkit/selection/SelectedItem';
// after filter 'items' is SelectedItem[]
const items = Selector.select(root, point, 2).filter(isSelectedItem);Constructors
Constructors
• new Selector(transformation?)
Create selector
| Name | Type | Description |
|---|---|---|
Optional transformation | Transformation | transformation from current node to plot (device). It is equal to node.getParent().getSceneTransform(). If a root node is used as a start node then it is not necessary to specify transformation. |
Methods
▸ asyncSelect(callback, root, rectArea, allowIntersection?): void
Select node in the current rectangular area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
callback | SelectionCallback | callback |
root | Node | node to be used for selection. |
rectArea | Rect | selection rectangle. |
Optional allowIntersection | boolean | allow intersection flag |
void
▸ asyncSelect(callback, root, point, radius?): void
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
callback | SelectionCallback | callback |
root | Node | node to be used for selection. |
point | Point | selection point |
Optional radius | number | selection radius |
void
▸ asyncSelect(callback, root, x, y, radius?): void
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
callback | SelectionCallback | callback |
root | Node | node to be used for selection. |
x | number | x-coordinate of the selection point |
y | number | y-coordinate of the selection point |
Optional radius | number | selection radius |
void
▸ asyncSelect(callback, root, point, halfWidth, halfHeight, allowIntersection?): void
Select node in the ellipse area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
callback | SelectionCallback | callback |
root | Node | node to be used for selection. |
point | Point | selection point |
halfWidth | number | selection ellipse half width |
halfHeight | number | selection ellipse half height |
Optional allowIntersection | boolean | allow intersection |
void
▸ asyncSelect(callback, root, xx, yy, allowIntersection?, evenOdd?): void
Select node in the polygonal area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
callback | SelectionCallback | callback |
root | Node | node to be used for selection. |
xx | number[] | x-coordinates of the selection polygon |
yy | number[] | y-coordinates of the selection polygon |
Optional allowIntersection | boolean | allow intersection flag |
Optional evenOdd | boolean | even odd mode |
void
▸ getTransformation(): Transformation
Gets current transformation
▸ select(root, rectArea, allowIntersection?): (Node | SelectedItem<any>)[]
Select node in the current rectangular area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
rectArea | Rect | selection rectangle. |
Optional allowIntersection | boolean | allow intersection flag |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ select(root, point, radius?): (Node | SelectedItem<any>)[]
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
point | Point | selection point |
Optional radius | number | selection radius |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ select(root, x, y, radius?): (Node | SelectedItem<any>)[]
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
x | number | x-coordinate of the selection point |
y | number | y-coordinate of the selection point |
Optional radius | number | selection radius |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ select(root, point, halfWidth, halfHeight, allowIntersection?): (Node | SelectedItem<any>)[]
Select node in the ellipse area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
point | Point | center of ellipse |
halfWidth | number | selection ellipse half width |
halfHeight | number | selection ellipse half height |
Optional allowIntersection | boolean | allow intersection |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ select(root, xx, yy, allowIntersection?, evenOdd?): (Node | SelectedItem<any>)[]
Select node in the polygonal area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
xx | number[] | x-coordinates of the selection polygon |
yy | number[] | y-coordinates of the selection polygon |
Optional allowIntersection | boolean | allow intersection flag |
Optional evenOdd | boolean | even odd mode |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ setTransformation(transformation): Selector
Sets current transformation
| Name | Type | Description |
|---|---|---|
transformation | Transformation | transformation from current node to device |
this
▸ Static select(root, rectArea, allowIntersection?): (Node | SelectedItem<any>)[]
Select node in the current rectangular area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
rectArea | Rect | selection rectangle. |
Optional allowIntersection | boolean | allow intersection flag |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ Static select(root, point, radius?): (Node | SelectedItem<any>)[]
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
point | Point | selection point |
Optional radius | number | selection radius |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ Static select(root, x, y, radius?): (Node | SelectedItem<any>)[]
Select node in the current point. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
x | number | x-coordinate of the selection point |
y | number | y-coordinate of the selection point |
Optional radius | number | selection radius |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ Static select(root, point, halfWidth, halfHeight, allowIntersection?): (Node | SelectedItem<any>)[]
Select node in the current ellipse. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
point | Point | selection point |
halfWidth | number | selection ellipse half width |
halfHeight | number | selection ellipse half height |
Optional allowIntersection | boolean | allow intersection |
(Node | SelectedItem<any>)[]
a collection of selected nodes
▸ Static select(root, xx, yy, allowIntersection?, evenOdd?): (Node | SelectedItem<any>)[]
Select node in the polygonal area. This method starts selection from the specified node. Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.
| Name | Type | Description |
|---|---|---|
root | Node | node to be used for selection. |
xx | number[] | x-coordinates of the selection polygon |
yy | number[] | y-coordinates of the selection polygon |
Optional allowIntersection | boolean | allow intersection flag |
Optional evenOdd | boolean | even odd mode |
(Node | SelectedItem<any>)[]
a collection of selected nodes