PlantUML——通用命令

PlantUML通用命令

1、注释

1.1、简单注释

所有以 ' 开始的都是一个的注释

js 复制代码
@startuml
'Line comments use a single apostrophe
@enduml

1.2、块状注释

块状注释使用 C 风格的注释,除了用一撇一捺代替', 然后你也可以把注释放在几行上,用/' 开始,'/结束。

js 复制代码
@startuml
/'
many lines comments
here
'/
@enduml

也可以在同一行中放置块状注释

js 复制代码
@startuml
/' case 1 '/ A -> B : AB-First step
B -> C : BC-Second step
/' case 2 '/ D -> E : DE-Third step
@enduml

2、缩放

  • 可以使用缩放命令缩放生成的图像。
  • 可以使用数字或分数来定义比例因子。您还可以指定任一宽度或高度(像素)
  • 也可以同时给出宽度和高度:图像被缩放以适应指定尺寸
    • scale 1.5
    • scale 2/3
    • scale 200 width
    • scale 200 height
    • scale 200*100
    • scale max 300*200
    • scale max 1024 width
    • scale max 800 height
js 复制代码
@startuml
scale 180*90
Bob->Alice : hello
@enduml

3、标题

使用 title 关键字添加标题。你可以在标题描述中使用 \n 添加新行。

js 复制代码
@startuml
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
skinparam titleBorderColor red
skinparam titleBackgroundColor Aqua-CadetBlue
title Simple communication\nexample
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
js 复制代码
@startuml
title
<u>Simple</u> communication example
on <i>several</i> lines and using <back:cadetblue>creole tags</back>
end title
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml

4、图片标题

使用 caption 关键字在图像下放置一个标题.

js 复制代码
@startuml
caption figure 1
Alice -> Bob: Hello
@enduml

5、页眉和页脚

  • 可以使用 headerfooter 命令在生成的图中增加页眉和页脚。
  • 可以选择指定 center, leftright 关键字使页眉或页脚实现居中、左对齐和右对齐。
  • 和标题一样,页眉或页脚内容可以在多行中定义,而且同样可以在页眉或页脚中输入一些 HTML 代码。
js 复制代码
@startuml
Alice -> Bob: Authentication Request
header
<font color=red>Warning:</font>
Do not use in production.
endheader
center footer Generated for demonstration
@enduml

6、图例说明

  • legendend legend 作为关键词,用于配置一个图例 (legend)
  • 支持可选地使用 left,right,center为这个图例指定对齐方式.
js 复制代码
@startuml
Alice -> Bob : Hello
legend right
Short
legend
endlegend
@enduml

7、图标示例

7.1、活动图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
start
:Hello world;
:This is defined on
several **lines**;
stop
@enduml

7.2、Archimate

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
archimate #Technology "VPN Server" as vpnServerA <<technology-device>>
rectangle GO #lightgreen
rectangle STOP #red
rectangle WAIT #orange
@enduml

7.3、类图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
a -- b
@enduml

7.4、组件图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
node n
(u) -> [c]
@enduml

7.5、甘特图

js 复制代码
@startgantt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
[t] lasts 5 days
@endgantt

7.6、对象图

js 复制代码
@startgantt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
object user {
name = "Dummy"
id = 123
}
@enduml

7.7、思维导图

js 复制代码
@startmindmap
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
* r
** d1
** d2
@endmindmap

7.8、Network (nwdiag)

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
nwdiag {
network inet {
web01 [shape = cloud]
}
}
@enduml

7.9、序列图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
a->b
@enduml

7.10、状态图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
[*] --> State1
State1 -> State2
@enduml

7.11、定时图

js 复制代码
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
robust "Web Browser" as WB
concise "Web User" as WU
@0
WU is Idle
WB is Idle
@100
WU is Waiting
WB is Processing
@300
WB is Waiting
@enduml

7.12、工作分解结构(WBS)

js 复制代码
@startwbs
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
* r
** d1
** d2
@endwbs

7.13、线框图

js 复制代码
@startsalt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
{+
Login | "MyName "
Password | "**** "
[Cancel] | [ OK ]
}
@endsalt
相关推荐
吴声子夜歌12 小时前
PlantUML——部署图
plantuml·部署图
吴声子夜歌17 小时前
PlantUML——活动图新语法
plantuml·活动图
吴声子夜歌20 小时前
PlantUML——组件图
plantuml·组件图
吴声子夜歌1 天前
PlantUML——定时图
plantuml·定时图
吴声子夜歌2 天前
PlantUML——状态图
uml·plantuml·状态图
吴声子夜歌2 天前
PlantUML——序列图
uml·plantuml·序列图
吴声子夜歌2 天前
PlantUML——活动图
uml·plantuml·活动图
吴声子夜歌3 天前
PlantUML——类图(二)
uml·plantuml·类图
吴声子夜歌3 天前
PlantUML——对象图
uml·plantuml·对象图