In a condition in an activity diagram, can I specify left or right arrows?

0 votes
asked Oct 25, 2022 in Wanted features by Frank
edited Oct 25, 2022

I'm doing an activity diagram, with swimlanes. How do I have a condition in the first lane, resulting in entering the second lane, without confusing the diagram with crossed lines?

What I'm getting is like this:

Ugly diagram with crossing lines

Source:

/' Example diagram to show why I want "no" on the left
'/
@startuml
|lane1|
start
if (condition) then (yes)
|lane2|
:do something;
endif
|lane1|
end
@enduml

Link to example 1 image

I could put the second lane under "else", which fixes the crossed lines, but then I have an unnecessary activity that I don't know how to get rid of:

image with "no" on right side but superfluous bobble

Source:

/' Example diagram with uncrossed lines but unnecessary empty action
'/
@startuml
|lane1|
start
if (condition) then (no)
:;
else (yes)
|lane2|
:do something;
endif
|lane1|
end
@enduml

Link to example 2 image

If I get rid of the unnecessary ":;" then the lines cross again -- so "no" would be on the right even though it is the "else" clause.

So, is it possible to specify that the empty "no" branch must come out the left side? Or a way to make the ":;" invisible while retaining its effect of making the branch come out on the left? Or some other workaround?

I see mention of arrow direction in the obsolete syntax, but I don't want to use a deprecated notation for a new diagram.

1 Answer

0 votes
answered Oct 26, 2022 by plantuml (295,000 points)

Thanks for the feedback.

With swimlanes, it's difficult to prevent all line crossing.

Fortunately, in your case, it was possible.

So this has been fixed on the online server.

Tell us if it helps!

commented Oct 27, 2022 by The-Lu (64,960 points)

Thanks, yes

  • Is it possible to do the same thing for `backward`?

See request here:

Regards.
commented Oct 27, 2022 by Frank

Thanks for the attempt. Fixing the line crossing automatically is good, BUT I appreciate that making it work in all situations is tricky, which is why I was trying to suggest being able to manually tweak the diagram when it is not quite optimal, either by saying which side the line is on, or by making the ":;" bobble disappear.

I think you are saying the crossed lines were a bug and I should simply upgrade to a newer version of PlantUML, is that right? If so, for the record, what is the version that I should upgrade to?

Unfortunately the fix does not appear complete, the label is in the wrong place. This is true regardless of whether the "Do Something" is in the "if" or the "else":

"if" over two swimlanes, with body in either part of the "if..else..endif" clause

See how the "no" is on the right, although the arrow comes out the left.

Source:

/' Putting the body of an "if" in another swimlane, in the "else" clause
'/
@startuml
|lane1|
start
if (condition) then (no)
else (yes)
|lane2|
:do something;
endif
|lane1|
end
@enduml

' Doing it in the "if" clause, diagram looks the same
@startuml
|lane1|
start
if (condition) then (yes)
|lane2|
:do something;
else (no)
endif
|lane1|
end
@enduml

If there is only one lane, of course, it's fine because the arrow and label are both on the right. It's only an issue when it is spread over lanes.

commented Nov 29, 2022 by Frank (100 points)
Please disregard the comment above. The issue has been fixed. The image in the comment is actually generated on the fly by the online server, which means it no longer matches the comment as the "no" is now in the correct place.

Many thanks to whoever fixed the issue. Sorry I cannot edit or delete the comment.

Frank
...