elk icon indicating copy to clipboard operation
elk copied to clipboard

Avoid overlap of "not connected" ports with org.eclipse.elk.layered algorithm

Open lredor opened this issue 6 years ago • 4 comments

Currently all ports not connected with an edge are layouted to the west side of their container. They are distributed along the west side. But if there are too many ports, in first time, the property org.eclipse.elk.spacing.portPort is ignored, and then the ports overlapped with each other. It will be better to use west side firt and then north if there is no longer space and then east ...

The idea is:

  • layout the ports with edges in first, apply the rule to avoid overlap. So even if the best side is east(for example), use another side if there is no longer space to respect the property org.eclipse.elk.spacing.portPort
  • layout "not connected" ports with the same rule (using free space left)

Steps to reproduce:

  • The original graph is like in "Initial graph.png" Initial graph
  • Open "PortsSample.elkg" in the "Layout Graph" view (included in ElkSamples.zip)
  • The result of the layout is like in "Graph after layout.png": all the ports have WEST as fixed side and are distributed on this side, with overlap. Even if there is org.eclipse.elk.spacing.portPort set to 20. Graph after layout

This issue has been created after a discussion on the forum. There is also a cloned issue on bugzilla : bugzilla 545990.

The problem is similar if there are edges (for example with "Diagram with ports and edges.elkg" included in ElkSamples.zip).

lredor avatar Apr 02 '19 06:04 lredor

Good idea 👍

spoenemann avatar Apr 02 '19 07:04 spoenemann

With a slightly different configuration we can have the size of the node set according to number of ports and label size. For example for PortsSample.elkg, we can use properties "org.eclipse.elk.nodeSize.constraints" and "org.eclipse.elk.nodeLabels.placement", and remove the fixed size of the node.

<?xml version="1.0" encoding="utf-8"?>
<graph:ElkNode xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:graph="http://www.eclipse.org/elk/ElkGraph" height="905.0" width="1765.0">
  <properties key="org.eclipse.elk.algorithm" value="org.eclipse.elk.layered"/>
  <properties key="org.eclipse.elk.layered.contentAlignment" value="[H_RIGHT]"/>
  <properties key="org.eclipse.elk.debugMode" value="true"/>
  <properties key="org.eclipse.elk.direction" value="RIGHT"/>
  <properties key="org.eclipse.elk.edgeRouting" value="ORTHOGONAL"/>
  <properties key="org.eclipse.elk.layered.layering.strategy" value="NETWORK_SIMPLEX"/>
  <properties key="org.eclipse.elk.spacing.portPort" value="20.0"/>
  <properties key="org.eclipse.elk.noLayout" value="false"/>
  <children identifier="A node with ports" x="20.0" y="20.0">
    <properties key="org.eclipse.elk.nodeSize.constraints" value="[PORTS, NODE_LABELS]"/>
    <properties key="org.eclipse.elk.nodeLabels.placement" value="[H_CENTER, V_TOP, INSIDE]"/>
    <labels height="16.0" width="100.0" x="75.0" y="5.0" text="A node with ports">
      <properties key="org.eclipse.elk.font.name" value="Tahoma"/>
      <properties key="org.eclipse.elk.font.size" value="8"/>
    </labels>
    <ports height="10.0" width="10.0" x="-2.0" y="80.0"/>
    <ports height="10.0" width="10.0" x="10.0" y="92.0"/>
    <ports height="10.0" width="10.0" x="242.0" y="40.0"/>
    <ports height="10.0" width="10.0" x="100.0" y="92.0"/>
    <ports height="10.0" width="10.0" x="60.0" y="-2.0"/>
    <ports height="10.0" width="10.0" x="-2.0" y="8.0"/>
    <ports height="10.0" width="10.0" x="-2.0" y="40.0"/>
    <ports height="10.0" width="10.0" x="242.0" y="70.0"/>
    <ports height="10.0" width="10.0" x="242.0" y="10.0"/>
    <ports height="10.0" width="10.0" x="150.0" y="-2.0"/>
    <ports height="10.0" width="10.0" x="180.0" y="92.0"/>
  </children>
</graph:ElkNode>

This does not resolve the problem with fixed size, but this is another approach. Result is PortsSampleWithNewConfiguration

lredor avatar May 14 '19 16:05 lredor

The overlapping problem itself is now tracked in #316. Distributing the ports will continue to be tracked here.

le-cds avatar Nov 04 '19 14:11 le-cds

@Eddykasp

soerendomroes avatar Nov 16 '22 10:11 soerendomroes