public GraphicsNode build(BridgeContext ctx, Document document) {
// inform the bridge context the builder to use
ctx.setGVTBuilder(this);
// build the GVT tree
RootGraphicsNode rootNode = new RootGraphicsNode();
Element svgElement = document.getDocumentElement();
GraphicsNode topNode = null;
try {
// get the appropriate bridge according to the specified element
Bridge bridge = ctx.getBridge(svgElement);
if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
return null;
}
// create the associated composite graphics node
GraphicsNodeBridge gnBridge = (GraphicsNodeBridge)bridge;
topNode = gnBridge.createGraphicsNode(ctx, svgElement);
if (topNode == null) {
return null;
}
buildComposite(ctx, svgElement, (CompositeGraphicsNode)topNode);
gnBridge.buildGraphicsNode(ctx, svgElement, topNode);
} catch (BridgeException ex) {
// update the exception with the missing parameters
ex.setGraphicsNode(rootNode);
Element errElement = ex.getElement();
ex.setLineNumber(ctx.getDocumentLoader().getLineNumber(errElement));
throw ex; // re-throw the udpated exception
} finally {
if (topNode != null) {
rootNode.getChildren().add(topNode);
}
}
// <!> FIXME: TO BE REMOVED
if (ctx.isDynamic()) {
BridgeEventSupport.loadScripts(ctx, document);