use of org.apache.batik.apps.rasterizer.SVGConverterException in project opencast by opencast.
the class AbstractCoverImageService method rasterizeSvg.
protected static void rasterizeSvg(File svgSource, File pngResult) throws CoverImageException {
SVGConverter converter = new SVGConverter();
converter.setDestinationType(DestinationType.PNG);
converter.setDst(pngResult);
converter.setSources(new String[] { svgSource.getAbsolutePath() });
try {
log.debug("Start converting SVG to PNG");
converter.execute();
} catch (SVGConverterException e) {
log.warn("Error while converting the SVG to a PNG: {}", e.getMessage());
throw new CoverImageException("Error while converting the SVG to a PNG", e);
}
}
use of org.apache.batik.apps.rasterizer.SVGConverterException in project xwiki-platform by xwiki.
the class ChartingPlugin method generateSvgChart.
private Chart generateSvgChart(JFreeChart jfchart, ChartParams params, XWikiContext context) throws IOException, GenerateException {
// Get a DOMImplementation
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document
Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the chart to render into the SVG Graphics2D implementation
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, params.getInteger(ChartParams.WIDTH).intValue(), params.getInteger(ChartParams.HEIGHT).intValue());
jfchart.draw(svgGenerator, rect);
boolean useCSS = false;
StringWriter swriter = new StringWriter();
svgGenerator.stream(swriter, useCSS);
String svgText = swriter.toString();
String pageURL = null;
SVGPlugin svgPlugin = (SVGPlugin) context.getWiki().getPlugin("svg", context);
if (svgPlugin == null) {
throw new GenerateException("SVGPlugin not loaded");
}
String imageURL;
try {
imageURL = svgPlugin.getSVGImageURL(svgText, params.getInteger(ChartParams.HEIGHT).intValue(), params.getInteger(ChartParams.WIDTH).intValue(), context);
} catch (SVGConverterException sce) {
throw new GenerateException(sce);
}
return new ChartImpl(params, imageURL, pageURL);
}
Aggregations