use of org.apache.batik.anim.dom.SAXSVGDocumentFactory in project yamcs-studio by yamcs.
the class SVGSymbolImage method loadDocument.
private void loadDocument(InputStream inputStream) {
svgHandler = null;
failedToLoadDocument = true;
if (imagePath == null || imagePath.isEmpty()) {
return;
}
var parser = XMLResourceDescriptor.getXMLParserClassName();
var factory = new SAXSVGDocumentFactory(parser);
try {
var workSpacePath = ResourceUtil.workspacePathToSysPath(new Path("/"));
var uri = "file://" + (workSpacePath == null ? "" : workSpacePath.toOSString()) + imagePath.toString();
svgDocument = factory.createDocument(uri, inputStream);
svgHandler = new SVGHandler((SVGDocument) svgDocument, Display.getCurrent());
svgHandler.setAlignedToNearestSecond(alignedToNearestSecond);
initRenderingHints();
var awtImage = svgHandler.getOffScreen();
if (awtImage != null) {
originalImageData = SVGUtils.toSWT(Display.getCurrent(), awtImage);
resetData();
}
svgHandler.setRenderListener(image -> {
if (disposed) {
return;
}
animatedImage = image;
repaintAnimated = true;
repaint();
});
needRender = true;
failedToLoadDocument = false;
} catch (Exception e) {
log.log(Level.WARNING, "Error loading SVG image " + imagePath, e);
}
}
Aggregations