SimList to observe; processes all objects currently on the SimList
the DisplayList to add DisplayObjects to
Prototype DisplayShape for showing collisions.
Prototype DisplayLine for showing ConcreteLines.
Prototype DisplayLine for showing contact forces.
Prototype DisplaySpring for the spring that appears when user clicks mouse near a RigidBody. See RigidBodyEventHandler.
Prototype DisplayShape for showing fixed, infinite mass Polygons.
Prototype DisplayLine for showing forces other than contact and thrust forces.
Prototype DisplayConnector for showing joints.
Prototype DisplayConnector for showing PathEndPoint.
Prototype DisplayShape for showing PointMass objects.
Prototype DisplayShape for showing Polygon.
Prototype DisplayRope for showing Ropes.
Prototype DisplaySpring for showing Springs.
Prototype DisplayLine for showing thrust forces.
Static
orderingWhether to add the next object 'over' or 'under' other DisplayObjects with
the same zIndex
. See DisplayObject.getZIndex.
'over' means the next object will appear above other DisplayObjects
with the same zIndex
; 'under' means it will appear below.
Private
addCreates DisplayObjects for the SimObjects, and add to DisplayList.
Private
addCreates DisplayObject for the SimObject, and adds DisplayObject to DisplayList.
Private
add_Add the DisplayObject to the DisplayList, following the setting of ordering.
the DisplayObject to add
the SimObject being displayed
Notifies this Observer that a change has occurred in the Subject.
contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter
Private
removeRemoves DisplayObject for the given SimObject from the DisplayList.
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'}}
a minimal string representation of this object.
Generated using TypeDoc
Automatically creates a DisplayObject for most types of SimObject when they are added to a SimList. Observes the SimList of a Simulation, adding or removing DisplayObjects to/from a DisplayList to represent the Simulation.
The constructor processes all the objects currently on the SimList, creating DisplayObjects for them.
Setting the Style of a DisplayObject
To control the style (color, line thickness, etc) used for a particular DisplayObject there are two approaches.
1. Modify the style directly
Modify the DisplayObject's style directly after it has been created. Here is an example:
2. Modify the prototype
Many DisplayObjects allow specifying a prototype DisplayObject. When a display property is
undefined
, then the property is fetched from the prototype. If it is alsoundefined
on the prototype then a default value is used.RigidBodyObserver sets up around a dozen prototype objects. The DisplayObjects that RigidBodyObserver creates all have their prototypes set to be these objects. Keep in mind that all objects with that prototype will be affected.
Here is an example where we cause Polygons to draw their names. For apps that extend Engine2DApp, the
rbo
property is an instance of RigidBodyObserver.Displaying Contact Forces
Instances of Force are displayed with DisplayLine objects.
The policy used here is to only show the first contact Force when there is a pair of opposing contact Forces. Forces named 'contact_force1' are shown. Forces named 'contact_force2' are assumed to be the second Force of pair and are not displayed.
See GenericObserver for example code that sets the color of the DisplayLine based on contact gap distance.