[FEATURE] Map usage integrated in the interactive servlet
JSTL (without EL) added
This commit is contained in:
@@ -42,6 +42,7 @@ import net.sourceforge.plantuml.SourceStringReader;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.code.Transcoder;
|
||||
import net.sourceforge.plantuml.code.TranscoderUtil;
|
||||
import net.sourceforge.plantuml.servlet.utility.SourceInformation;
|
||||
import HTTPClient.CookieModule;
|
||||
import HTTPClient.HTTPConnection;
|
||||
import HTTPClient.HTTPResponse;
|
||||
@@ -141,6 +142,11 @@ public class PlantUmlServlet extends HttpServlet {
|
||||
|
||||
request.setAttribute("net.sourceforge.plantuml.servlet.decoded", text);
|
||||
request.setAttribute("net.sourceforge.plantuml.servlet.encoded", encoded);
|
||||
|
||||
// check if an image map is necessary
|
||||
if (text != null && SourceInformation.containsLink(text)) {
|
||||
request.setAttribute("net.sourceforge.plantuml.servlet.mapneeded", Boolean.TRUE);
|
||||
}
|
||||
|
||||
// forward to index.jsp
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
|
||||
|
||||
@@ -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.utility;
|
||||
|
||||
/**
|
||||
* Utility class giving information about a diagram based on its source description.
|
||||
*/
|
||||
public class SourceInformation {
|
||||
/*
|
||||
* Check if there is a link ([[url]]) in the source of the diagram.
|
||||
* @param source the full textual representation of a diagram
|
||||
* @return true if there is at least one link
|
||||
*/
|
||||
public static boolean containsLink(String source) {
|
||||
// TODO build a better implementation
|
||||
return source.contains("[[");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<ul>
|
||||
<li>NullOutputStream is used by the Map feature.</li>
|
||||
<li>UmlExtractor encapsulates the PlantUML library to decode the UML compressed source.</li>
|
||||
<li>SourceInformation extracts useful information from the full textual source.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<%@ page info="index" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="false" %>
|
||||
|
||||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
|
||||
<%
|
||||
String contextRoot = request.getContextPath();
|
||||
String host = "http://" + request.getServerName() + ":" + request.getServerPort();
|
||||
@@ -8,6 +8,8 @@ String umltext = "";
|
||||
String imgurl = "";
|
||||
String svgurl = "";
|
||||
String txturl = "";
|
||||
String mapurl = "";
|
||||
Object mapNeeded = request.getAttribute("net.sourceforge.plantuml.servlet.mapneeded");
|
||||
Object encodedAttribute = request.getAttribute("net.sourceforge.plantuml.servlet.encoded");
|
||||
if (encodedAttribute != null) {
|
||||
encoded = encodedAttribute.toString();
|
||||
@@ -15,6 +17,9 @@ if (encodedAttribute != null) {
|
||||
imgurl = host + contextRoot + "/img/" + encoded;
|
||||
svgurl = host + contextRoot + "/svg/" + encoded;
|
||||
txturl = host + contextRoot + "/txt/" + encoded;
|
||||
if (mapNeeded != null) {
|
||||
mapurl = host + contextRoot + "/map/" + encoded;
|
||||
}
|
||||
}
|
||||
}
|
||||
Object decodedAttribute = request.getAttribute("net.sourceforge.plantuml.servlet.decoded");
|
||||
@@ -59,12 +64,19 @@ if (decodedAttribute != null) {
|
||||
<input type="submit"/>
|
||||
</p>
|
||||
</form>
|
||||
<% if ( !imgurl.isEmpty()) { %>
|
||||
<% if (!imgurl.isEmpty()) { %>
|
||||
<hr/>
|
||||
<a href="<%=svgurl%>">View as SVG</a>
|
||||
<a href="<%=txturl%>">View as ASCII Art</a>
|
||||
<p id="diagram">
|
||||
<img src="<%=imgurl %>" alt="PlantUML diagram"/>
|
||||
<% if (mapNeeded != null) { %>
|
||||
<img src="<%=imgurl %>" alt="PlantUML diagram" usemap="#umlmap" />
|
||||
<map name="umlmap">
|
||||
<c:import url="<%=mapurl %>" />
|
||||
</map>
|
||||
<% } else { %>
|
||||
<img src="<%=imgurl %>" alt="PlantUML diagram" />
|
||||
<% } %>
|
||||
</p>
|
||||
<% } //endif %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user