// start the rendering
File path = null;
if (template.getConfiguration().renderAsSvg(scalebarParams.renderAsSvg)) {
// render scalebar as SVG
final SVGGraphics2D graphics2D = CreateMapProcessor.getSvgGraphics(
new Dimension(maxWidthInPixelAdjusted, maxHeightInPixelAdjusted));
try {
tryLayout(graphics2D, scaleUnit, scale, niceIntervalLengthInWorldUnits, settings, 0);
path = File.createTempFile("scalebar-graphic-", ".svg", tempFolder);
CreateMapProcessor.saveSvgFile(graphics2D, path);
} finally {
graphics2D.dispose();
}
} else {
// render scalebar as raster graphic
final BufferedImage bufferedImage = new BufferedImage(maxWidthInPixelAdjusted, maxHeightInPixelAdjusted,
BufferedImage.TYPE_4BYTE_ABGR);
final Graphics2D graphics2D = bufferedImage.createGraphics();
try {
tryLayout(graphics2D, scaleUnit, scale, niceIntervalLengthInWorldUnits, settings, 0);
path = File.createTempFile("scalebar-graphic-", ".tiff", tempFolder);
ImageIO.write(bufferedImage, "tiff", path);
} finally {
graphics2D.dispose();
}
}
return path.toURI();
}