From 6e273ec07af21ad3c2a1b50fece9f46a3cc92658 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 24 Apr 2010 14:27:18 +0200 Subject: NEWT Cleanup - Moved all implementation details (awt/x11/windows/macosx/..) to com.jogamp.newt.impl - Moved awt event handling com.jogamp.newt.awt.event -> com.jogamp.newt.event.awt - NEWTEvent extends java.util.EventObject - NEWTEventListener extends java.util.EventListener - Added Trace*Adapter, logging the event, incl. the time lag --- .../jogl/demos/gl2/gears/DebugKeyAdapter.java | 50 ---------------------- .../test/junit/jogl/demos/gl2/gears/Gears.java | 4 +- .../junit/jogl/demos/gl2/gears/TestGearsAWT.java | 5 ++- .../junit/jogl/demos/gl2/gears/TestGearsNEWT.java | 4 +- 4 files changed, 8 insertions(+), 55 deletions(-) delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java (limited to 'src/junit/com/jogamp/test') diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java deleted file mode 100644 index da5e7d62f..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -package com.jogamp.test.junit.jogl.demos.gl2.gears; - -import com.jogamp.newt.event.*; - -class DebugKeyAdapter extends KeyAdapter { - - public void keyPressed(KeyEvent e) { - System.out.println("KEY-PRESSED "+Thread.currentThread()+": "+e); - } - public void keyReleased(KeyEvent e) { - System.out.println("KEY-RELEASED "+Thread.currentThread()+": "+e); - } - public void keyTyped(KeyEvent e) { - System.out.println("KEY-TYPED "+Thread.currentThread()+": "+e); - } -} - diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java index 45d5a4a58..956f4f1e3 100644 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java @@ -4,7 +4,7 @@ package com.jogamp.test.junit.jogl.demos.gl2.gears; import javax.media.opengl.*; import javax.media.opengl.awt.*; import com.jogamp.newt.event.*; -import com.jogamp.newt.awt.event.*; +import com.jogamp.newt.event.awt.*; import java.awt.Component; import com.jogamp.newt.Window; @@ -64,7 +64,7 @@ public class Gears implements GLEventListener { gl.glEnable(GL2.GL_NORMALIZE); - GearsMouseAdapter gearsMouse = new GearsMouseAdapter(); + MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); if (drawable instanceof Component) { Component comp = (Component) drawable; diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java index 36146df58..dc0923ee8 100755 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java @@ -35,7 +35,8 @@ package com.jogamp.test.junit.jogl.demos.gl2.gears; import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import javax.media.opengl.awt.GLCanvas; -import com.jogamp.newt.awt.event.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import java.awt.Frame; @@ -77,7 +78,7 @@ public class TestGearsAWT { Animator animator = new Animator(glCanvas); QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter(); - new AWTKeyAdapter(new DebugKeyAdapter()).addTo(glCanvas); + new AWTKeyAdapter(new TraceKeyAdapter()).addTo(glCanvas); new AWTKeyAdapter(quitKeyAdapter).addTo(glCanvas); frame.setVisible(true); diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java index e1de72ab5..835d19185 100755 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java @@ -37,6 +37,7 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import com.jogamp.newt.*; +import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; import org.junit.Assert; @@ -65,13 +66,14 @@ public class TestGearsNEWT { protected void runTestGL(GLCapabilities caps) throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test"); glWindow.addGLEventListener(new Gears()); Animator animator = new Animator(glWindow); QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter(); - glWindow.addKeyListener(new DebugKeyAdapter()); + glWindow.addKeyListener(new TraceKeyAdapter()); glWindow.addKeyListener(quitKeyAdapter); glWindow.setSize(width, height); -- cgit v1.2.3