001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.gvt.event;
020:
021: import org.apache.batik.gvt.GraphicsNode;
022:
023: /**
024: * An event which indicates that a keystroke occurred in a graphics node.
025: *
026: * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
027: * @version $Id: GraphicsNodeKeyEvent.java 475477 2006-11-15 22:44:28Z cam $
028: */
029: public class GraphicsNodeKeyEvent extends GraphicsNodeInputEvent {
030:
031: static final int KEY_FIRST = 400;
032:
033: /**
034: * The "key typed" event. This event is generated when a character is
035: * entered. In the simplest case, it is produced by a single key press.
036: * Often, however, characters are produced by series of key presses, and
037: * the mapping from key pressed events to key typed events may be
038: * many-to-one or many-to-many.
039: */
040: public static final int KEY_TYPED = KEY_FIRST;
041:
042: /**
043: * The "key pressed" event. This event is generated when a key
044: * is pushed down.
045: */
046: public static final int KEY_PRESSED = 1 + KEY_FIRST;
047:
048: /**
049: * The "key released" event. This event is generated when a key
050: * is let up.
051: */
052: public static final int KEY_RELEASED = 2 + KEY_FIRST;
053:
054: /**
055: * The unique value assigned to each of the keys on the
056: * keyboard. There is a common set of key codes that
057: * can be fired by most keyboards.
058: * The symbolic name for a key code should be used rather
059: * than the code value itself.
060: */
061: protected int keyCode;
062:
063: /**
064: * <code>keyChar</code> is a valid unicode character
065: * that is fired by a key or a key combination on
066: * a keyboard.
067: */
068: protected char keyChar;
069:
070: /**
071: * The key location.
072: */
073: protected int keyLocation;
074:
075: /**
076: * Constructs a new graphics node key event.
077: * @param source the graphics node where the event originated
078: * @param id the id of this event
079: * @param when the time the event occurred
080: * @param modifiers the modifier keys down while event occurred
081: * @param lockState bitmask indicating which key locks were activated
082: * @param keyCode the Java key code
083: * @param keyChar the generated character
084: * @param keyLocation the location of the key
085: */
086: public GraphicsNodeKeyEvent(GraphicsNode source, int id, long when,
087: int modifiers, int lockState, int keyCode, char keyChar,
088: int keyLocation) {
089: super (source, id, when, modifiers, lockState);
090: this .keyCode = keyCode;
091: this .keyChar = keyChar;
092: this .keyLocation = keyLocation;
093: }
094:
095: /**
096: * Return the integer code for the physical key pressed. Not localized.
097: */
098: public int getKeyCode() {
099: return keyCode;
100: }
101:
102: /**
103: * Return a character corresponding to physical key pressed.
104: * May be localized.
105: */
106: public char getKeyChar() {
107: return keyChar;
108: }
109:
110: /**
111: * Returns the key location.
112: */
113: public int getKeyLocation() {
114: return keyLocation;
115: }
116: }
|