【编程通识】PlantUML绘制时序图样例
生活随笔
收集整理的這篇文章主要介紹了
【编程通识】PlantUML绘制时序图样例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
??時序圖(Sequence Diagram),又名序列圖、循序圖、順序圖,是一種UML交互圖。它通過描述對象之間發送消息的時間順序顯示多個對象之間的動態協作。它可以表示用例的行為順序,當執行一個用例行為時,其中的每條消息對應一個類操作或狀態機中引起轉換的觸發事件。
樣例1:
@startumlA -> B : text1 B --> A : text2 '這里是注釋 /'這里是可換行的 注釋'/@enduml效果:
?
樣例2:加上消息序號
@startumlautonumber '這個關鍵字可自動為消息加序號 A -> B : text1 B --> A : text2autonumber 5 10 '也可以用于指定序號 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標簽
@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:延時
@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|| '指定間隔長度 A -> B : text3 B --> A : text4@enduml效果:
?
樣例9:消息者組合
@startumlbox "組合1" #LightBlue participant A participant B end box '組合A、B,并以藍色為底色A -> B : text1 B -> C : text2@enduml效果:
?
樣例10:加入時序圖說明
@startumlA -> B : text1 B --> A : text2legend center comment1 comment2 endlegend@enduml效果:
?
樣例11:加入標題和隱藏底部對象
@startumlhide footbox '隱藏底部對象title "標題1"A -> B : text1 B --> A : text2@enduml效果:
?
樣例12:不同消息者圖案
@startumlparticipant par actor A boundary B control C entity E database D '上面幾個是不同類型的事先聲明,聲明的變量具有不同圖案par->A : to actor par->B : to boundary par->C : to control par->E : to entity par->D : to database@enduml效果:
?
?
?
此外PlantUML還可用于繪制用例圖、類圖、流程圖、組件圖、狀態圖、對象圖等,以后用到了再補充。
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的【编程通识】PlantUML绘制时序图样例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【编程通识】正则表达式
- 下一篇: 【进程通信】Socket