Die momentane Syntax für das Aktivitätsdiagramm hat einige Einschränkungen und Nachteile (zum Beispiel ist es schwierig zu pflegen). Mit beta version wird eine komplett neue Syntax und Umsetzung den Benutzern (angefangen bei V7947) vorgeschlagen, sodaß wir besseres Format und Syntax definieren können. Ein weiterer Vorteil dieser neuen Implementierung ist, dass es nicht mehr nötig ist, Graphviz zu installieren (analog zu den Sequenzdiagrammen). Die neue Syntax wird die alte ersetzen. Allerdings wird aus Gründen der Kompatibilität die alte Syntax noch weiter erkannt werden um ascending compatibility sicherzustellen. Benutzer werden schlicht aufgefordert, auf die neue Syntax zu migrieren.
Einfache Aktivität
Aktivitäts Label beginnen mit : und enden mit ;. Textformatierungen können mit Creole Wiki Syntax erfolgen. Sie sind in ihrer Festlegungsreihenfolge indirekt verbunden.
@startuml
:Hello world;
:This is on defined on
several **lines**;
@enduml
Start Stop
Man kann die start und stop Schlüsselwörter verwenden um Beginn und Ende des Diagramms zu kennzeichnen.
@startuml
start
:Hello world;
:This is on defined on
several **lines**;
stop
@enduml
Das Schlüsselwort end beendet ebenfalls das Diagramm, zeigt aber als Symbol den durchkreuzten Kreis.
@startuml
start
:Hello world;
:This is on defined on
several **lines**;
end
@enduml
Bedingung
Man kann die Schlüsselwörter if, then und else verwenden, um Verzweigungen ins Diagramm einzufügen. Beschreibungen hierzu können innerhalb von Klammern angegeben werden.
@startuml
start
if (Graphviz installed?) then (yes)
:process all\ndiagrams;
else (no)
:process only
__sequence__ and __activity__ diagrams;
endif
stop
@enduml
Man kann das Schlüsselwort elseif für mehrere Abfragen verwenden:
@startuml
start
if (condition A) then (yes)
:Text 1;
elseif (condition B) then (yes)
:Text 2;
stop
elseif (condition C) then (yes)
:Text 3;
elseif (condition D) then (yes)
:Text 4;
else (nothing)
:Text else;
endif
stop
@enduml
Conditional with stop on an action [kill, detach]
You can stop action on a if loop.
@startuml
if (condition?) then
:error;
stop
endif
#palegreen:action;
@enduml
But if you want to stop at an precise action, you can use the kill or detach keyword:
kill
@startuml
if (condition?) then
#pink:error;
kill
endif
#palegreen:action;
@enduml
It is also possible to use a full action as repeat target and insert an action in the return path using the backward keyword.
@startuml
start
repeat :foo as starting label;
:read data;
:generate diagrams;
backward:This is backward;
repeat while (more data?)
stop
@enduml
Break on a repeat loop [break]
You can break after an action on a loop.
@startuml
start
repeat
:Test something;
if (Something went wrong?) then (no)
#palegreen:OK;
break
endif
->NOK;
:Alert "Error with long text";
repeat while (Something went wrong with long text?) is (yes) not (no)
->//merged step//;
:Alert "Sucess";
stop
@enduml
Es ist möglich eine Beschriftung hinter dem endwhile Schlüsselwort anzugeben. Eine Beschriftung kann aber auch mit dem is Schlüsselwort hinzugefügt werden..
@startuml
while (check filesize ?) is (not empty)
:read file;
endwhile (empty)
:close file;
@enduml
Parallele Verarbeitung
Mit dem fork, fork again und end fork Schlüsselworten kann eine parallele Verarbeitung angezeigt werden.
@startuml
start
if (multiprocessor?) then (yes)
fork
:Treatment 1;
fork again
:Treatment 2;
end fork
else (monoproc)
:Treatment 1;
:Treatment 2;
endif
@enduml
Split processing
Split
You can use split, split again and end split keywords to denote split processing.
@startuml
start
split
:A;
split again
:B;
split again
:C;
split again
:a;
:b;
end split
:D;
end
@enduml
Input split (multi-start)
You can use hidden arrows to make an input split (multi-start):
@startuml
split
-[hidden]->
:A;
split again
-[hidden]->
:B;
split again
-[hidden]->
:C;
end split
:D;
@enduml
@startuml
split
-[hidden]->
:A;
split again
-[hidden]->
:a;
:b;
split again
-[hidden]->
(Z)
end split
:D;
@enduml
You can use kill or detach to make an output split (multi-end):
@startuml
start
split
:A;
kill
split again
:B;
detach
split again
:C;
kill
end split
@enduml
@startuml
start
split
:A;
kill
split again
:b;
:c;
detach
split again
(Z)
detach
split again
end
split again
stop
end split
@enduml
Notizen
Textformatierung kann mit Creole Wiki Syntax gemacht werden. Eine Anmerkung kann auch schweben, indem das Schlüsselwort floating benutzt wird.
@startuml
start
:foo1;
floating note left: This is a note
:foo2;
note right
This note is on several
//lines// and can
contain <b>HTML</b>
====
* Calling the method ""foo()"" is prohibited
end note
stop
@enduml
Farben
Man kann spezielle Farben für gewisse Aktivitäten verwenden
@startuml
start
:starting progress;
#HotPink:reading configuration files
These files should edited at this point!;
#AAAAAA:ending of the process;
@enduml
Lines without arrows
You can use skinparam ArrowHeadColor none in order to connect activities using lines only, without arrows.
@startuml
skinparam ArrowHeadColor none
start
:Hello world;
:This is on defined on
several **lines**;
stop
@enduml
@startuml
skinparam ArrowHeadColor none
start
repeat :Enter data;
:Submit;
backward :Warning;
repeat while (Valid?) is (No) not (Yes)
stop
@enduml
Pfeile
Über die -> Notation, können Texte an den Pfeilen angezeigt werden und die Farbe der Pfeile geändert werden. Es sind auch gepunktete, gestrichelte, dicke oder unsichtbare Pfeile möglich.
@startuml
:foo1;
-> You can put text on arrows;
if (test) then
-[#blue]->
:foo2;
-[#green,dashed]-> The text can
also be on several lines
and **very** long...;
:foo3;
else
-[#black,dotted]->
:foo4;
endif
-[#gray,bold]->
:foo5;
@enduml
@startuml
start
:The connector below
wishes he was blue;
#blue:(B)
:This next connector
feels that she would
be better off green;
#green:(G)
stop
@enduml
Es ist möglich mit dem detach Schlüsselwort einen Pfeil zu entfernen.
@startuml
:start;
fork
:foo1;
:foo2;
fork again
:foo3;
detach
endfork
if (foo4) then
:foo5;
detach
endif
:foo6;
detach
:foo7;
stop
@enduml
SDL-Diagramme
Durch Ändern des letzten Separators ; können Sie unterschiedliche Wiedergabe für die Aktivität einstellen:
|
<
>
/
]
}
@startuml
:Ready;
:next(o)|
:Receiving;
split
:nak(i)<
:ack(o)>
split again
:ack(i)<
:next(o)
on several line|
:i := i + 1]
:ack(o)>
split again
:err(i)<
:nak(o)>
split again
:foo/
split again
:i > 5}
stop
end split
:finish;
@enduml
Komplettes Beispiel
@startuml
start
:ClickServlet.handleRequest();
:new page;
if (Page.onSecurityCheck) then (true)
:Page.onInit();
if (isForward?) then (no)
:Process controls;
if (continue processing?) then (no)
stop
endif
if (isPost?) then (yes)
:Page.onPost();
else (no)
:Page.onGet();
endif
:Page.onRender();
endif
else (false)
endif
if (do redirect?) then (yes)
:redirect process;
else
if (do forward?) then (yes)
:Forward request;
else (no)
:Render page template;
endif
endif
stop
@enduml