默认的参与者显示为矩形,如果通过对参与者的显式声明则可以改变其外形。显式参与者声明的语法:参与者类型 参与者名称 as 参与者别名
参与者类型有:
代码
类型
actor
角色
boundary
边界
control
控制
entity
实体
database
数据库
collections
集合
queue
队列
示例如下:
@startuml
participant participant_item as par
actor User as usr
boundary Boundary as bdy
control Control as ctr
entity Entity as ent
database Database as db
collections Collections as col
queue Queue as que
par -> usr : to User
par --> bdy : to Boundary
par -> ctr : to Control
par -> ent : to Entity
par -> db : to Database
par --> col : to Collections
par <- que : from Queue
@enduml
@startuml
Bob ->x Alice:信息丢失
Bob ->> Alice:细箭头
Bob -\ Alice:上半拉箭头
Bob --> Alice:虚线箭头
Bob ->o Alice:箭头加个圈
Bob <-> Alice:来而不往非礼也
Bob o<-> Alice:送礼到此为止
@enduml
@startuml
autonumber
Bob -> Alice : Blah Blah
Alice -> Bob : Blah Blah
autonumber 12
Bob -> Alice : Another Blah Blah
Alice -> Bob : Yet another Blah Blah
autonumber 24 5
Bob -> Alice : Yeh Yah
Alice -> Bob : Yeehah
Bob --> Alice : Seeya!
@enduml
@startuml
autonumber "<i>0000</i>"
Alice -> Bob : Hello
Bob --> Alice : Ciao
autonumber 30 10 "<font color=cyan><u>000</u></font>"
Alice -> Bob : Ciao
Bob -> Alice : Hello
@enduml
@startuml
autonumber
Bob -> Alice : Hello
Alice -> Bob : Sorry for the interruption.
autonumber stop
Bob -> Alice : Hello?
autonumber resume
Alice -> Bob : OK I'm back.
@enduml
也可以在Participant上添加注释,使用note left of/right of/over的语法。也可以通过背景色来进行高亮。多行注释一样使用end note结束。
@startuml
participant Alice
participant Bob
note left of Alice #aqua
Alice is an explorer
She went underground
end note
note over Bob : He is another guy
@enduml
@startuml
participant Bob
participant Alice
note over Alice : An explorer
note over Bob : Another guy
note over Alice : She is clever
/ note over Bob : He is smart
@enduml
@startuml
Bob -> Alice : hello
note across
This is ~~written~~ in <img https://gooscloud.dscloud.me/wiki/lib/exe/fetch.php?media=wiki:dokuwiki-128.png>
end note
@enduml
@startuml
== 寒暄 ==
Bob -> Alice : Hello
Alice -> Bob : Ciao
== 实质交流 ==
Bob -> Alice : How much is a Linux OS?
Alice -> Bob : It's free of charge and free to use.
@enduml
@startuml
participant User
User -> A: DoWork
activate A #FFBBBB
A -> A: Internal call
activate A #DarkSalmon
A -> B: << createRequest >>
activate B
B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A
@enduml
@startuml
skinparam handwritten true
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underline
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
User -> A: DoWork
activate A
A -> B: Create Request
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: Request Created
deactivate B
A --> User: Done
deactivate A
@enduml