Automatically creates a DisplayPath when a NumericalPath is added to a SimList. Observes the SimList of a Simulation, adding or removing DisplayPath to represent the NumericalPath in SimView with a zIndex of -10 so that it appears underneath other objects.

Note that the DisplayPath shows only a single NumericalPath, and is destroyed when that NumericalPath is removed from the SimList.

Setting Style of DisplayPath

To control the style (color, line thickness, etc) used for a particular DisplayPath there are two approaches:

1. Modify the DisplayPath style directly

Modify the DisplayPath's style directly, for example:

const dispPath1 = simView.getDisplayList().find(path1);
dispPath1.setStyle(0, DrawingStyle.lineStyle('red', 2));

2. Modify the prototype

PathObserver has a prototype DisplayPath. When a display property of a DisplayPath is undefined, then the property is fetched from the prototype DisplayPath. If it is also undefined on the prototype then a default value is used.

Keep in mind that all objects with a given prototype will be affected by any changes made to the prototype.

Here is an example where we set the prototype to have a thin blue line.

const pathObs = new PathObserver(simList, simView, null);
pathObs.protoDisplayPath.setStyle(0, DrawingStyle.lineStyle('blue', 1));

Resize the SimView to match NumericalPath

Often we want the SimView's dimensions to match that of the NumericalPath. To have the PathObserver change the bounding rectangle of the SimView to match that of the NumericalPath, specify the simRectSetter argument in the constructor. This will occur whenever the NumericalPath changes.

Implements

Constructors

  • Parameters

    • simList: SimList

      SimList to observe

    • simView: SimView

      the SimView to add DisplayObjects to

    • simRectSetter: null | ((a) => void)

      function to use for resizing the simulation rectangle of the SimView; if null then resizing is not done

    • Optional opt_expand: number

      factor to multiply the width and height by to expand the path bounds, which yields the rectangle used for resizing the SimView. For example, 1.1 will make the bounds 10% larger.

    Returns PathObserver

Methods

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

  • 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:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc