< Zurück | Inhalt | Weiter >

From AppearanceTest.java


//create the TransformGroup that the Key behavior will affect TransformGroup zoomTg = new TransformGroup(); zoomTg.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE ); zoomTg.setCapability( TransformGroup.ALLOW_TRANSFORM_READ );


//create the Key behavior and add to the scenegraph KeyNavigatorBehavior key = new KeyNavigatorBehavior( zoomTg ); key.setSchedulingBounds( createApplicationBounds() ); key.setEnable( true );

objRoot.addChild( key );


image


The keyboard controls for the KeyNavigatorBehavior are implemented in the KeyNavigator class, which performs the matrix modifications based on key presses. The KeyNavigator class has a fairly sophisticated implementation that includes a large number of movement key combinations and acceleration of movement. The key events that the KeyNavigator class handles are shown in table 11.4.


Table 11.4 KeyNavigatorBehavior keyboard controls


Key press

Effect

DOWN_ARROW

move backward

UP_ARROW

move forward

RIGHT_ARROW

rotate right

LEFT_ARROW

rotate left

PAGE_UP

rotate upward

PAGE_DOWN

rotate downward



ALT + RIGHT_ARROW

move right

ALT + LEFT_ARROW

move left

ALT + PAGE_UP

move upward

ALT+ PAGE_DOWN

move downward



EQUALS (HOME_NOMINAL)

stop movement

SHIFT

fast movement, rotation and scale

SHIFT + META

slow movement, rotation, and scale



PLUS_SIGN

increase Scale

MINUS_SIGN

decrease Scale