the simulation to handle events for
the clock that determines whether the simulation is running
Private
optionwhether alt, meta or control key is down
Private
shiftRemember whether shift key was down when these keys (left, right, S, F) are first pressed, so that we use the same value for shift key when the key is released. (Fixes the 'stuck thruster' problem).
Private
startfor rotating a body
Private
startfor rotating a body
Called at the end of a mouse drag operation, performs whatever action is
appropriate. Only called if startDrag returned true
.
the SimObject being dragged, or null
if no SimObject was found
the location of the mouse in
simulation coordinates of the SimView where simObject
was found, or in the
focus view
if simObject
is null
.
distance from the initial object position to the mouse location at start of drag.
Called when a key is pressed or released, performs whatever action is appropriate for that event.
the KeyboardEvent that happened
true
means this is a key-down event; false
means a key-up event
the modifier keys down during event
Called at each movement during a mouse drag, performs whatever action is
appropriate. Only called if startDrag returned true
.
The 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.
Setting the SimObject position to (x - offsetX, y - offsetY)
will move the SimObject
smoothly along with the mouse movement.
the SimObject being dragged, or null
if no SimObject was found
the location of the mouse in
simulation coordinates of the SimView where simObject
was found, or in the
focus view
if simObject
is null
.
distance from the initial object position (from DisplayObject.getPosition) to the mouse location at start of drag.
Private
resetSet 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
.
the ThrusterSet to be activated by keyboard commands, or null to turn off this set of thruster controls
'right' sets right hand controls, 'left' sets left hand controls
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
found, null
is passed for the first argument. If the EventHandler does not recognize
the SimObject then it should return false
.
the SimObject that is nearest to the mouse drag coordinates,
or null
if no SimObject was found
the location of the mouse in
simulation coordinates of the SimView where simObject
was found, or in the
focus view
if simObject
is null
.
distance from the initial object position (from DisplayObject.getPosition) to the mouse location at start of drag
location of 'drag point' on the
SimObject in body coordinates of the SimObject; this is where for example a spring
will be attached on the SimObject when dragging; or null
when no SimObject
was found
the modifier keys down during event
true
if the EventHandler will handle dragging the SimObject
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
User interface controller for RigidBodySim, provides mouse dragging of nearest moveable RigidBody, and keyboard thrust controls for one or two selected RigidBodys.
Mouse Drag
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 setDragStiffness.
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.
Thrusters
One or two RigidBodys can be specified to have keyboard activated thruster controls with setThrusters. You can specify a ThrusterSet of thrust forces for each RigidBody. The keyboard commands to fire thrusters are:
Some of the key commands will fire pairs of 'side ways' thrust controls. Holding shift key changes the pair of thrusters to give a rotation effect.
TO DO extract the stuff about thrusters into a subclass or decorating class, so that the mouse drag stuff could be reused separately.