Hello,
Few years ago I’ve asked about similar issue in GoXam and the answer was really helpful (here). Now I have this issue in GoDiagram and my playing with Focus property doesn’t help. Here is the layout I have after applying GoLayoutLayeredDigraph
Each node in the graph is a subgraph and the layout is applied to each of them. Nodes have 2 ports in fixed positions and I want to have all the nodes top aligned (and all the links as straight lines). This is true in case nodes have the same height, but if height differs, then nodes start to dance.
My nodes have 2 ports, input at the left border and output at the right border. They are located 15 pixels from the top of the node. I.e. expanded nodes should look like they are expanded down from the links, as in the image.
If I execute this code before performing layout:
foreach (var node in layout.Network.Nodes) { node.Focus = new SizeF(node.Focus.Width, 0); }
all nodes will be centered, like in your screenshot, but I was not able to find a value for a Focus to make nodes top aligned
edit: my nodes are the custom classes derived from GoSubGraph, so it may happen that I did something wrong there, making nodes to have 2 ports at the fixed points
Thanks for your help, Jake. Although applying offset to the Center makes difference, it is not consistent, i.e. I may find offset value to make some nodes aligned properly, but this make some other nodes (in parent subgraph for example) to be aligned even more worse than before.
Actually I briefly looked at your code, and for my understanding making Focus.Height = 0 for layout nodes should make them top alighed, and with default Focus they should be center aligned. But in my case things are vice versa, with all defaults nodes are more or less top aligned, but with Focus.Height = 0 they are center aligned. This is quite confusing.
Hello Jake,
To be sure that my nodes are not the root of the issue, I reproduced the same behavior with MultiPortSubGraph node from your examples. I made 4 ports at each side to simulate port placement near the top of the node. Here is how it looks
With overriden MakeProper method, like you provided, all nodes become center aligned. Looks like Focus value has no effect at all in this case because it leads to no visual difference in graph.
Setting of Focus value without custom layout has quite inconsistent results, I was not able to find any value or expression that works for all subgraphs.
Looks like I have to live with the default dancing layout. I may send you my example app, if you have a time to check it yourself.