plantuml官方文档注意事项

本文介绍如何使用简单语法绘制时序图,包括参与者声明、箭头样式修改、颜色设定等,帮助读者掌握时序图的基本绘制方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

时序图

简单示例

你可以用->来绘制参与者之间传递的消息, 而不必显式地声明参与者。
你也可以使用 --> 绘制一个虚线箭头。

另外,你还能用 <- 和 <–,这不影响绘图,但可以提高可读性。 注意:仅适用于时序图,对于其它示意图,规则是不同的。

声明参与者

声明参与者使用的关键字(不区分大小写)

  • participant
  • Actor
  • Boundary
  • DataBase
  • control
  • Entity

您可以使用关键字 order自定义顺序来打印参与者。这里测试不能和color同时设置,如下所示的代码会报错,As L后面color和order不能同时出现。

@startuml
participant  f001 order 40
' The  only  different  between  actor 
' and  participant  is the color
participant Alice order 20
participant  "I have long \n name " As  L #red order 10
f001 -> Alice: Authentication Request
Alice --> f001: Authenticaton Response

@enduml

在参与者中使用非字母符号

需要使用双引号,单引号测试不成功。注意这里括号是非字母符号

@startuml
participant  f001 order 40
' The  only  different  between  actor 
' and  participant  is the color
participant "Bob()"order 20
participant  "I have long \n name " As  L  order 10
f001 -> "Bob()": Authentication Request
 L --> f001: Authenticaton Response

@enduml

修改箭头的样式

箭头的样式:

  • 表示一条丢失的消息,末尾加x
  • 箭头只有上半部分或者下半部分:将<和>替换成\或者 /
  • 虚线箭头:用 – 替代 -
  • 箭头末尾加圈:->o
  • 双向箭头:<->
  • 细箭头:将箭头标记写两次 (如 >> 或 //)
@startuml
participant  f001 order 40
' The  only  different  between  actor 
' and  participant  is the color
participant "Bob()"order 20
participant  "I have long \n name " As  L  order 10
f001 -> f001: Authentication Request
f001 ->x "Bob()" 
f001 <<->>o "Bob()"
f001 -/ "Bob()"
"Bob()" -\ f001
@enduml

修改箭头的颜色

f001 -[#red]> f001: Authentication Request :将箭头的颜色变成红色

@startuml
participant  f001 order 40
' The  only  different  between  actor 
' and  participant  is the color
participant "Bob()"order 20
participant  "I have long \n name " As  L  order 10
f001 -[#red]> f001: Authentication Request
f001 ->x "Bob()" 
f001 <<->>o "Bob()"
f001 -/ "Bob()"
"Bob()" -\ f001
@enduml

基础总结性代码

@startuml
header Page Header
footer  Page %page%  of %lastpage%
title  Exampale  Title
participant  f001 order 40
' The  only  different  between  actor 
' and  participant  is the color
participant "Bob()"order 20
participant  "I have long \n name " As  L  order 10
f001 -[#red]> f001: Authentication Request
autonumber 15 15 "<font color=red><b>Message 0"
f001 ->x "Bob()": Hi
f001 <<->>o "Bob()": Hello
newpage A title for the\nlast page
f001 -/ "Bob()": world
"Bob()" -\ f001: vender
@enduml

效果如下所示:
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

helloworddm

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值