いくつかの例を示します。
PlantUML offers a unique approach to creating use case diagrams through its text-based language. One of the primary advantages of using PlantUML is its simplicity and efficiency. Instead of manually drawing shapes and connections, users can define their diagrams using intuitive and concise textual descriptions. This not only speeds up the diagram creation process but also ensures consistency and accuracy. The ability to integrate with various documentation platforms and its wide range of supported output formats make PlantUML a versatile tool for both developers and non-developers. Lastly, being open-source, PlantUML boasts a [strong community](https://forum.plantuml.net/) that continually contributes to its improvement and offers a wealth of resources for users at all levels.
WARNING This translation need to be updated. WARNING
ユースケースは丸括弧で囲んで使います(丸括弧の対は
楕円に似ているからです)。
usecase キーワードを使ってユースケースを定義することもできます。
as キーワードを使ってエイリアスを定義することもできます。このエイリアスは
あとで、ユースケースの関係を定義するために使います。
🎉 Copied!
|
@startuml
(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
@enduml
|
アクターは2つのコロンで囲まれます。
actor キーワードを使ってアクターを定義することもできます。
as キーワードを使ってエイリアスを定義することもできます。このエイリアスはあとで、ユースケースの関係を定義するために使います。
後から説明しますが、アクターの定義は必須ではありません。
🎉 Copied!
|
@startuml
:First Actor:
:Another\nactor: as Men2
actor Men3
actor :Last actor: as Men4
@enduml
|
アクターのスタイルを、デフォルトの棒人間以外に変更できます:
skinparam actorStyle awesome コマンドで、awesome manスタイル
skinparam actorStyle hollow コマンドで、hollow manスタイル
棒人間 (デフォルト)
🎉 Copied!
|
@startuml
:User: --> (Use)
"Main Admin" as Admin
"Use the application" as (Use)
Admin --> (Admin the application)
@enduml
|
Awesome man
🎉 Copied!
|
@startuml
skinparam actorStyle awesome
:User: --> (Use)
"Main Admin" as Admin
"Use the application" as (Use)
Admin --> (Admin the application)
@enduml
|
[Ref. QA-10493]
Hollow man
🎉 Copied!
|
@startuml
skinparam actorStyle Hollow
:User: --> (Use)
"Main Admin" as Admin
"Use the application" as (Use)
Admin --> (Admin the application)
@enduml
|
[Ref. PR#396]
クオート記号を使うことにより、複数行にわたる説明を記述できます。
また、次の区切り記号を使用できます:
-- (ダッシュ)
.. (ピリオド)
== (イコール)
__ (アンダースコア)
これらのペアで囲んで、その間にテキストを記述することで、区切り記号の中にタイトルを記入できます。
🎉 Copied!
|
@startuml
usecase UC1 as "You can use
several lines to define your usecase.
You can also use separators.
--
Several separators are possible.
==
And you can add titles:
..Conclusion..
This allows large description."
@enduml
|
パッケージを使用して、アクターやユースケースをグループ化できます。
🎉 Copied!
|
@startuml
left to right direction
actor Guest as g
package Professional {
actor Chef as c
actor "Food Critic" as fc
}
package Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
usecase "Review" as UC4
}
fc --> UC4
g --> UC1
g --> UC2
g --> UC3
@enduml
|
rectangle を使用するとパッケージの見た目を変更できます。
🎉 Copied!
|
@startuml
left to right direction
actor "Food Critic" as fc
rectangle Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3
@enduml
|
アクターとユースケースを繋げるには --> 矢印を使います。
矢印に使うハイフン - の数を増やすと矢印を長くできます。
矢印の定義に : を使うことにより矢印にラベルをつけることができます。
以下の例では User は定義なしにアクターとして使われています。
🎉 Copied!
|
@startuml
User -> (Start)
User --> (Use the application) : A small label
:Main Admin: ---> (Use the application) : This is\nyet another\nlabel
@enduml
|
もしアクターやユースケースが継承をする場合には、 <|-- 記号を使います。
🎉 Copied!
|
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User <|-- Admin
(Start) <|-- (Use)
@enduml
|
オブジェクトに関連のあるノートを作成するには note left of 、 note right of 、 note top of 、 note bottom of キーワードを使います。
または note キーワードを使ってノートを作成し、 .. 記号を使ってオブジェクトに紐づけることができます。
🎉 Copied!
|
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User -> (Start)
User --> (Use)
Admin ---> (Use)
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
@enduml
|
<< と >> を使い、アクターとユースケースを定義中にステレオタイプを追加できます。
🎉 Copied!
|
@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)
@enduml
|
デフォルトでは、クラス間の線は2個のハイフン -- で表され、縦方向につながります。横方向の線を描くには以下のようにハイフン1つかドット1つを書きます。
🎉 Copied!
|
@startuml
:user: --> (Use case 1)
:user: -> (Use case 2)
@enduml
|
線を反対にすることでも方向を変えることができます。
🎉 Copied!
|
@startuml
(Use case 1) <.. :user:
(Use case 2) <- :user:
@enduml
|
矢印の内側に left 、 right 、 up 、 down を書くことによっても線の方向を変えられます。
🎉 Copied!
|
@startuml
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml
|
例えば、 -down- ではなく -d- など、各方向の頭文字、または頭2文字( -do- )だけ使って矢印を短く記述することも出来ます。
ただし、この機能の使いすぎには注意しましょう。ほとんどの場合、特別なことをしなくても Graphviz がその場にあった表示を選びます。
left to right direction パラメータを使用した場合は、次のようになります:
🎉 Copied!
|
@startuml
left to right direction
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml
|
newpage キーワードは、いくつかのページや画像に図を分割します。
🎉 Copied!
|
@startuml
:actor1: --> (Usecase1)
newpage
:actor2: --> (Usecase2)
@enduml
|
デフォルトの作図方向は top to bottom となっています。
🎉 Copied!
|
@startuml
'default
top to bottom direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)
@enduml
|
作図方向を left to right に変更するには left to right direction コマンドを使います。
🎉 Copied!
|
@startuml
left to right direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)
@enduml
|
ダイアグラムの色やフォントを変更するには skinparam コマンドを使用します。
このコマンドは以下の場面で使用できます。
個別のステレオタイプ付きアクターやユースケースにそれぞれ色やフォントを定義することができます。
🎉 Copied!
|
@startuml
skinparam handwritten true
skinparam usecase {
BackgroundColor DarkSeaGreen
BorderColor DarkSlateGray
BackgroundColor<< Main >> YellowGreen
BorderColor<< Main >> YellowGreen
ArrowColor Olive
ActorBorderColor black
ActorFontName Courier
ActorBackgroundColor<< Human >> Gold
}
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)
@enduml
|
🎉 Copied!
|
@startuml
left to right direction
skinparam packageStyle rectangle
actor customer
actor clerk
rectangle checkout {
customer -- (checkout)
(checkout) .> (payment) : include
(help) .> (checkout) : extends
(checkout) -- clerk
}
@enduml
|
/ を加えると、ビジネスユースケースを作成できます。
ビジネスユースケース
🎉 Copied!
|
@startuml
(First usecase)/
(Another usecase)/ as (UC2)
usecase/ UC3
usecase/ (Last\nusecase) as UC4
@enduml
|
ビジネスアクター
🎉 Copied!
|
@startuml
:First Actor:/
:Another\nactor:/ as Man2
actor/ Woman3
actor/ :Last actor: as Person1
@enduml
|
[Ref. QA-12179]
個別の矢印ごとに色とスタイルを変更するには、次の記法を使用します:
#color;line.[bold|dashed|dotted];text:color
🎉 Copied!
|
@startuml
actor foo
foo --> (bar) : normal
foo --> (bar1) #line:red;line.bold;text:red : red bold
foo --> (bar2) #green;line.dashed;text:green : green dashed
foo --> (bar3) #blue;line.dotted;text:blue : blue dotted
@enduml
|
[Ref. QA-3770 and QA-3816]
[配置図、クラス図の同様の機能を参照]
個別の要素ごとに色とスタイルを変更するには、次の記法を使用します:
#[color|back:color];line:color;line.[bold|dashed|dotted];text:color
🎉 Copied!
|
@startuml
actor a
actor b #pink;line:red;line.bold;text:red
usecase c #palegreen;line:green;line.dashed;text:green
usecase d #aliceblue;line:blue;line.dotted;text:blue
@enduml
|
[Ref. QA-5340 and adapted from QA-6852]
Simple example
🎉 Copied!
|
@startuml
allowmixing
actor Actor
usecase Usecase
json JSON {
"fruit":"Apple",
"size":"Large",
"color": ["Red", "Green"]
}
@enduml
|
[Ref. QA-15481]
For another example, see on JSON page.
|
|