private void doUpdate() { if (restorePending) { return; // we will get called again // after the restore is // complete } canvas.stopRenderer(); canvas.setDoubleBufferEnable(doubleBufferAttr.getValue()); if (coordSysAttr.getValue()) { coordSwitch.setWhichChild(Switch.CHILD_ALL); } else { coordSwitch.setWhichChild(Switch.CHILD_NONE); } if (getAnnotationsAttr().getValue()) { staticBackAnnotationSwitch.setWhichChild(Switch.CHILD_ALL); dynamicBackAnnotationSwitch.setWhichChild(Switch.CHILD_ALL); staticFrontAnnotationSwitch.setWhichChild(Switch.CHILD_ALL); dynamicFrontAnnotationSwitch.setWhichChild(Switch.CHILD_ALL); } else { staticBackAnnotationSwitch.setWhichChild(Switch.CHILD_NONE); dynamicBackAnnotationSwitch.setWhichChild(Switch.CHILD_NONE); staticFrontAnnotationSwitch.setWhichChild(Switch.CHILD_NONE); dynamicFrontAnnotationSwitch.setWhichChild(Switch.CHILD_NONE); } if (perspectiveAttr.getValue()) { view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION); } else { view.setProjectionPolicy(View.PARALLEL_PROJECTION); } if (renderer != renderers[rendererAttr.getValue()]) { // TODO: renderer.clear(); // TODO: handle gui try { System.out.println("Clearing Attached : VolRend-doUpdate()"); clearAttach(); } catch (Exception e) { e.printStackTrace(); } renderer = renderers[rendererAttr.getValue()]; renderer.attach(dynamicAttachGroup, staticAttachGroup); } try { renderer.update(); annotations.update(); } catch (Exception e) { e.printStackTrace(); } catch (OutOfMemoryError e) { JOptionPane.showMessageDialog( null, "Ran out of memory!", "Render Error", JOptionPane.ERROR_MESSAGE); } int newVolEditId; if ((newVolEditId = volume.update()) != volEditId) { updateCenter(volume.minCoord, volume.maxCoord); newVolEditId = volEditId; } eyePtChanged(); canvas.startRenderer(); }
public View(Frame frame, int resolutionX, int resolutionY, int colorDepth, boolean fullscreen) { this.frame = frame; // *** set up graphics configuration *** if (fullscreen) { frame.setUndecorated(true); if (GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .isFullScreenSupported()) { GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .setFullScreenWindow(frame); } if (GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .isDisplayChangeSupported()) { DisplayMode displayMode = new DisplayMode(resolutionX, resolutionY, colorDepth, DisplayMode.REFRESH_RATE_UNKNOWN); GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .setDisplayMode(displayMode); } } graphicsConfiguration = SimpleUniverse.getPreferredConfiguration(); canvas3D = new MyCanvas3D(graphicsConfiguration); canvas3D.setDoubleBufferEnable(true); canvas3D.getGraphicsContext3D().setBufferOverride(false); // *** create universe *** universe = new SimpleUniverse(canvas3D); universe.getViewer().getView().setSceneAntialiasingEnable(true); canvas3D.getView().setFrontClipDistance(0.1f); canvas3D.getView().setBackClipDistance(50000f); // universe.setJ3DThreadPriority(Thread.MIN_PRIORITY); // *** create camera *** TransformGroup cameraTransformGroup = universe.getViewingPlatform().getMultiTransformGroup().getTransformGroup(0); camera = new Camera(cameraTransformGroup); canvas3D.startRenderer(); }