Update batik

This commit is contained in:
Paulo Veiga 2018-09-16 13:05:11 -07:00
parent 752aff4e5f
commit b89a82760c
3 changed files with 14 additions and 18 deletions

View File

@ -211,7 +211,7 @@
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-transcoder</artifactId> <artifactId>batik-transcoder</artifactId>
<version>1.9.1</version> <version>1.10</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -223,13 +223,8 @@
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-codec</artifactId> <artifactId>batik-codec</artifactId>
<version>1.9.1</version> <version>1.10</version>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>xml-apis</groupId>-->
<!--<artifactId>xml-apis</artifactId>-->
<!--<version>1.4.01</version>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>
<artifactId>javaee-api</artifactId> <artifactId>javaee-api</artifactId>

View File

@ -48,7 +48,7 @@ public class ExportProperties {
this.version = version; this.version = version;
} }
static public class GenericProperties extends ExportProperties { private static class GenericProperties extends ExportProperties {
private GenericProperties(ExportFormat format) { private GenericProperties(ExportFormat format) {
super(format); super(format);
} }
@ -65,7 +65,7 @@ public class ExportProperties {
this.size = size; this.size = size;
} }
public ImageProperties(ExportFormat format) { ImageProperties(ExportFormat format) {
super(format); super(format);
} }

View File

@ -49,13 +49,14 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.*; import javax.xml.xpath.*;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class ExporterFactory { public class ExporterFactory {
private static final String GROUP_NODE_NAME = "g"; private static final String GROUP_NODE_NAME = "g";
private static final String IMAGE_NODE_NAME = "image"; private static final String IMAGE_NODE_NAME = "image";
public static final int MANGING = 50; private static final int MANGING = 50;
public static final String UTF_8_CHARSET_NAME = "UTF-8"; private static final String UTF_8_CHARSET_NAME = "UTF-8";
private File baseImgDir; private File baseImgDir;
public ExporterFactory(@NotNull final ServletContext servletContext) throws ParserConfigurationException { public ExporterFactory(@NotNull final ServletContext servletContext) throws ParserConfigurationException {
@ -82,16 +83,16 @@ public class ExporterFactory {
final String svgString = normalizeSvg(mapSvg); final String svgString = normalizeSvg(mapSvg);
final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray())); final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray()));
TranscoderOutput trascoderOutput = new TranscoderOutput(output); TranscoderOutput transcoderOutput = new TranscoderOutput(output);
// Save the image. // Save the image.
transcoder.transcode(input, trascoderOutput); transcoder.transcode(input, transcoderOutput);
break; break;
} }
case JPG: { case JPG: {
// Create a JPEG transcoder // Create a JPEG transcoder
final Transcoder transcoder = new JPEGTranscoder(); final Transcoder transcoder = new JPEGTranscoder();
transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.99)); transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, .99f);
final ExportProperties.ImageProperties imageProperties = final ExportProperties.ImageProperties imageProperties =
(ExportProperties.ImageProperties) properties; (ExportProperties.ImageProperties) properties;
@ -123,22 +124,22 @@ public class ExporterFactory {
} }
case SVG: { case SVG: {
final String svgString = normalizeSvg(mapSvg); final String svgString = normalizeSvg(mapSvg);
output.write(svgString.getBytes(UTF_8_CHARSET_NAME)); output.write(svgString.getBytes(StandardCharsets.UTF_8));
break; break;
} }
case TEXT: { case TEXT: {
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.TEXT); final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.TEXT);
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output); exporter.export(xml.getBytes(StandardCharsets.UTF_8), output);
break; break;
} }
case OPEN_OFFICE_WRITER: { case OPEN_OFFICE_WRITER: {
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.OPEN_OFFICE); final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.OPEN_OFFICE);
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output); exporter.export(xml.getBytes(StandardCharsets.UTF_8), output);
break; break;
} }
case MICROSOFT_EXCEL: { case MICROSOFT_EXCEL: {
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.MICROSOFT_EXCEL); final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.MICROSOFT_EXCEL);
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output); exporter.export(xml.getBytes(StandardCharsets.UTF_8), output);
break; break;
} }
case FREEMIND: { case FREEMIND: {