eclipse / elk

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

Why do i get no width or height for my inner nodes #1055

Closed ymolists closed 3 months ago

ymolists commented 3 months ago

Ask your questions

Hi Folks

I have this graph i am trying to convert to json

When i use the 0.9.1 librabry from java here is the output i am getting. can anyone please help me figure why the inner nodes have no heights and widths ?

(Optional) ELK Version elk: '0.9.1'

(Optional) Additional context jdk17

Eddykasp commented 3 months ago

This is because elkt assumes default node sizes, when converting to json, however, only the information actually explicitly stored on the graph is translated. This is to ensure that translating back and forth maintains the same graph. So in json you have to actually write down the node sizes you want. Or you can set them elkt before you convert it.

ymolists commented 3 months ago

Thank you so much for that prompt answer.

i found a work around in that now if a node has no children i explicitly add a constraint like this

    nodeSize.constraints: MINIMUM_SIZE

With that i am now able to get correct sizes. Is there a better way to tell elkt to compute the size when it converts from elkt to json ? i dont plan to do the reverse . for now its a one way conversion and i dont want to do multiple pass to enforce the size.

Best regards and again thank you !

Eddykasp commented 3 months ago

No the conversion itself cannot directly do this for you, but I would suggest you give the nodes a size using layout [size: 50, 50] for example so you can actually control the minimum size rather than using the default values.

ymolists commented 3 months ago

thank you that solve this problem !