eclipse / elk

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

How to get perfectly centered lines using layered, interactive strategy? #1027

Open donutdan4114 opened 5 months ago

donutdan4114 commented 5 months ago

This is a very real example of how our elk is setup. I have tried to fix the layout to achieve a perfect look. I have tried most options, but not sure how most of them work.

Two issues, may or may not be related:

  1. The nodes end up off-center.
  2. The weird bend is the big problem. Sometimes I can fix the bend by not using INTERACTIVE, but not sure of other consequences to switching from that strategy.

I am sure I am missing something obvious with how I should even be thinking about the node setup.

p.s. Thank you everyone for this amazingly powerful tool. Truly a work of wonder that it can do all that it does!

2 1
soerendomroes commented 5 months ago

Try looking into nodePlacement.strategy. NETWORK_SIMPLEX as seen here might be what you want. But I think elk layered does currently not support the a node placement strategy that centers everything, maybe mrtree can do what you want.

BCampbellDev commented 5 months ago

Thanks @soerendomroes , I'm working on this with @donutdan4114 . I updated the nodes so that, when multiple edges leave a node, theres an "source" port for each, and when they converge on a node, that node has a matching number of 'target' ports - seems to help with one of the edge problems. There is still the issue of the middle path not being aligned.

I have tried switching back and forth between NETWORK_SIMPLEX and BRANDES_KOEPF - its seems that when using NETWORK_SIMPLEX the alignment is better, however the balancing we are going for is gone. If we use BRANDES_KOEPF , the balancing is better, but the alignment is off.

Not sure how to achieve the center alignment of NETWORK_SIMPLES with the balancing of BRANDES_KOEPF

Updated Model

BCampbellDev commented 5 months ago

Also ive found that when using BRANDES_KOEPF - if the farthest left node in the diagram, is made the width of the other nodes, 200, it solves the issue with the center line - not entirely sure why? lol maybe elk is working from left to right and thats the basis of the centering? so by making that node wider its pushing everything into a proper alignment?

soerendomroes commented 5 months ago

@BCampbellDev Sadly, there is currently no option for this. BRANDES_KOEPF even with bk.fixedAlignment: BALANCED will only balance based on the whole graph and not locally since this does usually cost more space and drawings get bigger. NETWORK_SIMPLEX cannot be combined with BRANDES_KOEPF. Implementing a simple centering strategy node placement strategy is however on our agenda.

soerendomroes commented 5 months ago

@BCampbellDev I will mark this as a bug and try to investigate this.

BCampbellDev commented 5 months ago

thanks @soerendomroes

BCampbellDev commented 5 months ago

@soerendomroes I was able to find some success by regrouping and using parent nodes, and I think this is the direction I will head in. I do have one question about this I'm wondering if you or anyone else could shed light on

Model

Is there a way to top align the three nodes, N3A, N3B, N3C ?

soerendomroes commented 5 months ago

@BCampbellDev Yes, by setting alignment for each node as documentated here and seen here.

BCampbellDev commented 5 months ago

Ah thank you @soerendomroes I will try that!

BCampbellDev commented 5 months ago

@soerendomroes perfect thank you so much

BCampbellDev commented 5 months ago

@soerendomroes would you have any thought on this one ? its slightly different so I created a new question for it

What is the best strategy / approach for balancing and aligning the contents of a node with the graph