New command to better control the layout of class and state diagrams

+2 votes
asked Oct 4, 2014 in Wanted features by poi (1,200 points)
edited Oct 27, 2014 by poi

Background

I use PlantUML as a tool for UmlAsSketch, http://martinfowler.com/bliki/UmlAsSketch.html.

The layout is important to the readability, which is crucial to UmlAsSketch. I often end up in frustrating experiments using arrows direction and hidden to affect the layout. (I know graphviz rules.)

Proposal

New command FreezeLayout, which freezes the positions of the items defined by code preceeding FreezeLayout. Sketch:
@startuml
code-defining-the-overall-picture
FreezeLayout
code-defining-more-stuff
FreezeLayout
code-defining-more-stuff
@enduml


Justification

This fits my approach. I make a diagram consisting of approx. seven classes or states. It looks great. I add more more items and suddenly the layout get entangled and difficult to read.

Currently, I have a state diagram, the "happy path" of which I would like to be vertical row of states. Down arrows provide that. Here I would like to add FreezeLayout. Next I want to add states to the left of the "happy path", which represents various Failures. And to the right I want to add states related to Breaks.

Admission: I don't know whether graphviz would play with these rules.
 

commented Oct 26, 2014 by Fuhrmanator (1,700 points)
DOT has "incremental layouts" on its wish list http://www.graphviz.org/doc/todo.html and googling found this discussion: http://lists.research.att.com/pipermail/graphviz-interest/2012q2/007295.html
commented Oct 27, 2014 by poi (1,200 points)
Yes, and with NEATO there is an option to lock positions of nodes with the attribute POS.

Their forum gave me the impression that the resources for development are limited.

Tools like GVPR I assume are not practical to use together with PlantUML.

3 Answers

+1 vote
answered Oct 8, 2014 by plantuml (294,960 points)

Thanks for your proposal.
We agree that one drawback of Graphviz is the lack of stability : adding new nodes in a diagram may completely change the layout, and this is sometimes very frustrating.

The bad new is that we don't think that your approch is going to work (but we could be wrong on this).
The main reason is that there are no mechanism inside Graphviz allowing this kind of freeze.

The good new is that since this is a common issue to many users, we are beginning to think about a way to solve it.
The solution we propose is that the order in which classes are declared defines the actual order the classes are displayed (from left to right).
And we add a new "layout_new_line" keyword to explicitly declare lines.

So for example, you can have:
(this is working with 8009beta3 https://dl.dropboxusercontent.com/u/13064071/plantuml.jar )

@startuml
class foo1
class foo2
class foo3
layout_new_line
class bar1
@enduml


This is really an alpha version : no packages, links between classes are not drawn.
And we plan to move/adapt spaces between classes to optimize links drawing.
The key point is that the class ordering will not be changed (this highly simplify the algorithms).

Any thought about our suggestion?
 

commented Oct 12, 2017 by rd27 (460 points)
Was something like layout_new_line ever implemented? It doesn't seem to work in 1.2017.15.
0 votes
answered Oct 13, 2014 by poi (1,200 points)
edited Oct 15, 2014 by poi

Thank you for your answer.

Now I spent some time on the Internet, mainly http://www.graphviz.org/. I tried to better understand the DOT language, espcially regarding the possibilities to control of the layout of UML-diagrams. My idea was to try to create a few of my diagrams with the DOT language. This way I would find out how valuable (to me) the various tricks are in praxis. (Haven't done that yet.)

The problem is that small changes in the dot-file may cause large changes in the layout. This "instability" is recognised and it is often discussed in the forum and the mail-list. I'm not the only one who is frustrated. Conclusion: DOT doesn't offer a good solution.

With DOT there is a bag of tricks to take control over the layout. It includes: the order, in which the nodes are introduced in the script; the weight of the edges; hidden nodes; hidden edges; direction of the edges; the rank of nodes (ranksep and rankdir); subgraph and cluster; nodesep and minlen; and maybe more. However, these tricks are not all that powerful and there are no strict rules on how to use them.

The program NEATO (undirected graphs) allows constraining positions of nodes; attribute "pos". With NEATO my proposal, FreezeLayout, might be possible, but with DOT it is not.

Not all the tricks in the bag are possible to use with PlantUML?

  • layout_new_line in 8009beta3 is that an interface to the attribute, "rank=same", of DOT? Yes, I think that would be useful. I'm not sure about the use of "rank=min", "rank=max","rank=source" and "rank=sink".
  •  the attribute, weight, would be possible to implement, e.g. "-[weight=100]->"
commented Oct 13, 2014 by poi (1,200 points)
Sorry, this not a separate answer, but rather a comment to the first answer by plantum
0 votes
answered Sep 18, 2019 by valexiev (1,200 points)
@poi: the best I can think of is the [norank] edge modifier, which makes it have no effect on the layout (this translates to graphviz "constraint=false").

You're asking for "freezing a layout" in stages, but your stated use case (to have the main line be vertical) is served by declaring all other edges [norank]
...