if (!(document instanceof SVGOMDocument)) {
throw new TranscoderException(
Messages.formatMessage("notsvg", null));
}
BridgeContext ctx = new BridgeContext(userAgent);
SVGOMDocument svgDoc = (SVGOMDocument)document;
SVGSVGElement root = svgDoc.getRootElement();
// build the GVT tree
GVTBuilder builder = new GVTBuilder();
ImageRendererFactory rendFactory = new ConcreteImageRendererFactory();
// flag that indicates if the document is dynamic
boolean isDynamic =
(hints.containsKey(KEY_EXECUTE_ONLOAD) &&
((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue() &&
BaseScriptingEnvironment.isDynamicDocument(svgDoc));
ctx.setDynamic(isDynamic);
GraphicsNode gvtRoot;
try {
gvtRoot = builder.build(ctx, svgDoc);
// dispatch an 'onload' event if needed
if (ctx.isDynamic()) {
BaseScriptingEnvironment se = new BaseScriptingEnvironment(ctx);
se.loadScripts();
se.dispatchSVGLoadEvent();
}
} catch (BridgeException ex) {
throw new TranscoderException(ex);
}
// get the 'width' and 'height' attributes of the SVG document
float docWidth = (float)ctx.getDocumentSize().getWidth();
float docHeight = (float)ctx.getDocumentSize().getHeight();
ctx = null;
builder = null;
// compute the image's width and height according the hints
float imgWidth = -1;