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;
48import com.jogamp.opengl.awt.GLCanvas;
50import org.junit.AfterClass;
51import org.junit.Assert;
52import org.junit.BeforeClass;
53import org.junit.FixMethodOrder;
55import org.junit.runners.MethodSorters;
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.opengl.test.junit.jogl.demos.es2.RedSquareES2;
62import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
63import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
64import com.jogamp.opengl.test.junit.util.QuitAdapter;
65import com.jogamp.opengl.util.Animator;
67@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 static boolean waitForKey =
false;
72 static boolean allow600dpi =
false;
74 static int width, height;
80 Assert.assertNotNull(glp);
84 setTestSupported(
false);
95 final Dimension glc_sz =
new Dimension(width/2, height);
97 Assert.assertNotNull(glCanvas1);
98 glCanvas1.setMinimumSize(glc_sz);
99 glCanvas1.setPreferredSize(glc_sz);
104 Assert.assertNotNull(glCanvas2);
105 glCanvas2.setMinimumSize(glc_sz);
106 glCanvas2.setPreferredSize(glc_sz);
110 final Panel demoPanel =
new Panel();
111 demoPanel.add(glCanvas1);
112 demoPanel.add(glCanvas2);
114 final Frame frame =
new Frame(
"AWT Print");
115 Assert.assertNotNull(frame);
117 final ActionListener print72DPIAction =
new ActionListener() {
118 public void actionPerformed(
final ActionEvent e) {
119 doPrintManual(frame, 72, 0, -1, -1);
121 final ActionListener print300DPIAction =
new ActionListener() {
122 public void actionPerformed(
final ActionEvent e) {
123 doPrintManual(frame, 300, -1, -1, -1);
125 final ActionListener print600DPIAction =
new ActionListener() {
126 public void actionPerformed(
final ActionEvent e) {
127 doPrintManual(frame, 600, -1, -1, -1);
129 final Button print72DPIButton =
new Button(
"72dpi");
130 print72DPIButton.addActionListener(print72DPIAction);
131 final Button print300DPIButton =
new Button(
"300dpi");
132 print300DPIButton.addActionListener(print300DPIAction);
133 final Button print600DPIButton =
new Button(
"600dpi");
134 print600DPIButton.addActionListener(print600DPIAction);
136 frame.setLayout(
new BorderLayout());
137 final Panel printPanel =
new Panel();
138 printPanel.add(print72DPIButton);
139 printPanel.add(print300DPIButton);
140 printPanel.add(print600DPIButton);
141 final Panel southPanel =
new Panel();
142 southPanel.add(
new Label(
"South"));
143 final Panel eastPanel =
new Panel();
144 eastPanel.add(
new Label(
"East"));
145 final Panel westPanel =
new Panel();
146 westPanel.add(
new Label(
"West"));
147 frame.add(printPanel, BorderLayout.NORTH);
148 frame.add(demoPanel, BorderLayout.CENTER);
149 frame.add(southPanel, BorderLayout.SOUTH);
150 frame.add(eastPanel, BorderLayout.EAST);
151 frame.add(westPanel, BorderLayout.WEST);
152 frame.setTitle(
"Tiles AWT Print Test");
155 animator.
add(glCanvas1);
156 animator.
add(glCanvas2);
163 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
166 frame.setVisible(
true);
175 boolean printDone =
false;
176 while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.
getTotalFPSDuration()<duration )) {
181 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 72, 0, -1, -1,
false );
182 waitUntilPrintJobsIdle(p);
185 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 72, 8, -1, -1,
false );
186 waitUntilPrintJobsIdle(p);
190 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, -1, -1,
false );
191 waitUntilPrintJobsIdle(p);
195 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, 2048, 2048,
false );
196 waitUntilPrintJobsIdle(p);
200 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 150, -1, -1, -1,
true );
201 waitUntilPrintJobsIdle(p);
205 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, BufferedImage.TYPE_INT_ARGB_PRE , 150, -1, -1, -1,
false );
206 waitUntilPrintJobsIdle(p);
210 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, BufferedImage.TYPE_INT_ARGB_PRE , 150, -1, -1, -1,
true);
211 waitUntilPrintJobsIdle(p);
215 final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE,
null, -1 , 600, -1, -1, -1,
false );
216 waitUntilPrintJobsIdle(p);
221 Assert.assertNotNull(frame);
222 Assert.assertNotNull(glCanvas1);
223 Assert.assertNotNull(glCanvas2);
224 Assert.assertNotNull(animator);
227 Assert.assertEquals(
false, animator.isAnimating());
228 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
230 frame.setVisible(
false);
232 Assert.assertEquals(
false, frame.isVisible());
233 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
235 final Frame _frame = frame;
236 _frame.remove(demoPanel);
242 public void test01_aa0() throws InterruptedException, InvocationTargetException {
248 public void test02_aa8() throws InterruptedException, InvocationTargetException {
255 static long duration = 500;
257 public static void main(
final String args[]) {
258 for(
int i=0; i<args.length; i++) {
259 if(args[i].equals(
"-time")) {
262 duration = Integer.parseInt(args[i]);
263 }
catch (
final Exception ex) { ex.printStackTrace(); }
264 }
else if(args[i].equals(
"-600dpi")) {
266 }
else if(args[i].equals(
"-wait")) {
271 final BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
272 System.err.println(
"Press enter to continue");
274 System.err.println(stdin.readLine());
275 }
catch (
final IOException e) { }
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.
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.
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.
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
Base Printable implementation class.
static void main(final String args[])
static void releaseClass()
void runTestGL(final GLCapabilities caps)
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 setSize(int width, int height)
Requests a new width and height for this AWTGLAutoDrawable.