Activity - Layout too complex. Am I doing something wrong ?

0 votes
asked Dec 13, 2023 in Question / help by JulianJ (120 points)

LAYOUT OK :

@startuml
  if (condition 1) then(yes)
    (1)
    detach
  else(no)
  endif
  if(condition 2) then(yes)
    (2)
    detach
  else(no)
  endif
  if(condition 3) then(yes)
    (3)
    detach
  else(no)
  endif
stop

@enduml

LAYOUT NOK :

@startuml
  if (condition 1) then(yes)
    :TEST 1 ;
    detach
  else(no)
  endif
  if(condition 2) then(yes)
    :TEST 2;
    detach
  else(no)
  endif
  if(condition 3) then(yes)
    :TEST 3;
    detach
  else(no)
  endif
stop

@enduml

Hello, sorry I cannot post any image due to corporate restrictions. When using connectors 1-2-3, the layout is good. If I change connectors to activity labels, the layout is overly complex. Is there a way to have the layout from the left, but with activity labels instead of connectors ? Can I add instructions in the code to achieve the same ?

Left : www.plantuml.com/plantuml/png/SoWkIImgAStDuL9Go4nJq4ZEpql9BCdCprCmr5GeoKZDqwXCBTRaKW023KC8dP9QafYS0MIcvXIdQkJbQuAOG5rfO2EGJ332CC68H1ECCKmm9cH2SKb-0HUN0v03z1G0

Right : www.plantuml.com/plantuml/png/SoWkIImgAStDuL9Go4nJq4ZEpql9BCdCprCmr5GeoKZDqwXCBTRaKW02gn3Nu105GmLhC2ybjIGnEGF8JCqfJjN8ozS4CO5wqy068PbZXDqS8nADCSPkZ34XOufByWkuk1o07A0d0G00

commented Dec 13, 2023 by The-Lu (70,400 points)

Hi all,
Here are the images:

And

Regards,
Th.

1 Answer

0 votes
answered Dec 13, 2023 by The-Lu (70,400 points)
selected Dec 14, 2023 by JulianJ
 
Best answer

Hello J., and all,

Here is a proposal using `elseif` and `!pragma useVerticalIf on`:

@startuml
!pragma useVerticalIf on
  if (condition 1) then(yes)
    :TEST 1 ;
    detach
  ( no ) elseif(condition 2) then (yes)
    :TEST 2;
    detach
  ( no ) elseif(condition 3) then(yes)
    :TEST 3;
    detach
  else(no)
  endif
stop
@enduml

Enjoy,
If that can help,

Regards,
Th.

commented Dec 13, 2023 by The-Lu (70,400 points)

Here are some other proposals:

@startuml
if (condition 1) then(no)
  if(condition 2) then(no)
    if(condition 3) then(no)
      label l;
    else(yes)
      :TEST 3 ;
      detach
    endif
  else(yes)
    :TEST 2;
    detach
  endif
else(yes)
  :TEST 1;
  detach
endif
stop
@enduml

Or:

@startuml
  if (condition 1) then(no)
     label l;
  else(yes)
    :TEST 1 ;
    detach
  endif
  if(condition 2) then(no)
     label l;
  else(yes)
    :TEST 2;
    detach
  endif
  if(condition 3) then(no)
     label l;
  else(yes)
    :TEST 3;
    detach
  endif
stop
@enduml

Enjoy, wink
Regards,
Th.

commented Dec 14, 2023 by JulianJ (120 points)
Thanks a lot for your help ! :)
...