com.jogamp.newt.awt.NewtCanvasAWT Java Examples
The following examples show how to use
com.jogamp.newt.awt.NewtCanvasAWT.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapViewTileRenderer.java From constellation with Apache License 2.0 | 5 votes |
/** * Initialise the tile renderer. As of Processing 3, the {@link PApplet} * class no longer extends {@link Applet}, meaning in order to integrate a * processing sketch with Swing or JavaFX you must initialise and extract * the {@link PSurface} class responsible for rendering the sketch and * instead integrate that. * * @return */ public Component init() { // the magical line to make sure all of the jogl files are loaded, preventing Processing loading the wrong libraries SharedDrawable.getGLProfile(); // initialise the processing sketch path sketchPath(); // use reflection to set insideSettings variable to true, initialise // settings, and then set insideSettings back to false try { Field is = PApplet.class.getDeclaredField("insideSettings"); is.setAccessible(true); try { is.set(this, Boolean.TRUE); settings(); } finally { is.set(this, Boolean.FALSE); is = null; } } catch (NoSuchFieldException | SecurityException | IllegalAccessException ex) { LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } // initialise the surface if (surface != null) { surface.stopThread(); } initSurface(); surface.startThread(); // case the surface to the correct component type and return it glComponent = new NewtCanvasAWT((GLWindow) surface.getNative()); return glComponent; }
Example #2
Source File: ClearVolumeOtherDemos.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void demoRendererInJFrame() throws InterruptedException, IOException { final ClearVolumeRendererInterface lClearVolumeRenderer = ClearVolumeRendererFactory.newBestRenderer( "ClearVolumeTest", 512, 512, NativeTypeEnum.UnsignedByte, 512, 512, 1, true); final NewtCanvasAWT lNewtCanvasAWT = lClearVolumeRenderer.getNewtCanvasAWT(); final JFrame lJFrame = new JFrame("ClearVolume"); lJFrame.setLayout(new BorderLayout()); final Container lContainer = new Container(); lContainer.setLayout(new BorderLayout()); lContainer.add(lNewtCanvasAWT, BorderLayout.CENTER); lJFrame.setSize(new Dimension(1024, 1024)); lJFrame.add(lContainer); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { lJFrame.setVisible(true); } }); lClearVolumeRenderer.setTransferFunction(TransferFunctions.getDefault()); lClearVolumeRenderer.setVisible(true); final int lResolutionX = 512; final int lResolutionY = lResolutionX; final int lResolutionZ = lResolutionX; final byte[] lVolumeDataArray = new byte[lResolutionX * lResolutionY * lResolutionZ]; for (int z = 0; z < lResolutionZ; z++) for (int y = 0; y < lResolutionY; y++) for (int x = 0; x < lResolutionX; x++) { final int lIndex = x + lResolutionX * y + lResolutionX * lResolutionY * z; int lCharValue = (((byte) x ^ (byte) y ^ (byte) z)); if (lCharValue < 12) lCharValue = 0; lVolumeDataArray[lIndex] = (byte) lCharValue; } lClearVolumeRenderer.setVolumeDataBuffer( 0, ByteBuffer.wrap(lVolumeDataArray), lResolutionX, lResolutionY, lResolutionZ); lClearVolumeRenderer.requestDisplay(); while (lClearVolumeRenderer.isShowing() && lJFrame.isVisible()) { Thread.sleep(100); lJFrame.setTitle("BRAVO! THIS IS A JFRAME! It WORKS!"); } lClearVolumeRenderer.close(); lJFrame.dispose(); }
Example #3
Source File: ClearGLVolumeRenderer.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
/** * @return the mNewtCanvasAWT */ @Override public NewtCanvasAWT getNewtCanvasAWT() { return mNewtCanvasAWT; }
Example #4
Source File: ClearVolumeRendererInterface.java From clearvolume with GNU Lesser General Public License v3.0 | 2 votes |
/** * Returns a Canvas that can be used to embed this renderer. * * @return A NewtCanvasAWT object or null if the renderer cannot be embedded. */ public NewtCanvasAWT getNewtCanvasAWT();