/** * Creates a <code>GraphicsNode</code> according to the specified parameters. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @return a graphics node that represents the specified element */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) { return null; } GraphicsNode node = instantiateGraphicsNode(); // 'transform' setTransform(node, e, ctx); // 'visibility' node.setVisible(CSSUtilities.convertVisibility(e)); associateSVGContext(ctx, e, node); return node; }
/** * Builds using the specified BridgeContext and element, the * specified graphics node. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @param node the graphics node to build */ public void buildGraphicsNode(BridgeContext ctx, Element e, GraphicsNode node) { ShapeNode shapeNode = (ShapeNode)node; shapeNode.setShapePainter(createShapePainter(ctx, e, shapeNode)); super.buildGraphicsNode(ctx, e, node); }
/** * Sets the graphics node's transform to the current animated transform * value. */ protected void setTransform(GraphicsNode n, Element e, BridgeContext ctx) { n.setTransform(computeTransform((SVGTransformable) e, ctx)); }
/** * Builds using the specified BridgeContext and element, the * specified graphics node. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @return node the new graphics node */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { PDFANode aNode = (PDFANode)super.createGraphicsNode(ctx, e); aNode.setDestination(((SVGAElement)e).getHref().getBaseVal()); aNode.setTransform(transform); return aNode; }
/** * Disposes this text element bridge by removing the text event listeners * that were added in {@link #initializeDynamicSupport}. */ public void dispose() { removeTextEventListeners(ctx, (NodeEventTarget) e); super.dispose(); }
/** * Disposes all resources related to the specified node and its subtree. */ protected static void disposeTree(Node node) { disposeTree(node, true); }
/** * Invoked when the geometry of a graphical element has changed. */ protected void handleGeometryChanged() { node.setFilter(CSSUtilities.convertFilter(e, node, ctx)); node.setMask(CSSUtilities.convertMask(e, node, ctx)); node.setClip(CSSUtilities.convertClipPath(e, node, ctx)); if (isSVG12) { if (!SVG_USE_TAG.equals(e.getLocalName())) { // ShapeChange events get fired only for basic shapes and paths. fireShapeChangeEvent(); } fireBBoxChangeEvent(); } }
/** * Invoked when an CSSEngineEvent is fired. */ public void handleCSSEngineEvent(CSSEngineEvent evt) { try { SVGCSSEngine eng = (SVGCSSEngine) evt.getSource(); int[] properties = evt.getProperties(); for (int i = 0; i < properties.length; i++) { int idx = properties[i]; handleCSSPropertyChanged(idx); String pn = eng.getPropertyName(idx); fireBaseAttributeListeners(pn); } } catch (Exception ex) { ctx.getUserAgent().displayError(ex); } }
break; case SVGCSSEngine.DISPLAY_INDEX: if (!getDisplay(e)) { disposeTree(e, false);
Rectangle2D bbox = ((AbstractGraphicsNodeBridge) bridge).getBBox(); if (bbox != null && (bbox.getWidth() == 0 || bbox.getHeight() == 0)) { return null;
/** * Checks if the bounding box of the node has changed, and if so, * fires a bboxchange event on the element. */ protected void checkBBoxChange() { if (e != null) { /*Rectangle2D oldBBox = bbox; Rectangle2D newBBox = getBBox(); if (oldBBox != newBBox && newBBox != null) { if (oldBBox == null || oldBBox.getX() != bbox.getX() || oldBBox.getY() != bbox.getY() || oldBBox.getWidth() != bbox.getWidth() || oldBBox.getHeight() != bbox.getHeight()) {*/ fireBBoxChangeEvent(); /*} }*/ } }
/** * Creates a <code>GraphicsNode</code> according to the specified parameters. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @return a graphics node that represents the specified element */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { CompositeGraphicsNode gn = (CompositeGraphicsNode)super.createGraphicsNode(ctx, e); if (gn == null) return null; associateSVGContext(ctx, e, gn); // 'color-rendering' RenderingHints hints = null; hints = CSSUtilities.convertColorRendering(e, hints); if (hints != null) gn.setRenderingHints(hints); // 'enable-background' Rectangle2D r = CSSUtilities.convertEnableBackground(e); if (r != null) gn.setBackgroundEnable(r); return gn; }
/** * Disposes this text element bridge by removing the text event listeners * that were added in {@link #initializeDynamicSupport}. */ public void dispose() { removeTextEventListeners(ctx, (NodeEventTarget) e); super.dispose(); }
/** * Disposes all resources related to the specified node and its subtree. */ protected static void disposeTree(Node node) { disposeTree(node, true); }
/** * Invoked when the geometry of a graphical element has changed. */ protected void handleGeometryChanged() { node.setFilter(CSSUtilities.convertFilter(e, node, ctx)); node.setMask(CSSUtilities.convertMask(e, node, ctx)); node.setClip(CSSUtilities.convertClipPath(e, node, ctx)); if (isSVG12) { if (!SVG_USE_TAG.equals(e.getLocalName())) { // ShapeChange events get fired only for basic shapes and paths. fireShapeChangeEvent(); } fireBBoxChangeEvent(); } }
/** * Invoked when an CSSEngineEvent is fired. */ public void handleCSSEngineEvent(CSSEngineEvent evt) { try { SVGCSSEngine eng = (SVGCSSEngine) evt.getSource(); int[] properties = evt.getProperties(); for (int idx : properties) { handleCSSPropertyChanged(idx); String pn = eng.getPropertyName(idx); fireBaseAttributeListeners(pn); } } catch (Exception ex) { ctx.getUserAgent().displayError(ex); } }
break; case SVGCSSEngine.DISPLAY_INDEX: if (!getDisplay(e)) { disposeTree(e, false);
Rectangle2D bbox = ((AbstractGraphicsNodeBridge) bridge).getBBox(); if (bbox != null && (bbox.getWidth() == 0 || bbox.getHeight() == 0)) { return null;
/** * Checks if the bounding box of the node has changed, and if so, * fires a bboxchange event on the element. */ protected void checkBBoxChange() { if (e != null) { /*Rectangle2D oldBBox = bbox; Rectangle2D newBBox = getBBox(); if (oldBBox != newBBox && newBBox != null) { if (oldBBox == null || oldBBox.getX() != bbox.getX() || oldBBox.getY() != bbox.getY() || oldBBox.getWidth() != bbox.getWidth() || oldBBox.getHeight() != bbox.getHeight()) {*/ fireBBoxChangeEvent(); /*} }*/ } }
/** * Creates a graphics node using the specified BridgeContext and * for the specified element. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @return a graphics node that represents the specified element */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { ShapeNode shapeNode = (ShapeNode)super.createGraphicsNode(ctx, e); if (shapeNode == null) { return null; } associateSVGContext(ctx, e, shapeNode); // delegates to subclasses the shape construction buildShape(ctx, e, shapeNode); // 'shape-rendering' and 'color-rendering' RenderingHints hints = null; hints = CSSUtilities.convertColorRendering(e, hints); hints = CSSUtilities.convertShapeRendering(e, hints); if (hints != null) shapeNode.setRenderingHints(hints); return shapeNode; }