Activity Diagram

To be able to generate those diagram, you must have Graphviz_software installed on your machine in the default directory c:\Program Files\GraphvizX.XX or /usr/ bin/dot. You can have_a_look_here_if_you_have_installed_Graphviz_somewhere_else.

Simple Activity

You can use (*) for the starting point and ending point of the activity diagram. In some occasion, you may want to use (*top) to force the starting point to be at the top of the diagram. Use –> for arrows. <uml t=“activity”>

(*) –> “First Activity” “First Activity” –> (*)

</uml>

Label on arrows

By default, an arrow starts at the last used activity. You can put a label on an arrow using brackets [ and ] just after the arrow definition. <uml t=“activity_001”>

(*) –> “First Activity” –>[You can put also labels] “Second Activity” –> (*)

</uml>

Changing arrow direction

You can use → for horizontal arrows. It is possible to force arrow's direction using the following syntax:

  • -down→ (default arrow)
  • -right→ or →
  • -left→
  • -up→

<uml t=“activity_002”>

(*) -up→ “First Activity” -right→ “Second Activity” –> “Third Activity” -left→ (*)

</uml>

Branches

You can use if/then/else keywords to define branches. <uml t=“activity_003”> (*) –> “Initialization”

if “Some Test” then

  1. →[true] “Some Activity”
  2. → “Another activity”
  3. right→ (*)

else

  1. >[false] “Something else”
  2. →[Ending process] (*)

endif

</uml> Unfortunately, you will have to sometimes repeat the same activity in the diagram text: <uml t=“activity_004”> (*) –> “check input” If “input is verbose” then –> [Yes] “turn on verbosity” –> “run command” else –> “run command” Endif –>(*) </uml>

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. <uml t=“activity_005”>

(*) –> if “Some Test” then

  1. →[true] “activity 1”
if "" then
  -> "activity 3" as a3
else
  if "Other test" then
    -left-> "activity 5"
  else
    --> "activity 6"
  endif
endif

else

  1. >[false] “activity 2”

endif

a3 –> if “last test” then

  1. → “activity 7”

else

  1. > “activity 8”

endif

</uml>

Synchronization

You can use === code === to display synchronization bars. <uml t=“activity_006”>

(*) –>

B1

–> “Parallel Activity 1” –>

B2

===B1=== –> “Parallel Activity 2” –>

B2

–> (*)

</uml>

Long activity 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. @startuml (*) -left→ “this <size:20>activity</size>

is <b>very</b> <color:red>long2</color>
and defined on several lines
that contains many <i>text</i>" as A1

-up→ “Another activity\n on several lines”

A1 –> “Short activity <img:sourceforge.jpg>” </uml> [imgp/activity_007.png]

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. <uml t=“activity_008”>

(*) –> “Some Activity” note right: This activity has to be defined “Some Activity” –> (*) note left This note is on several lines end note

</uml>

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 }. <uml t=“activity_009”>

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"

}

</uml>

Title the diagram

The title keywords is used to put a title. You can use title and end title keywords for a longer title, as in sequence diagrams. <uml t=“activity_010”> title Simple example\nof title

(*) –> “First activity” –> (*) </uml>

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.

You can define specific color and fonts for stereotyped activities. <uml t=“activity_011”>

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 –> (*)

</uml>

Octagon

You can change the shape of activities to octagon using the skinparam activityShape octagon command. <uml t=“activity_012”> 'Default is skinparam activityShape roundBox skinparam activityShape octagon

(*) –> “First Activity” “First Activity” –> (*)

</uml>

Complete example

<uml t=“activity_013”> title Servlet Container

(*) –> “ClickServlet.handleRequest()” –> “new Page”

if “Page.onSecurityCheck” then

  1. >[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

  1. →[false] ===REDIRECT_CHECK===

endif

if “Do redirect?” then →[yes] “redirect request” –>

BEFORE_DESTROY

else if “Do Forward?” then

  1. left→[yes] “Forward request”
  2. → ==BEFORE_DESTROY===

else

  1. right→[no] “Render page template”
  2. → ==BEFORE_DESTROY===

endif endif

–> “Page.onDestroy()” –>(*)

</uml>

plantuml/activity.txt · Last modified: 2014/12/03 00:51 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0