当前位置:网站首页>plantuml介绍与使用
plantuml介绍与使用
2022-07-01 21:43:00 【birdyson】
介绍
好用的免费画图插件,兼容vscode、IDEA等大牌IDE,使用编写代码的方式自动生成UML图形。官方中文文档:https://plantuml.com/zh/
安装方式
以IDEA为例,直接在Plugin
-> Marketplace
中安装即可,vscode同理。
入门
在文件目录中新建文件,可以看到PlantUML File
,新建此文件,选中你需要的UML图形。
UML绘图语法规则
全局规则
作用域
puml需要将代码写在@startuml
与@enduml
之间才能生效。
顺序图
箭头
@startuml
Client -> Server: 建立连接
' ↓这里为了可读性也可以反过来写成: <--
Server --> Client: 数据交互
Client --> Server: 数据交互
Server -> Client: 断开连接
@enduml
箭头样式:
No | 字段 | 表示 |
---|---|---|
1 | x | 丢失信息,箭头尾处为x |
2 | > | 实心箭头 |
3 | >> | 虚心箭头 |
4 | - | 实线 |
5 | – | 虚线 |
6 | <-> | 双向箭头 |
声明参与者
可以通过声明参与者的方式,为参与者更改属性、赋予别名as
(一旦赋予别名后续不可再使用原名)、设置权重order
(数量越小越靠前)。
@startuml
participant Client as c order 1
participant Server as s order 2
c -> s: 建立连接
s --> c: 数据交互
c --> s: 数据交互
s -> c: 断开连接
@enduml
可以使用的参与者属性:
No | 字段 | 表示 |
---|---|---|
1 | participant | 参与者 |
2 | actor | 角色 |
3 | control | 控制 |
4 | entity | 实体 |
5 | database | 数据库 |
6 | collections | 集合 |
7 | queue | 队列 |
8 | boundary | 边界 |
文字对齐
skinparam sequenceMessageAlign center
消息序号
autonumber 1.1
,指定自增数字,默认增加最后一个数字,可指定自增数字位。
@startuml
'https://plantuml.com/sequence-diagram
participant Client as c order 1
participant Server as s order 2
autonumber 1.1
c -[#red]> s: 建立连接
autonumber inc A
s --> c: 数据交互
c --> s: 数据交互
autonumber inc A
s -> c: 断开连接
@enduml
注释
note left:、
note right: 单行注释或者使用 note left ... endnote
多行注释。
分隔符
== 重复 ==
或... 重复 ...
间距
|||
设置间距,或指定间距||45||
生命线
activate c
初始化生命,deactivate c
结束生命线,可以嵌套使用。
返回
生命线可以返回内容,使用return
返回,同时可以配合autoactivate
实现自动生命线声明与销毁。
快捷创建、销毁、生命线/实例
@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++ #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml
也可以同时进行:
@startuml
alice -> bob ++ : hello1
bob -> charlie --++ : hello2
charlie --> alice -- : ok
@enduml
活动图
箭头
-->
代表普通箭头-[labels]->
代表带标签的箭头-left->
指定方向的箭头(down, up, left, right)
开始与结束
(*)
开始/结束start
/stop
开始/结束
边栏推荐
- 【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
- pytest合集(2)— pytest运行方式
- 《QTreeView+QAbstractItemModel自定义模型》:系列教程之三[通俗易懂]
- Talking from mlperf: how to lead the next wave of AI accelerator
- 杰理之蓝牙耳机品控和生产技巧【篇】
- 【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
- Mask wearing detection method based on yolov5
- 企业架构与项目管理的关联和区别
- CNN convolution neural network principle explanation + image recognition application (with source code) [easy to understand]
- 旁路由设置的正确方式
猜你喜欢
随机推荐
Wechat applet, continuously playing multiple videos. Synthesize the appearance of a video and customize the video progress bar
Significance and measures of security encryption of industrial control equipment
Training on the device with MIT | 256Kb memory
统计字符中每个字符出现的个数
[monomer] recommended configuration of streaming information i-bpsv3 server
ngnix基础知识
JS how to get a list of elements in a collection object
Airserver mobile phone third-party screen projection computer software
指标陷阱:IT领导者易犯的七个KPI错误
地图其他篇总目录
js数组拼接的四种方法[通俗易懂]
Medium pen test questions: flip the string, such as ABCD, print out DCBA
物联网rfid等
AirServer手机第三方投屏电脑软件
PMP与NPDP之间的区别是什么?
能升职加薪?PMP证书含金量浅析
C中main函数的几种写法
Unity 使用Sqlite
[NOIP2013]积木大赛 [NOIP2018]道路铺设 贪心/差分
Classify boost libraries by function