static void setComponentSize( final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { try { AWTEDTExecutor.singleton.invoke( true /* wait */, new Runnable() { public void run() { comp1.setMinimumSize(new_sz1); comp1.setPreferredSize(new_sz1); comp1.setSize(new_sz1); if (null != comp2) { comp2.setMinimumSize(new_sz2); comp2.setPreferredSize(new_sz2); comp2.setSize(new_sz2); } if (null != frame) { frame.pack(); } } }); } catch (final Throwable throwable) { throwable.printStackTrace(); Assume.assumeNoException(throwable); } }
/** Example panel. Animate an example file (E short) and play a tone (D long). */ public static void main(String[] args) { try { JFrame f = new JFrame(AnimationPanel.class.getName()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AnimationRenderer ani = new AnimationRenderer(); final AnimationPanel view = new AnimationPanel(ani); f.getContentPane().add(view, BorderLayout.CENTER); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); File file = new File("datafiles/examples/vis/es_.txt"); final AnimationSequence animation = AnimationParser.parseFile(file); String filename = NotesEnum.D.toString().toLowerCase() + "_" + DurationEnum.LONG.codeString() + ".wav"; // System.out.printf("sound clip filename = %s\n", filename); File dir = new File("datafiles/examples/aud"); final Playable audio = SoundClip.findPlayable(filename, dir, false); Runnable r = new Runnable() { @Override public void run() { audio.play(); } }; long currentTime = System.nanoTime(); ani.setAnimationSource( new AnimationSource() { public AnimationSequence getAnimationSequence() { return animation; } public int getNumPoints() { return 5; } public float getDiskRadius() { return 0.3f; } public boolean isConnected() { return true; } }); ani.setNanoStartTime(currentTime); SwingUtilities.invokeLater(r); } catch (Throwable ex) { ex.printStackTrace(); } }
private void run(int type, PerfModule pm) { int width = 800; int height = 480; pmod = pm; System.err.println("Perftst.run()"); try { GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); // For emulation library, use 16 bpp caps.setRedBits(5); caps.setGreenBits(6); caps.setBlueBits(5); caps.setDepthBits(16); Window nWindow = null; if (0 != (type & USE_AWT)) { Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0 nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps); window = GLWindow.create(nWindow); } else { window = GLWindow.create(caps); } window.addMouseListener(this); window.addGLEventListener(this); // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current .. // Size OpenGL to Video Surface window.setSize(width, height); window.setFullscreen(true); window.setVisible(true); window.display(); // Shut things down cooperatively window.destroy(); window.getFactory().shutdown(); System.out.println("Perftst shut down cleanly."); } catch (Throwable t) { t.printStackTrace(); } }
static void setFrameSize( final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { try { AWTEDTExecutor.singleton.invoke( true /* wait */, new Runnable() { public void run() { frame.setSize(new_sz); if (frameLayout) { frame.validate(); } } }); } catch (final Throwable throwable) { throwable.printStackTrace(); Assume.assumeNoException(throwable); } }