From 4d56491c3f8e76676e1c860d018bbe991d28ebac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Nov 2010 01:58:32 +0100 Subject: Seperated unit tests (newt/awt/headless) and cleaned up some imports and comments Seperated unit tests (newt/awt/headless) - no more *CORE* tests - junit.run.newt.headless: all NEWT headless (no-AWT) tests, without any AWT classes and with -Djava.awt.headless=true. Disabled for 'isOSX'. - junit.run.newt: all NEWT non AWT tests (same as above), but with full AWT. This test is not enabled via junit.run. Disabled for 'isOSX'. - junit.run.awt: all AWT tests without NEWT - using newt.event.jar to add AWT agnostic NEWT event adapter - junit.run.newt.awt: all NEWT + AWT tests - junit.run: junit.run.newt.headless,junit.run.awt,junit.run.newt.awt - swizzling around a few tests to achieve the above: TEST rules: - A runnable unit test must start with 'Test' - Only pure NEWT tests must have 'NEWT' in their name - AWT tests must have 'AWT' in their name. - AWT + NEWT tests must have '.newt.' in their package name, hence - Pure AWT tests (without NEWT) must not have '.newt.' in their package name --- .../jogamp/test/junit/jogl/acore/DumpVersion.java | 61 ---- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 1 + ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 330 --------------------- .../test/junit/jogl/demos/gl2/gears/Gears.java | 65 +--- .../junit/jogl/demos/gl2/gears/QuitAdapter.java | 53 ---- .../junit/jogl/demos/gl2/gears/TestGearsAWT.java | 1 + .../junit/jogl/demos/gl2/gears/TestGearsNEWT.java | 124 -------- .../demos/gl2/gears/TestGearsNewtAWTWrapper.java | 113 ------- .../jogl/demos/gl2/gears/newt/TestGearsNEWT.java | 126 ++++++++ .../gl2/gears/newt/TestGearsNewtAWTWrapper.java | 114 +++++++ ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 330 +++++++++++++++++++++ .../com/jogamp/test/junit/util/DumpVersion.java | 61 ++++ .../com/jogamp/test/junit/util/QuitAdapter.java | 53 ++++ .../classes/com/jogamp/newt/event/InputEvent.java | 3 +- .../classes/com/jogamp/newt/event/KeyAdapter.java | 3 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 3 +- .../classes/com/jogamp/newt/event/KeyListener.java | 3 +- .../com/jogamp/newt/event/MouseAdapter.java | 2 - .../classes/com/jogamp/newt/event/MouseEvent.java | 3 +- .../com/jogamp/newt/event/MouseListener.java | 3 +- .../classes/com/jogamp/newt/event/NEWTEvent.java | 4 +- .../com/jogamp/newt/event/NEWTEventFiFo.java | 1 - .../com/jogamp/newt/event/NEWTEventListener.java | 3 +- .../com/jogamp/newt/event/TraceMouseAdapter.java | 2 - .../com/jogamp/newt/event/TraceWindowAdapter.java | 2 - .../com/jogamp/newt/event/WindowAdapter.java | 2 - .../classes/com/jogamp/newt/event/WindowEvent.java | 3 +- .../com/jogamp/newt/event/WindowListener.java | 2 - .../com/jogamp/newt/event/awt/AWTAdapter.java | 73 +++-- .../newt/event/awt/AWTParentWindowAdapter.java | 2 - .../com/jogamp/newt/impl/DefaultEDTUtil.java | 9 +- 31 files changed, 757 insertions(+), 798 deletions(-) delete mode 100644 src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java delete mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java create mode 100644 src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java create mode 100644 src/junit/com/jogamp/test/junit/util/DumpVersion.java create mode 100644 src/junit/com/jogamp/test/junit/util/QuitAdapter.java (limited to 'src') diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java b/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java deleted file mode 100644 index 3fa7f111f..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/acore/DumpVersion.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.test.junit.jogl.acore; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -import javax.media.opengl.*; -import com.jogamp.opengl.util.VersionInfo; -import com.jogamp.common.os.Platform; - -import java.io.IOException; - -public class DumpVersion implements GLEventListener { - - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - - String prefix = Thread.currentThread().getName(); - - System.err.println(VersionInfo.getInfo(null, prefix, gl).toString()); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void display(GLAutoDrawable drawable) { - } - - public void dispose(GLAutoDrawable drawable) { - } -} diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java index e6988582c..0c64cfdf2 100644 --- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java @@ -29,6 +29,7 @@ package com.jogamp.test.junit.jogl.acore; import com.jogamp.test.junit.util.UITestCase; +import com.jogamp.test.junit.util.DumpVersion; import org.junit.Assert; import org.junit.Before; diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java deleted file mode 100644 index 326a6942a..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.test.junit.jogl.awt; - -import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; -import com.jogamp.test.junit.util.*; - -import java.lang.reflect.InvocationTargetException; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; - -import com.jogamp.newt.Screen; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.awt.NewtCanvasAWT; - -import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.media.opengl.GLEventListener; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.BorderFactory; -import javax.swing.border.Border; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { - static long durationPerTest = 500; // ms - static Robot robot; - static Border border; - static JFrame frame; - static JButton button; - static JPanel panel; - static JPanel colorPanel; - static boolean windowClosing; - - boolean modLightBrighter = true; - - Color modLight(Color c) { - Color c2; - if(modLightBrighter) { - c2 = c.brighter(); - } else { - c2 = c.darker(); - } - if(c2.equals(c)) { - modLightBrighter = !modLightBrighter; - } - return c2; - } - - class SwingGLAction implements GLEventListener { - public void init(GLAutoDrawable glad) { - } - - public void dispose(GLAutoDrawable glad) { - } - - public void display(GLAutoDrawable glad) { - colorPanel.setBackground(modLight(colorPanel.getBackground())); - colorPanel.repaint(); - } - - public void reshape(GLAutoDrawable glad, final int x, final int y, final int width, final int height) { - } - } - - @BeforeClass - public static void setup() throws InterruptedException, InvocationTargetException, AWTException { - int count; - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Start Pre-JOGL-Swing"); - - // GLProfile.initSingleton(false); - // GLProfile.initSingleton(true); - - // simulate AWT usage before JOGL's initialization of X11 threading - windowClosing=false; - border = BorderFactory.createLineBorder (Color.yellow, 2); - - panel = new JPanel(); - panel.setLayout(new BorderLayout()); - - button = new JButton("Click me"); - button.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - System.err.println("Test: "+e); - } - }); - panel.add(button, BorderLayout.NORTH); - - colorPanel = new JPanel(); - Dimension size = new Dimension(400,100); - colorPanel.setPreferredSize(size); - colorPanel.setBorder(border); - panel.add(colorPanel, BorderLayout.SOUTH); - - frame = new JFrame("PRE JOGL"); - frame.addWindowListener( new WindowAdapter() { - public void windowClosing(WindowEvent ev) { - windowClosing=true; - } - }); - frame.setContentPane(panel); - frame.setSize(512, 512); - frame.setLocation(0, 0); - frame.pack(); - - // AWT/Swing: From here on (post setVisible(true) - // you need to use AWT/Swing's invokeAndWait() - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(true); - colorPanel.setBackground(Color.white); - colorPanel.repaint(); - }}); - - robot = new Robot(); - robot.setAutoWaitForIdle(true); - - AWTRobotUtil.toFront(robot, frame); - AWTRobotUtil.requestFocus(robot, button); - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Before JOGL init"); - - GLProfile.initSingleton(false); - - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): End Pre-JOGL-Swing"); - } - - @AfterClass - public static void release() throws InterruptedException, InvocationTargetException { - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): Start"); - robot = null; - Assert.assertNotNull(frame); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.dispose(); - } - }); - frame=null; - System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): End"); - } - - protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable) - throws AWTException, InterruptedException, InvocationTargetException { - - Dimension size = new Dimension(400,400); - canvas.setPreferredSize(size); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - panel.add(canvas, BorderLayout.CENTER); - frame.pack(); - } - }); - - AWTRobotUtil.toFront(robot, frame); - - drawable.addGLEventListener(new Gears()); - - for(int i=0; i<100; i++) { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - colorPanel.setBackground(modLight(colorPanel.getBackground())); - colorPanel.repaint(); - } - }); - drawable.display(); // one in process display - Thread.sleep(10); - } - - colorPanel.setBackground(Color.blue); - drawable.addGLEventListener(new SwingGLAction()); - - Point p0 = canvas.getLocationOnScreen(); - Rectangle r0 = canvas.getBounds(); - robot.mouseMove( (int) ( p0.getX() + .5 ) , - (int) ( p0.getY() + .5 ) ); - robot.mousePress(InputEvent.BUTTON1_MASK); - for(int i=0; !windowClosing && i - * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel)

+ * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

* * This version is equal to Brian Paul's version 1.2 1999/10/21 */ @@ -24,8 +20,8 @@ public class Gears implements GLEventListener { private float angle = 0.0f; private int swapInterval; - private int prevMouseX, prevMouseY; private boolean mouseRButtonDown = false; + private int prevMouseX, prevMouseY; public Gears(int swapInterval) { this.swapInterval = swapInterval; @@ -35,42 +31,6 @@ public class Gears implements GLEventListener { this.swapInterval = 1; } - public static void main(String[] args) { - // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example - // - // NotFirstUIActionOnProcess - // - boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ; - GLProfile.initSingleton(firstUIActionOnProcess); - - Frame frame = new Frame("Gear Demo"); - GLCanvas canvas = new GLCanvas(); - // GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - // GLCanvas canvas = new GLCanvas(caps); - - final Gears gears = new Gears(); - canvas.addGLEventListener(gears); - - frame.add(canvas); - frame.setSize(300, 300); - final Animator animator = new Animator(canvas); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent e) { - // Run this on another thread than the AWT event queue to - // make sure the call to Animator.stop() completes before - // exiting - new Thread(new Runnable() { - public void run() { - animator.stop(); - System.exit(0); - } - }).start(); - } - }); - frame.setVisible(true); - animator.start(); - } - public void init(GLAutoDrawable drawable) { System.err.println("Gears: Init"); // Use debug pipeline @@ -113,12 +73,12 @@ public class Gears implements GLEventListener { // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); MouseListener gearsMouse = new GearsMouseAdapter(); - if (drawable instanceof Component) { - Component comp = (Component) drawable; - new AWTMouseAdapter(gearsMouse).addTo(comp); - } else if (drawable instanceof Window) { + if (drawable instanceof Window) { Window window = (Window) drawable; window.addMouseListener(gearsMouse); + } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) drawable; + new AWTMouseAdapter(gearsMouse).addTo(comp); } } @@ -154,9 +114,10 @@ public class Gears implements GLEventListener { // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if ((drawable instanceof GLJPanel) && - !((GLJPanel) drawable).isOpaque() && - ((GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { + if (GLProfile.isAWTAvailable() && + (drawable instanceof javax.media.opengl.awt.GLJPanel) && + !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && + ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { gl.glClear(GL2.GL_DEPTH_BUFFER_BIT); } else { gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); @@ -335,8 +296,8 @@ public class Gears implements GLEventListener { Window window = (Window) source; width=window.getWidth(); height=window.getHeight(); - } else if (source instanceof Component) { - Component comp = (Component) source; + } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) source; width=comp.getWidth(); height=comp.getHeight(); } else { diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java deleted file mode 100644 index e60543b7c..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.test.junit.jogl.demos.gl2.gears; - -import com.jogamp.opengl.util.Animator; -import com.jogamp.newt.event.*; - -class QuitAdapter extends WindowAdapter implements WindowListener, KeyListener { - boolean shouldQuit = false; - - public boolean shouldQuit() { return shouldQuit; } - - public void windowDestroyNotify(WindowEvent e) { - System.out.println("QUIT Window "+Thread.currentThread()); - shouldQuit = true; - } - - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='q') { - System.out.println("QUIT Key "+Thread.currentThread()); - shouldQuit = true; - } - } - public void keyPressed(KeyEvent e) {} - public void keyReleased(KeyEvent e) {} -} - 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 60435cb4a..9639c384b 100644 --- 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 @@ -37,6 +37,7 @@ import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.test.junit.util.UITestCase; +import com.jogamp.test.junit.util.QuitAdapter; import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import java.awt.Frame; 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 deleted file mode 100644 index 1589be84c..000000000 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.test.junit.jogl.demos.gl2.gears; - -import com.jogamp.test.junit.util.UITestCase; - -import javax.media.opengl.*; -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; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.After; -import org.junit.Test; - -public class TestGearsNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(true); - glp = GLProfile.getDefault(); - Assert.assertNotNull(glp); - width = 512; - height = 512; - } - - @AfterClass - public static void releaseClass() { - } - - 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); - QuitAdapter quitAdapter = new QuitAdapter(); - - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - - final GLWindow f_glWindow = glWindow; - glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='f') { - f_glWindow.invoke(false, new GLRunnable() { - public void run(GLAutoDrawable drawable) { - GLWindow win = (GLWindow)drawable; - win.setFullscreen(!win.isFullscreen()); - } }); - } - } - }); - - glWindow.setSize(width, height); - glWindow.setVisible(true); - animator.start(); - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration() * The NEWT will automatically handle the event semantics internally, regardless of whether a program is receiving these events or not.
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java index 4aa17bc02..fe224bba6 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java @@ -28,7 +28,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; import java.util.LinkedList; public class NEWTEventFiFo diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java index 90d00383d..677136573 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,8 +34,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - public interface NEWTEventListener extends java.util.EventListener { } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java index 17d8df80b..14ee633a0 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java @@ -28,8 +28,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - public class TraceMouseAdapter implements MouseListener { MouseListener downstream; diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java index 3545a42d4..88b165a8d 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java @@ -28,8 +28,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - public class TraceWindowAdapter implements WindowListener { WindowListener downstream; diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java index e57138c54..a1ad43a13 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java @@ -28,8 +28,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - public abstract class WindowAdapter implements WindowListener { public void windowResized(WindowEvent e) { diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index 5221b3664..2742e0d95 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,8 +34,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - /** * NEWT Window events are provided for notification purposes ONLY.
* NEWT will automatically handle component moves and resizes internally, regardless of whether a program is receiving these events or not.
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java index 174d4a414..0d201a2a4 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java @@ -34,8 +34,6 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; - public interface WindowListener extends NEWTEventListener { /** Window is resized, your application shall respect the new window dimension. A repaint is recommended. */ public void windowResized(WindowEvent e); diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index c7b4f7b84..c136946ac 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -28,13 +28,12 @@ package com.jogamp.newt.event.awt; -import com.jogamp.newt.util.EDTUtil; import com.jogamp.newt.impl.Debug; /** * Convenient adapter forwarding AWT events to NEWT via the event listener model.
*

- * You may attach an instance of this adapter to an AWT Component. When an event happen, + * You may attach an instance of this adapter to an AWT Component. When an event happens, * it is converted to a NEWT event and the given NEWT listener is being called.

*

* This adapter fullfills three use cases. First as a plain utility to write code AWT agnostic, @@ -47,56 +46,68 @@ import com.jogamp.newt.impl.Debug; * or to an AWT component, e.g. {@link java.awt.Component}.

*

* Common:
- * - javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ;
- com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
- *

+ *
+    // your demo/render code
+    javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ; 
+
+    // your AWT agnostic NEWT mouse listener code
+    com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ; 
+ * 

*

- * NEWT Usage:
- * - GLWindow glWindow = GLWindow.create();
- glWindow.addGLEventListener(demo1);
- glWindow.addMouseListener(mouseListener);
- *

+ * Default NEWT use case, without using the AWTAdapter:
+ *
+    // the NEWT GLAutoDrawable and Window
+    GLWindow glWindow = GLWindow.create();
+
+    // attach the renderer demo1
+    glWindow.addGLEventListener(demo1);
+
+    // attach the NEWT mouse event listener to glWindow
+    glWindow.addMouseListener(mouseListener);
+ * 

*

- * AWT Usage:
- * - GLCanvas glCanvas = new GLCanvas();
- glCanvas.addGLEventListener(demo1);
-
- new AWTMouseAdapter(mouseListener).addTo(glCanvas);
- *

+ * AWT use case, AWTAdapter used as an AWT event translator and forwarder to your NEWT listener:
+ *
+    // the AWT GLAutoDrawable and Canvas
+    GLCanvas glCanvas = new GLCanvas();
+
+    // attach the renderer demo1
+    glCanvas.addGLEventListener(demo1);
+
+    // attach the AWTMouseAdapter to glCanvas, which translates and forwards events to the NEWT mouseListener
+    new AWTMouseAdapter(mouseListener).addTo(glCanvas);
+ * 

*

- * AWT Usage (previous form in detail):
- * - AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
- glCanvas.addMouseListener(mouseAdapter);
- glCanvas.addMouseMotionListener(mouseAdapter);
- *

+ * Previous code in detail:
+ *
+    AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
+    glCanvas.addMouseListener(mouseAdapter);
+    glCanvas.addMouseMotionListener(mouseAdapter);
+ * 

* *

- * Second is just a litte variation, where we pass a NEWT Window
- * to impersonate as the source of the event.

+ * Second use case is just a litte variation of the previous use case, where we pass a NEWT Window
+ * to be used as the source of the event.

*

- * + *

     com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component

new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);
- *

+ *

* * Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.
* *

- * + *

     com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component
glWindow.addMouseListener(mouseListener); // add the custom EventListener to the NEWT component

new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
- *

+ *

* * @see #attachTo */ diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java index 44ad3586e..68f2b3e0f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java @@ -28,8 +28,6 @@ package com.jogamp.newt.event.awt; -import java.awt.KeyboardFocusManager; - /** * Specialized parent/client adapter, * where the NEWT child window really gets resized, diff --git a/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java b/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java index 0fdfd44fe..c5460ef40 100644 --- a/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java @@ -143,8 +143,13 @@ public class DefaultEDTUtil implements EDTUtil { task.run(); wait = false; // running in same thread (EDT) -> no wait if(stop && edt.tasks.size()>0) { - Throwable t = new Throwable("Warning: EDT about (2) to stop, having remaining tasks: "+edt.tasks.size()+" - "+edt); - t.printStackTrace(); + String msg = "Warning: EDT about (2) to stop, having remaining tasks: "+edt.tasks.size()+" - "+edt; + if(DEBUG) { + Throwable t = new Throwable(msg); + t.printStackTrace(); + } else { + System.err.println(msg); + } } } else { synchronized(edt.tasks) { -- cgit v1.2.3