plantuml / plantuml

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

Tweaking padding of Sequence Messages #218

Closed rtgoodwin closed 2 years ago

rtgoodwin commented 4 years ago

I know this has come up in various formats, but I'm not sure if the specific question has been asked. I'd like to put padding and possibly border (colored) around Sequence Diagram messages(?). This is very useful for when the text overlays some background or otherwise, and makes the text hard to read. Adding a white background helps, but w/o proper padding or border it kind of feels a little rough.

I don't mind rebuilding PlantUML, or even submitting a PR; I'm just not sure where to track it down in the code.

The missing bits seem to be:

image-08-00-52

Thanks for any pointers/suggestions, or even links to past discussions where this has been agreed or disagreed on!

arnaudroques commented 4 years ago

Thanks for the suggestion, this sounds like a good idea. The good new is that the implementation is not too difficult to do so we can take this part. The real issue is on the syntax itself.

As you have stated, you can currently use: <back:white><color:black><size:12>App verified</size></color></back>

Let's say that you'd like to describe your desired example. So we have to set border, padding and margin. What are your suggestion ?

Something like: `

App verified` This begins to be quite verbose, isn't it ? So your feedback is welcome !
rtgoodwin commented 4 years ago

Thank you for the response!

I think this is something probably to take up to skinparam vs individual creole syntax. Since you can already address stereotypes, you can manage styles separately if needed through that mechanism, instead of more inline styling.

So I am thinking something very simple like (using shortcut for easier reading):

skinparam SequenceMessage {
Padding 5
BackgroundColor White (or gradient, i.e. the normal supported color options)
BorderColor Blue
Margin 5
}

You can see below I sort of simulated it by using rnote over, but it doesn't quite feel the same, gets more visually confusing.

flow

Which brings me to a couple of other questions, but we can break them out into separate issues, if you like:

  1. rnote doesn't obey/have a Rounding behavior, as you can see in my screenshot even though other items are being rounded. Regular notes are rounded, but have the "paper flap" by default which is not always preferred.
  2. There doesn't seem to be a way to hide the ref or loop labels (literally the "ref" with the tag background). Sometimes it is desirable to have a "box" around a sequence, and ref/loop are fine UML constructs, but not always what is intended. I.e. you may wish to just have a pleasing separation. I know you can use the separators, which is helpful, but not quite the same. I think there could either be a clone of the ref syntax/construct that doesn't use labels (maybe simplebox?), or a skinparam to hide the label like SequenceReferenceLabelShow? Probably the latter is easier so there isn't a lot of duplication.
  3. Notes (or at least rnote) don't obey Box boundaries, or have skinparam NotePadding or skinparam NoteMargin of their own, which means they can have tight text or overlap Boxes. It's not a huge problem, simply can look a bit nicer I think? See my previous screenshot, where text is very close to rnote border, and how it overlaps the next participant box. I can "cheat" using \n of course 😄

Let me know if you wish me to break any of these into separate issues, and thank you! :) 😄 I'm sorry there is much feedback, but I hope it brings even more power and design capabilities to everyone!

arnaudroques commented 4 years ago

About your initial request, with last beta http://beta.plantuml.net/plantuml.jar you can now have:

@startuml
skinparam SequenceMessage {
  Margin 35
  Padding 5
  BackgroundColor Green
  BorderColor Blue
}
Alice->Bob : hello
@enduml

Is this what you are expecting ? We've done very little tests, so do not hesitate to post if you find issue.

Frankly, we do not like the idea of having the same setting of all messages. But let's test it.

We would like to generalize this to other diagrams (class, activity...) but we will wait for user requests.

About your other points 1, 2 and 3, please open different issues. And more important, please provide a short non-working example in each issues. It really speed up our understanding of your requests. For example, for point 1, provide an example:

@startuml
skinparam NoteRounding 5
Alice -> Bob
rnote over Alice : This is not rounded
@enduml

Thanks!

rtgoodwin commented 4 years ago

Wow, that was amazingly fast, thank you!!!

Untitled 2019-06-27 15-41-36

It does seem to work exactly as expected, but yes, I see what you mean about ALL messages being the same; I was not thinking about how messages themselves do not have stereotypes, unlike participants.

The main option I have considered to do this in a more general way is something similar to CSS, where you can have a group of skinparam settings tied together and then apply them to an/any object. (I believe there have been other asks around this, but not exactly the same.) The Creole and other stylings can already get quite lengthy, and adding more in-line seems like it would get harder to read and also harder to re-use. So, it would be something like:

style MyPrettyMessage {
     skinparam SequenceMessage {
        Margin 5
    }
   skinparam ParticipantBorderThickness 0
}

Bob->Alice: Look at my message! #MyPrettyMessage (or maybe #styles.MyPrettyMessage)
  or
Bob->Alice: <MyPrettyMessage>Look!</MyPrettyMessage>
  or
Bob->Alice: <style:MyPrettyMessage>Look! (optional </style>) 

for definitions:

participant/object/whatever "Bob" as Bob styles:MyPrettyMessage,SomeOtherStyle << Bob >> 
 or 
participant/object/whatever styles:MyPrettyMessage,SomeOtherStyle "Bob" as Bob  << Bob >>
 or  
participant/object/whatever <style:MyPrettyMessage,SomeOtherStyle> "Bob" as Bob  << Bob >> 

I think this is most likely the general usage that many users will expect, if they come from HTML/CSS (and if they would like that same metadata tagged into the SVG XML for example). I'm not using the term class since that is already well spoken for in UML. 😄 I think the key is picking the assigment operator that can target both "participants" as well as other elements like "messages". I would think any number of "styles" could be targeted to something, and only the relevant skinparams would be used.

If the creole style was extended, or for other reasons desire to keep it in line, a convention could be used similar to Tailwind CSS (or Tachyons) which uses very short CSS class names. So your example of:

<border:black><margin:3><padding:4><back:white><color:black><size:12>App verified</size></color></back></padding></margin></border>

becomes something like:

<style:border-black m-3 p-4 bg-white black size-12>App verified

(I notice you don't require closing tags most of the time, or the parser is OK with it anyway.)

Again, this is somewhat simulating CSS classes, but really creating new tokens that would either need to have attributes or conventions coded in, or defined and included somehow. (But Tailwind has an excellent set of conventions already, so they could probably be borrowed quite a bit.)

Personally I like the first option, being able to define your own "class", because it seems the most reusable and keeps style separate from content.

I feel I may have read somewhere that the skinparam are all processed sequentially/terminally, or some other challenge here, but perhaps not. If there is a challenge with forward/backward parsing, I suppose one could also do something like:

style BobsPrettyMessage {
     participants Bob (or stereotypes <<Bob>>)
     skinparam SequenceMessage {
        Margin 5
    }
}
style AlicesCoolMessage {
     participants Alice (or stereotypes <<Alice>>)
     skinparam SequenceMessage {
        BackgroundColor HotPink
    }
}

to pre-determine rules like stereotype matching seems to work now. I'm using Sequence terms like participants, but I suspect it could apply generally to any diagram/object, so probably something more global like stereotypes or a new token.

I'm happy to discuss more options and pros/cons. I tried to think of ideas that build on, instead of completely changing, for example, the entire skinparam concept. And I am not as familiar with all the diagram types, so please let me know where I have made poor assumptions.

Thank you again so much, and it's exciting to see these evolve! (And I will split out my other items 😄 )

arnaudroques commented 4 years ago

The