JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
MouseEvent.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 */
34
35package com.jogamp.newt.event;
36
37import java.util.Arrays;
38
39/**
40 * Pointer event of type {@link PointerType}.
41 * <p>
42 * The historical misleading class name may change in the future to <code>PointerEvent</code>.
43 * </p>
44 * <p>
45 * http://www.w3.org/Submission/pointer-events/#pointerevent-interface
46 * </p>
47 * <a name="coordUnit"><h5>Unit of Coordinates</h5></a>
48 * <p>
49 * All pointer coordinates of this interface are represented in pixel units,
50 * see {@link NativeSurface} and {@link NativeWindow}.
51 * </p>
52 * <a name="multiPtrEvent"><h5>Multiple-Pointer Events</h5></a>
53 * <p>
54 * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is &gt; 1,
55 * the first data element of the multiple-pointer fields represents the pointer triggering this event.<br/>
56 * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc.
57 * </p>
58 * <p>
59 * Multiple-pointer event's {@link #getButton() button number} is mapped to the <i>first {@link #getPointerId(int) pointer ID}</i>
60 * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers}
61 * field represent the pressed pointer IDs.
62 * </p>
63 * <p>
64 * Users can query the pressed button and pointer count via {@link InputEvent#getButtonDownCount()}
65 * or use the simple query {@link InputEvent#isAnyButtonDown()}.
66 * </p>
67 * <p>
68 * If representing a single-pointer {@link PointerType#Mouse} event, {@link #getPointerId(int) pointer-ID} is <code>0</code>
69 * and a {@link #getButton() button value} of <code>0</code> denotes no button activity, i.e. {@link PointerType#Mouse} move.
70 * </p>
71 */
72@SuppressWarnings("serial")
73public class MouseEvent extends InputEvent
74{
75 /** Class of pointer types */
76 public static enum PointerClass implements InputEvent.InputClass {
77 Offscreen, Onscreen, Undefined;
78 }
79
80 /** Type of pointer devices */
81 public static enum PointerType implements InputEvent.InputType {
82 /** {@link PointerClass#Offscreen} mouse. Ordinal 0. */
84 /** {@link PointerClass#Offscreen} touch pad, usually using fingers. Ordinal 1. */
86 /** {@link PointerClass#Onscreen} touch screen, usually using fingers. Ordinal 2. */
88 /** {@link PointerClass#Onscreen} pen usually on screen? Ordinal 3. FIXME*/
90 /** {@link PointerClass#Undefined} ?. Ordinal 4. */
92
93 public PointerClass getPointerClass() { return pc; }
94
95 /**
96 * Returns the matching PointerType value corresponding to the given PointerType's integer ordinal.
97 * <pre>
98 * given:
99 * ordinal = enumValue.ordinal()
100 * reverse:
101 * enumValue = EnumClass.values()[ordinal]
102 * </pre>
103 * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]
104 */
105 public static PointerType valueOf(final int ordinal) throws IllegalArgumentException {
106 final PointerType[] all = PointerType.values();
107 if( 0 <= ordinal && ordinal < all.length ) {
108 return all[ordinal];
109 }
110 throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PointerType.values()[0.."+(all.length-1)+"]");
111 }
112
113 /**
114 * Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values.
115 * <p>
116 * See {@link #valueOf(int)}.
117 * </p>
118 * @throws IllegalArgumentException if one of the given ordinal values is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]
119 */
120 public static PointerType[] valuesOf(final int[] ordinals) throws IllegalArgumentException {
121 final int count = ordinals.length;
122 final PointerType[] types = new PointerType[count];
123 for(int i=count-1; i>=0; i--) {
124 types[i] = PointerType.valueOf(ordinals[i]);
125 }
126 return types;
127 }
128
129 private PointerType(final PointerClass pc) {
130 this.pc = pc;
131 }
133 }
134
135 /** ID for button 1, value <code>1</code> */
136 public static final short BUTTON1 = 1;
137 /** ID for button 2, value <code>2</code> */
138 public static final short BUTTON2 = 2;
139 /** ID for button 3, value <code>3</code> */
140 public static final short BUTTON3 = 3;
141 /** ID for button 4, value <code>4</code> */
142 public static final short BUTTON4 = 4;
143 /** ID for button 5, value <code>5</code> */
144 public static final short BUTTON5 = 5;
145 /** ID for button 6, value <code>6</code> */
146 public static final short BUTTON6 = 6;
147 /** ID for button 6, value <code>7</code> */
148 public static final short BUTTON7 = 7;
149 /** ID for button 6, value <code>8</code> */
150 public static final short BUTTON8 = 8;
151 /** ID for button 6, value <code>9</code> */
152 public static final short BUTTON9 = 9;
153
154 /** Maximum number of buttons, value <code>16</code> */
155 public static final short BUTTON_COUNT = 16;
156
157 /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */
158 public static final float[] getRotationXYZ(final float rotationXorY, final int mods) {
159 final float[] rotationXYZ = new float[] { 0f, 0f, 0f };
160 if( 0 != ( mods & InputEvent.SHIFT_MASK ) ) {
161 rotationXYZ[0] = rotationXorY;
162 } else {
163 rotationXYZ[1] = rotationXorY;
164 }
165 return rotationXYZ;
166 }
167
168 public static final short getClickTimeout() {
169 return 300;
170 }
171
172 /**
173 * Constructor for traditional one-pointer event.
174 *
175 * @param eventType
176 * @param source
177 * @param when
178 * @param modifiers
179 * @param x X-axis
180 * @param y Y-axis
181 * @param clickCount Mouse-button click-count
182 * @param button button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1].
183 * A button value of <code>0</code> denotes no button activity, i.e. {@link PointerType#Mouse} move.
184 * @param rotationXYZ Rotation of all axis
185 * @param rotationScale Rotation scale
186 */
187 public MouseEvent(final short eventType, final Object source, final long when,
188 final int modifiers, final int x, final int y, final short clickCount, final short button,
189 final float[] rotationXYZ, final float rotationScale)
190 {
191 super(eventType, source, when, modifiers);
192 this.x = new int[]{x};
193 this.y = new int[]{y};
194 switch(eventType) {
195 case EVENT_MOUSE_CLICKED:
196 case EVENT_MOUSE_PRESSED:
197 case EVENT_MOUSE_DRAGGED:
198 this.pressure = constMousePressure1;
199 break;
200 default:
201 this.pressure = constMousePressure0;
202 }
203 this.maxPressure= 1.0f;
204 this.pointerID = new short[] { (short)0 };
205 this.clickCount=clickCount;
206 this.button=button;
207 this.rotationXYZ = rotationXYZ;
208 this.rotationScale = rotationScale;
209 this.pointerType = constMousePointerTypes;
210 }
211
212 /**
213 * Constructor for a multiple-pointer event.
214 * <p>
215 * First element of multiple-pointer arrays represents the pointer which triggered the event!
216 * </p>
217 * <p>
218 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
219 * </p>
220 *
221 * @param eventType
222 * @param source
223 * @param when
224 * @param modifiers
225 * @param pointerType PointerType for each pointer (multiple pointer)
226 * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers.
227 * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move.
228 * @param x X-axis for each pointer (multiple pointer)
229 * @param y Y-axis for each pointer (multiple pointer)
230 * @param pressure Pressure for each pointer (multiple pointer)
231 * @param maxPressure Maximum pointer pressure for all pointer
232 * @param button Corresponding mouse-button
233 * @param clickCount Mouse-button click-count
234 * @param rotationXYZ Rotation of all axis
235 * @param rotationScale Rotation scale
236 */
237 public MouseEvent(final short eventType, final Object source, final long when, final int modifiers,
238 final PointerType pointerType[], final short[] pointerID,
239 final int[] x, final int[] y, final float[] pressure, final float maxPressure,
240 final short button, final short clickCount, final float[] rotationXYZ, final float rotationScale)
241 {
242 super(eventType, source, when, modifiers);
243 this.x = x;
244 this.y = y;
245 final int pointerCount = pointerType.length;
246 if(pointerCount != pointerID.length ||
247 pointerCount != x.length ||
248 pointerCount != y.length ||
249 pointerCount != pressure.length) {
250 throw new IllegalArgumentException("All multiple pointer arrays must be of same size");
251 }
252 if( 0.0f >= maxPressure ) {
253 throw new IllegalArgumentException("maxPressure must be > 0.0f");
254 }
255 this.pressure = pressure;
256 this.maxPressure= maxPressure;
257 this.pointerID = pointerID;
258 this.clickCount=clickCount;
259 this.button=button;
260 this.rotationXYZ = rotationXYZ;
261 this.rotationScale = rotationScale;
262 this.pointerType = pointerType;
263 }
264
265 public final MouseEvent createVariant(final short newEventType) {
266 return new MouseEvent(newEventType, source, getWhen(), getModifiers(), pointerType, pointerID,
267 x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale);
268 }
269
270 /**
271 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
272 * @return the count of pointers involved in this event
273 */
274 public final int getPointerCount() {
275 return pointerType.length;
276 }
277
278 /**
279 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
280 * @return the {@link PointerType} for the data at index or null if index not available.
281 */
282 public final PointerType getPointerType(final int index) {
283 if(0 > index || index >= pointerType.length) {
284 return null;
285 }
286 return pointerType[index];
287 }
288
289 /**
290 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
291 * @return array of all {@link PointerType}s for all pointers
292 */
294 return pointerType;
295 }
296
297 /**
298 * Return the pointer id for the given index or -1 if index not available.
299 * <p>
300 * IDs start w/ 0 and are consecutive numbers.
301 * </p>
302 * <p>
303 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
304 * </p>
305 */
306 public final short getPointerId(final int index) {
307 if(0 > index || index >= pointerID.length) {
308 return -1;
309 }
310 return pointerID[index];
311 }
312
313 /**
314 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
315 * @return the pointer index for the given pointer id or -1 if id not available.
316 */
317 public final int getPointerIdx(final short id) {
318 if( id >= 0 ) {
319 for(int i=pointerID.length-1; i>=0; i--) {
320 if( pointerID[i] == id ) {
321 return i;
322 }
323 }
324 }
325 return -1;
326 }
327
328 /**
329 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
330 * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers.
331 */
332 public final short[] getAllPointerIDs() {
333 return pointerID;
334 }
335
336 /**
337 * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1].
338 * <p>
339 * A button value of <code>0</code> denotes no button activity, i.e. {@link PointerType#Mouse} move.
340 * </p>
341 * <p>
342 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
343 * </p>
344 */
345 public final short getButton() {
346 return button;
347 }
348
349 public final short getClickCount() {
350 return clickCount;
351 }
352
353 /**
354 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
355 * @return X-Coord of the triggering pointer-index zero in pixel units.
356 */
357 public final int getX() {
358 return x[0];
359 }
360
361 /**
362 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
363 * @return Y-Coord of the triggering pointer-index zero in pixel units.
364 */
365 public final int getY() {
366 return y[0];
367 }
368
369 /**
370 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
371 * @param index pointer-index within [0 .. {@link #getPointerCount()}-1]
372 * @return X-Coord associated with the pointer-index in pixel units.
373 * @see getPointerId(index)
374 */
375 public final int getX(final int index) {
376 return x[index];
377 }
378
379 /**
380 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
381 * @param index pointer-index within [0 .. {@link #getPointerCount()}-1]
382 * @return Y-Coord associated with the pointer-index in pixel units.
383 * @see getPointerId(index)
384 */
385 public final int getY(final int index) {
386 return y[index];
387 }
388
389 /**
390 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
391 * @return array of all X-Coords for all pointers in pixel units.
392 */
393 public final int[] getAllX() {
394 return x;
395 }
396
397 /**
398 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
399 * @return array of all Y-Coords for all pointers in pixel units.
400 */
401 public final int[] getAllY() {
402 return y;
403 }
404
405 /**
406 * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code>
407 * @return The pressure associated with the pointer-index 0.
408 * The value of zero is return if not available.
409 * @see #getMaxPressure()
410 */
411 public final float getPressure(final boolean normalized){
412 return normalized ? pressure[0] / maxPressure : pressure[0];
413 }
414
415 /**
416 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
417 * @param index pointer-index within [0 .. {@link #getPointerCount()}-1]
418 * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code>
419 * @return The pressure associated with the pointer-index.
420 * The value of zero is return if not available.
421 * @see #getMaxPressure()
422 */
423 public final float getPressure(final int index, final boolean normalized){
424 return normalized ? pressure[index] / maxPressure : pressure[index];
425 }
426
427 /**
428 * See details for <a href="#multiPtrEvent">multiple-pointer events</a>.
429 * @return array of all raw, un-normalized pressures for all pointers
430 */
431 public final float[] getAllPressures() {
432 return pressure;
433 }
434
435 /**
436 * Returns the maximum pressure known for the input device generating this event.
437 * <p>
438 * This value may be self calibrating on devices/OS, where no known maximum pressure is known.
439 * Hence subsequent events may return a higher value.
440 * </p>
441 * <p>
442 * Self calibrating maximum pressure is performed on:
443 * <ul>
444 * <li>Android</li>
445 * </ul>
446 * </p>
447 */
448 public final float getMaxPressure() {
449 return maxPressure;
450 }
451
452 /**
453 * Returns a 3-component float array filled with the values of the rotational axis
454 * in the following order: horizontal-, vertical- and z-axis.
455 * <p>
456 * A vertical rotation of <b>&gt; 0.0f is up</b> and <b>&lt; 0.0f is down</b>.
457 * </p>
458 * <p>
459 * A horizontal rotation of <b>&gt; 0.0f is left</b> and <b>&lt; 0.0f is right</b>.
460 * </p>
461 * <p>
462 * A z-axis rotation of <b>&gt; 0.0f is back</b> and <b>&lt; 0.0f is front</b>.
463 * </p>
464 * <p>
465 * <i>However</i>, on some OS this might be flipped due to the OS <i>default</i> behavior.
466 * The latter is true for OS X 10.7 (Lion) for example.
467 * </p>
468 * <p>
469 * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens},
470 * rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled.
471 * </p>
472 * <p>
473 * On PointerClass {@link PointerClass#Offscreen offscreen} devices, i.e. {@link PointerType#Mouse mouse},
474 * either the horizontal or the vertical rotation value is filled.
475 * </p>
476 * <p>
477 * The {@link InputEvent#SHIFT_MASK} modifier is set in case <b>|horizontal| &gt; |vertical|</b> value.<br/>
478 * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it.
479 * </p>
480 * <p>
481 * In case the pointer type is {@link PointerType#Mouse mouse},
482 * events are usually send in steps of one, ie. <i>-1.0f</i> and <i>1.0f</i>.
483 * Higher values may result due to fast scrolling.
484 * Fractional values may result due to slow scrolling with high resolution devices.<br/>
485 * Here the button number refers to the wheel number.
486 * </p>
487 * <p>
488 * In case the pointer type is of class {@link PointerClass#Onscreen}, e.g. {@link PointerType#TouchScreen touch screen},
489 * see {@link #getRotationScale()} for semantics.
490 * </p>
491 */
492 public final float[] getRotation() {
493 return rotationXYZ;
494 }
495
496 /**
497 * Returns the scale used to determine the {@link #getRotation() rotation value},
498 * which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}.
499 * <p>
500 * For {@link PointerClass#Offscreen}, the scale is usually <code>1.0f</code> and denominates
501 * an abstract value without association to a physical value.
502 * </p>
503 * <p>
504 * For {@link PointerClass#Onscreen}, the scale varies and denominates
505 * the divisor of the distance the finger[s] have moved on the screen.
506 * Hence <code>scale * rotation</code> reproduces the screen distance in pixels the finger[s] have moved.
507 * </p>
508 */
509 public final float getRotationScale() {
510 return rotationScale;
511 }
512
513 @Override
514 public final String toString() {
515 return toString(null).toString();
516 }
517
518 @Override
519 public final StringBuilder toString(StringBuilder sb) {
520 if(null == sb) {
521 sb = new StringBuilder();
522 }
523 sb.append("MouseEvent[").append(getEventTypeString(getEventType()))
524 .append(", ").append(Arrays.toString(x)).append("/").append(Arrays.toString(y))
525 .append(", button ").append(button).append(", count ")
526 .append(clickCount).append(", rotation [").append(rotationXYZ[0]).append(", ").append(rotationXYZ[1]).append(", ").append(rotationXYZ[2]).append("] * ").append(rotationScale);
527 if(pointerID.length>0) {
528 sb.append(", pointer<").append(pointerID.length).append(">[");
529 for(int i=0; i<pointerID.length; i++) {
530 if(i>0) {
531 sb.append(", ");
532 }
533 sb.append(pointerID[i]).append("/").append(pointerType[i]).append(": ")
534 .append(x[i]).append("/").append(y[i]).append(", ")
535 .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]");
536 }
537 sb.append("]");
538 }
539 sb.append(", ");
540 return super.toString(sb).append("]");
541 }
542
543 public static String getEventTypeString(final short type) {
544 switch(type) {
545 case EVENT_MOUSE_CLICKED: return "CLICKED";
546 case EVENT_MOUSE_ENTERED: return "ENTERED";
547 case EVENT_MOUSE_EXITED: return "EXITED";
548 case EVENT_MOUSE_PRESSED: return "PRESSED";
549 case EVENT_MOUSE_RELEASED: return "RELEASED";
550 case EVENT_MOUSE_MOVED: return "MOVED";
551 case EVENT_MOUSE_DRAGGED: return "DRAGGED";
552 case EVENT_MOUSE_WHEEL_MOVED: return "WHEEL_MOVED";
553 default: return "unknown (" + type + ")";
554 }
555 }
556
557 /** PointerType for each pointer (multiple pointer) */
558 private final PointerType pointerType[];
559 /** Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. */
560 private final short pointerID[];
561 /** X-axis for each pointer (multiple pointer) */
562 private final int x[];
563 /** Y-axis for each pointer (multiple pointer) */
564 private final int y[];
565 /** Pressure for each pointer (multiple pointer) */
566 private final float pressure[];
567 // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent!
568 private final short clickCount;
569 /**
570 * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1].
571 * <p>
572 * A button value of <code>0</code> denotes no button activity, i.e. {@link PointerType#Mouse} move.
573 * </p>
574 */
575 private final short button;
576 /** Rotation around the X, Y and X axis */
577 private final float[] rotationXYZ;
578 /** Rotation scale */
579 private final float rotationScale;
580 private final float maxPressure;
581
582 private static final float[] constMousePressure0 = new float[]{0f};
583 private static final float[] constMousePressure1 = new float[]{1f};
584 private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse };
585
586 public static final short EVENT_MOUSE_CLICKED = 200;
587 /** Only generated for {@link PointerType#Mouse} */
588 public static final short EVENT_MOUSE_ENTERED = 201;
589 /** Only generated for {@link PointerType#Mouse} */
590 public static final short EVENT_MOUSE_EXITED = 202;
591 public static final short EVENT_MOUSE_PRESSED = 203;
592 public static final short EVENT_MOUSE_RELEASED = 204;
593 public static final short EVENT_MOUSE_MOVED = 205;
594 public static final short EVENT_MOUSE_DRAGGED = 206;
595 public static final short EVENT_MOUSE_WHEEL_MOVED = 207;
596}
Pointer event of type PointerType.
Definition: MouseEvent.java:74
final short[] getAllPointerIDs()
See details for multiple-pointer events.
final StringBuilder toString(StringBuilder sb)
final PointerType getPointerType(final int index)
See details for multiple-pointer events.
final int getPointerCount()
See details for multiple-pointer events.
final PointerType[] getAllPointerTypes()
See details for multiple-pointer events.
final float getPressure(final int index, final boolean normalized)
See details for multiple-pointer events.
final int getY(final int index)
See details for multiple-pointer events.
final short getButton()
Returns the button number, e.g.
final short getPointerId(final int index)
Return the pointer id for the given index or -1 if index not available.
static final short getClickTimeout()
MouseEvent(final short eventType, final Object source, final long when, final int modifiers, final int x, final int y, final short clickCount, final short button, final float[] rotationXYZ, final float rotationScale)
Constructor for traditional one-pointer event.
MouseEvent(final short eventType, final Object source, final long when, final int modifiers, final PointerType pointerType[], final short[] pointerID, final int[] x, final int[] y, final float[] pressure, final float maxPressure, final short button, final short clickCount, final float[] rotationXYZ, final float rotationScale)
Constructor for a multiple-pointer event.
final int getPointerIdx(final short id)
See details for multiple-pointer events.
final float getMaxPressure()
Returns the maximum pressure known for the input device generating this event.
final float getRotationScale()
Returns the scale used to determine the rotation value, which semantics depends on the pointer type's...
final float[] getAllPressures()
See details for multiple-pointer events.
final int[] getAllX()
See details for multiple-pointer events.
final float getPressure(final boolean normalized)
final int getY()
See details for multiple-pointer events.
final int getX(final int index)
See details for multiple-pointer events.
final int[] getAllY()
See details for multiple-pointer events.
static String getEventTypeString(final short type)
final MouseEvent createVariant(final short newEventType)
static final float[] getRotationXYZ(final float rotationXorY, final int mods)
Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given i...
final float[] getRotation()
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
final int getX()
See details for multiple-pointer events.
static PointerType valueOf(final int ordinal)
Returns the matching PointerType value corresponding to the given PointerType's integer ordinal.
static PointerType[] valuesOf(final int[] ordinals)
Returns the PointerType array of matching PointerType values corresponding to the given PointerType's...
TouchPad
PointerClass#Offscreen touch pad, usually using fingers.
Definition: MouseEvent.java:85
Mouse
PointerClass#Offscreen mouse.
Definition: MouseEvent.java:83
TouchScreen
PointerClass#Onscreen touch screen, usually using fingers.
Definition: MouseEvent.java:87
Pen
PointerClass#Onscreen pen usually on screen? Ordinal 3.
Definition: MouseEvent.java:89