diff --git a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java index d1187ab..8cf05ad 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java @@ -61,6 +61,7 @@ class DiagramResponse { Map map = new HashMap(); map.put(FileFormat.PNG, "image/png"); map.put(FileFormat.SVG, "image/svg+xml"); + map.put(FileFormat.EPS, "application/postscript"); map.put(FileFormat.UTXT, "text/plain;charset=UTF-8"); CONTENT_TYPE = Collections.unmodifiableMap(map); } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java new file mode 100644 index 0000000..a69b00a --- /dev/null +++ b/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java @@ -0,0 +1,40 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ +package net.sourceforge.plantuml.servlet; + +import net.sourceforge.plantuml.FileFormat; + +/* + * EPS servlet of the webapp. + * This servlet produces the UML diagram in EPS format. + */ +@SuppressWarnings("serial") +public class EpsServlet extends UmlDiagramService { + + @Override + public FileFormat getOutputFormat() { + return FileFormat.EPS; + } + +} diff --git a/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java new file mode 100644 index 0000000..5226eeb --- /dev/null +++ b/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java @@ -0,0 +1,40 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ +package net.sourceforge.plantuml.servlet; + +import net.sourceforge.plantuml.FileFormat; + +/* + * EPS servlet of the webapp. + * This servlet produces the UML diagram in EPS format. + */ +@SuppressWarnings("serial") +public class EpsTextServlet extends UmlDiagramService { + + @Override + public FileFormat getOutputFormat() { + return FileFormat.EPS_TEXT; + } + +} diff --git a/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java index 2259c3b..9aeecc5 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java @@ -110,6 +110,12 @@ public class OldProxyServlet extends HttpServlet { if (format.equals("svg")) { return FileFormat.SVG; } + if (format.equals("eps")) { + return FileFormat.EPS; + } + if (format.equals("epstext")) { + return FileFormat.EPS_TEXT; + } if (format.equals("txt")) { return FileFormat.ATXT; } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java index 1460d25..c124122 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java @@ -122,6 +122,12 @@ public class ProxyServlet extends HttpServlet { if (format.equals("svg")) { return FileFormat.SVG; } + if (format.equals("eps")) { + return FileFormat.EPS; + } + if (format.equals("epstext")) { + return FileFormat.EPS_TEXT; + } if (format.equals("txt")) { return FileFormat.UTXT; } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/diagrams.txt b/src/main/java/net/sourceforge/plantuml/servlet/diagrams.txt index 89afbc0..34fa17a 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/diagrams.txt +++ b/src/main/java/net/sourceforge/plantuml/servlet/diagrams.txt @@ -20,6 +20,8 @@ abstract HttpServlet <|-- MapServlet abstract HttpServlet <|-- ProxyServlet UmlDiagramService <|-- PngServlet UmlDiagramService <|-- SvgServlet +UmlDiagramService <|-- EpsServlet +UmlDiagramService <|-- EpsTextServlet UmlDiagramService <|-- AsciiServlet UmlDiagramService o- DiagramResponse MapServlet o-- DiagramResponse diff --git a/src/main/java/net/sourceforge/plantuml/servlet/package.html b/src/main/java/net/sourceforge/plantuml/servlet/package.html index f933bbe..18dbf9f 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/package.html +++ b/src/main/java/net/sourceforge/plantuml/servlet/package.html @@ -3,7 +3,7 @@

This package is in charge of the JEE PlantUml Server.

there are 2 kind of servlets in this package :
- Interactive servlets : Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.
-- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.
+- Service servlets : ImgServlet, SvgServlet, EpsServlet, EpsTextServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.

Structure of the service part of the PlantUmlServer:
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 18e3aad..6b0db38 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -23,6 +23,14 @@ svgservlet net.sourceforge.plantuml.servlet.SvgServlet + + epsservlet + net.sourceforge.plantuml.servlet.EpsServlet + + + epstextservlet + net.sourceforge.plantuml.servlet.EpsTextServlet + asciiservlet net.sourceforge.plantuml.servlet.AsciiServlet @@ -34,7 +42,7 @@ oldproxyservlet net.sourceforge.plantuml.servlet.OldProxyServlet - + mapservlet net.sourceforge.plantuml.servlet.MapServlet @@ -68,6 +76,14 @@ svgservlet /svg/* + + epsservlet + /eps/* + + + epstextservlet + /epstext/* + asciiservlet /txt/* diff --git a/src/test/java/net/sourceforge/plantuml/servlet/AllTests.java b/src/test/java/net/sourceforge/plantuml/servlet/AllTests.java index cfcda0e..813b277 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/AllTests.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/AllTests.java @@ -12,6 +12,7 @@ public class AllTests extends TestSuite { suite.addTestSuite(TestImage.class); suite.addTestSuite(TestAsciiArt.class); suite.addTestSuite(TestSVG.class); + suite.addTestSuite(TestEPS.class); suite.addTestSuite(TestProxy.class); suite.addTestSuite(TestMap.class); suite.addTestSuite(TestCharset.class); diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java b/src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java new file mode 100644 index 0000000..7fd3544 --- /dev/null +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java @@ -0,0 +1,27 @@ +package net.sourceforge.plantuml.servlet; + +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + +import java.util.Scanner; + +public class TestEPS extends WebappTestCase { + /** + * Verifies the generation of the EPS for the Bob -> Alice sample + */ + public void testSimpleSequenceDiagram() throws Exception { + WebConversation conversation = new WebConversation(); + WebRequest request = new GetMethodWebRequest(getServerUrl() + "eps/" + TestUtils.SEQBOB); + WebResponse response = conversation.getResource(request); + // Analyze response + // Verifies the Content-Type header + assertEquals("Response content type is not EPS", "application/postscript", response.getContentType()); + // Get the content and verify its size + String diagram = response.getText(); + int diagramLen = diagram.length(); + assertTrue(diagramLen > 10000); + assertTrue(diagramLen < 12000); + } +}