Aktivitätsdiagramm (neue Syntax)

Die bisherige Syntax für Aktivitätsdiagramme wies einige Einschränkungen und Probleme bei der Wartbarkeit auf. Da wir diese Nachteile erkannt haben, haben wir eine komplett überarbeitete Syntax und Implementierung eingeführt, die nicht nur benutzerfreundlich, sondern auch stabiler ist.

Vorteile der neuen Syntax

  • Keine Abhängigkeit von Graphviz: Genau wie bei den Sequenzdiagrammen entfällt bei der neuen Syntax die Notwendigkeit einer Graphviz-Installation, wodurch der Einrichtungsprozess vereinfacht wird.
  • Einfache Wartung: Die intuitive Natur der neuen Syntax bedeutet, dass es einfacher ist, Ihre Diagramme zu verwalten und zu pflegen.

Umstellung auf die neue Syntax

Während wir die alte Syntax weiterhin unterstützen, um die Kompatibilität aufrechtzuerhalten, ermutigen wir die Benutzer, auf die neue Syntax zu migrieren, um die verbesserten Funktionen und Vorteile, die sie bietet, zu nutzen.

Stellen Sie noch heute um und erleben Sie einen rationalisierten und effizienten Diagrammprozess mit der neuen Aktivitätsdiagramm-Syntax.

Einfache Aktivität

Aktivitäts-Labels beginnen mit : und enden mit ;.

Textformatierungen können mit Creole Wiki Syntax erfolgen.

Sie sind in ihrer Festlegungsreihenfolge indirekt verbunden.

🎉 Copied!

@startuml
:Hello world;
:This is on defined on
several **lines**;
@enduml

Start Stop End

Man kann die start und stop Schlüsselwörter verwenden um Beginn und Ende des Diagramms zu kennzeichnen.

🎉 Copied!

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

🎉 Copied!

@startuml
start
:Hello world;
:This is on defined on
several **lines**;
end
@enduml

Bedingte

Sie können die Schlüsselwörter if, then, else und endif verwenden, um Tests in Ihr Diagramm einzufügen. Beschriftungen können in Klammern gesetzt werden.

Die 3 Syntaxen sind möglich:
  • if (...) then (...) ... [else (...) ...] endif

🎉 Copied!

@startuml

start

if (Graphviz installed?) then (yes)
  :process all\ndiagrams;
else (no)
  :process only
  __sequence__ and __activity__ diagrams;
endif

stop

@enduml

  • if (...) is (...) then ... [else (...) ...] endif

🎉 Copied!

@startuml
if (color?) is (<color:red>red) then
:print red;
else 
:print not red;
endif
@enduml

  • if (...) equals (...) then ... [else (...) ...] endif

🎉 Copied!

@startuml
if (counter?) equals (5) then
:print 5;
else 
:print not 5;
endif
@enduml

[Ref. QA-301]

Mehrere Tests (horizontaler Modus)

Sie können das Schlüsselwort elseif verwenden, um mehrere Tests durchzuführen (standardmäßig im horizontalen Modus):

🎉 Copied!

@startuml
start
if (condition A) then (yes)
  :Text 1;
elseif (condition B) then (yes)
  :Text 2;
  stop
(no) elseif (condition C) then (yes)
  :Text 3;
(no) elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml

Mehrere Tests (vertikaler Modus)

Sie können den Befehl !pragma useVerticalIf on verwenden, um die Tests im vertikalen Modus durchzuführen:

🎉 Copied!

@startuml
!pragma useVerticalIf on
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

Sie können die Befehlszeilenoption -P verwenden, um das Pragma anzugeben:

java -jar plantuml.jar -PuseVerticalIf=on

[Refs. QA-3931, GH-582]

Switch and case [switch, case, endswitch]

You can use switch, case and endswitch keywords to put switch in your diagram.

Labels can be provided using parentheses.

🎉 Copied!

@startuml
start
switch (test?)
case ( condition A )
  :Text 1;
case ( condition B ) 
  :Text 2;
case ( condition C )
  :Text 3;
case ( condition D )
  :Text 4;
case ( condition E )
  :Text 5;
endswitch
stop
@enduml

Conditional with stop on an action [kill, detach]

You can stop action on a if loop.

🎉 Copied!

@startuml
if (condition?) then
  :error;
  stop
endif
#palegreen:action;
@enduml

But if you want to stop at the precise action, you can use the kill or detach keyword:

  • kill

🎉 Copied!

@startuml
if (condition?) then
  #pink:error;
  kill
endif
#palegreen:action;
@enduml

[Ref. QA-265]

  • detach

🎉 Copied!

@startuml
if (condition?) then
  #pink:error;
  detach
endif
#palegreen:action;
@enduml

Repeat-Schleife

Mit den repeat und repeatwhile Schlüsselwörtern können Repeat-Schleifen dargestellt werden.

🎉 Copied!

@startuml

start

repeat
  :read data;
  :generate diagrams;
repeat while (more data?)

stop

@enduml

Es ist desweiteren möglich repeat an einer Aktion zu nutzen und am Rückpfad mittels des keywords backward eine weitere Aktion zu spezifizieren. Weiterhin kann auch auf eine andere Aktion verwiesen werden.

🎉 Copied!

@startuml

start

repeat :foo as starting label;
  :read data;
  :generate diagrams;
backward:This is backward;
repeat while (more data?)

stop

@enduml

*[Ref. QA-5826]*
WARNING
 This translation need to be updated. 
WARNING

Break on a repeat loop [break]

You can use the break keyword after an action on a loop.

🎉 Copied!

@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 "Success";
stop
@enduml

[Ref. QA-6105]

Goto and Label Processing [label, goto]

⚠ It is currently only experimental 🚧

You can use label and goto keywords to denote goto processing, with:
  • label <label_name>
  • goto <label_name>

🎉 Copied!

@startuml
title Point two queries to same activity\nwith `goto`
start
if (Test Question?) then (yes)
'space label only for alignment
label sp_lab0
label sp_lab1
'real label
label lab
:shared;
else (no)
if (Second Test Question?) then (yes)
label sp_lab2
goto sp_lab1
else
:nonShared;
endif
endif
:merge;
@enduml

[Ref. QA-15026, QA-12526 and initially QA-1626]

While-Schleife

Mit den while und end while Schlüsselwörtern können While-Schleifen dargestellt werden.

🎉 Copied!

@startuml

start

while (data available?)
  :read data;
  :generate diagrams;
endwhile

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

🎉 Copied!

@startuml
while (check filesize ?) is (not empty)
  :read file;
endwhile (empty)
:close file;
@enduml

WARNING
 This translation need to be updated. 
WARNING

Parallele Verarbeitung

Mit dem fork, fork again und end fork Schlüsselworten kann eine parallele Verarbeitung angezeigt werden.

🎉 Copied!

@startuml

start

if (multiprocessor?) then (yes)
  fork
    :Treatment 1;
  fork again
    :Treatment 2;
  end fork
else (monoproc)
  :Treatment 1;
  :Treatment 2;
endif

@enduml

WARNING
 This translation need to be updated. 
WARNING

Split processing

Split

You can use split, split again and end split keywords to denote split processing.

🎉 Copied!

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

🎉 Copied!

@startuml
split
   -[hidden]->
   :A;
split again
   -[hidden]->
   :B;
split again
   -[hidden]->
   :C;
end split
:D;
@enduml

🎉 Copied!

@startuml
split
   -[hidden]->
   :A;
split again
   -[hidden]->
   :a;
   :b;
split again
   -[hidden]->
   (Z)
end split
:D;
@enduml

[Ref. QA-8662]

Output split (multi-end)

You can use kill or detach to make an output split (multi-end):

🎉 Copied!

@startuml
start
split
   :A;
   kill
split again
   :B;
   detach
split again
   :C;
   kill
end split
@enduml

🎉 Copied!

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

🎉 Copied!

@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

*[Ref. [QA-2398](https://forum.plantuml.net/2398/is-it-possible-to-add-a-comment-on-top-of-a-activity-partition?show=2403#a2403)]*
WARNING
 This translation need to be updated. 
WARNING

Farben

Man kann spezielle Farben für gewisse Aktivitäten verwenden

🎉 Copied!

@startuml

start
:starting progress;
#HotPink:reading configuration files
These files should edited at this point!;
#AAAAAA:ending of the process;

@enduml

*[Ref. [QA-4906](https://forum.plantuml.net/4906/setting-ad-hoc-gradient-backgrounds-in-activity?show=4917#a4917)]*
WARNING
 This translation need to be updated. 
WARNING

Lines without arrows

You can use skinparam ArrowHeadColor none in order to connect activities using lines only, without arrows.

🎉 Copied!

@startuml
skinparam ArrowHeadColor none
start
:Hello world;
:This is on defined on
several **lines**;
stop
@enduml

🎉 Copied!

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

🎉 Copied!

@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

Connector

You can use parentheses to denote connector.

🎉 Copied!

@startuml
start
:Some activity;
(A)
detach
(A)
:Other activity;
@enduml

Color on connector

You can add color on connector.

🎉 Copied!

@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

[Ref. QA-10077]

Gruppierung

Aktivitäten können durch Partitionen gruppiert werden:

🎉 Copied!

@startuml
start
partition Initialization {
    :read config file;
    :init internal variable;
}
partition Running {
    :wait for user interaction;
    :print information;
}

stop
@enduml

*[Ref. [QA-2793](https://forum.plantuml.net/2793/activity-beta-partition-name-more-than-one-word-does-not-work?show=2798#a2798)]* *[Ref. [QA-542](https://forum.plantuml.net/542/ability-to-define-hyperlink-on-diagram-elements?show=14003#c14003)]*
WARNING
 This translation need to be updated. 
WARNING

Schwimmbahnen

Mit dem Pipe Zeichen | kann man Schwimmbahnen definieren.

Es ist auch möglich die Schwimmbahnfarbe zu ändern.

🎉 Copied!

@startuml
|Swimlane1|
start
:foo1;
|#AntiqueWhite|Swimlane2|
:foo2;
:foo3;
|Swimlane1|
:foo4;
|Swimlane2|
:foo5;
stop
@enduml

*[Ref. [QA-2681](https://forum.plantuml.net/2681/possible-define-alias-swimlane-place-alias-everywhere-else?show=2685#a2685)]*
WARNING
 This translation need to be updated. 
WARNING

Abtrennen

Es ist möglich mit dem detach Schlüsselwort einen Pfeil zu entfernen.

🎉 Copied!

@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:
  • |
  • <
  • >
  • /
  • ]
  • }

🎉 Copied!

@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

WARNING
 This translation need to be updated. 
WARNING

Komplettes Beispiel

🎉 Copied!

@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

Condition Style

Inside style (by default)

🎉 Copied!

@startuml
skinparam conditionStyle inside
start
repeat
  :act1;
  :act2;
repeatwhile (<b>end)
:act3;
@enduml

🎉 Copied!

@startuml
start
repeat
  :act1;
  :act2;
repeatwhile (<b>end)
:act3;
@enduml

Diamond style

🎉 Copied!

@startuml
skinparam conditionStyle diamond
start
repeat
  :act1;
  :act2;
repeatwhile (<b>end)
:act3;
@enduml

InsideDiamond (or Foo1) style

🎉 Copied!

@startuml
skinparam conditionStyle InsideDiamond
start
repeat
  :act1;
  :act2;
repeatwhile (<b>end)
:act3;
@enduml

🎉 Copied!

@startuml
skinparam conditionStyle foo1
start
repeat
  :act1;
  :act2;
repeatwhile (<b>end)
:act3;
@enduml

[Ref. QA-1290 and #400]

Condition End Style

Diamond style (by default)

  • With one branch

🎉 Copied!

@startuml
skinparam ConditionEndStyle diamond
:A;
if (decision) then (yes)
    :B1;
else (no)
endif
:C;
@enduml

  • With two branches (B1, B2)

🎉 Copied!

@startuml
skinparam ConditionEndStyle diamond
:A;
if (decision) then (yes)
    :B1;
else (no)
    :B2;
endif
:C;
@enduml
@enduml

Horizontal line (hline) style

  • With one branch

🎉 Copied!

@startuml
skinparam ConditionEndStyle hline
:A;
if (decision) then (yes)
    :B1;
else (no)
endif
:C;
@enduml

  • With two branches (B1, B2)

🎉 Copied!

@startuml
skinparam ConditionEndStyle hline
:A;
if (decision) then (yes)
    :B1;
else (no)
    :B2;
endif
:C;
@enduml
@enduml

[Ref. QA-4015]

Using (global) style

Without style (by default)

🎉 Copied!

@startuml
start
:init;
-> test of color;
if (color?) is (<color:red>red) then
:print red;
else 
:print not red;
note right: no color
endif
partition End {
:end;
}
-> this is the end;
end
@enduml

With style

You can use style to change rendering of elements.

🎉 Copied!

@startuml
<style>
activityDiagram {
  BackgroundColor #33668E
  BorderColor #33668E
  FontColor #888
  FontName arial

  diamond {
    BackgroundColor #ccf
    LineColor #00FF00
    FontColor green
    FontName arial
    FontSize 15
  }
  arrow {
    FontColor gold
    FontName arial
    FontSize 15
  }
  partition {
    LineColor red
    FontColor green
    RoundCorner 10
    BackgroundColor PeachPuff
  }
  note {
    FontColor Blue
    LineColor Navy
    BackgroundColor #ccf
  }
}
document {
   BackgroundColor transparent
}
</style>
start
:init;
-> test of color;
if (color?) is (<color:red>red) then
:print red;
else 
:print not red;
note right: no color
endif
partition End {
:end;
}
-> this is the end;
end
@enduml


Privacy Policy      Advertise