【编程通识】PlantUML绘制时序图样例
生活随笔
收集整理的這篇文章主要介紹了
【编程通识】PlantUML绘制时序图样例
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
??時(shí)序圖(Sequence Diagram),又名序列圖、循序圖、順序圖,是一種UML交互圖。它通過(guò)描述對(duì)象之間發(fā)送消息的時(shí)間順序顯示多個(gè)對(duì)象之間的動(dòng)態(tài)協(xié)作。它可以表示用例的行為順序,當(dāng)執(zhí)行一個(gè)用例行為時(shí),其中的每條消息對(duì)應(yīng)一個(gè)類操作或狀態(tài)機(jī)中引起轉(zhuǎn)換的觸發(fā)事件。
樣例1:
@startumlA -> B : text1 B --> A : text2 '這里是注釋 /'這里是可換行的 注釋'/@enduml效果:
?
樣例2:加上消息序號(hào)
@startumlautonumber '這個(gè)關(guān)鍵字可自動(dòng)為消息加序號(hào) A -> B : text1 B --> A : text2autonumber 5 10 '也可以用于指定序號(hào) A -> B : text3 B --> A : text4@enduml效果:
?
樣例3:加上消息注釋
@startumlA -> B : text1 note left: comment1B --> A : text2 note right: comment2A -> B : text3 note left: comment3B --> A : text4 note right: comment4@enduml效果:
?
樣例4:加上消息者注釋
@startumlparticipant A participant Brnote left of A comment on A left 1 comment on A left 2 end note '多行注釋這樣寫note right of B: comment on B right '單行注釋這樣寫note over A: comment on A headhnote over A, B comment for A and B on there head end note@enduml效果:
?
樣例5:使用html標(biāo)簽
@startumlparticipant A participant Bnote left of A: <size:20>comment on A left 1</size> '字體大小 note left of A: ~~comment on A left 2~~ '波浪線 note right of B: comment on --刪除部分-- B right '消息者注釋刪除線 note right of B: picture <img library.JPG> '插入圖片A -> B : **text1** '加粗 B --> A : ~~text2~~ '下劃線 A -> B : <color red>text3</color> '字體顏色 B --> A : <s:black>text4</s> '消息刪除線@enduml效果:
?
樣例6:劃分階段
@startuml==階段一== A -> B : text1 B --> A : text2==階段二== A -> B : text3 B --> A : text4@enduml效果:
?
樣例7:延時(shí)
@startuml...100 years later... A -> B : text1 B --> A : text2...200 years later... A -> B : text3 B --> A : text4@enduml效果:
?
樣例8:加入間隔
@startumlA -> B : text1 B --> A : text2||| A -> B : text3 B --> A : text4||60|| '指定間隔長(zhǎng)度 A -> B : text3 B --> A : text4@enduml效果:
?
樣例9:消息者組合
@startumlbox "組合1" #LightBlue participant A participant B end box '組合A、B,并以藍(lán)色為底色A -> B : text1 B -> C : text2@enduml效果:
?
樣例10:加入時(shí)序圖說(shuō)明
@startumlA -> B : text1 B --> A : text2legend center comment1 comment2 endlegend@enduml效果:
?
樣例11:加入標(biāo)題和隱藏底部對(duì)象
@startumlhide footbox '隱藏底部對(duì)象title "標(biāo)題1"A -> B : text1 B --> A : text2@enduml效果:
?
樣例12:不同消息者圖案
@startumlparticipant par actor A boundary B control C entity E database D '上面幾個(gè)是不同類型的事先聲明,聲明的變量具有不同圖案par->A : to actor par->B : to boundary par->C : to control par->E : to entity par->D : to database@enduml效果:
?
?
?
此外PlantUML還可用于繪制用例圖、類圖、流程圖、組件圖、狀態(tài)圖、對(duì)象圖等,以后用到了再補(bǔ)充。
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的【编程通识】PlantUML绘制时序图样例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【编程通识】正则表达式
- 下一篇: 【进程通信】Socket