PlantUML - Activity Diagram 2

1 篇文章 / 0 new
author
PlantUML - Activity Diagram 2
Current syntax for activity diagram has several limitations and drawbacks (for example, it's difficult to maintain).

So a completely new syntax and implementation is proposed as beta version to users (starting with V7947), so that we could define a better format and syntax.
Another advantage of this new implementation is that it's done without the need of having GraphViz installed (as for sequence diagrams).

The new syntax will replace the old one. However, for compatibility reason, the old syntax will still be recognized, to ensure ascending compatibility.
Users are simply encouraged to migrate to the new syntax.

Some features are still missing : partition, skins, notes, error management, titles... But the product is already useable to have simple or very complex diagrams.

If you have ideas or find issues, please provide feedback so that we could enhance this new syntax.

Simple Activity

Activities label starts with : and ends with ;

Text formatting can be done using creole wiki syntax.

They are implicitely linked in their definition order.

@startuml

:Hello world;

:This is on defined on
several **lines**;

@enduml
        

Start/Stop

You can use start and stop keywords to denote the beginning and the end of a diagram.
@startuml

start

:Hello world;

:This is on defined on
several **lines**;

stop

@enduml
        

Conditional

You can use if, then and else keywords to put tests if your diagram. Labels can be provided using parentheses.
@startuml

start

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

stop

@enduml
        

Repeat loop

You can use repeat and repeatwhile keywords to have repeat loops.
@startuml

start

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

stop

@enduml
        

While loop

You can use while and end while keywords to have repeat loops.
@startuml

start

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

stop

@enduml
        
It is possible to provide a label after the endwhile keyword, or using the is keyword.
@startuml
while (check filesize ?) is (not empty)
  :read file;
endwhile (empty)
:close file;
@enduml
        

Parallel processing

You can use fork, fork again and end fork keywords to denote parallel processing.
@startuml

start

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


@enduml
        

Notes

Text formatting can be done using creole wiki syntax.
@startuml

start
:foo1;
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
        

Color

You can use specify a color for some activities.
@startuml

start
:starting progress;
#red:reading configuration files
These files must do be edited at this point!;
#AAAAAA:ending of the process;

@enduml
        

Complete example

@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
        
關鍵字: 
Free Web Hosting