Multilingual Wiki Documentation

You are currently using syntax.
In an attempt to improve PlantUML documentation...
Please do not use this website for your own diagrams.
You can click here and use the online server here for your own documentation.

Recent changes    Wiki Toc    View page history    Add new chapter    Reorder page    Raw

ユースケース図

いくつかの例を示します。

Use Case Diagram

Let's have a few examples:

ユースケース

ユースケースは丸括弧で囲んで使います(丸括弧の対は 楕円に似ているからです)。

usecase キーワードを使ってユースケースを定義することもできます。 as キーワードを使ってエイリアスを定義することもできます。このエイリアスは あとで、ユースケースの関係を定義するために使います。

@startuml

(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4

@enduml

Usecases

Use cases are enclosed using between parentheses (because two parentheses looks like an oval).

You can also use the usecase keyword to define a usecase. And you can define an alias, using the as keyword. This alias will be used later, when defining relations.

@startuml

(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4

@enduml

アクター

アクターは2つのコロンで囲まれます。

actor キーワードを使ってアクターを定義することもできます。 as キーワードを使ってエイリアスを定義することもできます。このエイリアスはあとで、ユースケースの関係を定義するために使います。

後から説明しますが、アクターの定義は必須ではありません。

@startuml

:First Actor:
:Another\nactor: as Men2
actor Men3
actor :Last actor: as Men4

@enduml

Actors

Actor are enclosed using between two points.

You can also use the actor keyword to define an actor. And you can define an alias, using the as keyword. This alias will be used latter, when defining relations.

We will see later that the actor definitions are optional.

@startuml

:First Actor:
:Another\nactor: as Men2
actor Men3
actor :Last actor: as Men4

@enduml

ユースケースの説明

クオート記号を使うことにより、複数行にわたる説明を記述できます。

また、次の区切り記号を使用できます: -- .. == __。 区切り記号の中にはタイトルを記入できます。

@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

Usecases description

If you want to have description on several lines, you can use quotes.

You can also use the following separators: -- .. == __. And you can put titles within the separators.

@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

Use package

You can use packages to group actors or use cases.

@startuml
left to right direction
actor "Food Critic" as fc
package Restaurant {
  usecase "Eat Food" as UC1
  usecase "Pay for Food" as UC2
  usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3
@enduml

You can use rectangle to change the display of the package.

@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 は定義なしにアクターとして使われています。

@startuml

User -> (Start)
User --> (Use the application) : A small label

:Main Admin: ---> (Use the application) : This is\nyet another\nlabel

@enduml

Basic example

To link actors and use cases, the arrow --> is used.

The more dashes - in the arrow, the longer the arrow. You can add a label on the arrow, by adding a : character in the arrow definition.

In this example, you see that User has not been defined before, and is used as an actor.

@startuml

User -> (Start)
User --> (Use the application) : A small label

:Main Admin: ---> (Use the application) : This is\nyet another\nlabel

@enduml

継承

もしアクターやユースケースが継承をする場合には、 <|-- 記号を使います。

@startuml
:Main Admin: as Admin
(Use the application) as (Use)

User <|-- Admin
(Start) <|-- (Use)

@enduml

Extension

If one actor/use case extends another one, you can use the symbol <|--.

@startuml
:Main Admin: as Admin
(Use the application) as (Use)

User <|-- Admin
(Start) <|-- (Use)

@enduml

ノートの使用方法

オブジェクトに関連のあるノートを作成するには note left ofnote right ofnote top ofnote bottom of キーワードを使います。

または note キーワードを使ってノートを作成し、 .. 記号を使ってオブジェクトに紐づけることができます。

@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

Using notes

You can use the note left of , note right of , note top of , note bottom of keywords to define notes related to a single object.

A note can be also define alone with the note keywords, then linked to other objects using the .. symbol.

@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

ステレオタイプ

<<>> を使い、アクターとユースケースを定義中にステレオタイプを追加できます。

@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>

User -> (Start)
User --> (Use)

MySql --> (Use)

@enduml

Stereotypes

You can add stereotypes while defining actors and use cases using << and >>.

@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つを書きます。

@startuml
:user: --> (Use case 1)
:user: -> (Use case 2)
@enduml

線を反対にすることでも方向を変えることができます。

@startuml
(Use case 1) <.. :user:
(Use case 2) <- :user:
@enduml

矢印の内側に leftrightupdown を書くことによっても線の方向を変えられます。

@startuml
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml

例えば、 -down- ではなく -d- など、各方向の頭文字、または頭2文字( -do- )だけ使って矢印を短くすることも出来ます。

ただし、この機能の使いすぎには注意しましょう。ほとんどの場合、特別なことをしなくても Graphviz がその場にあった表示を選びます。

Changing arrows direction

By default, links between classes have two dashes -- and are vertically oriented. It is possible to use horizontal link by putting a single dash (or dot) like this:

@startuml
:user: --> (Use case 1)
:user: -> (Use case 2)
@enduml

You can also change directions by reversing the link:

@startuml
(Use case 1) <.. :user:
(Use case 2) <- :user:
@enduml

It is also possible to change arrow direction by adding left, right, up or down keywords inside the arrow:

@startuml
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml

You can shorten the arrow by using only the first character of the direction (for example, -d- instead of -down-) or the two first characters (-do-).

Please note that you should not abuse this functionality : Graphviz gives usually good results without tweaking.

図を分割する

newpage キーワードは、いくつかのページや画像に図を分割します。

@startuml
:actor1: --> (Usecase1)
newpage
:actor2: --> (Usecase2)
@enduml

Splitting diagrams

The newpage keywords to split your diagram into several pages or images.

@startuml
:actor1: --> (Usecase1)
newpage
:actor2: --> (Usecase2)
@enduml

左から右に描画する

デフォルトの作図方向は top to bottom となっています。

@startuml
'default
top to bottom direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)

@enduml

作図方向を left to right に変更するには left to right direction コマンドを使います。

@startuml

left to right direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)

@enduml

Left to right direction

The general default behavior when building diagram is top to bottom.

@startuml
'default
top to bottom direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)

@enduml

You may change to left to right using the left to right direction command. The result is often better with this direction.

@startuml

left to right direction
user1 --> (Usecase 1)
user2 --> (Usecase 2)

@enduml

スキン設定(Skinparam)

ダイアグラムの色やフォントを変更するには skinparam コマンドを使用します。

このコマンドは以下の場面で使用できます。

個別のステレオタイプ付きアクターやユースケースにそれぞれ色やフォントを定義することができます。

@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

Skinparam

You can use the skinparam command to change colors and fonts for the drawing.

You can use this command :

You can define specific color and fonts for stereotyped actors and usecases.

@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

完全な例

@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

Complete example

@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


Please report any bugs to plantuml@gmail.com or here.
This website is still in beta testing.