Layout control proposition

+4 votes
asked Jul 10, 2013 in Wanted features by DavidG (120 points)

Hi,

As I use more and more PlantUML to generate documentation, I feel more and more frustrated about the layout.
I would like to have more control how the blocks are arrange.

When I was young ;-) I do a lot of Swing UI and play with LayoutManager to place UI components.
It would be cool to have the same concept in PlantUML.

I'm thinking about doing something like this (don't look at the syntax, it's just to sketch the idea)

First we need to declare a Layout definition :

@startuml

layout <type> {
    <optional layout parameters>...
}
@enduml


For example :

@startuml

' Define an horizontal layout
layout HBoxLayout {
    alignement: center
}

' Define an vertical layout
layout VBoxLayout {
    alignement: top
}

' Define a 4x3 grid
layout GridLayout {
    column: 4
    row:    3
}
@enduml


We can imagine any layout type we want/need.

So, when declaring a block (class, component, etc) we can put it in a layout:

@startuml

    layout HBoxLayout {
        layout HBoxLayout {
            alignement: center
            
            component MyComponent1
            component MyComponent2
        }
        
        layout VBoxLayout {
            alignement: top
            
            component OtherComponent1
            component OtherComponent2
            OtherComponent1 ..> OtherComponent2
        }
    }
    
    layout GridLayout {
        column: 4
        row:    3
        
        ' Set this one at coordinate (2,2) of the grid
        component AnyComponent1 @2,2
    }
    
@enduml


Again, this is only a proposition, just to start a discussion.
Maybe there is better/simpler way to do this than what I describe.
And maybe it's not a feature we ant regarding the PlantUML philosophy

Thanks for your help
WBR // David

1 Answer

+1 vote
answered Jul 10, 2013 by plantuml (295,000 points)
selected Jul 10, 2013 by DavidG
 
Best answer
Hello,

Thanks for your suggestion.
Actually, there is something we are just starting to think about : allowing users to have other ways than GraphViz/dot to do the layout.
The real goal for us is to have a 100% java implementation (and not to depend of GraphViz/dot anymore).

So someday in the future, we will probably have the choice to choose some layout engine, either fully automatic (like GraphViz/dot does today)
or partially manually (like your Swing layout proposal).

Unfortunalty, this needs some very complex algorithms, especially for node placing and edge drawing.
Even with your proposal, where node are placed by the user, the program has to determine the "best" way to draw edge/link between classes,
minimizing crossing and allowing text placement, which is not a simple process (any good references about that are welcome :-)

So the bad news in that it's going to take a long time (probably more than one year...).
Don't hold your breath : we will put some news here when progress will be done.

Regards,
commented Jul 10, 2013 by DavidG (120 points)
Hi, thanks for your reply and your consideration.
I can imagine that it's not a simple problem if it's not supported by GraphViz.

I know that yWorks (http://www.yworks.com) has a Java libraries with powerful layout.
But it's not Open Source.
I know it because I also use the yEd editor to do some diagrams.

Thanks for your help
Regards, David
commented Jan 22, 2019 by blisteredoutlaw (100 points)
Just bumping this back up to the top since it's been a while.  I absolutely love this tool and am pushing for our organization to adopt it as our standard diagram tool.  I'm in the middle of prototyping a bunch of existing diagrams with Plant UML.  The layout of deployment/component diagrams is the biggest issue I'm facing right now.  A lot of our diagrams have various layers of systems of hardware and software components that must be visualized in a grid layout.  Has there been any progress on adding a grid layout engine?

Thanks for you help.
...