Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support EPS and EPS text output #48

Merged
merged 6 commits into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DiagramResponse {
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
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);
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
40 changes: 40 additions & 0 deletions src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ private FileFormat getOutputFormat() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ private FileFormat getOutputFormat(String format) {
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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/sourceforge/plantuml/servlet/diagrams.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>This package is in charge of the JEE PlantUml Server.</p>
<p>there are 2 kind of servlets in this package :<br>
- Interactive servlets : Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.<br>
- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
- Service servlets : ImgServlet, SvgServlet, EpsServlet, EpsTextServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
<br>
Structure of the service part of the PlantUmlServer: <br>
<img src="http://www.plantuml.com/plantuml/img/XP51ReCm44Ntd6AMH0etwAPIbNPJjIhg0OoPm4WsTiPZrAZDtGk5913IP3b_dlx_7jTK8g3riWUBja0EIJsLf7RbJDeIcavHHH1MMa0R5G9yMlD4gc9bS-IMDC9t0k1ZOKX3wwY4qZsZf2yYlYSCoWVk8WO1tgrX9WVlce30mQywZrFGQ9OBKrD1XPAxo1hJenAPPlo636uSMoKz_1R5HndcT9KSag7tMFeKshU-qDBhxTRJW6sV_FVCW4qv6foRMJFRloe_tntEvvnamSDFbYqlUuFjZCVv1lJExcj_n9R_DZ1DTOV8stl4Oz14_pCkkpnqSgxVRPVhQV5hm2y0" />
Expand Down
18 changes: 17 additions & 1 deletion src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
<servlet-name>svgservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>epsservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>epstextservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsTextServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>asciiservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
Expand All @@ -34,7 +42,7 @@
<servlet>
<servlet-name>oldproxyservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.OldProxyServlet</servlet-class>
</servlet>
</servlet>
<servlet>
<servlet-name>mapservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.MapServlet</servlet-class>
Expand Down Expand Up @@ -68,6 +76,14 @@
<servlet-name>svgservlet</servlet-name>
<url-pattern>/svg/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>epsservlet</servlet-name>
<url-pattern>/eps/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>epstextservlet</servlet-name>
<url-pattern>/epstext/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>asciiservlet</servlet-name>
<url-pattern>/txt/*</url-pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static Test suite() {
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);
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java
Original file line number Diff line number Diff line change
@@ -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);
}
}