網頁

2023/4/9

UML 免費線上循序圖繪製工具 PlantUML

好用的免費線上循序圖(sequence diagram)繪製工具PlantUML


使用PlantUML語法來繪製sequence diagram比較方便,比起其他類似的工具功能較完整。

PlantUML語法範例一。

@startuml
participant client
participant app
database    db
participant cloud
skinparam sequenceMessageAlign center
skinparam ParticipantPadding 50

client ->> app : create request
activate app
app -->> client : accepted
app -> db : CREATE record\nwith state 'building'
activate db
db -->> app : success
deactivate db
|||
app -> cloud : CREATE resource
activate cloud
alt #LightBlue
  cloud -->> app : success
  |||
  app -> db : UPDATE record's\n state to 'available'
  activate db
  db -->> app : success
  deactivate db
  app ->> client : success message
else #Pink
  cloud -->> app : failed
  deactivate cloud
  |||
  app -> db : DELETE record
  activate db
  db -->> app : success
  deactivate db
  app ->> client : failed message
  deactivate app
end
@enduml

自動生成的循序圖。




範例二

@startuml
participant client
participant app 
database    db
participant cloud
skinparam sequenceMessageAlign center
skinparam ParticipantPadding 50

client ->> app: create request
activate app
app -->> client: accepted
app -> db : CREATE record\nwith state 'building'
activate db
db -->> app : success
deactivate db
|||
app -> cloud : CREATE resource
activate cloud
cloud -[#red]->>x app : success
note right : network failure
deactivate cloud
|||
app -> db : DELETE record
activate db
db -->> app : success
deactivate db
app ->> client: failed message
deactivate app
note over db: record deleted, but resource existed
@enduml



沒有留言:

張貼留言