绘制序列图

发布于 2024-11-16 03:56:13 字数 1539 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

情绪失控 2024-11-23 03:56:13

PlantUML
http://plantuml.sourceforge.net/sequence.html

PlantUML用于绘制UML图,使用简单又人性化
可读的文字描述。

然后可以使用生成的图像,而无需参考
GPL/LGPL/ASL/EPL/MIT 许可证。甚至没有必要规定
它们是用 PlantUML 生成的,尽管这将是
受到 PlantUML 团队的赞赏。

根据我的经验,它很容易使用,并且可以生成漂亮的图表。
我强烈推荐它。

输出文件类型:

-tsvg 使用 SVG 格式生成图像
-teps 使用 EPS 格式生成图像
-txmi 为类图生成 XMI​​ 文件
-thtml 为类图生成 HTML 文件
-ttxt 生成带有 ASCII 艺术的图像
-tutxt 使用 Unicode 字符生成带有 ASCII 艺术的图像

以下示例展示了如何创建简单的序列图。
输入图像描述这里

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

您还可以通过使用生命线激活和销毁来创建更详细的图表:
输入图像描述这里

@startuml
participant User

User -> A: DoWork
activate A

A -> B: << createRequest >>
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: RequestCreated
deactivate B

A -> User: Done
deactivate A

@enduml

PlantUML.
http://plantuml.sourceforge.net/sequence.html

PlantUML is used to draw UML diagram, using a simple and human
readable text description.

The generated images can then be used without any reference to the
GPL/LGPL/ASL/EPL/MIT license. It is not even necessary to stipulate
that they have been generated with PlantUML, although this will be
appreciate by PlantUML team.

In my experience it has been easy to use and it produces nice looking diagrams.
I can't recommend it more highly.

Output file types:

-tsvg     To generate images using SVG format
-teps     To generate images using EPS format
-txmi     To generate XMI file for class diagram
-thtml    To generate HTML files for class diagram
-ttxt     To generate images with ASCII art
-tutxt    To generate images with ASCII art using Unicode characters

Here is an example showing how to create a simple sequence diagram.
enter image description here

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

You can also create more detailed diagrams by using lifeline activation and destruction:
enter image description here

@startuml
participant User

User -> A: DoWork
activate A

A -> B: << createRequest >>
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: RequestCreated
deactivate B

A -> User: Done
deactivate A

@enduml
你没皮卡萌 2024-11-23 03:56:13

我发现并且通常用来从纯文本制作序列图的最好软件是 SDEdit。它是一个 Java 工具,因此您可以在任何操作系统中使用它。而且它是免费软件!

使用此工具,您可以编写以下内容:

#![SD ticket order]
ext:External[pe]
user:Actor
/order:Order[x]
db:TicketDB
acc:Account

ext:user.order a ticket!
user:order.new()
order:return=db.reserve(date,count)
db:return=acc.debit(cost)
acc:return=db.bonus(date,count)

获取此工具:

SDEdit example

The best software I've found and I usually use to make sequence diagrams from plain text is SDEdit. It's a Java tool, so you can use it in any operating system. And it's free software!

With this tool, you write the following:

#![SD ticket order]
ext:External[pe]
user:Actor
/order:Order[x]
db:TicketDB
acc:Account

ext:user.order a ticket!
user:order.new()
order:return=db.reserve(date,count)
db:return=acc.debit(cost)
acc:return=db.bonus(date,count)

to obtain this:

SDEdit example

蓝眼泪 2024-11-23 03:56:13

对于序列图,您可以查看websequencediagrams - 它创建了漂亮的图表并且具有很多功能(示例页面)。它不是一个命令行实用程序,但它有自己的 Web-API。

ditaa 从 ascii 源代码创建漂亮的图表。用java编写,可以在命令行上调用,将ascii文本转换为图表。

For sequence diagrams, you may take a look at websequencediagrams - it creates nice looking diagrams and has a lot of functionalities (examples page). It's not a command line utility, but it does have its web-API.

ditaa creates nice looking diagrams from ascii source. Written in java, it can be called on the command line to convert ascii text to diagrams.

凹づ凸ル 2024-11-23 03:56:13

另一个序列图工具是 http://sequencediagram.org ,可以在其中绘制图表以生成脚本和脚本来获取同时绘制图表。

因此,这对于大型图表很有用,因为您通常会忘记自己在脚本中的位置。

在此处输入图像描述

Another sequence diagram tool is http://sequencediagram.org where it's possible to draw the diagram to generate the script and script to get the diagram at the same time.

So, it's good for large diagrams where you normally lose track of where you are in the script.

enter image description here

半﹌身腐败 2024-11-23 03:56:13

更新:可能mermaid已经足够好了,你可以在各种Markdown编辑器中使用它,例如 hackmd。否则,要打印,请参阅下面我的原始答案。


这个答案可能并不完全符合您的想法,所以让我简单介绍一下背景。

多年来,我开始欣赏文学编程,这是一种编写高质量软件并保持代码易于理解的超级好方法。也许唯一的方法......无论如何,序列图是可视化的,可以很好地补充代码和写作。这有利于理解。

LaTeX / PGF / pgf-umlsd / noweb

因此,出于此目的,LaTeX + pgf- umlsd 可以创建非常漂亮的图表。与大多数其他工具一样,它们是在语义上指定的,这意味着您说的是“什么”,而不是“它应该是什么样子”。该程序计算出正确的图片。

所以这个 LaTeX 代码

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf-umlsd}

\begin{document}
\begin{sequencediagram}
  \newthread{t}{:Thread}
  \newinst[1]{i}{:Instance}
  \begin{sdblock}{Block}{description}
     \begin{call}{t}{function()}{i}{}
  \end{call}
  \end{sdblock}
\end{sequencediagram}
\end{document}

创建了这张图片(当然使用文档其余部分的字体等):

手册中的示例

LaTeX 源代码中,可执行代码的相关位就在图表下方,
把事情放在一起。我使用 noweb网站docs) 获取可运行的代码或文章的源代码。

HTH。

update: probably mermaid is good enough, you can use it in various markdown editors, such as hackmd. Otherwise, for print, see my origina answer below.


This answers is maybe not exactly what you had in mind, so let me shortly give a context.

Over the years I've come to appreciate literate programming as a super nice way to write quality software and keep that code comprehensible. Maybe the only way... In any case, sequence diagrams, being visual, nicely complement code and writing. This facilitates understanding.

LaTeX / PGF / pgf-umlsd / noweb

So for this purpose, LaTeX + pgf-umlsd can create very good looking diagrams. They are specified semantically, like most other tools, meaning you say what sequence you what, not how it should look. The program computes the right picture.

So this LaTeX code

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf-umlsd}

\begin{document}
\begin{sequencediagram}
  \newthread{t}{:Thread}
  \newinst[1]{i}{:Instance}
  \begin{sdblock}{Block}{description}
     \begin{call}{t}{function()}{i}{}
  \end{call}
  \end{sdblock}
\end{sequencediagram}
\end{document}

creates this picture (of course using the fonts of the rest of your document, etc.):

example from the manual

In the LaTeX source the relevant bits of executable code are just below the diagram,
keeping things together. I use noweb (site, docs) to get the runnable code or the source for the article.

HTH.

始于初秋 2024-11-23 03:56:13

GenMyModel 现在支持序列图。

序列样本

GenMyModel now supports sequence diagrams.

Sequence sample

段念尘 2024-11-23 03:56:13

EventStudio System Designer 5 可能适合您。它从基于文本的输入生成序列图。还可以处理多种场景。

EventStudio System Designer 5 might work for you. It generates sequence diagrams from text based input. Also handles multiple scenarios.

踏雪无痕 2024-11-23 03:56:13

对于序列图,您可能还需要查看 Visual Paradigm,这是一个非常强大的工具。

For sequence diagrams you may also want to look at Visual Paradigm, quite a powerful tool.

嘦怹 2024-11-23 03:56:13

对于序列图,您可能还需要查看UMLGraph< /s>.

2018-08-24 更新:网页似乎已移至此处

For sequence diagrams, you also might want to look at UMLGraph.

Update 2018-08-24: web page seems to have moved to here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文