Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION);
if (ptm != null) {
pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue());
}
UserAgent ua = createBatikUserAgent(pxToMillimeter);
GVTBuilder builder = new GVTBuilder();
final ImageManager imageManager = (ImageManager)hints.get(
ImageProcessingHints.IMAGE_MANAGER);
final ImageSessionContext sessionContext = (ImageSessionContext)hints.get(
ImageProcessingHints.IMAGE_SESSION_CONTEXT);
boolean useEnhancedBridgeContext = (imageManager != null && sessionContext != null);
final BridgeContext ctx = (useEnhancedBridgeContext
? new GenericFOPBridgeContext(ua, null, imageManager, sessionContext)
: new BridgeContext(ua));
Document doc = svg.getDocument();
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
//Build the GVT tree
final GraphicsNode root;
try {
root = builder.build(ctx, clonedDoc);
} catch (Exception e) {
throw new ImageException("GVT tree could not be built for SVG graphic", e);
}
//Create the painter