KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > event > GraphicsNodeKeyEvent


1 /*
2
3    Copyright 2000-2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt.event;
19
20 import org.apache.batik.gvt.GraphicsNode;
21
22 /**
23  * An event which indicates that a keystroke occurred in a graphics node.
24  *
25  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
26  * @version $Id: GraphicsNodeKeyEvent.java,v 1.7 2005/02/22 09:13:02 cam Exp $
27  */

28 public class GraphicsNodeKeyEvent extends GraphicsNodeInputEvent {
29
30     static final int KEY_FIRST = 400;
31
32     /**
33      * The "key typed" event. This event is generated when a character is
34      * entered. In the simplest case, it is produced by a single key press.
35      * Often, however, characters are produced by series of key presses, and
36      * the mapping from key pressed events to key typed events may be
37      * many-to-one or many-to-many.
38      */

39     public static final int KEY_TYPED = KEY_FIRST;
40
41     /**
42      * The "key pressed" event. This event is generated when a key
43      * is pushed down.
44      */

45     public static final int KEY_PRESSED = 1 + KEY_FIRST;
46
47     /**
48      * The "key released" event. This event is generated when a key
49      * is let up.
50      */

51     public static final int KEY_RELEASED = 2 + KEY_FIRST;
52
53     /**
54      * The unique value assigned to each of the keys on the
55      * keyboard. There is a common set of key codes that
56      * can be fired by most keyboards.
57      * The symbolic name for a key code should be used rather
58      * than the code value itself.
59      */

60     int keyCode;
61
62     /**
63      * <code>keyChar</code> is a valid unicode character
64      * that is fired by a key or a key combination on
65      * a keyboard.
66      */

67     char keyChar;
68
69     /**
70      * Constructs a new graphics node key event.
71      * @param source the graphics node where the event originated
72      * @param id the id of this event
73      * @param when the time the event occurred
74      * @param modifiers the modifier keys down while event occurred
75      */

76     public GraphicsNodeKeyEvent(GraphicsNode source, int id,
77                                 long when, int modifiers, int keyCode,
78                                 char keyChar) {
79         super(source, id, when, modifiers);
80         this.keyCode = keyCode;
81         this.keyChar = keyChar;
82     }
83
84     /**
85      * Return the integer code for the physical key pressed. Not localized.
86      */

87     public int getKeyCode() {
88         return keyCode;
89     }
90
91     /**
92      * Return a character corresponding to physical key pressed.
93      * May be localized.
94      */

95     public char getKeyChar() {
96         return keyChar;
97     }
98
99 }
100
Popular Tags