New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic line breaks for long lines (global setting) #35

Closed
cstettler opened this Issue Feb 24, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@cstettler

When defining diagrams with long texts on labels, the label texts are spreading the extent of the diagram. It is possible to manually enter \nin order to force a line break, but this adds syntactic clutter to the diagram source.

It would be great to be able to define a skinparam that allows for setting a maximum line width for label texts and have PlantUML inserting the line breaks automatically, e.g. MaximumLabelLineLength or similar.

@cstettler cstettler changed the title from Automatic line breaks for long line (global setting) to Automatic line breaks for long lines (global setting) Feb 24, 2017

@arnaudroques

This comment has been minimized.

Show comment
Hide comment
@arnaudroques

arnaudroques Feb 24, 2017

Contributor

If you are talking about sequence diagram, there is an undocumented setting that looks like what you are looking for:
@startuml
skinparam maxMessageSize 100
A->B:very long long long message name
@enduml
http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIhEpimhI2nAp5N8JQpmJIqkJanF3SwiIbKmD33WSjIrSx8gIosgLCZ9pqj78d8X2XNo4dDJkHnIyr90HW40

Does this fit your need ?
We should probably document this one...

Contributor

arnaudroques commented Feb 24, 2017

If you are talking about sequence diagram, there is an undocumented setting that looks like what you are looking for:
@startuml
skinparam maxMessageSize 100
A->B:very long long long message name
@enduml
http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIhEpimhI2nAp5N8JQpmJIqkJanF3SwiIbKmD33WSjIrSx8gIosgLCZ9pqj78d8X2XNo4dDJkHnIyr90HW40

Does this fit your need ?
We should probably document this one...

@cstettler

This comment has been minimized.

Show comment
Hide comment
@cstettler

cstettler Feb 24, 2017

Thank you for that hint, but unfortunately, we are using use case diagrams. It would be great to have such a feature available in all diagram types, as it helps a lot to keep the sources clean from layout information.

If you have any hint on where to start from, I could come up with a pull request.

Thank you for that hint, but unfortunately, we are using use case diagrams. It would be great to have such a feature available in all diagram types, as it helps a lot to keep the sources clean from layout information.

If you have any hint on where to start from, I could come up with a pull request.

@arnaudroques

This comment has been minimized.

Show comment
Hide comment
@arnaudroques

arnaudroques Feb 24, 2017

Contributor

This was not hard to implement, so please find a new beta:
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
This version supports:
@startuml
skinparam maxMessageSize 100
actor foo
foo --> (Use case) : this is a very long sentence on one single line
@enduml
We should probably better name the parameter (maxMessageSize being not perfect)
Tell us if it's working for you and if it is what you are expecting. Thanks.

Contributor

arnaudroques commented Feb 24, 2017

This was not hard to implement, so please find a new beta:
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
This version supports:
@startuml
skinparam maxMessageSize 100
actor foo
foo --> (Use case) : this is a very long sentence on one single line
@enduml
We should probably better name the parameter (maxMessageSize being not perfect)
Tell us if it's working for you and if it is what you are expecting. Thanks.

@cstettler

This comment has been minimized.

Show comment
Hide comment
@cstettler

cstettler Feb 24, 2017

Nice, thank you for the fast reply and fix. As we are using the PlantUML integration plugin for IntelliJIDEA: do you know by when this new PlantUML version will be shipped as part of the plugin?

When trying your enhancement with maxMessageSize, I saw some edge cases where in some labels single-character "words" (e.g. a in a very long text a) were broken onto a new line, which is not so nice. If the whole approach would be based on "number of characters per line" instead of "pixels", it would be easy to define a second property that defines a minimum length for the next (or last) word leading to an oversize line and only break the line if the word exceeds that minimum length (ok, easier with an example: with a maximum line length of 10 characters and a minimum word length of 3, the text 123 567 89A BC, the word BCwould not be broken onto the next line, whereas with a minimum word length of 2, it would).

Nice, thank you for the fast reply and fix. As we are using the PlantUML integration plugin for IntelliJIDEA: do you know by when this new PlantUML version will be shipped as part of the plugin?

When trying your enhancement with maxMessageSize, I saw some edge cases where in some labels single-character "words" (e.g. a in a very long text a) were broken onto a new line, which is not so nice. If the whole approach would be based on "number of characters per line" instead of "pixels", it would be easy to define a second property that defines a minimum length for the next (or last) word leading to an oversize line and only break the line if the word exceeds that minimum length (ok, easier with an example: with a maximum line length of 10 characters and a minimum word length of 3, the text 123 567 89A BC, the word BCwould not be broken onto the next line, whereas with a minimum word length of 2, it would).

@mikus

This comment has been minimized.

Show comment
Hide comment
@mikus

mikus Jun 27, 2017

It would be a useful feature for other diagram types. I would love to use it in component diagrams as well.

mikus commented Jun 27, 2017

It would be a useful feature for other diagram types. I would love to use it in component diagrams as well.

@arnaudroques

This comment has been minimized.

Show comment
Hide comment
@arnaudroques

arnaudroques Jun 27, 2017

Contributor

Actually, it does (at least with last version).

So you can have:

@startuml
skinparam maxMessageSize 100
[component1]
[component2]
component1 --> component2 : this is a very long sentence on one single line
@enduml

http://www.plantuml.com/plantuml/uml/JSun3i8m44JHtgUO2qHAA2bGBa15YLAimiYiiDUHro3WzBWBqcz6hvdPczJsp2duGssJAXbPtcUwI-H5lyGqZk6wbhmLexLf-Hk79Uo0OJXX9npHxkhe2Lwi7wHY4TwDjXB5UeIhnKGaDOQPTkjNVW00

Is this what you are looking for ?
(And any idea about a better parameter name still welcome :-) )

Contributor

arnaudroques commented Jun 27, 2017

Actually, it does (at least with last version).

So you can have:

@startuml
skinparam maxMessageSize 100
[component1]
[component2]
component1 --> component2 : this is a very long sentence on one single line
@enduml

http://www.plantuml.com/plantuml/uml/JSun3i8m44JHtgUO2qHAA2bGBa15YLAimiYiiDUHro3WzBWBqcz6hvdPczJsp2duGssJAXbPtcUwI-H5lyGqZk6wbhmLexLf-Hk79Uo0OJXX9npHxkhe2Lwi7wHY4TwDjXB5UeIhnKGaDOQPTkjNVW00

Is this what you are looking for ?
(And any idea about a better parameter name still welcome :-) )

@mikus

This comment has been minimized.

Show comment
Hide comment
@mikus

mikus Jun 27, 2017

Ok, maybe I used the wrong thread. What I mean is the long component description rather than link label. Like in the following snippet:

@startuml
skinparam maxMessageSize 100
component component1 [
   this is a very long component description
]
@enduml

mikus commented Jun 27, 2017

Ok, maybe I used the wrong thread. What I mean is the long component description rather than link label. Like in the following snippet:

@startuml
skinparam maxMessageSize 100
component component1 [
   this is a very long component description
]
@enduml
@arnaudroques

This comment has been minimized.

Show comment
Hide comment
@arnaudroques

arnaudroques Feb 20, 2018

Contributor

Sorry about the delay..

With last beta http://beta.plantuml.net/plantuml.jar you can now have:

@startuml
skinparam wrapWidth 100
component component1 [
   this is a very long component description
]
note left
   this is a very long note that show be wrapped
end note
@enduml

and also

@startuml
skinparam wrapMessageWidth 100
A->B:very long long long message name

@enduml

If you have any comment please use #104 now.
Thanks!

Contributor

arnaudroques commented Feb 20, 2018

Sorry about the delay..

With last beta http://beta.plantuml.net/plantuml.jar you can now have:

@startuml
skinparam wrapWidth 100
component component1 [
   this is a very long component description
]
note left
   this is a very long note that show be wrapped
end note
@enduml

and also

@startuml
skinparam wrapMessageWidth 100
A->B:very long long long message name

@enduml

If you have any comment please use #104 now.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment