PlantUML は、シンプルなプレーンテキスト記述からダイアグラムを生成できるオープンソースツールです。
基本のダイアグラムブロック
@startuml
User -> Service : Authenticate
Service --> User : Token
@enduml
クラス図 (Class Diagrams)
属性とアクセス修飾子 (Visibility)
@startuml
class BankAccount {
+String owner
#Integer accountNumber
-Decimal balance
~String branchCode
+deposit(amount : Decimal) : void
-calculateInterest() : Decimal
{static} String bankName
{abstract} getAccountType() : String
}
@enduml
| 修飾子 | 可視性 (Visibility) |
|---|---|
+ |
パブリック (Public) |
- |
プライベート (Private) |
# |
プロテクテッド (Protected) |
~ |
パッケージプライベート (Package Private) |
クラス間の関係 (Class Relationships)
@startuml
Animal <|-- Dog : Extension / Inheritance
Car *-- Engine : Composition
College o-- Student : Aggregation
Driver ..> Car : Dependency
Interface <|.. Impl : Implementation (Dotted)
@enduml
| 構文 | 関係性 | 意味 |
|---|---|---|
| `< | --` | 汎化 / 継承 (Generalization / Inheritance) |
*-- |
コンポジション (Composition) | 親が存在しないと子は存在できない |
o-- |
集約 (Aggregation) | 子は独立して存在可能 |
| `< | ..` | 実現 (Realization) |
..> |
依存 (Dependency) | 一時的な利用関係 |
ノートと注釈 (Notes & Annotations)
@startuml
class Customer
note left of Customer : Customer identity record
note "Floating standalone note" as N1
@enduml
アクティビティ図 (Activity Diagrams)
@startuml
start
:Receive Payment;
if (Verified?) then (yes)
:Fulfill Order;
:Send Email;
else (no)
:Notify Customer;
endif
stop
@enduml