Provides access to a value of a Subject and meta-data such as name, a set of possible values and more. Part of the Observer design pattern which ensures that change notification happens regardless of how the value was changed. See Subject, Observer, Parameter for an overview.

It is very easy to connect a Parameter to a user interface control like NumericControl, ChoiceControl, or CheckBoxControl.

Parameter helps to minimize the knowledge that classes have about each other. For example, a NumericControl can display and modify the ParameterNumber of a Subject without knowing anything about the Subject other than it implements the Subject interface.

See Internationalization for information about localized and language-independent strings.

Getter and Setter Methods

A Parameter operates by calling getter and setter methods on its Subject. These methods are specified to the Parameter's constructor, and used in the Parameter's getValue and setValue methods. We assume that the Subject's setter method will perform notification of changes via Subject.broadcastParameter.

Here are examples of getter and setter methods showing how the Parameter is broadcast in the setter method of the Subject.

getMass(): number {
return this.block_.getMass();

setMass(value: number) {

Here is an example showing how the getter and setter methods are specified when creating a ParameterNumber. This is from SingleSpringSim:

this.addParameter(new ParameterNumber(this, SingleSpringSim.en.MASS,
() => this.getMass(), a => this.setMass(a)));

Choices and Values

A Parameter can have a set of choices and values. If they are specified, then the Parameter value is only allowed to be set to one of those values.

  • getValues returns a list of values that the Parameter can be set to.

  • getChoices returns a corresponding list of localized (translated) strings which are shown to the user as the choices for this Parameter, typically in a user interface menu such as ChoiceControl.

When the set of Parameter choices is changed, a GenericEvent should be broadcast with the name CHOICES_MODIFIED. Then any control that is displaying the available choices can update its display.

interface Parameter {
    getAsString(): string;
    getChoices(): string[];
    getName(opt_localized?): string;
    getSubject(): Subject;
    getValue(): any;
    getValues(): string[];
    isComputed(): boolean;
    nameEquals(name): boolean;
    setComputed(value): void;
    setFromString(value): void;
    toStringShort(): string;

Hierarchy (view full)

Implemented by


  • Returns the value of this Parameter in string form.

    Returns string

    the value of this Parameter in string form

  • Name of this SubjectEvent, either the language-independent name for scripting purposes or the localized name for display to user.

    The language-independent name should be the same as the English version but capitalized and with spaces and dashes replaced by underscore, see Util.toName and nameEquals.


    • Optional opt_localized: boolean

      true means return the localized version of the name; default is false which means return the language independent name.

    Returns string

    name of this object

  • Returns the value of this SubjectEvent, or undefined if there is no assigned value.

    Returns any

    the value of this SubjectEvent

  • Returns the set of values corresponding to getChoices that this Parameter can be set to.

    Returns string[]

    set of values that this Parameter can be set to, in string form.

  • Returns whether the value is being automatically computed; setting the value of this Parameter has no effect.

    Examples of automatically computed Parameters: the variables that give the current energy of a simulation. Another example is when the size of a graph's SimView is under control of an AutoScale.

    Returns boolean

    whether the value is being automatically computed

  • Whether this SubjectEvent has the given name, adjusting for the transformation to a language-independent form of the name, as is done by Util.toName.


    • name: string

      the English or language-independent version of the name

    Returns boolean

    whether this SubjectEvent has the given name (adjusted to language-independent form)

  • Sets whether the value is being automatically computed. See isComputed.


    • value: boolean

      whether the value is being automatically computed.

    Returns void

  • Sets the value of this Parameter after converting the given string to the appropriate type (boolean, number or string).


    • value: string

      the value to set this Parameter to, in string form

    Returns void


    if the string cannot be converted to the needed type

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:


    Returns string

    a minimal string representation of this object.

Generated using TypeDoc