/** Sets the GVT tree to display. */ protected void setGraphicsNode(GraphicsNode gn, boolean createDispatcher) { gvtRoot = gn; if (gn != null && createDispatcher) { initializeEventHandling(); } if (eventDispatcher != null) { eventDispatcher.setRootNode(gn); } }
/** Renders the GVT tree. */ protected void renderGVTTree() { Rectangle visRect = getRenderRect(); if (gvtRoot == null || visRect.width <= 0 || visRect.height <= 0) { return; } // Renderer setup. if (renderer == null || renderer.getTree() != gvtRoot) { renderer = createImageRenderer(); renderer.setTree(gvtRoot); } // Area of interest computation. AffineTransform inv; try { inv = renderingTransform.createInverse(); } catch (NoninvertibleTransformException e) { throw new IllegalStateException("NoninvertibleTransformEx:" + e.getMessage()); } Shape s = inv.createTransformedShape(visRect); // Rendering thread setup. gvtTreeRenderer = new GVTTreeRenderer( renderer, renderingTransform, doubleBufferedRendering, s, visRect.width, visRect.height); gvtTreeRenderer.setPriority(Thread.MIN_PRIORITY); Iterator it = gvtTreeRendererListeners.iterator(); while (it.hasNext()) { gvtTreeRenderer.addGVTTreeRendererListener((GVTTreeRendererListener) it.next()); } // Disable the dispatch during the rendering // to avoid concurrent access to the GVT tree. if (eventDispatcher != null) { eventDispatcher.setEventDispatchEnabled(false); } gvtTreeRenderer.start(); }
public void setRenderingTransform(AffineTransform at, boolean performRedraw) { renderingTransform = new AffineTransform(at); suspendInteractions = true; if (eventDispatcher != null) { try { eventDispatcher.setBaseTransform(renderingTransform.createInverse()); } catch (NoninvertibleTransformException e) { handleException(e); } } if (jgvtListeners != null) { Iterator iter = jgvtListeners.iterator(); ComponentEvent ce = new ComponentEvent(this, JGVTComponentListener.COMPONENT_TRANSFORM_CHANGED); while (iter.hasNext()) { JGVTComponentListener l = (JGVTComponentListener) iter.next(); l.componentTransformChanged(ce); } } if (performRedraw) scheduleGVTRendering(); }