Please provide a way to draw if/elseif/else structure vertically in activity diagrams

0 votes
asked Oct 23, 2015 in Wanted features by MAV (540 points)

I'm working on some code with switch case structures on big enumerate type or if/elsif/else structures with big conditions.

For now, I use the if/elseif/else plantUML structure to draw them but the different cases are placed horizontally.

It is a problem when the associated conditions or actions are big, the diagram becomes very large.

Example :

@startuml
title lot_of_elsif
start
if (Enum) Then (Value_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
:Do_A;
elseif (Enum) Then (Value_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
:Do_B;
elseif (Enum) Then (Value_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
:Do_C;
elseif (Enum) Then (Value_DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD)
:Do_D;
elseif (Enum) Then (Value_EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE)
:Do_E;
elseif (Enum) Then (Value_FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
:Do_F;
elseif (Enum) Then (Value_GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG)
:Do_G;
elseif (Enum) Then (Value_HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH)
:Do_H;
Else (Value_ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)
:Do_Z;
endif
end
@enduml

activity diagram

Please provide a way to draw if/elseif/else structure vertically in activity diagrams.

1 Answer

+1 vote
answered Nov 1, 2015 by plantuml (176,140 points)

This is still under work, but you can try an alpha version here: https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

With this version you must add a line to enable the feature:
!pragma useVerticalIf on

Example:

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

In the final version, this pragma stuff will not be needed.
It's not clear yet if PlantUML will decide on its own to select horizontal/vertical strategy, or if the user will have to use a special command to change the layout (maybe a new keyword instead of "if" )

There are still issue about label layout, but the general idea is here.
Tell us what do you think about it!

...