KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > events > DOMMouseEvent


1 /*
2
3    Copyright 2000,2002-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.dom.events;
19
20 import org.w3c.dom.events.EventTarget JavaDoc;
21 import org.w3c.dom.events.MouseEvent JavaDoc;
22 import org.w3c.dom.views.AbstractView;
23
24 /**
25  * The MouseEvent class provides specific contextual information
26  * associated with Mouse events.
27  *
28  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
29  */

30 public class DOMMouseEvent extends DOMUIEvent implements MouseEvent JavaDoc {
31
32     private int screenX;
33     private int screenY;
34     private int clientX;
35     private int clientY;
36     private boolean ctrlKey;
37     private boolean altKey;
38     private boolean shiftKey;
39     private boolean metaKey;
40     private short button;
41     private EventTarget JavaDoc relatedTarget;
42
43     /**
44      * DOM: <code>screenX</code> indicates the horizontal coordinate
45      * at which the event occurred relative to the origin of the
46      * screen coordinate system.
47      */

48     public int getScreenX() {
49     return screenX;
50     }
51
52     /**
53      * DOM: <code>screenY</code> indicates the vertical coordinate at
54      * which the event occurred relative to the origin of the screen
55      * coordinate system.
56      */

57     public int getScreenY() {
58     return screenY;
59     }
60
61     /**
62      * DOM: <code>clientX</code> indicates the horizontal coordinate
63      * at which the event occurred relative to the DOM
64      * implementation's client area.
65      */

66     public int getClientX() {
67     return clientX;
68     }
69
70     /**
71      * DOM: <code>clientY</code> indicates the vertical coordinate at
72      * which the event occurred relative to the DOM implementation's
73      * client area.
74      */

75     public int getClientY() {
76     return clientY;
77     }
78
79     /**
80      * DOM: <code>ctrlKey</code> indicates whether the 'ctrl' key was
81      * depressed during the firing of the event.
82      */

83     public boolean getCtrlKey() {
84     return ctrlKey;
85     }
86
87     /**
88      * DOM: <code>shiftKey</code> indicates whether the 'shift' key
89      * was depressed during the firing of the event.
90      */

91     public boolean getShiftKey() {
92     return shiftKey;
93     }
94
95     /**
96      * DOM: <code>altKey</code> indicates whether the 'alt' key was
97      * depressed during the firing of the event. On some platforms
98      * this key may map to an alternative key name.
99      */

100     public boolean getAltKey() {
101     return altKey;
102     }
103
104     /**
105      * DOM: <code>metaKey</code> indicates whether the 'meta' key was
106      * depressed during the firing of the event. On some platforms
107      * this key may map to an alternative key name.
108      */

109     public boolean getMetaKey() {
110     return metaKey;
111     }
112
113     /**
114      * DOM: During mouse events caused by the depression or release of
115      * a mouse button, <code>button</code> is used to indicate which
116      * mouse button changed state. The values for <code>button</code>
117      * range from zero to indicate the left button of the mouse, one
118      * to indicate the middle button if present, and two to indicate
119      * the right button. For mice configured for left handed use in
120      * which the button actions are reversed the values are instead
121      * read from right to left.
122      */

123     public short getButton() {
124     return button;
125     }
126
127     /**
128      * DOM: Used to identify a secondary <code>EventTarget</code> related
129      * to a UI
130      * event. Currently this attribute is used with the mouseover event to
131      * indicate the <code>EventTarget</code> which the pointing device exited
132      * and with the mouseout event to indicate the <code>EventTarget</code>
133      * which the pointing device entered.
134      */

135     public EventTarget JavaDoc getRelatedTarget() {
136     return relatedTarget;
137     }
138
139     /**
140      * DOM: The <code>initMouseEvent</code> method is used to
141      * initialize the value of a <code>MouseEvent</code> created
142      * through the <code>DocumentEvent</code> interface. This method
143      * may only be called before the <code>MouseEvent</code> has been
144      * dispatched via the <code>dispatchEvent</code> method, though it
145      * may be called multiple times during that phase if necessary.
146      * If called multiple times, the final invocation takes
147      * precedence.
148      *
149      * @param typeArg Specifies the event type.
150      * @param canBubbleArg Specifies whether or not the event can bubble.
151      * @param cancelableArg Specifies whether or not the event's default
152      * action can be prevented.
153      * @param viewArg Specifies the <code>Event</code>'s
154      * <code>AbstractView</code>.
155      * @param detailArg Specifies the <code>Event</code>'s mouse click count.
156      * @param screenXArg Specifies the <code>Event</code>'s screen x coordinate
157      * @param screenYArg Specifies the <code>Event</code>'s screen y coordinate
158      * @param clientXArg Specifies the <code>Event</code>'s client x coordinate
159      * @param clientYArg Specifies the <code>Event</code>'s client y coordinate
160      * @param ctrlKeyArg Specifies whether or not control key was depressed
161      * during the <code>Event</code>.
162      * @param altKeyArg Specifies whether or not alt key was depressed during
163      * the <code>Event</code>.
164      * @param shiftKeyArg Specifies whether or not shift key was depressed
165      * during the <code>Event</code>.
166      * @param metaKeyArg Specifies whether or not meta key was depressed
167      * during the <code>Event</code>.
168      * @param buttonArg Specifies the <code>Event</code>'s mouse button.
169      * @param relatedTargetArg Specifies the <code>Event</code>'s related
170      * <code>EventTarget</code>.
171      */

172     public void initMouseEvent(String JavaDoc typeArg,
173                    boolean canBubbleArg,
174                    boolean cancelableArg,
175                    AbstractView viewArg,
176                    int detailArg,
177                    int screenXArg,
178                    int screenYArg,
179                    int clientXArg,
180                    int clientYArg,
181                    boolean ctrlKeyArg,
182                    boolean altKeyArg,
183                    boolean shiftKeyArg,
184                    boolean metaKeyArg,
185                    short buttonArg,
186                    EventTarget JavaDoc relatedTargetArg) {
187     initUIEvent(typeArg, canBubbleArg, cancelableArg,
188                     viewArg, detailArg);
189     this.screenX = screenXArg;
190     this.screenY = screenYArg;
191     this.clientX = clientXArg;
192     this.clientY = clientYArg;
193     this.ctrlKey = ctrlKeyArg;
194     this.altKey = altKeyArg;
195     this.shiftKey = shiftKeyArg;
196     this.metaKey = metaKeyArg;
197     this.button = buttonArg;
198     this.relatedTarget = relatedTargetArg;
199     }
200 }
201
Popular Tags