29package com.jogamp.opengl.test.junit.jogl.tile;
31import java.awt.BorderLayout;
32import java.awt.Button;
33import java.awt.Dimension;
37import java.awt.event.ActionEvent;
38import java.awt.event.ActionListener;
39import java.awt.image.BufferedImage;
40import java.awt.print.PageFormat;
41import java.io.BufferedReader;
42import java.io.IOException;
43import java.io.InputStreamReader;
44import java.lang.reflect.InvocationTargetException;
46import com.jogamp.opengl.GLCapabilities;
47import com.jogamp.opengl.GLProfile;
49import org.junit.AfterClass;
50import org.junit.Assert;
51import org.junit.BeforeClass;
52import org.junit.FixMethodOrder;
54import org.junit.runners.MethodSorters;
56import com.jogamp.newt.awt.NewtCanvasAWT;
57import com.jogamp.newt.event.TraceKeyAdapter;
58import com.jogamp.newt.event.TraceWindowAdapter;
59import com.jogamp.newt.event.awt.AWTKeyAdapter;
60import com.jogamp.newt.event.awt.AWTWindowAdapter;
61import com.jogamp.newt.opengl.GLWindow;
62import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
63import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
64import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
65import com.jogamp.opengl.test.junit.util.QuitAdapter;
66import com.jogamp.opengl.util.Animator;
68@FixMethodOrder(MethodSorters.NAME_ASCENDING)
71 static boolean waitForKey =
false;
73 static boolean allow600dpi =
false;
75 static int width, height;
81 Assert.assertNotNull(glp);
85 setTestSupported(
false);
96 final Dimension glc_sz =
new Dimension(width/2, height);
98 Assert.assertNotNull(glad1);
100 Assert.assertNotNull(canvas1);
101 canvas1.setMinimumSize(glc_sz);
102 canvas1.setPreferredSize(glc_sz);
103 canvas1.setSize(glc_sz);
107 Assert.assertNotNull(glad2);
109 Assert.assertNotNull(canvas2);
110 canvas2.setMinimumSize(glc_sz);
111 canvas2.setPreferredSize(glc_sz);
112 canvas2.setSize(glc_sz);
115 final Panel demoPanel =
new Panel();
116 demoPanel.add(canvas1);
117 demoPanel.add(canvas2);
119 final Frame frame =
new Frame(
"Newt/AWT Print");
120 Assert.assertNotNull(frame);
122 final ActionListener print72DPIAction =
new ActionListener() {
123 public void actionPerformed(
final ActionEvent e) {
124 doPrintManual(frame, 72, 0, -1, -1);
126 final ActionListener print300DPIAction =
new ActionListener() {
127 public void actionPerformed(
final ActionEvent e) {
128 doPrintManual(frame, 300, -1, -1, -1);
130 final ActionListener print600DPIAction =
new ActionListener() {
131 public void actionPerformed(
final ActionEvent e) {
132 doPrintManual(frame, 600, -1, -1, -1);
134 final Button print72DPIButton =
new Button(
"72dpi");
135 print72DPIButton.addActionListener(print72DPIAction);
136 final Button print300DPIButton =
new Button(
"300dpi");
137 print300DPIButton.addActionListener(print300DPIAction);
138 final Button print600DPIButton =
new Button(
"600dpi");
139 print600DPIButton.addActionListener(print600DPIAction);
141 frame.setLayout(
new BorderLayout());
142 final Panel printPanel =
new Panel();
143 printPanel.add(print72DPIButton);
144 printPanel.add(print300DPIButton);
145 printPanel.add(print600DPIButton);
146 final Panel southPanel =
new Panel();
147 southPanel.add(
new Label(
"South"));
148 final Panel eastPanel =
new Panel();
149 eastPanel.add(
new Label(
"East"));
150 final Panel westPanel =
new Panel();
151 westPanel.add(
new Label(
"West"));
152 frame.add(printPanel, BorderLayout.NORTH);
153 frame.add(demoPanel, BorderLayout.CENTER);
154 frame.add(southPanel, BorderLayout.SOUTH);
155 frame.add(eastPanel, BorderLayout.EAST);
156 frame.add(westPanel, BorderLayout.WEST);
157 frame.setTitle(
"Tiles Newt/AWT Print Test");
168 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
171 frame.setVisible(
true);
180 boolean printDone =
false;
181 while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.
getTotalFPSDuration()<duration )) {
186 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 72, 0, -1, -1,
false );
187 waitUntilPrintJobsIdle(p);
190 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 72, 8, -1, -1,
false );
191 waitUntilPrintJobsIdle(p);
195 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, -1, -1,
false );
196 waitUntilPrintJobsIdle(p);
200 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, 2048, 2048,
false );
201 waitUntilPrintJobsIdle(p);
205 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, -1, -1,
true );
206 waitUntilPrintJobsIdle(p);
210 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, BufferedImage.TYPE_INT_ARGB_PRE , 150, -1, -1, -1,
false );
211 waitUntilPrintJobsIdle(p);
215 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, BufferedImage.TYPE_INT_ARGB_PRE , 150, -1, -1, -1,
true );
216 waitUntilPrintJobsIdle(p);
220 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 600, -1, -1, -1,
false );
221 waitUntilPrintJobsIdle(p);
226 Assert.assertNotNull(frame);
227 Assert.assertNotNull(canvas1);
228 Assert.assertNotNull(canvas2);
229 Assert.assertNotNull(animator);
232 Assert.assertEquals(
false, animator.isAnimating());
233 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
235 frame.setVisible(
false);
237 Assert.assertEquals(
false, frame.isVisible());
238 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
240 final Frame _frame = frame;
241 _frame.remove(demoPanel);
249 public void test01_aa0() throws InterruptedException, InvocationTargetException {
255 public void test02_aa8() throws InterruptedException, InvocationTargetException {
262 static long duration = 500;
264 public static void main(
final String args[]) {
265 for(
int i=0; i<args.length; i++) {
266 if(args[i].equals(
"-time")) {
269 duration = Integer.parseInt(args[i]);
270 }
catch (
final Exception ex) { ex.printStackTrace(); }
271 }
else if(args[i].equals(
"-600dpi")) {
273 }
else if(args[i].equals(
"-wait")) {
278 final BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
279 System.err.println(
"Press enter to continue");
281 System.err.println(stdin.readLine());
282 }
catch (
final IOException e) { }
AWT Canvas containing a NEWT Window using native parenting.
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...
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
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.
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
Base Printable implementation class.
void runTestGL(final GLCapabilities caps)
static void main(final String args[])
static void releaseClass()
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)
final long getTotalFPSDuration()
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.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.