List of usage examples for javax.media.j3d J3DGraphics2D flush
public abstract void flush(boolean wait);
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void newOffScreen(int w, int h) { if (w * h == 0) { logger.error("bad window size"); return;//from w w w .ja v a 2 s . c o m } im = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); imC = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, im, true, false); imC.setCapability(ImageComponent2D.ALLOW_IMAGE_READ); offScreenCanvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration(), true) { @Override public void postRender() { int stdEffectiveWidth = effectiveWidth; int stdEffectiveHeight = effectiveHeight; effectiveWidth = offScreenCanvas.getWidth(); effectiveHeight = offScreenCanvas.getHeight(); J3DGraphics2D vGraphics = super.getGraphics2D(); vGraphics.setFont(new Font("sans-serif", Font.PLAIN, 10)); vGraphics.setColor(Color.YELLOW); offScreenLocToWin = new LocalToWindow(objScene, offScreenCanvas); offScreenLocToWin.update(); fireProjectionChanged(new ProjectionEvent(this, offScreenLocToWin)); draw2D(vGraphics, offScreenLocToWin, effectiveWidth, effectiveHeight); vGraphics.flush(false); effectiveWidth = stdEffectiveWidth; effectiveHeight = stdEffectiveHeight; offScreenRenderDone = true; } }; offScreenView = offScreenCanvas.getView(); offScreen = offScreenCanvas.getScreen3D(); offScreenCanvas.setOffScreenLocation(0, 0); offScreenCanvas.setOffScreenBuffer(imC); offScreen.setSize(w, h); double width = 0.0254 / 90.0 * w; double height = 0.0254 / 90.0 * h; offScreen.setPhysicalScreenWidth(width); offScreen.setPhysicalScreenHeight(height); universe.getViewer().getView().addCanvas3D(offScreenCanvas); if (offScreenView != null) if (perspective) offScreenView.setProjectionPolicy(View.PERSPECTIVE_PROJECTION); else offScreenView.setProjectionPolicy(View.PARALLEL_PROJECTION); }