29package com.jogamp.opengl.test.junit.jogl.tile;
31import java.awt.BorderLayout;
32import java.awt.Button;
33import java.awt.Container;
34import java.awt.Dimension;
37import java.awt.event.ActionEvent;
38import java.awt.event.ActionListener;
39import java.awt.print.PageFormat;
40import java.io.BufferedReader;
41import java.io.IOException;
42import java.io.InputStreamReader;
43import java.lang.reflect.InvocationTargetException;
45import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.GLProfile;
47import com.jogamp.opengl.awt.GLJPanel;
48import javax.swing.BorderFactory;
49import javax.swing.JButton;
50import javax.swing.JComponent;
51import javax.swing.JFrame;
52import javax.swing.JLayeredPane;
53import javax.swing.JPanel;
54import javax.swing.SwingUtilities;
56import org.junit.AfterClass;
57import org.junit.Assert;
58import org.junit.BeforeClass;
59import org.junit.FixMethodOrder;
61import org.junit.runners.MethodSorters;
63import com.jogamp.common.os.Platform;
64import com.jogamp.newt.event.TraceKeyAdapter;
65import com.jogamp.newt.event.TraceWindowAdapter;
66import com.jogamp.newt.event.awt.AWTKeyAdapter;
67import com.jogamp.newt.event.awt.AWTWindowAdapter;
68import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
69import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
70import com.jogamp.opengl.test.junit.util.MiscUtils;
71import com.jogamp.opengl.test.junit.util.QuitAdapter;
72import com.jogamp.opengl.util.Animator;
74@FixMethodOrder(MethodSorters.NAME_ASCENDING)
77 static boolean waitForKey =
false;
79 static int width, height;
85 Assert.assertNotNull(glp);
89 setTestSupported(
false);
99 protected void runTestGL(
final GLCapabilities caps,
final boolean addLayout,
final boolean layered,
final boolean skipGLOrientationVerticalFlip,
final boolean useAnim)
throws InterruptedException, InvocationTargetException {
100 final Dimension glc_sz =
new Dimension(width, height);
102 Assert.assertNotNull(glJPanel1);
104 glJPanel1.setMinimumSize(glc_sz);
105 glJPanel1.setPreferredSize(glc_sz);
106 glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height);
113 final JComponent tPanel, demoPanel;
116 final JButton tb =
new JButton(
"On Top");
117 tb.setBounds(width/2, height/2, 200, 50);
120 final Dimension lsz =
new Dimension(width, height);
121 demoPanel =
new JLayeredPane();
122 demoPanel.setMinimumSize(lsz);
123 demoPanel.setPreferredSize(lsz);
124 demoPanel.setBounds(0, 0, lsz.width, lsz.height);
125 demoPanel.setBorder(BorderFactory.createTitledBorder(
"Layered Pane"));
126 demoPanel.add(glJPanel1, JLayeredPane.DEFAULT_LAYER);
127 demoPanel.add(tb, Integer.valueOf(2));
130 tPanel.setBounds(0, 0, width, height);
131 tPanel.setLayout(
null);
133 demoPanel = glJPanel1;
138 demoPanel =
new JPanel();
139 demoPanel.add(glJPanel1);
141 demoPanel = glJPanel1;
145 final JFrame frame =
new JFrame(
"Swing Print");
146 Assert.assertNotNull(frame);
148 final ActionListener print72DPIAction =
new ActionListener() {
149 public void actionPerformed(
final ActionEvent e) {
150 doPrintManual(frame, 72, 0, -1, -1);
152 final ActionListener print150DPIAction =
new ActionListener() {
153 public void actionPerformed(
final ActionEvent e) {
154 doPrintManual(frame, 150, -1, -1, -1);
156 final ActionListener print300DPIAction =
new ActionListener() {
157 public void actionPerformed(
final ActionEvent e) {
158 doPrintManual(frame, 300, -1, -1, -1);
160 final Button print72DPIButton =
new Button(
"72dpi");
161 print72DPIButton.addActionListener(print72DPIAction);
162 final Button print150DPIButton =
new Button(
"150dpi");
163 print150DPIButton.addActionListener(print150DPIAction);
164 final Button print300DPIButton =
new Button(
"300dpi");
165 print300DPIButton.addActionListener(print300DPIAction);
167 final JPanel printPanel =
new JPanel();
168 printPanel.add(print72DPIButton);
169 printPanel.add(print150DPIButton);
170 printPanel.add(print300DPIButton);
171 final JPanel southPanel =
new JPanel();
172 southPanel.add(
new Label(
"South"));
173 final JPanel eastPanel =
new JPanel();
174 eastPanel.add(
new Label(
"East"));
175 final JPanel westPanel =
new JPanel();
176 westPanel.add(
new Label(
"West"));
179 if(
null != animator ) {
180 animator.
add(glJPanel1);
186 SwingUtilities.invokeAndWait(
new Runnable() {
188 final Container fcont = frame.getContentPane();
190 fcont.setLayout(
new BorderLayout());
191 fcont.add(printPanel, BorderLayout.NORTH);
192 fcont.add(demoPanel, BorderLayout.CENTER);
193 fcont.add(southPanel, BorderLayout.SOUTH);
194 fcont.add(eastPanel, BorderLayout.EAST);
195 fcont.add(westPanel, BorderLayout.WEST);
199 frame.setSize(glc_sz);
200 fcont.setLayout(
null);
201 if(
null != tPanel ) {
204 fcont.add(demoPanel);
206 frame.setVisible(
true);
212 if(
null != animator ) {
215 Assert.assertEquals(
true, animator.isAnimating());
218 final long t0 = System.currentTimeMillis();
220 boolean printDone =
false;
221 while( !quitAdapter.shouldQuit() && ( 0 == duration || ( t1 - t0 ) < duration ) ) {
227 final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT,
null, -1 , 150, -1, -1, -1,
false);
228 waitUntilPrintJobsIdle(p);
231 t1 = System.currentTimeMillis();
234 Assert.assertNotNull(frame);
235 Assert.assertNotNull(glJPanel1);
237 if(
null != animator ) {
239 Assert.assertEquals(
false, animator.isAnimating());
241 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
243 frame.setVisible(
false);
245 Assert.assertEquals(
false, frame.isVisible());
246 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
248 final Frame _frame = frame;
249 _frame.remove(demoPanel);
257 runTestGL(caps,
false ,
false ,
false ,
false );
263 runTestGL(caps,
true ,
false ,
false ,
false );
269 runTestGL(caps,
false ,
true ,
false ,
false );
275 runTestGL(caps,
true ,
true ,
false ,
false );
280 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
285 runTestGL(caps,
false ,
false ,
false ,
false );
290 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
295 runTestGL(caps,
true ,
false ,
false ,
false );
300 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
305 runTestGL(caps,
false ,
true ,
false ,
false );
310 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
315 runTestGL(caps,
true ,
true ,
false ,
false );
321 runTestGL(caps,
false ,
false ,
true ,
false );
327 runTestGL(caps,
true ,
false ,
true ,
false );
333 runTestGL(caps,
false ,
true ,
true ,
false );
339 runTestGL(caps,
true ,
true ,
true ,
false );
344 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
349 runTestGL(caps,
false ,
false ,
true ,
false );
354 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
359 runTestGL(caps,
true ,
false ,
true ,
false );
364 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
369 runTestGL(caps,
false ,
true ,
true ,
false );
374 if( Platform.OSType.WINDOWS != Platform.getOSType() ) {
379 runTestGL(caps,
true ,
true ,
true ,
false );
382 static long duration = 500;
384 public static void main(
final String args[]) {
385 for(
int i=0; i<args.length; i++) {
386 if(args[i].equals(
"-time")) {
389 }
else if(args[i].equals(
"-width")) {
392 }
else if(args[i].equals(
"-height")) {
395 }
else if(args[i].equals(
"-wait")) {
400 final BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
401 System.err.println(
"Press enter to continue");
403 System.err.println(stdin.readLine());
404 }
catch (
final IOException e) { }
void setBitmap(final boolean enable)
Requesting offscreen bitmap mode.
AWT: printable: PRESSED (t0), TYPED (t0), RELEASED (t1) non-printable: PRESSED (t0),...
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 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...
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
A lightweight Swing component which provides OpenGL rendering support.
final void setSkipGLOrientationVerticalFlip(final boolean v)
Skip isGLOriented() based vertical flip, which usually is required by the offscreen backend,...
void setOpaque(final boolean opaque)
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
void setFlipVerticalInGLOrientation(final boolean v)
Base Printable implementation class.
Base unit test class implementing issuing PrinterJob#print() on a Printable implementation,...
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.