当前位置:网站首页>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
开始/结束
边栏推荐
- What is the difference between consonants and Initials? (difference between initials and consonants)
- 灵动微 MM32 多路ADC-DMA配置
- Icml2022 | interventional contrastive learning based on meta semantic regularization
- String类型转换BigDecimal、Date类型
- Count the number of each character in the character
- 游览器打开摄像头案例
- idea中类中显示成员变量和方法
- MQ learning notes
- Training on the device with MIT | 256Kb memory
- 二叉树的基本操作
猜你喜欢
MySQL learning notes - SQL optimization of optimization
编程英语生词笔记本
杰理之、产线装配环节【篇】
MySQL series transaction log redo log learning notes
MIT|256KB 内存下的设备上训练
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
收到一封CTO来信,邀约面试机器学习工程师
焱融看 | 混合云时代下,如何制定多云策略
locust 系列入门
九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
随机推荐
一次调试去了解redis集群的slot机制
“丝路正青春 风采看福建”在闽外籍青年短视频大赛火热征集作品中
企业架构与项目管理的关联和区别
Mask wearing detection method based on yolov5
pytest合集(2)— pytest运行方式
"The silk road is in its youth and looks at Fujian" is in the hot collection of works in the Fujian foreign youth short video competition
MySQL清空表数据
Case of camera opening by tour
idea中类中显示成员变量和方法
The correct way to set the bypass route
Using closures to switch toggle by clicking a button
Which securities company should we choose to open an account for flush stock? Is it safe to open an account with a mobile phone?
Show member variables and methods in classes in idea
Test cancellation 1
What is the difference between consonants and Initials? (difference between initials and consonants)
Business visualization - make your flowchart'run'up
Make a three digit number of all daffodils "recommended collection"
PCB线路板塞孔工艺的那些事儿~
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Count the number of each character in the character