SelectionsWrapper
SelectionsWrapper
Wrapper class to hold and manage a set of Selectables. Can notfiy to other parts of the code about changes in the # of selections through its array of listeners functions.
Constructor
public SelectionsWrapper
new SelectionsWrapper()
Intializes a SelectionsWrapper with no elements in this.seclections
or this.listeners
and this.disabled
set to false.
Properties
No publicly accessible properties on SelectionsWrapper
private selections: Set<Selectable>
Description needed
private disabled: false | true
Description needed
private listeners: Set<() => void>
Description needed
Methods
public addChangeListener
addChangeListener(listener) => void
Adds listener
to this.listeners
.
Parameters
-
listener: () => void
– A function to call when an element gets added or removed fromthis.selections
.
public removeChangeListener
removeChangeListener(listener) => void
Removes listener
to this.listeners
.
Parameters
-
listener: () => void
– A function to call when an element gets added or removed fromthis.selections
.
public setDisabled
setDisabled(disabled) => void
Sets this.disabled
equal to disabled
.
Parameters
-
disabled: false | true
– Boolean value to setthis.disabled
to (defaults to true).
public select
select(s) => false | true
If s
is not in this.selections
, adds s
to this.selections
then calls every function in this.listeners
.
Parameters
-
s: Selectable
– Selectable to add tothis.selections
.
Returns
-
false | true
– True ifthis.disabled
is false ands
is not inthis.selections
, and false otheriwse.
public deselect
deselect(s) => false | true
If s
is in this.selections
, removes s
from this.selections
then calls every function in this.listeners
.
Parameters
-
s: Selectable
– Selectable to remove fromthis.selections
.
Returns
-
false | true
– True ifthis.disabled
is false ands
is inthis.selections
, and false otheriwse.
public all
all(f) => false | true
Returns whether or not f
returns true for every element of this.selections
.
Parameters
-
f: Selectable
– A function that takes a Selectables
and returns a boolean.
Returns
-
false | true
– Returns true iff
returns true for every element inthis.selections
and false otherwise.
public any
any(f) => false | true
Returns whether or not f
returns true for at least one element of this.selections
.
Parameters
-
f: Selectable
– A function that takes a Selectables
and returns a boolean.
Returns
-
false | true
– Returns true iff
returns true for every element inthis.selections
and false otherwise.
public has
has(s) => false | true
Checks to see if the elements of s
are also in this.selections
.
Parameters
-
s: Selectable[]
– An array of type Selectable.
Returns
-
false | true
– True if every Selectable in s is also inthis.selections
and false otherwise.
public amount
amount() => number
Returns the number of elements in this.selections
.
Returns
-
number
– The value ofthis.selections.size
.
public midpoint
midpoint(all) => Vector
Returns a vector that represents the midpoint of the elements in this.selections
, will returns
zero vector if there no elements.
Parameters
-
all: false | true
– Ifall
is set to false elements of type Wire and Port will be excluded from the midpoint calculation and only elements of type Component will be used to calculate the midpoint (defaults to false).
Returns
-
Vector
– A Vector containing the midpoint of the elements inthis.selections
.
public get
get() => Selectable[]
Returns an array containing the elements of this.selections
.
Returns
-
Selectable[]
– An array of type Selectable that contains the elements ofthis.selections
.
public isDisabled
isDisabled() => false | true
Returns the value of this.disabled.
Returns
-
false | true
– True ifthis.disabled
is true and false otherwise.
Static Methods
No static methods for SelectionsWrapper