eclipse / elk

Eclipse Layout Kernel - Automatic layout for Java applications.
https://www.eclipse.org/elk/
Other
256 stars 84 forks source link

Define a Cluster of Nodes at a specific position (North/West/East/South) #854

Open BjBe82 opened 2 years ago

BjBe82 commented 2 years ago

I try to cluster a set of Data in different areas of the diagram. Let’s assume there are the following Elements:

The goal is to have RIU in the TopLeft, BAT_1/BAT_2 in the BottomLeft, PCDU in the TopRight and Others in the BottomRight of the diagram.

To cluster the elements a hierarchical node will be added representing the orientation (maybe not required). I tried to use "position" in combination with "partition" to force the grouping node in the corresponding direction.

Example Model

But as it looks like the algorithm just adds new layers to the partitions which causes a not intended behavior. I also tried to force one layer per partition by using “layerConstraint” but using “layerConstraint” FIRST for TopLeft and BottomLeft causes an exception: “UnsupportedConfigurationException: Node 'TopRight' has its layer constraint set to FIRST_SEPARATE, but has at least one incoming edge”

Is there a other way to configure the intended behavior?

soerendomroes commented 2 years ago

You can't have an edge from TopLeft to BottomLeft, since it is an in-layer edge. Can you draw our desired drawing as you would like it to be?

BjBe82 commented 2 years ago

TopLeft, BottomLeft, TopRight and BottomRight are only used to group elements in that area like a cluster. Then i tried to position the “cluster” nodes in a way that they are top-left, bottom-left, top-right and bottom-right oriented in the Diagram.

I tied to achieve something like this:

grafik

soerendomroes commented 2 years ago

This does not work since you introduce in-layer edges. What you need is for example box or rectpacking layout for your grouping elements and maybe layered at the bottom. But I guess the edge routing does not handle this very well, even if you introduce ports for all outgoing edges (which you have since only layered can do hierarchy-aware layout). To create a drawing as you describe is not trivial and is to my knowledge not supported by ELK. However, feel free to try out the pointers I gave you.

BjBe82 commented 2 years ago

Thx for the answer and hints so far.

Tested: rectpacking + layered algorithm

grafik

Example Model

The position of the nodes looks fine but as you already mentioned the edge routing does not handle this very well. It is also not possible to introduce segmented edges (i.e RIU-> Others splitted into "RIU->TopLeft + TopLeft->BottomRight + BottomRight->Others) Trying to add an edge from RIU to TopLeft causes an exception: UnsupportedGraphException: The source or the target of edge ElkEdge ElkNode "RIU" (0.0,0.0 | 30.0,30.0) -> ElkNode "topLeft" (0.0,0.0 | 30.0,30.0) could not be found. This usually happens when an edge connects a node laid out by ELK Layered to a node in another level of hierarchy laid out by either another instance of ELK Layered or another layout algorithm alltogether. The former can be solved by setting the hierarchyHandling option to INCLUDE_CHILDREN.

soerendomroes commented 2 years ago

Yes, because you cannot do hierarchy-aware edges in rectpacking. What I meant was introduce ports that have the correct position (and a very small size) based on the hierarchical edges you want to introduce and only create edges in the current hierarchy level, while the ports serve as a link between the hierarchy levels.

BjBe82 commented 2 years ago

Yes but even if i change it to edges on the same level with dummy ports the edge is not nicely routed:

grafik

Example Model

soerendomroes commented 2 years ago

You are right, rectpacking does not support port constraint or hierarchy-aware layout. Implementing this seems to be complicated, so it might take a while to add this new feature if we have the time to do this.

Currently, I understand this issue as a feature request for port constraint and hierarchy-aware layout for rectpacking. if you have anything to add feel free to do that.

soerendomroes commented 2 years ago

Have you tried something like this, where you manually compute the positions of the ports and only use the layered algorithm?