|All Implemented Interfaces|
User interface controller for RigidBodySim, provides mouse dragging of nearest moveable RigidBody, and keyboard thrust controls for one or two selected RigidBodys.
When the Clock is running, mouse dragging is accomplished by connecting a spring between
the RigidBody and the mouse position. The spring has zero rest length. The spring
stiffness can be set via
When the Clock is not running, mouse dragging will move the RigidBody. Holding down the alt, meta, or control key will rotate the RigidBody when moving the mouse.
One or two RigidBodys can be specified to have keyboard activated thruster controls with
#setThrusters. You can specify a
of thrust forces for each RigidBody. The keyboard commands to fire thrusters are:
- Right hand controls: keys J, K, L, I and arrow keys.
- Left hand controls: keys S, D, F, E.
Some of these key commands will fire pairs of 'side ways' thrust controls. Holding shift key with those changes the pair of thrusters to give a rotation effect.
new RigidBodyEventHandler( sim, clock )
this.finishDrag( simObject, location, offset ) →
Called at the end of a mouse drag operation, performs whatever action is
appropriate. Only called if
this.handleKeyEvent( keyCode, pressed, keyEvent ) →
Called when a key is pressed or released, performs whatever action is appropriate for that event.
this.mouseDrag( simObject, location, offset, mouseEvent ) →
Called at each movement during a mouse drag, performs whatever action is
appropriate. Only called if
SimObject being moved is passed in, along with the current mouse position, in
simulation coordinates, and an offset calculated at the start of the drag.
The offset is the distance from the SimObject's initial position,
to the mouse position at the start of the drag.
Therefore, setting the SimObject position to
(x - offsetX, y - offsetY)
will move the SimObject smoothly along with the mouse movement.
this.setDragStiffness( stiffness ) →
this.setThrusters( thrusters, side ) →
Set the given ThrusterSet to be activated by keyboard thrust controls. Right hand controls: keys J, K, L, I and arrow keys. Left hand controls: keys S, D, F, E.
this.startDrag( simObject, location, offset, dragBody, mouseEvent ) →
Called at the start of a mouse drag. The nearest dragable SimObject is passed in,
along with mouse position in simulation coordinates. If no dragable SimObject was
null is passed for the first argument. If the EventHandler does not recognize
the SimObject then it should return
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
toStringShort() on a DisplayShape might return something like
Set of internationalized strings.