1 18 package org.apache.batik.bridge; 19 20 import org.apache.batik.gvt.CompositeGraphicsNode; 21 import org.apache.batik.gvt.GraphicsNode; 22 import org.w3c.dom.Element ; 23 import org.w3c.dom.Node ; 24 import org.w3c.dom.svg.SVGTests; 25 26 32 public class SVGSwitchElementBridge extends AbstractSVGBridge 33 implements GraphicsNodeBridge { 34 35 38 public SVGSwitchElementBridge() {} 39 40 43 public String getLocalName() { 44 return SVG_SWITCH_TAG; 45 } 46 47 public Bridge getInstance(){ 48 return this; 49 } 50 51 58 public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { 59 GraphicsNode refNode = null; 60 GVTBuilder builder = ctx.getGVTBuilder(); 61 for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) { 62 if (n.getNodeType() == Node.ELEMENT_NODE) { 63 Element ref = (Element )n; 64 if (n instanceof SVGTests 65 && SVGUtilities.matchUserAgent(ref, ctx.getUserAgent())) { 66 refNode = builder.build(ctx, ref); 67 break; 68 } 69 } 70 } 71 if (refNode == null) { 72 return null; 73 } 74 CompositeGraphicsNode group = new CompositeGraphicsNode(); 75 group.add(refNode); 76 String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE); 78 if (s.length() != 0) { 79 group.setTransform 80 (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s)); 81 } 82 return group; 83 } 84 85 93 public void buildGraphicsNode(BridgeContext ctx, 94 Element e, 95 GraphicsNode node) { 96 if (ctx.isInteractive()) { 98 ctx.bind(e, node); 99 } 100 } 101 102 106 public boolean getDisplay(Element e) { 107 return CSSUtilities.convertDisplay(e); 108 } 109 110 113 public boolean isComposite() { 114 return false; 115 } 116 } 117 | Popular Tags |