private void setTitle( final JFrame frame, final GLJPanel glc, final GLCapabilitiesImmutable caps) { final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl"; final java.awt.Rectangle b = glc.getBounds(); final float[] minSurfacePixelScale = glc.getMinimumSurfaceScale(new float[2]); final float[] maxSurfacePixelScale = glc.getMaximumSurfaceScale(new float[2]); final float[] reqSurfacePixelScale = glc.getRequestedSurfaceScale(new float[2]); final float[] hasSurfacePixelScale = glc.getCurrentSurfaceScale(new float[2]); frame.setTitle( "GLJPanel[" + capsA + "], swapI " + swapInterval + ", win: [" + b.x + "/" + b.y + " " + b.width + "x" + b.height + "], pix: " + glc.getSurfaceWidth() + "x" + glc.getSurfaceHeight() + ", scale[min " + minSurfacePixelScale[0] + "x" + minSurfacePixelScale[1] + ", max " + maxSurfacePixelScale[0] + "x" + maxSurfacePixelScale[1] + ", req " + reqSurfacePixelScale[0] + "x" + reqSurfacePixelScale[1] + " -> has " + hasSurfacePixelScale[0] + "x" + hasSurfacePixelScale[1] + "]"); }
protected GLJPanel newGLJPanel( final JFrame frame, final GLCapabilities caps, final FPSAnimator animator, final SnapshotGLEventListener snap) throws AWTException, InterruptedException, InvocationTargetException { final GLJPanel glJPanel = new GLJPanel(caps); Assert.assertNotNull(glJPanel); glJPanel.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel.setMinimumSize(wsize); glJPanel.setPreferredSize(wsize); glJPanel.setSize(wsize); glJPanel.setSurfaceScale(reqSurfacePixelScale); { final GLEventListener demo = createDemo(caps); if (null != demo) { glJPanel.addGLEventListener(demo); } } if (null != snap) { glJPanel.addGLEventListener(snap); } glJPanel.addGLEventListener( new GLEventListener() { @Override public void init(final GLAutoDrawable drawable) {} @Override public void dispose(final GLAutoDrawable drawable) {} @Override public void display(final GLAutoDrawable drawable) {} @Override public void reshape( final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { setTitle(frame, glJPanel, caps); } }); setTitle(frame, glJPanel, caps); frame.addComponentListener( new ComponentListener() { @Override public void componentResized(final ComponentEvent e) { setTitle(frame, glJPanel, caps); } @Override public void componentMoved(final ComponentEvent e) { setTitle(frame, glJPanel, caps); } @Override public void componentShown(final ComponentEvent e) {} @Override public void componentHidden(final ComponentEvent e) {} }); if (SwingUtilities.isEventDispatchThread()) { frame.getContentPane().add(glJPanel, BorderLayout.CENTER); frame.getContentPane().validate(); frame.pack(); frame.setVisible(true); } else { SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.getContentPane().add(glJPanel, BorderLayout.CENTER); frame.getContentPane().validate(); frame.pack(); frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel, true)); final float[] minSurfacePixelScale = glJPanel.getMinimumSurfaceScale(new float[2]); final float[] maxSurfacePixelScale = glJPanel.getMaximumSurfaceScale(new float[2]); final float[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new float[2]); final float[] hasSurfacePixelScale = glJPanel.getCurrentSurfaceScale(new float[2]); System.err.println( "HiDPI PixelScale: min " + minSurfacePixelScale[0] + "x" + minSurfacePixelScale[1] + ", max " + maxSurfacePixelScale[0] + "x" + maxSurfacePixelScale[1] + ", req " + reqSurfacePixelScale[0] + "x" + reqSurfacePixelScale[1] + " -> val " + valReqSurfacePixelScale[0] + "x" + valReqSurfacePixelScale[1] + " -> has " + hasSurfacePixelScale[0] + "x" + hasSurfacePixelScale[1]); setTitle(frame, glJPanel, caps); } if (null != animator) { animator.add(glJPanel); animator.setUpdateFPSFrames(60, System.err); } return glJPanel; }