PlantUML-活动图-2021-06-25-周六
2021-07-26 本文已影响0人
勇往直前888
开始/结束
你可以使用关键字start和stop表示图示的开始和结束。
@startuml
start
:Hello world;
:This is on defined on
several **lines**;
stop
@enduml

条件语句
- 在图示中可以使用关键字 if,then 和 else 设置分支测试。标注文字则放在括号中。
@startuml
start
if (condition A) then (yes)
:Text 1;
elseif (condition B) then (yes)
:Text 2;
stop
elseif (condition C) then (yes)
:Text 3;
elseif (condition D) then (yes)
:Text 4;
else (nothing)
:Text else;
endif
stop
@enduml

- 使用Switch用于分支语句

- 可以使用stop, kill , detach等命令打断条件; kill和detach效果一样


重复循环
- 你可以使用关键字repeat和repeatwhile进行重复循环。使用backward关键字回传。条件在下。

- 可以使用关键字while和end while进行while循环。条件在上

- 可以使用break关键字跳出循环
@startuml
start
repeat
:Test something;
if (Something went wrong?) then (no)
#palegreen:OK;
break
endif
->NOK;
:Alert "Error with long text";
repeat while (Something went wrong with long text?) is (yes) not (no)
->//merged step//;
:Alert "Success";
stop
@enduml

并行处理
你可以使用关键字 fork,fork again 和 end fork 表示并行处理。通常用来表示多线程。

注释
可以使用note,floating等关键字

颜色
使用#可以设置背景色

箭头
使用->
标记,你可以给箭头添加文字或者修改箭头颜色。同时,你也可以选择点状 (dotted),条状(dashed),加粗或者是隐式箭头

连接器
你可以使用括号定义连接器。用#添加颜色

组合
通过定义分区(partition),你可以把多个活动组合(group)在一起。

泳道
你可以使用管道符|
来定义泳道。还可以改变泳道的颜色
