jj2000.disp
Class ImgKeyListener
java.lang.Object
|
+--java.awt.event.KeyAdapter
|
+--jj2000.disp.ImgKeyListener
- All Implemented Interfaces:
- java.util.EventListener, java.awt.event.KeyListener
- public class ImgKeyListener
- extends java.awt.event.KeyAdapter
This class implements the listener for keyboard events for the JJ2000
decoder that displays in a ImgScrollPane.
The following key sequences are defined:
- : scroll image up
- : scroll image down
- : scroll image left
- : scroll image right
- : scroll image up by a vertical block increment
- : scroll image down by a vertical block increment
- 'Q' or 'q': exit the application
- '-': zoom out by 2
- '=' or '+': zoom in by 2
- '1': display at a zoom of 1
- 'Ctrl-C': exit the application
The amount by which the arrows scroll the image is determined by the
modifier keys. If the Ctrl key is held down, the block increment will be
used, otherwise the unit increment will. If the Shift key is held down then
the increment is multiplied by ACCEL_FACTOR. That is the Ctrl key selects
between unit and block increments, while the Shift key selects between
normal and accelerated mode.
Field Summary |
static int |
ACCEL_FACTOR
The acceleration factor when the shift key is pressed: 10 |
(package private) Decoder |
dec
Decoder instance |
(package private) java.awt.Frame |
helpFrame
Frame used to display tools |
(package private) ImgScrollPane |
isp
The component where the image is displayed |
Method Summary |
private int |
calcIncrement(java.awt.event.KeyEvent evt,
java.awt.Adjustable adj)
Returns the increment based on the modifier keys of the KeyEvent. |
private static java.awt.TextArea |
getHelp()
Create a help TextArea concerning the tools associated with keys. |
void |
keyPressed(java.awt.event.KeyEvent evt)
Hanldes the keyPressed events. |
void |
keyTyped(java.awt.event.KeyEvent evt)
Handles the key typed event. |
Methods inherited from class java.awt.event.KeyAdapter |
keyReleased |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
helpFrame
java.awt.Frame helpFrame
- Frame used to display tools
isp
ImgScrollPane isp
- The component where the image is displayed
dec
Decoder dec
- Decoder instance
ACCEL_FACTOR
public static final int ACCEL_FACTOR
- The acceleration factor when the shift key is pressed: 10
- See Also:
- Constant Field Values
ImgKeyListener
public ImgKeyListener(ImgScrollPane isp,
Decoder dec)
- Instantiate a new ImgKeyListener that will work on the specified
ImgScrollPane.
- Parameters:
isp
- The image scroll pane on which the actions should
operate.dec
- The decoder instance
keyPressed
public void keyPressed(java.awt.event.KeyEvent evt)
- Hanldes the keyPressed events. Normal keys are not treated here because
some don't have a defined keycode (as incredible as it might seem!).
- Specified by:
keyPressed
in interface java.awt.event.KeyListener
- Overrides:
keyPressed
in class java.awt.event.KeyAdapter
- Parameters:
evt
- The key event to process.
keyTyped
public void keyTyped(java.awt.event.KeyEvent evt)
- Handles the key typed event. Normal (i.e. "text") keys are handled
here.
- Specified by:
keyTyped
in interface java.awt.event.KeyListener
- Overrides:
keyTyped
in class java.awt.event.KeyAdapter
- Parameters:
evt
- The key event to process.
calcIncrement
private int calcIncrement(java.awt.event.KeyEvent evt,
java.awt.Adjustable adj)
- Returns the increment based on the modifier keys of the KeyEvent. If
control is down then the Adjustable block increment is used, otherwise
the unit one is used. If the shift key is down the increment is
multiplied by ACCEL_FACTOR.
- Parameters:
evt
- The KeyEvent fom where to obtain the modifiersadj
- The Adjustable from where to obtain the increments
getHelp
private static java.awt.TextArea getHelp()
- Create a help TextArea concerning the tools associated with keys.
- Returns:
- The help TextArea