@startuml
|Swimlane1|
start
:foo1;
|#AntiqueWhite|Swimlane2|
:foo2;
:foo3;
|Swimlane1|
:foo4;
|Swimlane2|
:foo5;
stop
@enduml
(12)分离(detach)
可以使用关键字detach移除箭头。
@startuml
:start;
fork
:foo1;
:foo2;
fork again
:foo3;
detach
endfork
if (foo4) then
:foo5;
detach
endif
:foo6;
detach
:foo7;
stop
@enduml
(13)特殊领域语言(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
(14)一个完整的例子
@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
二、超市购物
流程:
顾客:选择自已所要购买的商品,并把选好的商品拿到收银台交给收银员。
收银员:询问顾客是否是会员,如果是会员,索要顾客的会员卡,把会员卡扫描进系统并对会员卡进行验证。然后逐一扫描顾客所 选商品的条形码。扫描完商品信息后,根据收款机上显示的商品金额收货款,售货单和商品交给顾客。
收款机:边接收商品条码,边累加商品金额,打印售货单。
@startuml
|顾客|
start
:选择商品;
:商品交给收银员;
|#AntiqueWhite|顾客|
if (是否是会员) then (yes)
:会员;
|收银员|
:扫描会员卡;
|#AntiqueWhite|收款机|
if (接收会员编号) then (yes)
:提示会员卡有效;
else (no)
:提示会员卡无效;
endif
else (no)
|顾客|
:非会员;
endif
|收银员|
:扫描商品条码;
|收款机|
:接收商品条形码;
:统计商品金额;
|收银员|
while (是否还有商品) is (yes)
|收银员|
:扫描商品条码;
endwhile (no)
|顾客|
:交付货款;
|收银员|
:接收货款;
|收款机|
:打印售货单;
|收银员|
:货单及货品交给顾客;
|顾客|
:接收货单及货品;
stop
@enduml