force left and right positionning issu with rectangle

0 votes
asked Feb 28, 2019 in Bug by setop (320 points)
edited Feb 28, 2019 by setop

(edit : I've narrowed the issue)

I have this diagram :

@startuml

rectangle MMM {
    rectangle KKK {
        [mmmm]
    }
    [inini]
    [rrrr]
}
[RRR] -> [mmmm]
[mmmm] -> [inini]
[inini] -> [rrrr]
@enduml

rendered as following :

I was hoping "inini" to be at the right side of "mmmm", but plantuml renders is the other way with a long weird arrow.

When I comment out the "MMM" rectangle then element are properly aligned :

But the outer rectangle is meaningful for what I want to draw.

I it an issue in the engine or in my graph ? Is there a workaround ?

1 Answer

0 votes
answered Mar 11, 2019 by Mark

Hi,

This seems to be achievable using an invisible rectangle as a hack to group the [rrrr] and [inini] components.

@startuml

skinparam package<<invisible>> {
    Shadowing none
    BorderColor #white
    FontSize 0
    StereotypeFontSize 0
}

[RRR]
rectangle MMM {
    package invisible <<invisible>> {
        [rrrr]
        [inini]
    }
    rectangle KKK {
        [mmmm]
    }
}
[RRR] -> [mmmm]
[mmmm] -> [inini]
[inini] -> [rrrr]
@enduml

Example here:

http://www.plantuml.com/plantuml/png/PP31QeSm3CRlVOh0peCzW8Xii8juqQDuw3HeiAOIkyasVFSLerFuVuM6_Dea7ycMO2LyJiwOPIIUhTW9PjkEjiSa8VwYXJuSfYdy6eYg1jlvbRW7zemxUlNIeRnvvmMUre62udVFeQ8VX1Sj32Zem_UCjuVDcBeioyO8ji5oxn2AeZX67IxWtmGy6bBL4jLSAN4ycc_xVRNFy_nUE4MT7pVr0i_foJNiu6YfKP4EpP2xkBu_

When using command line tools, the diagram is occasionally rendered with the curved connections as shown in your initial example, but the online sandbox rendering appears to generate the corrected output.

The trick is to assign a stereotype <<invisible>> to the rectangle to allow specific styling to make it invisible (or to blend into the background).

I hope this workaround works for you!

Good luck.

commented Mar 13, 2019 by zimchaa (1,040 points)
Hi, it's possible to use the 'together' tag to avoid the need for the special stereotype styling - it works very similarly and is available on a few different diagrams:

http://www.plantuml.com/plantuml/uml/JOx12eCm38RlVOgym2vxWE5TlBYZU0YQQLcRIfinnl3T5mnE_qB3_xN9dwe8Pdd5uChJyu8P8vGPn_JsFC43Go4uFGqfBec9vIwVGA1zL-UwjcrxbsaGv4bfqpJmTQ2ID97CbCrkwhAgFwndFURNxJxcr7LzReog_UDgeN2vxToAWlz8guOij28UTUKV

(includes a couple of different skinparams I like as well - IMHO)
commented Dec 4, 2020 by setop (320 points)
Very clever !

Works well on my case.

Quite lightweight and less hacky than the 'invisible' trick.

I'll experiment that on more elaborated diagram.

Thanks a lot
...