How to make PlantUML left/right/up/down arrow longer?

0 votes
asked Mar 19, 2022 in Question / help by Shadow43375 (140 points)

The syntax for switching the directionality of the arrows in PlantUML is clear. One can use an -left->, -right->, -up->, -down-> to achieve left, right, up, and down directionality respectively. The documentation is equally clear that increasing the length of an arrow on rendering can be done syntactically through increasing the number of dashed in the arrow in the UML code (eg. --> is increased to ---> or ---->).

This doesn't seem to work (at least in the Visual Studio Code extension by Jebbs) when there is also directionality included. So, for example, -left---> does not increase the length of the arrow. Is this expected behavior?

commented Mar 20, 2022 by Martin (9,120 points)
edited Mar 20, 2022 by Martin

You'll find that "-up-->" is in fact a longer arrow than "-up->" (similarly for down).  But it is a valid question for left/right. 

But I don't think it is an easy change for Plantuml.  It uses 'dot' syntax to obtain the layout of the shapes.  But 'dot' only supports "minlen=n" to specify vertical rank, and "dir=back" to specify reverse direction.

So if you take this simple diagram:

click for online server

Its layout is created with this dot:

click for online server

You can see that the vertically placed nodes can use minlen=1 and minlen=2 (and dir=back for 'up').  But the horizontally placed nodes have to all use minlen=0 (and dir=back for 'left').  So basically dot only allows you to specify the 'row' a node is on and not the 'column' (unless there's some newer attributes I'm not aware of).  And you can see from the layout that although the rows are aligned, there's no real concept of column alignment.

However, there is a workaround.  You can put in a long comment on the horizontal edges to make them longer:

click for online server

Under the covers, this is creating an edge label with a table with an explicit width:

label=<<TABLE BGCOLOR="#00000E" FIXEDSIZE="TRUE" WIDTH="174" HEIGHT="18"><TR><TD></TD></TR></TABLE>>

So a naive implementation of your idea could be for the horizontal arrow length to set the edge's [minimum] label width (adding a blank label if necessary) to a constant multiple of the arrow length.  It would achieve visibly longer arrows (for arrows with short/empty labels).

(Caveat: The vertical ranking is more powerful - row placement takes into account the height of the tallest node in the row and adjusts the vertical arrow lengths accordingly.  The idea above wouldn't do that for node widths.)

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...