活动图(新语法)

当前活动图(activity diagram)的语法有诸多限制和缺点,比如代码难以维护。

所以从V7947开始提出一种全新的、更好的语法格式和软件实现供用户使用(beta版)。

就像序列图一样,新的软件实现的另一个优点是它不再依赖与Graphviz。

新的语法将会替换旧的语法。然而考虑到兼容性,旧的语法仍被能够使用以确保向前兼容。

但是我们鼓励用户使用新的语法格式。

简单活动图

活动标签(activity label)以冒号开始,以分号结束。

文本格式支持creole wiki语法。

活动默认安装它们定义的顺序就行连接。

@startuml

:Hello world;

:This is on defined on

several **lines**;

@enduml

开始/结束

你可以使用关键字start和stop表示图示的开始和结束。

@startuml

start

:Hello world;

:This is on defined on

several **lines**;

stop

@enduml

@startuml

start

:Hello world;

:This is on defined on

several **lines**;

end

@enduml

条件语句

在图示中可以使用关键字if,then和else设置分支测试。标注文字则放在括号中。

@startuml

start

if (Graphviz installed?) then (yes)

:process all\ndiagrams;

else (no)

:process only

__sequence__ and __activity__ diagrams;

endif

stop

@enduml

也可以使用关键字elseif设置多个分支测试。

@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

重复循环

你可以使用关键字repeat和repeatwhile进行重复循环。

@startuml

start

repeat

:read data;

:generate diagrams;

repeat while (more data?)

stop

@enduml

while循环

可以使用关键字while和end while进行while循环。

@startuml

start

while (data available?)

:read data;

:generate diagrams;

endwhile

stop

@enduml

还可以在关键字endwhile后添加标注,还有一种方式是使用关键字is。

@startuml

while (check filesize ?) is (not empty)

:read file;

endwhile (empty)

:close file;

@enduml

并行处理

你可以使用关键字fork,fork again和end fork表示并行处理。

@startuml

start

if (multiprocessor?) then (yes)

fork

:Treatment 1;

fork again

:Treatment 2;

end fork

else (monoproc)

:Treatment 1;

:Treatment 2;

endif

@enduml

注释

文本格式支持creole wiki语法。

@startuml

start

:foo1;

note left: This is a note

:foo2;

note right

This note is on several

//lines// and can

contain HTML

====

* Calling the method ""foo()"" is prohibited

end note

stop

@enduml

标题和图例

你可以给图表(diagram)添加标题、标头、脚注和图例。

@startuml

title this is my title

if (condition?) then (yes)

:yes;

else (no)

:no;

note right

this is a note

end note

endif

stop

legend

this is the legend

endlegend

footer dummy footer

header

this is

a long __dummy__ header

end header

@enduml

颜色

你可以为活动(activity)指定一种颜色。

@startuml

start

:starting progress;

#HotPink:reading configuration files

These files should edited at this point!;

#AAAAAA:ending of the process;

@enduml

箭头

使用->标记,你可以给箭头添加文字或者修改箭头颜色。

@startuml

:foo1;

-> You can put text on arrows;

if (test) then

-[#blue]->

:foo2;

-[#green]-> The text can

also be on several lines

and **very** long...;

:foo3;

else

-[#black]->

:foo4;

endif

-[#gray]->

:foo5;

@enduml

组合(grouping)

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

@startuml

start

partition Initialization {

:read config file;

:init internal variable;

}

partition Running {

:wait for user interaction;

:print information;

}

stop

@enduml

泳道(Swimlanes)

你可以使用管道符|来定义泳道。

还可以改变泳道的颜色。

@startuml

|Swimlane1|

start

:foo1;

|#AntiqueWhite|Swimlane2|

:foo2;

:foo3;

|Swimlane1|

:foo4;

|Swimlane2|

:foo5;

stop

@enduml

分离(detach)

可以使用关键字detach移除箭头。

@startuml

:start;

fork

:foo1;

:foo2;

fork again

:foo3;

detach

endfork

if (foo4) then

:foo5;

detach

endif

:foo6;

detach

:foo7;

stop

@enduml

特殊领域语言(SDL)

通过修改活动标签最后的分号分隔符(;),可以为活动设置不同的形状。

|

<

>

/

]

}

@startuml

:Ready;

:next(o)|

:Receiving;

split

:nak(i)<

:ack(o)>

split again

:ack(i)<

:next(o)

on several line|

:i := i + 1]

:ack(o)>

split again

:err(i)<

:nak(o)>

split again

:foo/

split again

:i > 5}

stop

end split

:finish;

@enduml

一个完整的例子

@startuml

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

原文:http://zh.plantuml.com/activity2.html

plantuml 依赖_plantuml语法相关推荐

  1. plantuml 依赖_PlantUML快速入门

    UML 的简介 统一建模语言(UML)是一个通用的可视化建模语言,用于对软件进行描述.可视化处理.构造和建立软件系统制品的文档.其重要性就不多言(虽然没见到多少人用,但我仍然认为它很重要,只要大家愿意 ...

  2. plantuml 依赖_PlantUML入门

    by tot in unsplash 1. 背景 随着工作时间的增长,越发觉得用专业的图形(用例图,时序图,ER图等等)去准确表达想法是很重要的.比如针对某个需求绘制的的用例图,比一段乏味的文字来的更 ...

  3. plantuml 依赖_PlantUML参考手册

    title: PlantUML参考手册 date: 2020-03-03 15:37:35 tags: - UML - 手册 categories: - 手册 - UML PlantUML参考手册 前 ...

  4. plantuml 依赖_Plantuml的基本使用

    pom.xml添加依赖 net.sourceforge.plantuml plantuml 1.2020.10 对应controller写入plantuml脚本 package com.imddysc ...

  5. plantuml 依赖_遇见PlantUML

    前言 来到公司实习也快一个月了,最大的体会就是,虽然大部分时间做的是简单的增删该查,但不同于在学校时写的Demo,你要充分考虑程序的鲁棒性(健壮性).可扩展性(可维护性).时间/空间复杂度等.因为是要 ...

  6. plantuml 依赖_ubuntu安装PlantUML

    1. 安装graphviz 这是PlantUML依赖的图形库,支持所有OS, 可以在此下载 http://graphviz.org/Download..php ubuntu平台可以直接到这里: htt ...

  7. plantuml样式_PlantUML 简明教程

    PlantUML 简介 PlantUML 是一个开源项目,支持快速绘制时序图.用例图.类图.活动图.组件图.状态图.对象图.部署图等.同时还支持非 UML 图的甘特图.架构图等.例如下面等用例图: @ ...

  8. plantuml 依赖_使用PlantUML绘制类图

    本文基于sublime的PlantUML插件绘制类图.如需了解插件安装,请点击 Sublime安装PlantUML插件 类的UML表示 使用UML表示一个类,主要由三部分组成. 类名 . 属性 . 方 ...

  9. plantuml样式_PlantUML之活动图

    基本语法 每个普通节点:冒号开头,分号结尾 活动图的起始和结尾:start.end或stop start :case1; :case2; end 条件语句 start if(predicate?) t ...

最新文章

  1. 使用Ubuntu笔记
  2. 轻松学习Linux之自动执行任务
  3. 既生瑜何生亮 access_token VS refresh_token
  4. iOS-BMK标注覆盖物
  5. 探秘:TriCore处理器中断机制
  6. 122. 买卖股票的最jia时机||(JavaScript)
  7. 阿里巴巴宣布成立半导体公司,要自主研发芯片
  8. 《C和C++游戏趣味编程》 第8章 十步万度
  9. 为什么要学习 Spring Boot?
  10. FISCO BCOS(五)———部署安装jdk1.8
  11. hashmap扩容机制 jdk1.7
  12. 独立团-手游脱机封包辅助课程(完整版)
  13. 计算机管理USB,大势电脑至usb管理软件
  14. 三菱FX系列PLC连接触摸屏及组态软件以太网通信方案
  15. java openoffic excel转html,Java利用OpenOffice進行將word,excel轉化成html解析到界面(上)...
  16. 粉丝福利,抽5本《新程序员》004期免费送
  17. MOOC清华《面向对象程序设计》第9章:听课感想
  18. APL开发日志--2012-11-28
  19. Tushare库之Libor拆借利率
  20. python django 实名认证 调用第三方平台

热门文章

  1. cyclone IV 系列轻量级FPGA 芯片ep4ce6e22c8 引脚分布图
  2. 【超详细】C51单片机与HC-05蓝牙模块实现手机点灯
  3. 在线客服系统源码开发实战总结:需求分析及前端代码基本技术方案
  4. HDU-1248 寒冰王座 完全背包
  5. Qt添加资源文件,为QAction添加图标,建立信号槽函数并实现
  6. VC++6.0安装教程
  7. 零信任|IAM是基于动态身份的安全新边界
  8. 全球与中国身份和访问管理(IAM)软件行业调查与未来发展趋势研究报告
  9. 提取KIndle中每本书的笔记并单独保存
  10. Dependencies for Graphs 阅读笔记