- Fix mindmap img export support. Now images are embedded in the SVG.

This commit is contained in:
Paulo Gustavo Veiga 2012-07-12 20:59:01 -03:00
parent 99ee5a7da9
commit 6582f073bd
14 changed files with 3028 additions and 155 deletions

View File

@ -42,3 +42,9 @@ SUB_TOPIC=子节点
ISOLATED_TOPIC=独立节点 ISOLATED_TOPIC=独立节点
CENTRAL_TOPIC=中心节点 CENTRAL_TOPIC=中心节点
SHORTCUTS=快捷键 SHORTCUTS=快捷键
ENTITIES_COULD_NOT_BE_DELETED=不能删除节点或者关系。至少应选择一个对象。
AT_LEAST_ONE_TOPIC_MUST_BE_SELECTED=至少应选择一个节点。
CLIPBOARD_IS_EMPTY=无法拷贝。 粘贴板是空的。
CENTRAL_TOPIC_CAN_NOT_BE_DELETED=不能删除根节点。
RELATIONSHIP_COULD_NOT_BE_CREATED=不能创建关系。 应先选择创建关系的一对上级节点。
SELECTION_COPIED_TO_CLIPBOARD=节点已拷贝到粘贴板。

View File

@ -43,3 +43,10 @@ SUB_TOPIC=子節點
ISOLATED_TOPIC=獨立節點 ISOLATED_TOPIC=獨立節點
CENTRAL_TOPIC=中心節點 CENTRAL_TOPIC=中心節點
SHORTCUTS=快捷鍵 SHORTCUTS=快捷鍵
ENTITIES_COULD_NOT_BE_DELETED=不能刪除節點或者關係。至少應選擇一個對象。
AT_LEAST_ONE_TOPIC_MUST_BE_SELECTED=至少應選擇一個節點。
CLIPBOARD_IS_EMPTY=無法拷貝。 粘貼板是空的。
CENTRAL_TOPIC_CAN_NOT_BE_DELETED=不能刪除根節點。
RELATIONSHIP_COULD_NOT_BE_CREATED=不能創建關係。 應先選擇創建關係的一對上級節點。
SELECTION_COPIED_TO_CLIPBOARD=節點已拷貝到粘貼板。

View File

@ -40,14 +40,6 @@ public class ExportProperties {
return result; return result;
} }
public void setBaseImagePath(String baseUrl) {
this.baseImgPath = baseUrl;
}
public String getBaseImgPath() {
return baseImgPath;
}
static public class GenericProperties extends ExportProperties { static public class GenericProperties extends ExportProperties {
private GenericProperties(ExportFormat format) { private GenericProperties(ExportFormat format) {
super(format); super(format);

View File

@ -31,7 +31,9 @@ import org.jetbrains.annotations.Nullable;
import org.w3c.dom.*; import org.w3c.dom.*;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import sun.misc.BASE64Encoder;
import javax.servlet.ServletContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -48,16 +50,19 @@ public class ExporterFactory {
private static final String GROUP_NODE_NAME = "g"; private static final String GROUP_NODE_NAME = "g";
private static final String RECT_NODE_NAME = "rect"; private static final String RECT_NODE_NAME = "rect";
private static final String IMAGE_NODE_NAME = "image"; private static final String IMAGE_NODE_NAME = "image";
private File baseImgDir;
public ExporterFactory(@NotNull final ServletContext servletContext) throws ParserConfigurationException {
private ExporterFactory() throws ParserConfigurationException { this.baseImgDir = new File(servletContext.getRealPath("/"));
} }
public static void export(@NotNull ExportProperties properties, @Nullable String xml, @NotNull OutputStream output, @Nullable String mapSvg) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException { public ExporterFactory(@NotNull final File baseImgDir) throws ParserConfigurationException {
this.baseImgDir = baseImgDir;
}
public void export(@NotNull ExportProperties properties, @Nullable String xml, @NotNull OutputStream output, @Nullable String mapSvg) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
final ExportFormat format = properties.getFormat(); final ExportFormat format = properties.getFormat();
final String imgPath = properties.getBaseImgPath();
switch (format) { switch (format) {
case PNG: { case PNG: {
// Create a JPEG transcoder // Create a JPEG transcoder
@ -68,7 +73,7 @@ public class ExporterFactory {
transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth()); transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth());
// Create the transcoder input. // Create the transcoder input.
final Document document = normalizeSvg(mapSvg, imgPath); final Document document = normalizeSvg(mapSvg, false);
final String svgString = domToString(document); final String svgString = domToString(document);
final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray())); final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray()));
@ -89,7 +94,7 @@ public class ExporterFactory {
transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth()); transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth());
// Create the transcoder input. // Create the transcoder input.
final Document document = normalizeSvg(mapSvg, imgPath); final Document document = normalizeSvg(mapSvg, false);
final String svgString = domToString(document); final String svgString = domToString(document);
final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray())); final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray()));
@ -104,7 +109,7 @@ public class ExporterFactory {
final Transcoder transcoder = new PDFTranscoder(); final Transcoder transcoder = new PDFTranscoder();
// Create the transcoder input. // Create the transcoder input.
final Document document = normalizeSvg(mapSvg, imgPath); final Document document = normalizeSvg(mapSvg, false);
final String svgString = domToString(document); final String svgString = domToString(document);
final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray())); final TranscoderInput input = new TranscoderInput(new CharArrayReader(svgString.toCharArray()));
@ -115,7 +120,7 @@ public class ExporterFactory {
break; break;
} }
case SVG: { case SVG: {
final Document dom = normalizeSvg(mapSvg, imgPath); final Document dom = normalizeSvg(mapSvg, true);
output.write(domToString(dom).getBytes("UTF-8")); output.write(domToString(dom).getBytes("UTF-8"));
break; break;
} }
@ -129,7 +134,7 @@ public class ExporterFactory {
} }
} }
private static Document normalizeSvg(@NotNull String svgXml, final String imgBaseUrl) throws XMLStreamException, ParserConfigurationException, IOException, SAXException, TransformerException { private Document normalizeSvg(@NotNull String svgXml, boolean embedImg) throws XMLStreamException, ParserConfigurationException, IOException, SAXException, TransformerException {
final DocumentBuilder documentBuilder = getDocumentBuilder(); final DocumentBuilder documentBuilder = getDocumentBuilder();
svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" "); svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
@ -155,7 +160,8 @@ public class ExporterFactory {
fitSvg(document); fitSvg(document);
fixImageTagHref(document, imgBaseUrl); final Node child = document.getFirstChild();
fixImageTagHref(document, (Element) child);
return document; return document;
@ -187,12 +193,7 @@ public class ExporterFactory {
return result.toString(); return result.toString();
} }
private static void fixImageTagHref(Document document, String imgBaseUrl) { private void fixImageTagHref(@NotNull Document document, @NotNull Element element) {
final Node child = document.getFirstChild();
fixImageTagHref(document, (Element) child, imgBaseUrl);
}
private static void fixImageTagHref(@NotNull Document document, @NotNull Element element, String imgBaseUrl) {
final NodeList list = element.getChildNodes(); final NodeList list = element.getChildNodes();
@ -201,7 +202,7 @@ public class ExporterFactory {
// find all groups // find all groups
if (GROUP_NODE_NAME.equals(node.getNodeName())) { if (GROUP_NODE_NAME.equals(node.getNodeName())) {
// Must continue looking .... // Must continue looking ....
fixImageTagHref(document, (Element) node, imgBaseUrl); fixImageTagHref(document, (Element) node);
} else if (IMAGE_NODE_NAME.equals(node.getNodeName())) { } else if (IMAGE_NODE_NAME.equals(node.getNodeName())) {
@ -209,20 +210,63 @@ public class ExporterFactory {
// Cook image href ... // Cook image href ...
final String imgUrl = elem.getAttribute("href"); final String imgUrl = elem.getAttribute("href");
int index = imgUrl.lastIndexOf("/");
elem.removeAttribute("href"); elem.removeAttribute("href");
if (index != -1) { FileInputStream fis = null;
final String iconName = imgUrl.substring(index + 1);
// Hack for backward compatibility . This can be removed in 2012. :) // Obtains file name ...
String imgPath; try {
imgPath = imgBaseUrl + "/" + imgUrl; final File iconFile = iconFile(imgUrl);
elem.setAttribute("xlink:href", imgPath); ByteArrayOutputStream bos = new ByteArrayOutputStream();
fis = new FileInputStream(iconFile);
BASE64Encoder encoder = new BASE64Encoder();
encoder.encode(fis, bos);
elem.setAttribute("xlink:href", "data:image/png;base64," + bos.toString("8859_1"));
elem.appendChild(document.createTextNode(" ")); elem.appendChild(document.createTextNode(" "));
} catch (IOException e) {
e.printStackTrace();
} finally {
close(fis);
} }
} }
} }
} }
private File iconFile(@NotNull final String imgUrl) throws IOException {
int index = imgUrl.lastIndexOf("/");
final String iconName = imgUrl.substring(index + 1);
final File iconsDir = new File(baseImgDir, "icons");
File iconFile = new File(iconsDir, iconName);
if (!iconFile.exists()) {
// It's not a icon, must be a note, attach image ...
final File legacyIconsDir = new File(baseImgDir, "images");
iconFile = new File(legacyIconsDir, iconName);
}
if (!iconFile.exists()) {
final File legacyIconsDir = new File(iconsDir, "legacy");
iconFile = new File(legacyIconsDir, iconName);
}
if (!iconFile.exists()) {
throw new IOException("Icon could not be found:" + imgUrl);
}
return iconFile;
}
private void close(Closeable fis) {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
// Ignore ...
}
}
}
private static void fitSvg(Document document) { private static void fitSvg(Document document) {
// viewBox size // viewBox size
int mapWidth = 1024; int mapWidth = 1024;

View File

@ -18,30 +18,21 @@
package com.wisemapping.rest.view; package com.wisemapping.rest.view;
import com.wisemapping.exporter.ExportException;
import com.wisemapping.exporter.ExportFormat; import com.wisemapping.exporter.ExportFormat;
import com.wisemapping.exporter.ExportProperties; import com.wisemapping.exporter.ExportProperties;
import com.wisemapping.exporter.ExporterFactory; import com.wisemapping.exporter.ExporterFactory;
import com.wisemapping.mail.NotificationService; import com.wisemapping.mail.NotificationService;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import org.apache.batik.transcoder.TranscoderException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.oxm.XmlMappingException;
import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.web.servlet.view.AbstractView; import org.springframework.web.servlet.view.AbstractView;
import org.xml.sax.SAXException;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.util.Map; import java.util.Map;
public class TransformView extends AbstractView { public class TransformView extends AbstractView {
@ -53,8 +44,9 @@ public class TransformView extends AbstractView {
@Autowired @Autowired
private Jaxb2Marshaller jaxbMarshaller; private Jaxb2Marshaller jaxbMarshaller;
public TransformView(@NotNull final String contentType) { public TransformView(@NotNull final String contentType,@NotNull NotificationService notificationService) {
this.contentType = contentType; this.contentType = contentType;
this.notificationService = notificationService;
this.exportFormat = ExportFormat.fromContentType(contentType); this.exportFormat = ExportFormat.fromContentType(contentType);
} }
@ -86,19 +78,19 @@ public class TransformView extends AbstractView {
response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// Change image link URL. // Change image link URL.
setBaseBaseImgUrl(exportFormat, properties); final ServletContext servletContext = request.getSession().getServletContext();
final ExporterFactory factory = new ExporterFactory(servletContext);
try { try {
// Write the conversion content ... // Write the conversion content ...
final ServletOutputStream outputStream = response.getOutputStream(); final ServletOutputStream outputStream = response.getOutputStream();
if (exportFormat == ExportFormat.FREEMIND) { if (exportFormat == ExportFormat.FREEMIND) {
ExporterFactory.export(properties, content, outputStream, null); factory.export(properties, content, outputStream, null);
} else if (exportFormat == ExportFormat.WISEMAPPING) { } else if (exportFormat == ExportFormat.WISEMAPPING) {
final Object mindmap = viewMap.get("mindmap"); final Object mindmap = viewMap.get("mindmap");
final StreamResult result = new StreamResult(outputStream); final StreamResult result = new StreamResult(outputStream);
jaxbMarshaller.marshal(mindmap, result); jaxbMarshaller.marshal(mindmap, result);
} else { } else {
ExporterFactory.export(properties, null, outputStream, content); factory.export(properties, null, outputStream, content);
} }
} catch (Throwable e) { } catch (Throwable e) {
notificationService.reportMindmapExportError(content, Utils.getUser(), request.getHeader("User-Agent"),e); notificationService.reportMindmapExportError(content, Utils.getUser(), request.getHeader("User-Agent"),e);
@ -109,19 +101,5 @@ public class TransformView extends AbstractView {
public String getContentType() { public String getContentType() {
return contentType; return contentType;
} }
private void setBaseBaseImgUrl(@NotNull ExportFormat format, @NotNull ExportProperties properties) {
final String baseUrl;
if (format == ExportFormat.SVG) {
baseUrl = "http://www.wisemapping.com/images";
} else {
final ServletContext servletContext = this.getServletContext();
baseUrl = "file://" + servletContext.getRealPath("/");
}
properties.setBaseImagePath(baseUrl);
}
private static final String IMG_SIZE_PARAMETER = "imgSize"; private static final String IMG_SIZE_PARAMETER = "imgSize";
} }

View File

@ -1,4 +1,4 @@
# Chine Traditional \ufeff# Chine Traditional
NAME=\u540d\u79f0 NAME=\u540d\u79f0
DESCRIPTION=\u63cf\u8ff0 DESCRIPTION=\u63cf\u8ff0
@ -206,3 +206,5 @@ DESELECT_ALL_TOPIC=\u4e0d\u9009\u4efb\u4f55\u8282\u70b9
SHORTCUTS=\u5feb\u6377\u952e SHORTCUTS=\u5feb\u6377\u952e
COLLAPSE_CHILDREN=\u6298\u53e0\u5b50\u8282\u70b9 COLLAPSE_CHILDREN=\u6298\u53e0\u5b50\u8282\u70b9
KEYBOARD_SHORTCUTS_MSG=\u5feb\u6377\u952e\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8282\u7ea6\u65f6\u95f4\uff0c\u4f7f\u4f60\u7684\u624b\u4e0d\u5fc5\u79bb\u5f00\u952e\u76d8\u800c\u53bb\u4f7f\u7528\u9f20\u6807\u3002 KEYBOARD_SHORTCUTS_MSG=\u5feb\u6377\u952e\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8282\u7ea6\u65f6\u95f4\uff0c\u4f7f\u4f60\u7684\u624b\u4e0d\u5fc5\u79bb\u5f00\u952e\u76d8\u800c\u53bb\u4f7f\u7528\u9f20\u6807\u3002
COPY_AND_PASTE_TOPICS=\u62f7\u8d1d\u548c\u7c98\u8d34\u8282\u70b9
MULTIPLE_LINES=\u6dfb\u52a0\u591a\u884c\u957f\u6587\u672c

View File

@ -1,4 +1,4 @@
# Chine Simplified \ufeff# Chine Simplified
NAME=\u540d\u7a31 NAME=\u540d\u7a31
DESCRIPTION=\u63cf\u8ff0 DESCRIPTION=\u63cf\u8ff0
@ -206,3 +206,5 @@ DESELECT_ALL_TOPIC=\u4e0d\u9078\u4efb\u4f55\u7bc0\u9ede
SHORTCUTS=\u5feb\u6377\u9375 SHORTCUTS=\u5feb\u6377\u9375
COLLAPSE_CHILDREN=\u6298\u758a\u5b50\u7bc0\u9ede COLLAPSE_CHILDREN=\u6298\u758a\u5b50\u7bc0\u9ede
KEYBOARD_SHORTCUTS_MSG=\u5feb\u6377\u9375\u53ef\u4ee5\u5e6b\u52a9\u4f60\u7bc0\u7d04\u6642\u9593\uff0c\u4f7f\u4f60\u7684\u624b\u4e0d\u5fc5\u96e2\u958b\u9375\u76e4\u800c\u53bb\u4f7f\u7528\u6ed1\u9f20\u3002 KEYBOARD_SHORTCUTS_MSG=\u5feb\u6377\u9375\u53ef\u4ee5\u5e6b\u52a9\u4f60\u7bc0\u7d04\u6642\u9593\uff0c\u4f7f\u4f60\u7684\u624b\u4e0d\u5fc5\u96e2\u958b\u9375\u76e4\u800c\u53bb\u4f7f\u7528\u6ed1\u9f20\u3002
COPY_AND_PASTE_TOPICS=\u62f7\u8c9d\u548c\u7c98\u8cbc\u7bc0\u9ede
MULTIPLE_LINES=\u6dfb\u52a0\u591a\u884c\u9577\u6587\u672c

View File

@ -85,29 +85,25 @@
<servlet> <servlet>
<servlet-name>mvc-servlet</servlet-name> <servlet-name>mvc-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param> <init-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
<param-value> <param-value>
/WEB-INF/wisemapping-servlet.xml /WEB-INF/wisemapping-servlet.xml
</param-value> </param-value>
</init-param> </init-param>
<load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet> <servlet>
<servlet-name>mvc-rest</servlet-name> <servlet-name>mvc-rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param> <init-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
<param-value> <param-value>
/WEB-INF/wisemapping-rest.xml /WEB-INF/wisemapping-rest.xml
</param-value> </param-value>
</init-param> </init-param>
<load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!--suppress SpringModelInspection -->
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
@ -69,26 +70,32 @@
<bean id="transformViewPdf" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewPdf" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="application/pdf"/> <constructor-arg value="application/pdf"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>
<bean id="transformViewPng" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewPng" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="image/png"/> <constructor-arg value="image/png"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>
<bean id="transformViewJpeg" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewJpeg" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="image/jpeg"/> <constructor-arg value="image/jpeg"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>
<bean id="transformViewFreemind" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewFreemind" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="application/freemind"/> <constructor-arg value="application/freemind"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>
<bean id="transformViewSvg" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewSvg" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="image/svg+xml"/> <constructor-arg value="image/svg+xml"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>
<bean id="transformViewWise" class="com.wisemapping.rest.view.TransformView"> <bean id="transformViewWise" class="com.wisemapping.rest.view.TransformView">
<constructor-arg value="application/wisemapping+xml"/> <constructor-arg value="application/wisemapping+xml"/>
<constructor-arg ref="notificationService"/>
</bean> </bean>

View File

@ -6,7 +6,6 @@ import com.wisemapping.exporter.ExportProperties;
import com.wisemapping.exporter.ExporterFactory; import com.wisemapping.exporter.ExporterFactory;
import com.wisemapping.importer.ImporterException; import com.wisemapping.importer.ImporterException;
import com.wisemapping.model.MindMap;
import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -33,20 +32,17 @@ public class ExportTest {
final ExportProperties properties = ExportProperties.create(format); final ExportProperties properties = ExportProperties.create(format);
final ExportProperties.ImageProperties imageProperties = (ExportProperties.ImageProperties) properties; final ExportProperties.ImageProperties imageProperties = (ExportProperties.ImageProperties) properties;
imageProperties.setSize(ExportProperties.ImageProperties.Size.LARGE); imageProperties.setSize(ExportProperties.ImageProperties.Size.LARGE);
String baseUrl = "file://" + svgFile.getParentFile().getAbsolutePath() + "/../../../../../../wise-editor/src/main/webapp/icons";
properties.setBaseImagePath(baseUrl);
String baseUrl = svgFile.getParentFile().getAbsolutePath() + "/../../../../../../wise-editor/src/main/webapp";
ExporterFactory factory = new ExporterFactory(new File(baseUrl));
// Write content ... // Write content ...
if (pngFile.exists()) { if (pngFile.exists()) {
// Export mile content ... // Export mile content ...
final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream();
ExporterFactory.export(imageProperties, null, bos, svgXml); factory.export(imageProperties, null, bos, svgXml);
// Assert.assertEquals(expContent.toString().trim(), expContent.toString().trim());
} else { } else {
OutputStream outputStream = new FileOutputStream(pngFile, false); OutputStream outputStream = new FileOutputStream(pngFile, false);
ExporterFactory.export(imageProperties, null, outputStream, svgXml); factory.export(imageProperties, null, outputStream, svgXml);
outputStream.close(); outputStream.close();
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 215 KiB