JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
AWTMouseAdapter.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.newt.event.awt;
30
31import com.jogamp.nativewindow.NativeSurfaceHolder;
32
33import jogamp.newt.awt.event.AWTNewtEventFactory;
34
35public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener,
36 java.awt.event.MouseMotionListener,
37 java.awt.event.MouseWheelListener
38{
39 public AWTMouseAdapter(final com.jogamp.newt.event.MouseListener newtListener, final NativeSurfaceHolder nsProxy) {
40 super(newtListener, nsProxy);
41 }
42
43 public AWTMouseAdapter(final com.jogamp.newt.event.MouseListener newtListener, final com.jogamp.newt.Window newtProxy) {
44 super(newtListener, newtProxy);
45 }
46
47 public AWTMouseAdapter(final com.jogamp.newt.Window downstream) {
48 super(downstream);
49 }
50
51 public AWTMouseAdapter() {
52 super();
53 }
54
55 @Override
56 public synchronized AWTAdapter addTo(final java.awt.Component awtComponent) {
57 awtComponent.addMouseListener(this);
58 awtComponent.addMouseMotionListener(this);
59 awtComponent.addMouseWheelListener(this);
60 return this;
61 }
62
63 @Override
64 public synchronized AWTAdapter removeFrom(final java.awt.Component awtComponent) {
65 awtComponent.removeMouseListener(this);
66 awtComponent.removeMouseMotionListener(this);
67 awtComponent.removeMouseWheelListener(this);
68 return this;
69 }
70
71 @Override
72 public synchronized void mouseClicked(final java.awt.event.MouseEvent e) {
73 if( !isSetup ) { return; }
74 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
75 if( consumeAWTEvent ) {
76 e.consume();
77 }
78 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
79 ((com.jogamp.newt.event.MouseListener)newtListener).mouseClicked(event);
80 }
81 }
82
83 @Override
84 public synchronized void mouseEntered(final java.awt.event.MouseEvent e) {
85 if( !isSetup ) { return; }
86 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
87 if( consumeAWTEvent ) {
88 e.consume();
89 }
90 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
91 ((com.jogamp.newt.event.MouseListener)newtListener).mouseEntered(event);
92 }
93 }
94
95 @Override
96 public synchronized void mouseExited(final java.awt.event.MouseEvent e) {
97 if( !isSetup ) { return; }
98 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
99 if( consumeAWTEvent ) {
100 e.consume();
101 }
102 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
103 ((com.jogamp.newt.event.MouseListener)newtListener).mouseExited(event);
104 }
105 }
106
107 @Override
108 public synchronized void mousePressed(final java.awt.event.MouseEvent e) {
109 if( !isSetup ) { return; }
110 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
111 if( consumeAWTEvent ) {
112 e.consume();
113 }
114 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
115 ((com.jogamp.newt.event.MouseListener)newtListener).mousePressed(event);
116 }
117 }
118
119 @Override
120 public synchronized void mouseReleased(final java.awt.event.MouseEvent e) {
121 if( !isSetup ) { return; }
122 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
123 if( consumeAWTEvent ) {
124 e.consume();
125 }
126 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
127 ((com.jogamp.newt.event.MouseListener)newtListener).mouseReleased(event);
128 }
129 }
130
131 @Override
132 public synchronized void mouseDragged(final java.awt.event.MouseEvent e) {
133 if( !isSetup ) { return; }
134 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
135 if( consumeAWTEvent ) {
136 e.consume();
137 }
138 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
139 ((com.jogamp.newt.event.MouseListener)newtListener).mouseDragged(event);
140 }
141 }
142
143 @Override
144 public synchronized void mouseMoved(final java.awt.event.MouseEvent e) {
145 if( !isSetup ) { return; }
146 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
147 if( consumeAWTEvent ) {
148 e.consume();
149 }
150 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
151 ((com.jogamp.newt.event.MouseListener)newtListener).mouseMoved(event);
152 }
153 }
154
155 @Override
156 public synchronized void mouseWheelMoved(final java.awt.event.MouseWheelEvent e) {
157 if( !isSetup ) { return; }
158 final com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
159 if( consumeAWTEvent ) {
160 e.consume();
161 }
162 if( EventProcRes.DISPATCH == processEvent(false, event) ) {
163 ((com.jogamp.newt.event.MouseListener)newtListener).mouseWheelMoved(event);
164 }
165 }
166}
167
Pointer event of type PointerType.
Definition: MouseEvent.java:74
Convenient adapter forwarding AWT events to NEWT via the event listener model.
synchronized void mouseWheelMoved(final java.awt.event.MouseWheelEvent e)
AWTMouseAdapter(final com.jogamp.newt.event.MouseListener newtListener, final com.jogamp.newt.Window newtProxy)
synchronized AWTAdapter removeFrom(final java.awt.Component awtComponent)
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
synchronized void mouseDragged(final java.awt.event.MouseEvent e)
synchronized void mouseEntered(final java.awt.event.MouseEvent e)
synchronized void mouseClicked(final java.awt.event.MouseEvent e)
synchronized void mousePressed(final java.awt.event.MouseEvent e)
synchronized void mouseExited(final java.awt.event.MouseEvent e)
synchronized void mouseMoved(final java.awt.event.MouseEvent e)
AWTMouseAdapter(final com.jogamp.newt.Window downstream)
AWTMouseAdapter(final com.jogamp.newt.event.MouseListener newtListener, final NativeSurfaceHolder nsProxy)
synchronized void mouseReleased(final java.awt.event.MouseEvent e)
Accessor interface for implementing classes with ownership of a NativeSurface via an is-a or has-a re...