Class myphysicslab.lab.util.ParameterString

Provided By
All Implemented Interfaces

Provides access to a string value of a Subject. See myphysicslab.lab.util.Parameter for more documentation.

How to Represent an Enum

To create a ParameterString that represents a string enum requires some extra code for satisfying the compiler about the conversion between string and enum. Here is an example from myphysicslab.lab.engine2D.ContactSim:

new ParameterString(this, RigidBodySim.en.EXTRA_ACCEL,
  (/** function(this:myphysicslab.lab.engine2D.ContactSim, string) * /}
  (function(s) { this.setExtraAccel(ExtraAccel.stringToEnum(s)); })),
  ExtraAccel.getChoices(), ExtraAccel.getValues());

This defines a special setter function because setExtraAccel takes an argument of the enum type ExtraAccel, not of type string. (The code example uses a closure compiler 'type cast': the type is in a comment followed by the object in parenthesis.)

See Enums for more information.

new ParameterString( subject, name, localName, getter, setter, opt_choices, opt_values )


the Subject whose value this ParameterString represents


the name of this Parameter; this will be underscorized so the English name can be passed in here. See myphysicslab.lab.util.UtilityCore#toName.


the localized name of this Parameter

getterfunction(this: myphysicslab.lab.util.Subject): string

A method of subject with no arguments that returns the value of this Parameter

setterfunction(this: myphysicslab.lab.util.Subject, string): ?

A method of subject with one argument that sets the value of this Parameter


the translated localized strings corresponding to the values (optional)


the language-independent strings that the parameter can be set to (optional) When specified, only these values are allowed.

Instance Methods