유즈 케이스 다이어그램

Let's have few examples :

Note that you can disable the shadowing using the skinparam shadowing false command.

유즈케이스

유즈케이스는 (두개의 괄호는 원으로 보이기 때문에) 괄호로 싸서 표현합니다.

아니면 usecase 키워를 이용하여 정의할 수 있습니다. 그리고 as 키워드를 이용하여 별칭을 정의 할 수 있습니다. 별칭은 관계를 정의할 때 사용됩니다.

🎉 Copied!

@startuml

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

@enduml

Actors

액터를 정의하는 이름은 콜론 사이에 있습니다.

Actor 키워드를 사용하여 액터를 정의할 수도 있습니다.

별칭은 as 키워드로 할당될 수 있으며, 나중에 관계를 정의할 때 액터 이름 대신 사용될 수 있습니다.

다음 예에서 액터 정의는 선택 사항임을 알 수 있습니다.

🎉 Copied!

@startuml

:First Actor:
:Another\nactor: as Man2
actor Woman3
actor :Last actor: as Person1

@enduml

Change Actor style

You can change the actor style from stick man (by default) to:
  • an awesome man with the skinparam actorStyle awesome command;
  • a hollow man with the skinparam actorStyle hollow command.

Stick man (by default)

🎉 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]

유즈케이스 종류

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.

🎉 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

Use package

You can use packages to group actors or use cases.

🎉 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

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

🎉 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

기본 예제

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.

🎉 Copied!

@startuml

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

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

@enduml

Extension

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

🎉 Copied!

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

User <|-- Admin
(Start) <|-- (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.

🎉 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

Stereotypes

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

🎉 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개 (혹은 점)을 넣어서 수평방향 링크를 사용할 수 있다:

🎉 Copied!

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

You can also change directions by reversing the link:

🎉 Copied!

@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:

🎉 Copied!

@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.

Splitting diagrams

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

🎉 Copied!

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

Left to right direction

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

🎉 Copied!

@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.

🎉 Copied!

@startuml

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

@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.

🎉 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

Complete example

🎉 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

Business Use Case

You can add / to make Business Use Case.

Business Usecase

🎉 Copied!

@startuml

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

@enduml

Business Actor

🎉 Copied!

@startuml

:First Actor:/
:Another\nactor:/ as Man2
actor/ Woman3
actor/ :Last actor: as Person1

@enduml

[Ref. QA-12179]

Change arrow color and style (inline style)

You can change the color or style of individual arrows using the inline following notation:

  • #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][See similar feature on deployment-diagram or class diagram]

Change element color and style (inline style)

You can change the color or style of individual element using the following notation:
  • #[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]

Display JSON Data on Usecase diagram

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.


Privacy Policy      Advertise