if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
return;
}
GraphicsNode childGVTNode = null;
GraphicsNodeBridge gnb = (GraphicsNodeBridge)bridge;
List gvtChildList = composite.getChildren();
try {
childGVTNode = gnb.createGraphicsNode(ctx, e);
gvtChildList.add(childGVTNode);
if (gnb.isContainer()) {
buildComposite(ctx,
(CompositeGraphicsNode)childGVTNode,
e.getFirstChild());
} else if (TAG_USE.equals(e.getLocalName())) {
URIResolver ur;
ur = new URIResolver((SVGDocument)e.getOwnerDocument(),
ctx.getDocumentLoader());
String href = XLinkSupport.getXLinkHref(e);
try {
Node n = ur.getNode(href);
if (n.getOwnerDocument() == null) {
throw new Error("Can't use documents");
}
Element elt = (Element)n;
boolean local =
n.getOwnerDocument() == e.getOwnerDocument();
Element inst;
if (local) {
inst = (Element)elt.cloneNode(true);
} else {
inst = (Element)e.getOwnerDocument().
importNode(elt, true);
}
if (inst instanceof SVGSymbolElement) {
Element tmp = e.getOwnerDocument().createElementNS
(SVG_NAMESPACE_URI, TAG_SVG);
for (n = inst.getFirstChild();
n != null;
n = inst.getFirstChild()) {
tmp.appendChild(n);
}
NamedNodeMap attrs = inst.getAttributes();
int len = attrs.getLength();
for (int i = 0; i < len; i++) {
Attr attr = (Attr)attrs.item(i);
String ns = attr.getNamespaceURI();
tmp.setAttributeNS(attr.getNamespaceURI(),
attr.getName(),
attr.getValue());
}
tmp.setAttributeNS(null, ATTR_WIDTH, "100%");
tmp.setAttributeNS(null, ATTR_HEIGHT, "100%");
inst = tmp;
}
((HiddenChildElement)inst).setParentElement(e);
if (inst instanceof SVGSVGElement) {
if (e.hasAttributeNS(null, ATTR_WIDTH)) {
inst.setAttributeNS(null, ATTR_WIDTH,
e.getAttributeNS(null,
ATTR_WIDTH));
}
if (e.hasAttributeNS(null, ATTR_HEIGHT)) {
inst.setAttributeNS(null, ATTR_HEIGHT,
e.getAttributeNS(null,
ATTR_HEIGHT));
}
}
if (!local) {
SVGOMDocument doc;
doc = (SVGOMDocument)elt.getOwnerDocument();
SVGOMDocument d;
d = (SVGOMDocument)e.getOwnerDocument();
computeStyleAndURIs(elt, (ViewCSS)doc.getDefaultView(),
inst, (ViewCSS)d.getDefaultView(),
((SVGOMDocument)doc).getURLObject());
}
buildGraphicsNode(ctx,
(CompositeGraphicsNode)childGVTNode,
inst);
} catch (Exception ex) {
ex.printStackTrace();
}
} else if (TAG_SWITCH.equals(e.getLocalName())) {
for (Node n = e.getFirstChild();
n != null;
n = n.getNextSibling()) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (n instanceof SVGTests) {
if (SVGUtilities.matchUserAgent
((Element)n,
ctx.getUserAgent())) {
buildGraphicsNode
(ctx,
(CompositeGraphicsNode)childGVTNode,
(Element)n);
break;
}
}
}
}
}
gnb.buildGraphicsNode(childGVTNode, ctx, e);
} catch (BridgeException ex) {
if (ex.getGraphicsNode() != null) {
GraphicsNode gn = ex.getGraphicsNode();
gnb.buildGraphicsNode(gn, ctx, e);
gvtChildList.add(gn);
} else if (childGVTNode != null) {
// we have to remove the graphics node if it has been added
gvtChildList.remove(childGVTNode);
}