PlantUML Server

你可以通过在线的 Web Service 来用 PlantUML 即时生成图像。这个是一个在线演示的网站: http://www.plantuml.com/plantuml。你也可以将其安装在自己的 JEE Web 应用服务器上。

如果你不想安装一个完整的 JEE 应用服务器,那么也可以选择在本地安装 PlantUML PicoWeb Server

交互界面

大输入框用于输入图表描述。您可以输入任何图表描述,然后按下提交按钮,图表就会显示在下面。 以@startxxx 关键字作为图表的开头是个不错的做法。

验证图表后,您会被重定向到一个对您的图表进行编码的编码 URL。text-encoding[编码形式]是与他人共享图表的一种便捷方式,因为它比多行图表更短,而且可以使用在线 PlantUML 服务器在浏览器中轻松显示。

例如,SyfFKj2rKt3CoKnELR1Io4ZDoSa70000 是以下内容的编码形式:

@startuml
Bob -> Alice : hello
@enduml

指定初始图

默认情况下,PlantUML 服务器会显示著名的Bob -> Alice 样本,但使用它的编码形式调用其它图也很容易。 只需在 URL 后加上/uml/ENCODED

例如,这个链接http://www.plantuml.com/plantuml/uml/Aov9B2hXil98pSd9LoZFByf9iUOgBial0000用一个简单的 Hello World 活动图打开 PlantUML 服务器。

元数据

PlantUML 在生成的 PNG 元数据中以text-encoding[编码文本]的形式保存图表源代码。因此,可以使用查询参数metadata ,给出某个图片 URL 来检索这个源代码。

例如,如果要检索图片http://i.stack.imgur.com/HJvKF.png 的图表源代码,请使用下面的服务器请求:http://www.plantuml.com/plantuml/?metadata=http://i.stack.imgur.com/HJvKF.png

听起来像魔术!不,这只是一个聪明的工程 :-)

Web service mode

The web service interface of the PlantUML Server is dedicated to developers.

PNG service

To get a PNG file of a diagram, use the following URL scheme: /plantuml/png/ENCODED

SVG service

To get a SVG XML file of a diagram, use the following URL scheme: /plantuml/svg/ENCODED

Note that not all diagrams can be produced in SVG. For example, ditaa diagrams are only available in PNG format.

ASCII Art service

To get an ASCII Art representation of a diagram, encoded in UTF-8, use the following URL scheme: /plantuml/txt/ENCODED

Note that only sequence diagrams can be produced in ASCII Art.

图像地图服务

要获取与先前生成的 PNG 图像相关的客户端图像地图,请使用以下 URL 方案: /plantuml/map/ENCODED

输出是一个标签列表。 <area>标签的列表,每一行都与图表描述中的链接相匹配。

例如,下图

@startuml
participant Bob [[http://plantuml.com]]
Bob -> Alice : [[http://forum.plantuml.net]] hello
@enduml

会产生以下输出

<map id="plantuml_map" name="plantuml_map">
<area shape="rect" id="id1" href="http://forum.plantuml.net" title="http://forum.plantuml.net" alt="" coords="38,50,199,65"/>
<area shape="rect" id="id2" href="http://plantuml.com" title="http://plantuml.com" alt="" coords="8,3,50,116"/>
</map>

请注意,您需要将这些<area... 标记包含在<map... html 标记内,以制作完整的图像地图。

Proxy service

With the proxy service, the source description of the diagram can be fetched by the PlantUML Server from a remote document.

The proxy service uses the following URL scheme: /plantuml/proxy?src=RESOURCE&idx=INDEX&fmt=FORMAT

  • RESOURCE is the complete URL of the document which contains the diagram description (with the @startxxx and @endxxx tags), it could be a .html or a .txt file.
  • INDEX is optional, it specifies the occurrence (starting at 0) of the diagram description that will be parsed when there are more than one diagram descriptions in the remote document. It defaults to zero.
  • FORMAT is optional, it specifies the format to return. Supported values are: png, svg, eps, epstext and txt. Default is png,

For example, try this link: http://www.plantuml.com/plantuml/proxy?src=https://raw.github.com/plantuml/plantuml-server/master/src/main/webapp/resource/test/test2diagrams.txt

Note that the address of the remote document is specified as a parameter, so it is not necessary to URL encode the URL.

Installation of the PlantUML Server

To install PlantUML Server on your own JEE 5 web server, download the plantuml.war file and copy it on the webapp folder of your server.

Because of the transition from javax.* to jakarta.*, the PlantUML Server does not work on Tomcat 6/7/8/9 anymore. You have to use Tomcat 10.

Source code

PlantUML Server is open source, the code is available at https://github.com/plantuml/plantuml-server.

(The main source is at https://github.com/plantuml/plantuml)


Privacy Policy      Advertise