活动图

  • 基于PlantUML
  • 活动图
PlantUML制图-概述

活动图

基础

  • **XXX** 表示加粗

activity-1.png

1
2
3
4
5
@startuml activity-1
:第一行;
:第一行
第 **二行加粗** 了;
@enduml

开始,结束,终止

  • start 开始
  • stop 结束
  • end 终止

activity-2.png

1
2
3
4
5
6
7
8
9
10
11
12
13
@startuml activity-2
start
:第一行;
:第一行
第 **二行加粗** 了;
end

start
:第一行;
:第一行
第 **二行加粗** 了;
stop
@enduml

条件判断

  • if 条件框
  • then yes判断线上文字
  • else no判断线上文字
  • endif 条件判断结束符

activity-3.png

1
2
3
4
5
6
7
8
9
@startuml activity-3
start
if (你好吗?) then (好)
:选择了好;
else (不好)
:选择了__不好(带下划线)__;
endif
stop
@enduml

多条件判断

  • elseif 多条件框

activity-4.png

1
2
3
4
5
6
7
8
9
10
11
12
13
@startuml activity-4
start
if (你好吗?) then (好)
:选择了好;
elseif (确认好吗?) then (确定好)
:选择了确定好;
elseif (再次确认好吗?) then (确定确定好)
:选择了确定确定好;
else (不好)
:不好;
endif
stop
@enduml

末判断循环

  • repeat 循环体框选
  • while 循环判断
  • is 循环箭头文字

activity-5.png

1
2
3
4
5
6
7
8
@startuml activity-5
start
repeat
:上班;
:回家;
repeat while (挂了?) is (没有)
stop
@enduml

首判断循环

  • endwhile 循环体结束标识

activity-6.png

activity-7.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@startuml activity-6
start
while (能动?)
:上班;
:回家;
endwhile
stop
@enduml

@startuml activity-7
start
while (能动?) is (能)
:上班;
:回家;
endwhile (不能)
:挂了;
stop
@enduml

并行

  • fork 并行标识
  • fork again 并行标识
  • end fork 结束并行标识

activity-8.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@startuml activity-8
start
if (进入并行?) then (进入)
fork
:任务 1;
fork again
:任务 2;
end fork
else (不进入)
:任务 1;
:任务 2;
endif
stop
@enduml

注释

  • floating 无箭头标识
  • note 注释声明
  • [left|right] 位置标识
  • //XXX// 斜体字
  • ==== 分割线
  • * 小圆点
  • ""XXX"" 代码块
  • <b>XXX</b> html符

activity-9.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@startuml activity-9
start
:过程1;
floating note left: 这是过程1的注释, 在左边, 没有箭头
:过程2;
note right
这是过程2的注释 在右边
//斜体字// 正常字
正常字 <b>HTML文字</b>
====
* 小圆点 ""代码块"" 加分割线
end note
stop
@enduml

颜色

  • #{颜色名}:xxx; 指定颜色名
  • #{颜色名A}/{颜色名B}:xxx; 指定渐变颜色, 左上/右下
  • #{颜色名A}\{颜色名B}:xxx; 指定渐变颜色, 左下\右上
  • #{颜色名A}|{颜色名B}:xxx; 指定渐变颜色, 左|右
  • #{HEX}:xxx 指定HEX值(长短HEX均可)

activity-10.png

1
2
3
4
5
6
7
8
9
@startuml activity-10
start
:正常颜色;
#HotPink:直接使用颜色名字[[https://www.w3schools.com/colors/colors_names.asp]];
#HotPink|White:甚至是渐变色;
#AAAAAA:使用 HEX 值;
#555:使用 短 HEX 值;
stop
@enduml

颜色取值

activity-11.png

1
2
3
@startuml activity-11
colors
@enduml

activity-12.png

1
2
3
@startuml activity-12
colors chocolate
@enduml

箭头样式

  • -> 后接箭头文字
  • -[#blue]-> 指定颜色
  • -[#green,dashed]-> 指定颜色和样式, dashed 粗粒度虚线, dotted 细粒度虚线, bold 粗实线

activity-13.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@startuml activity-13
start
:foo1;
-> 指定箭头旁文字;
if (test) then
-[#blue]-> 蓝色箭头;
:foo2;
-[#green,dashed]-> 绿色加粗虚线
文字可换行
**甚至可加粗**;
:foo3;
else
-[#black,dotted]-> 黑色加细虚线
:foo4;
endif
-[#gray,bold]->
:foo5;
stop
@enduml

分组

  • partition 分组

activity-14.png

1
2
3
4
5
6
7
8
9
10
11
12
13
@startuml activity-14
start
partition 分组1 {
:上班;
:吃饭;
}
:回家;
partition 分组2 {
:睡觉;
:玩;
}
stop
@enduml

泳道

  • |泳道名| 泳道名
  • |#{颜色}|泳道名| 指定颜色的泳道

activity-15.png

1
2
3
4
5
6
7
8
9
10
11
12
13
@startuml activity-15
|服务A|
start
:查库1;
|#AntiqueWhite|服务B|
:写表;
:计算;
|服务A|
:查库2;
|服务B|
:上传;
stop
@enduml

无下文

  • detach 无下文

activity-16.png

1
2
3
4
5
6
7
8
9
10
11
@startuml activity-16
start
if (你好吗?) then (好)
:选择了好;
else (不好)
:这个分支没有下文;
detach
endif
:待结束;
stop
@enduml

岔路

  • split 岔路
  • split again 岔路
  • end split 岔路停止

activity-17.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@startuml activity-17
start
: 过程1;
: 过程2;
split
: 岔路1;
split again
: 岔路2;
split again
: 岔路3;
split again
: 岔路4;
detach
split again
: 岔路5;
stop
end split;
stop
@enduml

块样式

  • ;, |, <, >, ], /, } 各种样式

activity-18.png

1
2
3
4
5
6
7
8
9
10
11
@startuml activity-18
start
:样式1;
:样式2|
:样式3<
:样式4>
:样式5]
:样式6/
:样式7}
stop
@enduml

综合示例

activity-19.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
@startuml activity-19
start
:ClickServlet.handleRequest();
:new page;
if (Page.onSecurityCheck) then (true)
:Page.onInit();
if (isForward?) then (no)
:Process controls;
if (continue processing?) then (no)
stop
endif

if (isPost?) then (yes)
:Page.onPost();
else (no)
:Page.onGet();
endif
:Page.onRender();
endif
else (false)
endif

if (do redirect?) then (yes)
:redirect process;
else
if (do forward?) then (yes)
:Forward request;
else (no)
:Render page template;
endif
endif
stop
@enduml