Is it possible to draw if/elseif/else structure vertically

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

Hi everyone,

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.

Is it possible to draw those structure vertically instead of honrizontally?

Text 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

 

Corresponding diagram :

activity diagram

Thanks for your support.

MAV

2 Answers

+1 vote
answered Nov 1, 2015 by plantuml (131,070 points)
Hi,

It's not possible yet, but we like the idea.

We will work on the subject and post a message here when some beta will be ready.

Thanks for the suggestion!
0 votes
answered Nov 2, 2015 by MAV (580 points)
Thank's a lot,

 

I'm waiting the beta version :).

 

MAV
commented Nov 29, 2015 by plantuml (131,070 points)
Hi,
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!

Thanks
commented Dec 24, 2015 by MAV (580 points)
Hi,

Tanks a lot for your beta version. I have tried it some weeks ago but the q&a didn't not work.
I will give you my firsts comments:
Your job is great. There is a lot of promises But some things look strange :
1) Could the arrows come from the left of the actions ?
2) Maybe the last branch (else branche, often empty) can have the same size than the others to have a good alignment (and have the merge of all the branches at the down/right corner of the block)

Thank you again for your job.

MAV
...