plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
9.73k stars 881 forks source link

The display of text, line, and arrow on the left side of the Lifeline is incorrect. #1683

Open devwitalik opened 3 months ago

devwitalik commented 3 months ago

Steps to reproduce the behavior:

@startuml
skinparam {
   Maxmessagesize 200
}

activate Test
Test <<-- Test : the arrow and text are located inside the Lifeline because they are counted from the right side of the active member's column bar (Lifeline). Which is an incorrect display, right?
Test <<-- Test : also the arrow is not displayed correctly (issue: #1678). (I wonder if the closing of the Lifeline is displayed correctly? Should it also include the arrow before it, i.e. close after it? If not, how do I close the Life Line after the last arrow?)
deactivate Test

@enduml

http://www.plantuml.com/plantuml/uml/RP5DwnCn4CRl-HGFUB1_Q4lre58Assj1JmgUPvFPxc1UIYQnhU9tTpTjfQANm0o_vsN8NWlbKeCt-atYYJ85_3G0Fj4bi2eTMUK7u-rcOtuPGxR8TogCBwp5p0zskzMgZTYYZ0pAEPr1qQ7mfKmZmoSxQHmagZXkr4SPs4jaz6ofQbjU6snJZJCyv1GQckKu5ZHb6jgcjM043Ztdrpf9V0qHFMKi7iOlQtmTnOuG1KL8j2bdjWLEzEJfkhpvTlyUGLxJqoMYYEcFZ1tkHlwAXQXMtkBLctVlFqo1YmFEAJhEa5jHwvDAFBRUpqUB_i-lm-SnLUyWfPMOI_lg-AbCpqFAF05Bo9hNBO11GvapIuV3C9TTOfnObt2u0u_mwObtlEqyQRavTo_6yT-_Q_OSNGt-Dm00

Screenshots IMG

jimnelson372 commented 2 days ago

I am examining the code to see what can be done here. I just recently fixed some other problems related to left side self messages, but those fixes didn't address the active lifeline conditions. (See #1777.)

In your example, the positioning is definitely wrong. However, one of the effect you asked about parenthetically isn't wrong:

(I wonder if the closing of the Lifeline is displayed correctly? Should it also include the arrow before it, i.e. close after it? If not, how do I close the Life Line after the last arrow?)

Closing the lifeline by the end of the self message is caused by the "deactivate" statement immediately following that arrow. It's easier to see on the Right side self arrows, since they are drawn in the correct position, but instead of using that "deactivate" as you're doing here, leave it out and you'll get:

testpuml_002

Where the lifeline continues on, just as in the first case. To explicitly have the self message cause the deactivation, you can also use --: just before the comment, rather than just : . It's easier, as I said, to see on the Right side.

Here is a test script:

@startuml
Test -> Test : 1st self message, no activation
Test -> Test ++: 2nd self message, starting activation
Test -> Test ++: 3rd self message, staring another activation
Test -> Test : 4th self message, continuing in the current activation
Test -> Test --: 5th self message, deactivating once
Test -> Test : 6th self message, continuing the activation
Test -> Test --: 7th self message, exiting the activation
Test -> Test : 8th self message, no activation
@enduml

Which generates:

testpuml_003

Unfortunately, the bug with the positioning on the left side during active timelines makes this look a mess, if we switch to left side self messages:

testpuml_004

I'm glad you asked about the ending of the timeline, though, since I initially thought I would need to change the vertical positioning. But when double checking the documentation, I saw examples (for the right side) similar to what I shared above.

I hope to have a solution for the left side positioning soon.

Regards, Jim Nelson

arnaudroques commented 2 days ago

@jimnelson372

It’s great to see the progress you’re making on this issue.

I’d like to mention that we currently have two algorithms in use: "puma" and "teoz." "Puma" is quite old and notoriously difficult to fix. While it would be beneficial if you manage to address the issue with "puma," please be aware that our long-term goal is to have these issues resolved in "teoz." (see https://plantuml.com/teoz )

Eventually, we plan to decommission "puma" once "teoz" is fully operational and can handle all scenarios.

Thank you again for your efforts!

jimnelson372 commented 1 day ago

Understood, @arnaudroques.

Fortunately, my focus to start was on drawing code common to both "teoz" and "puma" for these left directed self messages. While many changes were required in the common drawing code for these left side self messages, I did have to make changes to the self message class in "teoz" and had that version working first. Then I found how I could make the "puma" prepare the same conditions that drawing class needed. So both are fixed. I'm preparing the pull request.

Here's what the first script in this issue now produces. I left the text as given, even though it's no longer having the problems the text message says it is having. First in puma (which was the example).

testleftactive

But, here it is with teoz turn on:

testleftactive

A slightly modified version of my own script above (with a step 2.5, and with the text and arrows in green so I can tell where they may overlap the timeline) now looks like this, first in "puma":

testleftactive

And it works equally well in "teoz":

testleftactive

And here is "teoz" with the rose skin chosen:

testleftactive

You can see that I have left the drawing of the active levels alone, letting them increase to the right. After all, there can be a mix of left side and right side messages so it was best to leave the time line drawing along and just have the left side self messages do what was appropriate for them.

These left side self messages now leave the active level they belong to and enter back at the appropriate active level. Also, it was intentional for that message labeled 4th to start and end from the left side of that second activation group, while keeping its text from moving further right.One of the tricks was for the 0 level to 1 level to have a longer upper line while moves from level 1 to 2 and so on have longer lower lines. And the 1 back to 0 must be drawn differently than the 2 back 1, etc. Some of these differences from how the right side self messages work is what took me a little longer to account for in my fix.

I look forward to finishing the pull request.

Regards, Jim Nelson

jimnelson372 commented 1 day ago

...Though I have not yet addressed the left side arrow head issue mentioned in the first example, and also issue: #1678. I'm looking at that now.