Class: NamedSelection
Defined in: selection.ts:139
A set of places and flows with a name and a color. It is what a user builds by picking and drawing; maps, plots, and databases read it. It keeps the order things were added in, for undo.
Constructors
Constructor
new NamedSelection(
_name,_color):NamedSelection
Defined in: selection.ts:146
Parameters
_name
string
_color
string
Returns
NamedSelection
Properties
events
readonlyevents:EventEmitter<NamedSelectionEvents>
Defined in: selection.ts:141
Emits SelectionEvent.CHANGE after every change.
Accessors
color
Get Signature
get color():
string
Defined in: selection.ts:157
The CSS color that marks the selection on the map and in plots. Setting it emits SelectionEvent.CHANGE.
Returns
string
Set Signature
set color(
color):void
Defined in: selection.ts:158
Parameters
color
string
Returns
void
flows
Get Signature
get flows(): readonly
Flow[]
Defined in: selection.ts:168
Flows from one place to another, in the order they were added.
Returns
readonly Flow[]
isEmpty
Get Signature
get isEmpty():
boolean
Defined in: selection.ts:171
Whether the selection has no places and no flows.
Returns
boolean
name
Get Signature
get name():
string
Defined in: selection.ts:149
The label shown for the selection. Setting it emits SelectionEvent.CHANGE.
Returns
string
Set Signature
set name(
name):void
Defined in: selection.ts:150
Parameters
name
string
Returns
void
places
Get Signature
get places(): readonly
Place[]
Defined in: selection.ts:165
Places whose members are selected, in the order they were added.
Returns
readonly Place[]
Methods
addFlow()
addFlow(
flow):boolean
Defined in: selection.ts:269
Adds a flow. A flow between the same two places as one already there is ignored, even if drawn elsewhere. Returns whether it was added.
Parameters
flow
Returns
boolean
addPlace()
addPlace(
place):boolean
Defined in: selection.ts:176
Adds a place. A place equal to one already there is ignored. Returns whether it was added.
Parameters
place
Returns
boolean
clear()
clear():
void
Defined in: selection.ts:301
Removes every place and flow. Keeps the name and color. Does nothing when already empty.
Returns
void
hasFlow()
hasFlow(
flow):boolean
Defined in: selection.ts:261
Whether there is a flow between places equal to flow.from and flow.to.
Parameters
flow
Pick<Flow, "from" | "to">
Returns
boolean
hasPlace()
hasPlace(
place):boolean
Defined in: selection.ts:256
Parameters
place
Returns
boolean
moveRegion()
moveRegion(
ring,delta):boolean
Defined in: selection.ts:219
Translates a region by [deltaLon, deltaLat] in degrees and shifts any connected flow endpoints and arrow anchors atomically, emitting a single change event.
Also updates flows that reference ring even when the region place itself is stored in another NamedSelection.
Parameters
ring
delta
Returns
boolean
Whether a matching region place or flow endpoint was found and moved.
removeFlow()
removeFlow(
flow):boolean
Defined in: selection.ts:284
Removes the flow between places equal to flow.from and flow.to. Returns whether there was one.
Parameters
flow
Pick<Flow, "from" | "to">
Returns
boolean
removePlace()
removePlace(
place,options?):boolean
Defined in: selection.ts:190
Removes the place equal to place. Returns whether there was one. Pass { cascadeFlows: true } to also remove any flows referencing that place in one change event.
Parameters
place
options?
cascadeFlows?
boolean
Returns
boolean
undo()
undo():
boolean
Defined in: selection.ts:289
Takes back the last place or flow added that is still there. Returns whether there was one.
Returns
boolean