KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2000,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 java.awt.event.InputEvent JavaDoc;
21
22 import org.apache.batik.gvt.GraphicsNode;
23
24 /**
25  * The root event class for all graphics node-level input events.
26  *
27  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
28  * @version $Id: GraphicsNodeInputEvent.java,v 1.6 2005/02/22 09:13:02 cam Exp $
29  */

30 public abstract class GraphicsNodeInputEvent extends GraphicsNodeEvent {
31
32     /**
33      * The shift key modifier constant.
34      */

35     public static final int SHIFT_MASK = InputEvent.SHIFT_MASK;
36
37     /**
38      * The control key modifier constant.
39      */

40     public static final int CTRL_MASK = InputEvent.CTRL_MASK;
41
42     /**
43      * The meta key modifier constant.
44      */

45     public static final int META_MASK = InputEvent.META_MASK;
46
47     /**
48      * The alt key modifier constant.
49      */

50     public static final int ALT_MASK = InputEvent.ALT_MASK;
51
52     /**
53      * The alt-graph key modifier constant.
54      */

55     public static final int ALT_GRAPH_MASK = InputEvent.ALT_GRAPH_MASK;
56
57     /**
58      * The mouse button1 modifier constant.
59      */

60     public static final int BUTTON1_MASK = InputEvent.BUTTON1_MASK;
61
62     /**
63      * The mouse button2 modifier constant.
64      */

65     public static final int BUTTON2_MASK = InputEvent.ALT_MASK;
66
67     /**
68      * The mouse button3 modifier constant.
69      */

70     public static final int BUTTON3_MASK = InputEvent.META_MASK;
71
72     /**
73      * The graphics node input events Time stamp. The time stamp is in
74      * UTC format that indicates when the input event was
75      * created.
76      */

77     long when;
78
79     /**
80      * The state of the modifier key at the time the graphics node
81      * input event was fired.
82      */

83     int modifiers;
84
85     /**
86      * Constructs a new graphics node input event.
87      * @param source the graphics node where the event originated
88      * @param id the id of this event
89      * @param when the time the event occurred
90      * @param modifiers the modifier keys down while event occurred
91      */

92     protected GraphicsNodeInputEvent(GraphicsNode source, int id,
93                                      long when, int modifiers) {
94         super(source, id);
95         this.when = when;
96         this.modifiers = modifiers;
97     }
98
99     /**
100      * Constructs a new graphics node input event from an AWT InputEvent.
101      * @param source the graphics node where the event originated
102      * @param evt the AWT InputEvent triggering this event's creation
103      */

104     protected GraphicsNodeInputEvent(GraphicsNode source, InputEvent JavaDoc evt) {
105         super(source, evt.getID());
106         this.when = evt.getWhen();
107         this.modifiers = evt.getModifiers();
108     }
109
110     /**
111      * Returns whether or not the Shift modifier is down on this event.
112      */

113     public boolean isShiftDown() {
114         return (modifiers & SHIFT_MASK) != 0;
115     }
116
117     /**
118      * Returns whether or not the Control modifier is down on this event.
119      */

120     public boolean isControlDown() {
121         return (modifiers & CTRL_MASK) != 0;
122     }
123
124     /**
125      * Returns whether or not the Meta modifier is down on this event.
126      */

127     public boolean isMetaDown() {
128         return (modifiers & META_MASK) != 0;
129     }
130
131     /**
132      * Returns whether or not the Alt modifier is down on this event.
133      */

134     public boolean isAltDown() {
135         return (modifiers & ALT_MASK) != 0;
136     }
137
138     /**
139      * Returns whether or not the Alt-Graph modifier is down on this event.
140      */

141     public boolean isAltGraphDown() {
142         return (modifiers & ALT_GRAPH_MASK) != 0;
143     }
144
145     /**
146      * Returns the timestamp of when this event occurred.
147      */

148     public long getWhen() {
149         return when;
150     }
151
152     /**
153      * Returns the modifiers flag for this event.
154      */

155     public int getModifiers() {
156         return modifiers;
157     }
158 }
159
Popular Tags