List of usage examples for javax.media.j3d Canvas3D getScreen3D
public Screen3D getScreen3D()
From source file:PrintFromButton.java
public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); BufferedImage bImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGBA, bImage); buffer.setCapability(ImageComponent2D.ALLOW_IMAGE_READ); Raster drawRaster = new Raster(new Point3f(0.0f, 0.0f, 0.0f), Raster.RASTER_COLOR, 0, 0, 200, 200, buffer, null);//from ww w. j av a 2 s .co m drawRaster.setCapability(Raster.ALLOW_IMAGE_WRITE); // create the main scene graph BranchGroup scene = createSceneGraph(drawRaster); // create the on-screen canvas Canvas3D d = new Canvas3D(config, false); add("Center", d); // create a simple universe u = new SimpleUniverse(d); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); // create an off Screen Buffer c = new OffScreenCanvas3D(config, true, drawRaster); // set the offscreen to match the onscreen Screen3D sOn = d.getScreen3D(); Screen3D sOff = c.getScreen3D(); sOff.setSize(sOn.getSize()); sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); // attach the same view to the offscreen canvas u.getViewer().getView().addCanvas3D(c); // create the gui Button b = new Button("Print"); b.addActionListener(this); Panel p = new Panel(); p.add(b); add("North", p); u.addBranchGraph(scene); }