1package com.jogamp.opengl.test.junit.jogl.awt;
3import java.awt.BorderLayout;
4import java.awt.Component;
5import java.awt.Dimension;
6import java.awt.GraphicsConfiguration;
7import java.awt.Rectangle;
8import java.awt.ScrollPane;
10import java.io.IOException;
12import com.jogamp.opengl.GLCapabilities;
13import com.jogamp.opengl.GLProfile;
14import com.jogamp.opengl.awt.GLCanvas;
15import javax.swing.JFrame;
16import javax.swing.JPanel;
17import javax.swing.JScrollPane;
18import javax.swing.JTextArea;
19import javax.swing.WindowConstants;
21import org.junit.Assert;
22import org.junit.Assume;
24import org.junit.FixMethodOrder;
25import org.junit.runners.MethodSorters;
27import com.jogamp.common.util.ReflectionUtil;
28import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
29import com.jogamp.opengl.test.junit.util.MiscUtils;
30import com.jogamp.opengl.test.junit.util.UITestCase;
31import com.jogamp.opengl.util.Animator;
45@FixMethodOrder(MethodSorters.NAME_ASCENDING)
47 static long durationPerTest = 500;
57 @SuppressWarnings(
"serial")
66 ReflectionUtil.callStaticMethod(
67 "com.sun.awt.AWTUtilities",
"setComponentMixingCutoutShape",
68 new Class<?>[] { Component.class, Shape.class },
69 new Object[] {
this,
new Rectangle() } ,
70 GraphicsConfiguration.class.getClassLoader());
71 System.err.println(
"com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) passed");
72 }
catch (
final RuntimeException re) {
73 System.err.println(
"com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) failed: "+re.getMessage());
83 final String typeS = useJScroll ?
"LW" :
"HW";
84 final JFrame frame =
new JFrame(
"Mix Hw/Lw Swing - ScrollPane "+typeS);
85 Assert.assertNotNull(frame);
87 final Dimension f_sz =
new Dimension(600,400);
88 final Dimension glc_sz =
new Dimension(500,600);
91 Assert.assertNotNull(glCanvas);
93 glCanvas.setPreferredSize(glc_sz);
95 final JPanel panel =
new JPanel(
new BorderLayout());
96 panel.setOpaque(
false);
99 panel.add(scrollPane, BorderLayout.CENTER);
101 final ScrollPane scrollPane =
new ScrollPane();
102 scrollPane.add(glCanvas);
103 panel.add(scrollPane, BorderLayout.CENTER);
106 final JTextArea textArea =
new JTextArea();
107 textArea.setText(
"Test\nTest\nTest\nTest\n");
109 panel.add(textArea, BorderLayout.NORTH);
112 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
115 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
117 frame.setLocationRelativeTo(
null);
118 frame.setTitle(
"GLCanvas in JScrollPane example");
120 frame.setVisible(
true);
122 }
catch (
final Throwable t) {
124 Assume.assumeNoException(t);
130 Thread.sleep(durationPerTest);
135 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
137 frame.setVisible(
false);
140 }
catch (
final Throwable t) {
142 Assume.assumeNoException(t);
150 runTestGL(caps,
true);
157 runTestGL(caps,
false);
160 public static void main(
final String args[])
throws IOException {
161 for(
int i=0; i<args.length; i++) {
162 if(args[i].equals(
"-time")) {
163 durationPerTest =
MiscUtils.
atol(args[++i], durationPerTest);
171 System.out.println(
"durationPerTest: "+durationPerTest);
173 org.junit.runner.JUnitCore.
main(tstname);
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
A heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
static long atol(final String str, final long def)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.