plantuml-stdlib / C4-PlantUML

C4-PlantUML combines the benefits of PlantUML and the C4 model for providing a simple way of describing and communicate software architectures
MIT License
6.41k stars 1.1k forks source link

Set padding for elements inside a boundary #299

Closed skngetich closed 1 year ago

skngetich commented 1 year ago

I would like to change the padding of the elements in a boundary. How can I do that?

Potherca commented 1 year ago

Hi! To make it easier to help, could you post a (simplified) diagram, so we have an example to work with?

Potherca commented 1 year ago

In the meantime, I've looked into this some more. Sadly, PlantUML does not offer an easy way to add spacing inside an element.

TL;DR (short version)

Use a dummy container inside the boundary as a workaround.

```plantuml @startuml !include skinparam { rectangle<> { borderColor transparent stereotypeFontSize 0 fontSize 0 } } Boundary(b, "Boundary") { rectangle padding <> { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } } @enduml ``` ![](http://cdn-0.plantuml.com/plantuml/png/NP31IiD048Rl-nHZJYa8AlGOGZ7YhI0K3vvacXtBOZApp4uEKVhkBjjQJM_p_n_3VCmc6QfDu-1k0lV3v0cQRdtNhTyxOSF0fArpwJDmHCKHlXs0Kc_8Xu6Qvkbrktrhsr83x4KzQIU3A9WYfxn3R8Kb8oMnETApiEt25y5z0H__uz4TdNEFCh57dUlzBLI_eLejZqD4xmCVuDhY8bxtUVsIgbMXBwH9k8uPdSPplvkpuLYdt9_6VA-0Fvc7XStPTaFiy_j-0000)

Full details

I'll use this diagram as the basis for further examples:

```plantuml @startuml !include Boundary(b, "Boundary") { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } @enduml ``` ![](http://www.plantuml.com/plantuml/png/SoWkIImgAStDuLBCp4lEAKr9LR1nDj5tDebtpiyhISpCIosou-9ooY_DIqaigjH8qb5GWd6KD1MgkHI00AvI8nae3USfQO9b0rABYlFpD0g0KX0cL3ouihWaDLUZ62WEOGBD0qiWB3D4iOshbiiXDIy5w5O0)
See full details ### No skinparam "margin" or "padding" Sadly, there is no skinparam for "margin" or "padding":
```plantuml @startuml !include skinparam rectangle<> { margin 100 100 100 100 padding 100 100 100 100 } Boundary(b, "Boundary") { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } @enduml ``` ![](http://cdn-0.plantuml.com/plantuml/png/PP312eCm44Jl-nLRJn4ALV0e8lK72ls0ifeWeMQL91wa-EzDrTgM7W8pys0cREayMJ-Q3WwQcswK2lCgErNPhUhPasPb2m1trpoG9ODMDPwuxLIUr_t8aknK5FW0H3HaMysO9idtUv61fDJS_g4P0CvRYwYF6BrD5A-Lk7z2D07lBeeNUb7MzIo6W5QvvTV9UMM42_agGzy2FcFfpnhCK2gMuGnF)
### Skinparam `nodesep` and `ranksep` There is skinparam `nodesep` and `ranksep` which can be used to increase the space _between_ elements but not _around_ them. That is to say: the space between an element and the boundary does not change.
```plantuml @startuml !include skinparam nodesep 100 /' horizontal margin '/ skinparam ranksep 100 /' vertical margin '/ Boundary(b, "Boundary") { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } @enduml ``` ![](http://cdn-0.plantuml.com/plantuml/png/LOv1Ii0m44NtESMOJLCGsaAN8iLUGF004fj1GvD9cIH25UzkRBMsMSt_xy7F49FcbBqJDvOcbmt2tTWtO_yy1ahQ4lAz476sj6ZM7YWOZBX0rxRGLF0Ms7xyY0wyvbTBK3KdcpND9_iTETdfueg7aCbeNjNBBSY_86lu553UyGar5NmaMM_q4Ja6Kaj1-_dRFwqneLUnzFifQzZ0_rXtMHDVOa0osRjl)
### Padding and Margin (new CSS-like style) not working There _are_ [padding and margin instruction](https://forum.plantuml.net/3118/introduce-padding-setting?show=11438#c11438) using the [new CSS-like style](http://alphadoc.plantuml.com/doc/asciidoc/en/style-evolution), but they do not seem to be implemented for the elements used by C4. This _could_ be a bug in PlantUML and might be worth reporting there.
```plantuml @startuml !include Boundary(b, "Boundary") { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } @enduml ``` ![](http://cdn-0.plantuml.com/plantuml/png/ZL31QWCX4BtFLqot5mEbII379OH8SoiK-W75w21ICvRHFImX_rwxQrDwMmyoxptUUpg7N8oKuHBX8R2DWoFizMwjTnywSJ61IVO0VIvZf3qWIae5hu3r78tzz986TZh59FXuEhrCmgiH7nYtcyq4tunpWNt3DwYNa2s6VIIyBdGydt-AZ8pB7FswlHYEpQVEJzZzWcxLOkwVLBRATzIjvbIId5XzLMaU6_y-va8NbIi_ZpLl4lxAjl_Qu0O7ObVN_0q0)
### Workaround What _could_ work is a workaround, putting the elements in an invisible container. This does mean adding a container inside every boundary. Not ideal.
```plantuml @startuml !include skinparam { rectangle<> { borderColor transparent stereotypeFontSize 0 fontSize 0 } } Boundary(b, "Boundary") { rectangle padding <> { Container(c, "Container") Person(p, "Person") System(s, "System") Boundary(b1, "Boundary") } } @enduml ``` ![](http://cdn-0.plantuml.com/plantuml/png/NP31IiD048Rl-nHZJYa8AlGOGZ7YhI0K3vvacXtBOZApp4uEKVhkBjjQJM_p_n_3VCmc6QfDu-1k0lV3v0cQRdtNhTyxOSF0fArpwJDmHCKHlXs0Kc_8Xu6Qvkbrktrhsr83x4KzQIU3A9WYfxn3R8Kb8oMnETApiEt25y5z0H__uz4TdNEFCh57dUlzBLI_eLejZqD4xmCVuDhY8bxtUVsIgbMXBwH9k8uPdSPplvkpuLYdt9_6VA-0Fvc7XStPTaFiy_j-0000)
skngetich commented 1 year ago

Thank you very much for the descriptive description. From your explanations, I have realized that the issue was the margin between the elements and not the padding. I sorted it out using nodesep and ranksep.

Potherca commented 1 year ago

Glad to be of help. Happy diagramming!