JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
NEWTDemoListener.java
Go to the documentation of this file.
1/**
2 * Copyright 2015 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 */
28package com.jogamp.newt.opengl.util;
29
30import java.net.URLConnection;
31import java.util.ArrayList;
32import java.util.List;
33
34import com.jogamp.common.util.IOUtil;
35import com.jogamp.graph.font.FontScale;
36import com.jogamp.nativewindow.CapabilitiesImmutable;
37import com.jogamp.nativewindow.ScalableSurface;
38import com.jogamp.newt.Window;
39import com.jogamp.newt.Display;
40import com.jogamp.newt.Display.PointerIcon;
41import com.jogamp.newt.event.KeyEvent;
42import com.jogamp.newt.event.KeyListener;
43import com.jogamp.newt.event.MouseEvent;
44import com.jogamp.newt.event.MouseListener;
45import com.jogamp.newt.event.WindowAdapter;
46import com.jogamp.newt.event.WindowEvent;
47import com.jogamp.newt.opengl.GLWindow;
48import com.jogamp.opengl.FPSCounter;
49import com.jogamp.opengl.GL;
50import com.jogamp.opengl.GLAnimatorControl;
51import com.jogamp.opengl.GLAutoDrawable;
52import com.jogamp.opengl.GLDrawable;
53import com.jogamp.opengl.GLRunnable;
54import com.jogamp.opengl.util.Gamma;
55import com.jogamp.opengl.util.PNGPixelRect;
56
57import jogamp.newt.driver.PNGIcon;
58
59/**
60 * NEWT {@link GLWindow} Demo functionality
61 * <ul>
62 * <li>SPACE: Toggle animator {@link GLAnimatorControl#pause() pause}/{@link GLAnimatorControl#resume() resume}</li>
63 * <li>A: Toggle window {@link Window#setAlwaysOnTop(boolean) always on top}</li>
64 * <li>B: Toggle window {@link Window#setAlwaysOnBottom(boolean) always on bottom}</li>
65 * <li>C: Toggle different {@link Window#setPointerIcon(PointerIcon) pointer icons}</li>
66 * <li>D: Toggle window {@link Window#setUndecorated(boolean) decoration on/off}</li>
67 * <li>F: Toggle window {@link Window#setFullscreen(boolean) fullscreen on/off}</li>
68 * <li>Three-Finger Double-Tap: Toggle window {@link Window#setFullscreen(boolean) fullscreen on/off}</li>
69 * <li>G: Increase {@link Gamma#setDisplayGamma(GLDrawable, float, float, float) gamma} by 0.1, +SHIFT decrease gamma by 0.1</li>
70 * <li>I: Toggle {@link Window#setPointerVisible(boolean) pointer visbility}</li>
71 * <li>J: Toggle {@link Window#confinePointer(boolean) pointer jail (confine to window)}</li>
72 * <li>M: Toggle {@link Window#setMaximized(boolean, boolean) window maximized}: Y, +CTRL off, +SHIFT toggle X+Y, +ALT X</li>
73 * <li>P: Set window {@link Window#setPosition(int, int) position to 100/100}</li>
74 * <li>Q: Quit</li>
75 * <li>R: Toggle window {@link Window#setResizable(boolean) resizable}</li>
76 * <li>S: Toggle window {@link Window#setSticky(boolean) sticky}</li>
77 * <li>V: Toggle window {@link Window#setVisible(boolean) visibility} for 5s</li>
78 * <li>V: +CTRL: Rotate {@link GL#setSwapInterval(int) swap interval} -1, 0, 1</li>
79 * <li>W: {@link Window#warpPointer(int, int) Warp pointer} to center of window</li>
80 * <li>X: Toggle {@link ScalableSurface#setSurfaceScale(float[]) [{@link ScalableSurface#IDENTITY_PIXELSCALE}, {@link ScalableSurface#AUTOMAX_PIXELSCALE}]</li>
81 * </ul>
82 */
83public class NEWTDemoListener extends WindowAdapter implements KeyListener, MouseListener {
84 protected final GLWindow glWindow;
85 final PointerIcon[] pointerIcons;
86 int pointerIconIdx = 0;
87 float gamma = 1f;
88 float brightness = 0f;
89 float contrast = 1f;
90 boolean confinedFixedCenter = false;
91
92 /**
93 * Creates a new instance with given pointer icons, which are not used if {@code null}.
94 * @param glWin the GLWindow instance to use
95 * @param pointerIcons if {@code null} don't use multiple pointer icons
96 */
97 public NEWTDemoListener(final GLWindow glWin, final PointerIcon[] pointerIcons) {
98 this.glWindow = glWin;
99 this.pointerIcons = pointerIcons;
100 }
101 /**
102 * Creates a new instance with {@link #createPointerIcons(Display)} default pointer icons.
103 * @param glWin the GLWindow instance to use
104 */
105 public NEWTDemoListener(final GLWindow glWin) {
106 this(glWin, createPointerIcons(glWin.getScreen().getDisplay()));
107 }
108
109 protected void printlnState(final String prelude) {
110 System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString());
111 }
112 protected void printlnState(final String prelude, final String post) {
113 System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString()+", "+post);
114 }
115
116 @Override
117 public void keyPressed(final KeyEvent e) {
118 if( e.isAutoRepeat() || e.isConsumed() ) {
119 return;
120 }
121 if( !glWindow.isVisible() ) {
122 printlnState("[key "+e+" but invisible]");
123 return;
124 }
125 final int keySymbol = e.getKeySymbol();
126 switch(keySymbol) {
127 case KeyEvent.VK_SPACE:
128 e.setConsumed(true);
129 glWindow.invokeOnCurrentThread(new Runnable() {
130 @Override
131 public void run() {
133 if( null != anim ) {
134 if( anim.isPaused()) {
135 anim.resume();
136 } else {
137 anim.pause();
138 }
139 }
140 } } );
141 break;
142 case KeyEvent.VK_A:
143 e.setConsumed(true);
144 glWindow.invokeOnNewThread(null, false, new Runnable() {
145 @Override
146 public void run() {
147 printlnState("[set alwaysontop pre]");
149 printlnState("[set alwaysontop post]");
150 } } );
151 break;
152 case KeyEvent.VK_B:
153 e.setConsumed(true);
154 glWindow.invokeOnNewThread(null, false, new Runnable() {
155 @Override
156 public void run() {
157 printlnState("[set alwaysonbottom pre]");
159 printlnState("[set alwaysonbottom post]");
160 } } );
161 break;
162 case KeyEvent.VK_C:
163 e.setConsumed(true);
164 glWindow.invokeOnNewThread(null, false, new Runnable() {
165 @Override
166 public void run() {
167 if( null != pointerIcons ) {
168 printlnState("[set pointer-icon pre]");
169 final PointerIcon currentPI = glWindow.getPointerIcon();
170 final PointerIcon newPI;
171 if( pointerIconIdx >= pointerIcons.length ) {
172 newPI=null;
173 pointerIconIdx=0;
174 } else {
175 newPI=pointerIcons[pointerIconIdx++];
176 }
177 glWindow.setPointerIcon( newPI );
178 printlnState("[set pointer-icon post]", currentPI+" -> "+glWindow.getPointerIcon());
179 }
180 } } );
181 break;
182 case KeyEvent.VK_D:
183 e.setConsumed(true);
184 glWindow.invokeOnNewThread(null, false, new Runnable() {
185 @Override
186 public void run() {
187 printlnState("[set undecorated pre]");
189 printlnState("[set undecorated post]");
190 } } );
191 break;
192 case KeyEvent.VK_F:
193 e.setConsumed(true);
195 glWindow.invokeOnNewThread(null, false, new Runnable() {
196 @Override
197 public void run() {
198 printlnState("[set fullscreen pre]");
199 if( glWindow.isFullscreen() ) {
200 glWindow.setFullscreen( false );
201 } else {
202 if( e.isAltDown() ) {
203 glWindow.setFullscreen( null );
204 } else {
205 glWindow.setFullscreen( true );
206 }
207 }
208 printlnState("[set fullscreen post]");
210 } } );
211 break;
212 case KeyEvent.VK_G:
213 e.setConsumed(true);
214 glWindow.invokeOnNewThread(null, false, new Runnable() {
215 @Override
216 public void run() {
217 final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f );
218 System.err.println("[set gamma]: "+gamma+" -> "+newGamma);
219 if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) {
220 gamma = newGamma;
221 }
222 } } );
223 break;
224 case KeyEvent.VK_I:
225 e.setConsumed(true);
226 glWindow.invokeOnNewThread(null, false, new Runnable() {
227 @Override
228 public void run() {
229 printlnState("[set pointer-visible pre]");
231 printlnState("[set pointer-visible post]");
232 } } );
233 break;
234 case KeyEvent.VK_J:
235 e.setConsumed(true);
236 glWindow.invokeOnNewThread(null, false, new Runnable() {
237 @Override
238 public void run() {
239 printlnState("[set pointer-confined pre]", "warp-center: "+e.isShiftDown());
240 final boolean confine = !glWindow.isPointerConfined();
241 glWindow.confinePointer(confine);
242 printlnState("[set pointer-confined post]", "warp-center: "+e.isShiftDown());
243 if( e.isShiftDown() ) {
244 setConfinedFixedCenter(confine);
245 } else if( !confine ) {
247 }
248 } } );
249 break;
250 case KeyEvent.VK_M:
251 e.setConsumed(true);
252 glWindow.invokeOnNewThread(null, false, new Runnable() {
253 @Override
254 public void run() {
255 // none: max-v
256 // alt: max-h
257 // shift: max-hv
258 // ctrl: max-off
259 final boolean horz, vert;
260 if( e.isControlDown() ) {
261 horz = false;
262 vert = false;
263 } else if( e.isShiftDown() ) {
264 final boolean bothMax = glWindow.isMaximizedHorz() && glWindow.isMaximizedVert();
265 horz = !bothMax;
266 vert = !bothMax;
267 } else if( !e.isAltDown() ) {
268 horz = glWindow.isMaximizedHorz();
269 vert = !glWindow.isMaximizedVert();
270 } else if( e.isAltDown() ) {
271 horz = !glWindow.isMaximizedHorz();
272 vert = glWindow.isMaximizedVert();
273 } else {
274 vert = glWindow.isMaximizedVert();
275 horz = glWindow.isMaximizedHorz();
276 }
277 printlnState("[set maximize pre]", "max[vert "+vert+", horz "+horz+"]");
278 glWindow.setMaximized(horz, vert);
279 printlnState("[set maximize post]", "max[vert "+vert+", horz "+horz+"]");
280 } } );
281 break;
282 case KeyEvent.VK_P:
283 e.setConsumed(true);
284 glWindow.invokeOnNewThread(null, false, new Runnable() {
285 @Override
286 public void run() {
287 printlnState("[set position pre]");
288 glWindow.setPosition(100, 100);
289 printlnState("[set position post]");
290 } } );
291 break;
292 case KeyEvent.VK_Q:
293 if( quitAdapterEnabled && 0 == e.getModifiers() ) {
294 System.err.println("QUIT Key "+Thread.currentThread());
295 quitAdapterShouldQuit = true;
296 }
297 break;
298 case KeyEvent.VK_R:
299 e.setConsumed(true);
300 glWindow.invokeOnNewThread(null, false, new Runnable() {
301 @Override
302 public void run() {
303 printlnState("[set resizable pre]");
305 printlnState("[set resizable post]");
306 } } );
307 break;
308 case KeyEvent.VK_S:
309 e.setConsumed(true);
310 glWindow.invokeOnNewThread(null, false, new Runnable() {
311 @Override
312 public void run() {
313 printlnState("[set sticky pre]");
315 printlnState("[set sticky post]");
316 } } );
317 break;
318 case KeyEvent.VK_V:
319 e.setConsumed(true);
320 if( e.isControlDown() ) {
321 glWindow.invoke(false, new GLRunnable() {
322 @Override
323 public boolean run(final GLAutoDrawable drawable) {
324 final GL gl = drawable.getGL();
325 final int _i = gl.getSwapInterval();
326 final int i;
327 switch(_i) {
328 case 0: i = -1; break;
329 case -1: i = 1; break;
330 case 1: i = 0; break;
331 default: i = 1; break;
332 }
333 gl.setSwapInterval(i);
334
335 final GLAnimatorControl a = drawable.getAnimator();
336 if( null != a ) {
337 a.resetFPSCounter();
338 }
339 if(drawable instanceof FPSCounter) {
340 ((FPSCounter)drawable).resetFPSCounter();
341 }
342 System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval());
343 return true;
344 }
345 });
346 } else {
347 glWindow.invokeOnNewThread(null, false, new Runnable() {
348 @Override
349 public void run() {
350 final boolean wasVisible = glWindow.isVisible();
351 {
352 printlnState("[set visible pre]");
353 glWindow.setVisible(!wasVisible);
354 printlnState("[set visible post]");
355 }
356 if( wasVisible && !e.isShiftDown() ) {
357 try {
358 java.lang.Thread.sleep(5000);
359 } catch (final InterruptedException e) {
360 e.printStackTrace();
361 }
362 printlnState("[reset visible pre]");
363 glWindow.setVisible(true);
364 printlnState("[reset visible post]");
365 }
366 } } );
367 }
368 break;
369 case KeyEvent.VK_W:
370 e.setConsumed(true);
371 glWindow.invokeOnNewThread(null, false, new Runnable() {
372 @Override
373 public void run() {
374 printlnState("[set pointer-pos pre]");
376 printlnState("[set pointer-pos post]");
377 } } );
378 break;
379 case KeyEvent.VK_X:
380 e.setConsumed(true);
381 final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]);
382 final float[] reqSurfacePixelScale;
383 if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
384 reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
385 } else {
386 reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
387 }
388 System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
389 glWindow.setSurfaceScale(reqSurfacePixelScale);
390 final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]);
391 final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]);
392 System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
393 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
394 valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
395 hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
396 setTitle();
397 }
398 }
399 @Override
400 public void keyReleased(final KeyEvent e) { }
401
402 public void setConfinedFixedCenter(final boolean v) {
403 confinedFixedCenter = v;
404 }
405 @Override
406 public void mouseMoved(final MouseEvent e) {
407 if( e.isConfined() ) {
408 mouseCenterWarp(e);
409 }
410 }
411 @Override
412 public void mouseDragged(final MouseEvent e) {
413 if( e.isConfined() ) {
414 mouseCenterWarp(e);
415 }
416 }
417 @Override
418 public void mouseClicked(final MouseEvent e) {
419 if(e.getClickCount() == 2 && e.getPointerCount() == 3) {
421 System.err.println("setFullscreen: "+glWindow.isFullscreen());
422 }
423 }
424 private void mouseCenterWarp(final MouseEvent e) {
425 if(e.isConfined() && confinedFixedCenter ) {
426 final int x=glWindow.getSurfaceWidth()/2;
427 final int y=glWindow.getSurfaceHeight()/2;
428 glWindow.warpPointer(x, y);
429 }
430 }
431 @Override
432 public void mouseEntered(final MouseEvent e) {}
433 @Override
434 public void mouseExited(final MouseEvent e) {}
435 @Override
436 public void mousePressed(final MouseEvent e) {}
437 @Override
438 public void mouseReleased(final MouseEvent e) {}
439 @Override
440 public void mouseWheelMoved(final MouseEvent e) {}
441
442 /////////////////////////////////////////////////////////////
443
444 private boolean quitAdapterShouldQuit = false;
445 private boolean quitAdapterEnabled = false;
446 private boolean quitAdapterEnabled2 = true;
447
448 protected void quitAdapterOff() {
449 quitAdapterEnabled2 = false;
450 }
451 protected void quitAdapterOn() {
453 quitAdapterEnabled2 = true;
454 }
455 public void quitAdapterEnable(final boolean v) { quitAdapterEnabled = v; }
456 public void clearQuitAdapter() { quitAdapterShouldQuit = false; }
457 public boolean shouldQuit() { return quitAdapterShouldQuit; }
458 public void doQuit() { quitAdapterShouldQuit=true; }
459
460 @Override
461 public void windowDestroyNotify(final WindowEvent e) {
462 if( quitAdapterEnabled && quitAdapterEnabled2 ) {
463 System.err.println("QUIT Window "+Thread.currentThread());
464 quitAdapterShouldQuit = true;
465 }
466 }
467
468 /////////////////////////////////////////////////////////////
469
470 public void setTitle() {
472 }
473 public static void setTitle(final GLWindow win) {
474 final CapabilitiesImmutable chosenCaps = win.getChosenCapabilities();
476 final CapabilitiesImmutable caps = null != chosenCaps ? chosenCaps : reqCaps;
477 final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl";
478 final float[] sDPI = FontScale.ppmmToPPI( win.getPixelsPerMM(new float[2]) );
479 final float[] minSurfacePixelScale = win.getMinimumSurfaceScale(new float[2]);
480 final float[] maxSurfacePixelScale = win.getMaximumSurfaceScale(new float[2]);
481 final float[] reqSurfacePixelScale = win.getRequestedSurfaceScale(new float[2]);
482 final float[] hasSurfacePixelScale = win.getCurrentSurfaceScale(new float[2]);
483 win.setTitle("GLWindow["+capsA+"], win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]+
484 ", scale[min "+minSurfacePixelScale[0]+"x"+minSurfacePixelScale[1]+", max "+
485 maxSurfacePixelScale[0]+"x"+maxSurfacePixelScale[1]+", req "+
486 reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" -> has "+
487 hasSurfacePixelScale[0]+"x"+hasSurfacePixelScale[1]+"]");
488 }
489
490 public static PointerIcon[] createPointerIcons(final Display disp) {
491 final List<PointerIcon> pointerIcons = new ArrayList<PointerIcon>();
492 {
493 disp.createNative();
494 {
495 PointerIcon _pointerIcon = null;
496 final IOUtil.ClassResources res = new IOUtil.ClassResources(new String[] { "jogamp/newt/assets/cross-grey-alpha-16x16.png" }, disp.getClass().getClassLoader(), null);
497 try {
498 _pointerIcon = disp.createPointerIcon(res, 8, 8);
499 pointerIcons.add(_pointerIcon);
500 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
501 } catch (final Exception e) {
502 System.err.println(e.getMessage());
503 }
504 }
505 {
506 PointerIcon _pointerIcon = null;
507 final IOUtil.ClassResources res = new IOUtil.ClassResources(new String[] { "jogamp/newt/assets/pointer-grey-alpha-16x24.png" }, disp.getClass().getClassLoader(), null);
508 try {
509 _pointerIcon = disp.createPointerIcon(res, 0, 0);
510 pointerIcons.add(_pointerIcon);
511 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
512 } catch (final Exception e) {
513 System.err.println(e.getMessage());
514 }
515 }
516 {
517 PointerIcon _pointerIcon = null;
518 final IOUtil.ClassResources res = new IOUtil.ClassResources(new String[] { "arrow-red-alpha-64x64.png" }, disp.getClass().getClassLoader(), null);
519 try {
520 _pointerIcon = disp.createPointerIcon(res, 0, 0);
521 pointerIcons.add(_pointerIcon);
522 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
523 } catch (final Exception e) {
524 System.err.println(e.getMessage());
525 }
526 }
527 {
528 PointerIcon _pointerIcon = null;
529 final IOUtil.ClassResources res = new IOUtil.ClassResources(new String[] { "arrow-blue-alpha-64x64.png" }, disp.getClass().getClassLoader(), null);
530 try {
531 _pointerIcon = disp.createPointerIcon(res, 0, 0);
532 pointerIcons.add(_pointerIcon);
533 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
534 } catch (final Exception e) {
535 System.err.println(e.getMessage());
536 }
537 }
538 if( PNGIcon.isAvailable() ) {
539 PointerIcon _pointerIcon = null;
540 final IOUtil.ClassResources res = new IOUtil.ClassResources(new String[] { "jogamp-pointer-64x64.png" }, disp.getClass().getClassLoader(), null);
541 try {
542 final URLConnection urlConn = res.resolve(0);
543 if( null != urlConn ) {
544 final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
545 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size()+1, image.toString());
546 _pointerIcon = disp.createPointerIcon(image, 32, 0);
547 pointerIcons.add(_pointerIcon);
548 System.err.printf("Create PointerIcon #%02d: %s%n", pointerIcons.size(), _pointerIcon.toString());
549 }
550 } catch (final Exception e) {
551 System.err.println(e.getMessage());
552 }
553 }
554 }
555 return pointerIcons.toArray(new PointerIcon[pointerIcons.size()]);
556 }
557}
Simple static font scale methods for unit conversions.
Definition: FontScale.java:37
static float[] ppmmToPPI(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
Definition: FontScale.java:105
abstract void createNative()
Manual trigger the native creation, if it is not done yet.
abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY)
Returns the newly created PointerIcon or null if not implemented on platform.
abstract Display getDisplay()
final boolean isShiftDown()
getModifiers() contains SHIFT_MASK.
final boolean isAutoRepeat()
getModifiers() contains AUTOREPEAT_MASK.
final int getModifiers()
Return the modifier bits of this event, e.g.
final boolean isControlDown()
getModifiers() contains CTRL_MASK.
final boolean isConfined()
getModifiers() contains CONFINED_MASK.
final boolean isAltDown()
getModifiers() contains ALT_MASK.
static final short VK_W
See VK_A.
Definition: KeyEvent.java:639
static final short VK_A
VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A)
Definition: KeyEvent.java:595
static final short VK_C
See VK_A.
Definition: KeyEvent.java:599
static final short VK_M
See VK_A.
Definition: KeyEvent.java:619
final short getKeySymbol()
Returns the virtual key symbol reflecting the current keyboard layout.
Definition: KeyEvent.java:176
static final short VK_P
See VK_A.
Definition: KeyEvent.java:625
static final short VK_SPACE
Constant for the SPACE function key.
Definition: KeyEvent.java:505
static final short VK_D
See VK_A.
Definition: KeyEvent.java:601
static final short VK_S
See VK_A.
Definition: KeyEvent.java:631
static final short VK_R
See VK_A.
Definition: KeyEvent.java:629
static final short VK_Q
See VK_A.
Definition: KeyEvent.java:627
static final short VK_V
See VK_A.
Definition: KeyEvent.java:637
static final short VK_J
See VK_A.
Definition: KeyEvent.java:613
static final short VK_F
See VK_A.
Definition: KeyEvent.java:605
static final short VK_I
See VK_A.
Definition: KeyEvent.java:611
static final short VK_X
See VK_A.
Definition: KeyEvent.java:641
static final short VK_G
See VK_A.
Definition: KeyEvent.java:607
static final short VK_B
See VK_A.
Definition: KeyEvent.java:597
Pointer event of type PointerType.
Definition: MouseEvent.java:74
final int getPointerCount()
See details for multiple-pointer events.
final boolean isConsumed()
Returns true if this events has been consumed, otherwise false.
Definition: NEWTEvent.java:105
final void setConsumed(final boolean consumed)
If consumed is true, this event is marked as consumed, ie.
Definition: NEWTEvent.java:126
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final float[] getMaximumSurfaceScale(final float[] result)
Returns the maximum pixel scale of the associated NativeSurface.
Definition: GLWindow.java:515
final void warpPointer(final int x, final int y)
Moves the pointer to x/y relative to this window's origin in pixel units.
Definition: GLWindow.java:342
final void setPointerIcon(final PointerIcon pi)
Definition: GLWindow.java:322
final String getStateMaskString()
Returns a string representation of the current state mask.
Definition: GLWindow.java:246
final CapabilitiesImmutable getRequestedCapabilities()
Gets an immutable set of requested capabilities.
Definition: GLWindow.java:272
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:466
final void setPointerVisible(final boolean mouseVisible)
Makes the pointer visible or invisible.
Definition: GLWindow.java:312
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:525
final void setTitle(final String title)
Definition: GLWindow.java:297
final boolean isAlwaysOnBottom()
Definition: GLWindow.java:366
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
Definition: GLWindow.java:520
final void setAlwaysOnTop(final boolean value)
Definition: GLWindow.java:351
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
Definition: GLWindow.java:500
final void setMaximized(final boolean horz, final boolean vert)
Definition: GLWindow.java:391
final int getX()
Returns the current x position of this window, relative to it's parent.
Definition: GLWindow.java:436
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
Definition: GLWindow.java:441
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Definition: GLWindow.java:505
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:461
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
Definition: GLWindow.java:534
final void setAlwaysOnBottom(final boolean value)
Definition: GLWindow.java:361
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final PointerIcon getPointerIcon()
Returns the current PointerIcon, which maybe null for the default.
Definition: GLWindow.java:317
final Rectangle getBounds()
Returns a newly created Rectangle containing window origin, getX() & getY(), and size,...
Definition: GLWindow.java:456
final boolean isPointerConfined()
Definition: GLWindow.java:327
final boolean isMaximizedHorz()
Definition: GLWindow.java:401
final void setSticky(final boolean value)
Definition: GLWindow.java:381
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
Definition: GLWindow.java:266
final void setResizable(final boolean value)
Definition: GLWindow.java:371
final boolean isPointerVisible()
Definition: GLWindow.java:307
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
Definition: GLWindow.java:431
final void setUndecorated(final boolean value)
Definition: GLWindow.java:337
final boolean isMaximizedVert()
Definition: GLWindow.java:396
final boolean setSurfaceScale(final float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated NativeSurface, where size_in_pixel_uni...
Definition: GLWindow.java:495
final float[] getMinimumSurfaceScale(final float[] result)
Returns the minimum pixel scale of the associated NativeSurface.
Definition: GLWindow.java:510
final void confinePointer(final boolean grab)
Confine the pointer to this window, ie.
Definition: GLWindow.java:332
void keyReleased(final KeyEvent e)
A key has been released, excluding auto-repeat modifier keys.
void mouseEntered(final MouseEvent e)
Only generated for PointerType#Mouse.
static void setTitle(final GLWindow win)
static PointerIcon[] createPointerIcons(final Display disp)
void mouseExited(final MouseEvent e)
Only generated for PointerType#Mouse.
void printlnState(final String prelude, final String post)
void keyPressed(final KeyEvent e)
A key has been pressed, excluding auto-repeat modifier keys.
NEWTDemoListener(final GLWindow glWin)
Creates a new instance with createPointerIcons(Display) default pointer icons.
void windowDestroyNotify(final WindowEvent e)
Window destruction has been requested.
void mouseWheelMoved(final MouseEvent e)
Traditional event name originally produced by a mouse pointer type.
NEWTDemoListener(final GLWindow glWin, final PointerIcon[] pointerIcons)
Creates a new instance with given pointer icons, which are not used if null.
Provides convenient wrapper for GLDrawableFactory control over individual display's gamma,...
Definition: Gamma.java:60
static boolean setDisplayGamma(final GLDrawable drawable, final float gamma, final float brightness, final float contrast)
Convenient wrapper for GLDrawableFactory#setDisplayGamma(com.jogamp.nativewindow.NativeSurface,...
Definition: Gamma.java:69
static PNGPixelRect read(final InputStream in, final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, final boolean destIsGLOriented)
Reads a PNG image from the specified InputStream.
Specifies an immutable set of capabilities that a window's rendering context must support,...
boolean isBackgroundOpaque()
Returns whether an opaque or translucent surface is requested, supported or chosen.
Adding mutable surface pixel scale property to implementing class, usually to a NativeSurface impleme...
static final float IDENTITY_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in same pixel- and window-units.
static final float AUTOMAX_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale,...
Native PointerIcon handle.
Definition: Display.java:92
Listener for KeyEvents.
FPSCounter feature.
Definition: FPSCounter.java:37
void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean isPaused()
Indicates whether this animator is started and either manually paused or paused automatically due to ...
boolean resume()
Resumes animation if paused.
boolean pause()
Pauses this animator.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
boolean invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all regis...
GLAnimatorControl getAnimator()
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
int getSwapInterval()
Return the current swap interval.