Skip to main content

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 from this.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 from this.selections.

public setDisabled

setDisabled(disabled) => void

Sets this.disabled equal to disabled.

Parameters

  •  disabled: false | true – Boolean value to set this.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 to this.selections.

Returns

  •   false | true – True if this.disabled is false and s is not in this.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 from this.selections.

Returns

  •   false | true – True if this.disabled is false and s is in this.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 Selectable s and returns a boolean.

Returns

  •   false | true – Returns true if f returns true for every element in this.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 Selectable s and returns a boolean.

Returns

  •   false | true – Returns true if f returns true for every element in this.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 in this.selections and false otherwise.

public amount

amount() => number

Returns the number of elements in this.selections.

Returns

  •   number – The value of this.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 – If all 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 in this.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 of this.selections.

public isDisabled

isDisabled() => false | true

Returns the value of this.disabled.

Returns

  •   false | true – True if this.disabled is true and false otherwise.

Static Methods

No static methods for SelectionsWrapper