Activity Diagram (legacy)
This is the old Activity Diagram (legacy) syntax, to see the new current version see: link::activity-diagram-beta[Activity Diagram (new)].
Branches
You can use if/then/else
keywords to define branches.
@startuml
(*) --> "Initialization"
if "Some Test" then
-->[true] "Some Action"
--> "Another Action"
-right-> (*)
else
->[false] "Something else"
-->[Ending process] (*)
endif
@enduml
Unfortunately, you will have to sometimes repeat the same activity in the diagram text:
More on Branches
By default, a branch is connected to the last defined activity, but it
is possible to override this and to define a link with the if
keywords.
It is also possible to nest branches.
Long action description
When you declare activities, you can span on several lines the
description text. You can also add \n
in the description.
You can also give a short code to the activity with the as
keyword.
This code can be used latter in the diagram description.
Notes
You can add notes on a activity using the commands
note left
,
note right
, note top
or note bottom
,
just after the description of the activity you want to note.
If you want to put a note on the starting point, define the note at the very beginning of the diagram description.
You can also have a note on several lines, using the
endnote
keywords.
Partition
You can define a partition using the partition
keyword, and
optionally declare a background color for your partition (Using a html
color code or name)
When you declare activities, they are automatically put in the last used partition.
You can close the partition definition using a closing bracket }
.
@startuml
partition Conductor {
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
}
partition Audience #LightSkyBlue {
=== S1 === --> Applauds
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
partition Orchestra #CCCCEE {
WavesArmes --> Introduction
--> "Play music"
}
@enduml
Skinparam
You can use the link::skinparam[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 link::preprocessing[included file], * In a configuration file, provided in the link::command-line[command line] or the link::ant-task[ANT task]. You can define specific color and fonts for stereotyped activities.
@startuml
skinparam backgroundColor #AAFFFF
skinparam activity {
StartColor red
BarColor SaddleBrown
EndColor Silver
BackgroundColor Peru
BackgroundColor<< Begin >> Olive
BorderColor Peru
FontName Impact
}
(*) --> "Climbs on Platform" << Begin >>
--> === S1 ===
--> Bows
--> === S2 ===
--> WavesArmes
--> (*)
@enduml
Complete example
@startuml
title Servlet Container
(*) --> "ClickServlet.handleRequest()"
--> "new Page"
if "Page.onSecurityCheck" then
->[true] "Page.onInit()"
if "isForward?" then
->[no] "Process controls"
if "continue processing?" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if "is Post?" then
-->[yes] "Page.onPost()"
--> "Page.onRender()" as render
--> ===REDIRECT_CHECK===
else
-->[no] "Page.onGet()"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if "Do redirect?" then
->[yes] "redirect request"
--> ==BEFORE_DESTROY===
else
if "Do Forward?" then
-left->[yes] "Forward request"
--> ==BEFORE_DESTROY===
else
-right->[no] "Render page template"
--> ==BEFORE_DESTROY===
endif
endif
--> "Page.onDestroy()"
-->(*)
@enduml