A collection of static functions for making controls, used in several applications. CommonControls is a 'static' class, meaning it is not instantiated, instead it only a convenient place to keep several common functions for constructing an application.

Properties

LONG_TRAILS: 0.05 = 0.05

Value of alpha for "long trails" effect.

SHORT_TRAILS: 0.1 = 0.1

Value of alpha for "short trails" effect.

Methods

  • Makes a DisplayAxes which shows the simRect of a SimView, adding it to the SimView; and makes a GenericObserver which resizes the axes whenever the SimView's simRect changes (for example because of pan-zoom controls).

    Parameters

    • simView: SimView

      the SimView to add axes to

    • Optional bottomLeft_opt: boolean

      true means to align axes at bottom left. We usually want this for the simulation view. For graphs we want the default which puts the axes thru the origin whenever possible.

    Returns DisplayAxes

    the axes that were created

  • Creates a EasyScriptParser with additional commands 'reset' and 'step' for controlling the SimRunner

    Parameters

    • subjects: Subject[]

      list of Subject's to gather Parameters from; note that the order here is significant; the Parameters are processed according to the order of the Subjects in this list.

    • dependent: Subject[]

      those Subject's whose initial conditions change depending on another configuration parameter. Generally this is the VarsList of a simulation. These must also be included in subjects.

    • simRun: SimRunner

      the SimRunner to use for 'reset' and 'step' commands

    • terminal: Terminal

      the Terminal that executes scripts

    Returns EasyScriptParser

    the EasyScriptParser for controlling the SimRunner

  • Makes controls for pan and zoom of a SimView. Use gray icons so that they are visible with black background or white background.

    Parameters

    • simView: SimView

      the SimView under control

    • overlay: boolean = true

      whether the controls should appear over the parent element, default is true

    • Optional resetFunc: (() => void)

      optional function to execute when click on center button, it should reset the SimView to the original default location and scale; if undefined, then uses current SimView rectangle

        • (): void
        • Returns void

    Returns HTMLDivElement

    the div containing the pan-zoom controls.

  • Make rewind, pause/play, and step controls for SimRunner. Uses icons from the images directory with names rewind.png, forward.png, pause.png, next.png.

    Parameters

    • simrun: SimRunner

      the SimRunner to make controls for

    • Optional opt_overlay: boolean

      whether the controls should appear over the parent_div, default is false.

    Returns GroupControl

    a GroupControl containing all the controls that were made

  • Makes a ParameterBoolean named SHOW_CLOCK for a DisplayClock. The ParameterBoolean causes the DisplayClock to be added to the targetView.

    Makes a GenericObserver which observes the targetView and broadcasts the ParameterBoolean whenever the DisplayClock is added or removed from the targetView.

    Parameters

    Returns ParameterBoolean

    the ParameterBoolean named SHOW_CLOCK

  • Makes a ParameterBoolean named SHOW_ENERGY for an EnergyBarGraph. The ParameterBoolean causes the EnergyBarGraph to be added to the targetView.

    Sets size of EnergyBarGraph based on the targetView size.

    Makes a GenericObserver which observes the targetView and broadcasts the ParameterBoolean whenever the EnergyBarGraph is added or removed from the targetView.

    Parameters

    • energyGraph: EnergyBarGraph
    • targetView: SimView

      where to show the EnergyBarGraph

    • subject: AbstractSubject

      where to add the ParameterBoolean

    • Optional opt_name: string

      name of parameter (optional)

    • Optional opt_i18n_name: string

      localized name of parameter (optional)

    Returns ParameterBoolean

    the ParameterBoolean named SHOW_ENERGY

Generated using TypeDoc