Use Case Diagram
A use case diagram is a visual representation used in software engineering to depict the interactions between system actors and the system itself. It captures the dynamic behavior of a system by illustrating its use cases and the roles that interact with them. These diagrams are essential in specifying the system's functional requirements and understanding how users will interact with the system. By providing a high-level view, use case diagrams help stakeholders understand the system's functionality and its potential value. 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 that continually contributes to its improvement and offers a wealth of resources for users at all levels.
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.
|
🎉 Copied!
|
|
Actors
The name defining an actor is enclosed between colons.
You can also use the actor keyword to define an actor.
An alias can be assigned using the as keyword and can be used later instead of the actor's name, e. g. when defining relations.
You can see from the following examples, that the actor definitions are optional.
|
🎉 Copied!
|
|
Change Actor style
You can change the actor style from stick man (by default) to:
- an awesome man with the
skinparam actorStyle awesomecommand; - a hollow man with the
skinparam actorStyle hollowcommand.
Stick man (by default)
|
🎉 Copied!
|
|
Awesome man
|
🎉 Copied!
|
|
[Ref. QA-10493]
Hollow man
|
🎉 Copied!
|
|
[Ref. PR#396]
Usecases description
If you want to have a description spanning several lines, you can use quotes.
You can also use the following separators:
--(dashes)..(periods)==(equals)__(underscores)
|
🎉 Copied!
|
|
Please note that the alias and the description are switched around from the basic example:
|
🎉 Copied!
|
|
Use package
You can use packages to group actors or use cases.
|
🎉 Copied!
|
|
You can use
rectangle to change the display of the package.
|
🎉 Copied!
|
|
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.
|
🎉 Copied!
|
|
Extension
If one actor/use case extends another one, you can use the symbol <|--.
|
🎉 Copied!
|
|
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!
|
|
Stereotypes
You can add stereotypes while defining actors and use cases using << and >>.
|
🎉 Copied!
|
|
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:
|
🎉 Copied!
|
|
You can also change directions by reversing the link:
|
🎉 Copied!
|
|
It is also possible to change arrow direction by adding
left, right, up
or down keywords inside the arrow:
|
🎉 Copied!
|
|
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.
And with the left to right direction parameter:
|
🎉 Copied!
|
|
Splitting diagrams
The newpage keywords to split your diagram into several pages or images.
|
🎉 Copied!
|
|
Left to right direction
The general default behavior when building diagram is top to bottom.
|
🎉 Copied!
|
|
You may change to left to right using the left to right direction command.
The result is often better with this direction.
|
🎉 Copied!
|
|
See also 'Change diagram orientation' on Deployment diagram page.
Skinparam
You can use the skinparam
command to change colors and fonts for the drawing.
You can use this command :
- In the diagram definition, like any other commands,
- In an included file,
- In a configuration file, provided in the command line or the ANT task.
|
🎉 Copied!
|
|
Complete example
|
🎉 Copied!
|
|
Business Use Case
You can add / to make Business Use Case.
Business Usecase
|
🎉 Copied!
|
|
Business Actor
|
🎉 Copied!
|
|
[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!
|
|
[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!
|
|
[Ref. QA-5340 and adapted from QA-6852]
Display JSON Data on Usecase diagram
Simple example
|
🎉 Copied!
|
|
[Ref. QA-15481] For another example, see on JSON page.