简体   繁体   English

GEF / draw2d:DirectedGraph节点故障

[英]GEF/draw2d: DirectedGraph nodes out of order

I have a program where I have a tree. 我有一个程序,其中有一棵树。 I place the nodes and their edges in NodeList and EdgeList. 我将节点及其边缘放置在NodeList和EdgeList中。 Then put the lists in a DirectedGraph which I then run through DirectedGraphLayout.visit(). 然后将列表放入DirectedGraph中,然后通过DirectedGraphLayout.visit()运行它。

I now place the nodes and edges on the screen. 现在,将节点和边缘放在屏幕上。 The diagram is almost perfect but there are some inconsistencies with nodes being out of order. 该图几乎是完美的,但存在一些与节点混乱不符的矛盾之处。

The first one is shown in the following picture. 下图显示了第一个。 As you can see it places a few children of parent1, then places some nodes from parent2. 如您所见,它放置了parent1的几个孩子,然后放置了parent2的一些节点。 Then for some reason that I can't figure out it places the last child from parent1 to the right of parent2's children. 然后由于某种原因,我不知道将最后一个孩子从parent1放置到parent2的孩子的右边。

Picture 图片

The next problem are the children of a parent being out of order. 下一个问题是父母的孩子的家庭秩序混乱。 When the children should be placed in the order: 1 2 3 4, they are instead placed in different orders such as: 2 3 1 4. 当应该按照以下顺序放置孩子时:1 2 3 4,而是按照不同的顺序放置孩子,例如:2 3 1 4。

I have tried adding the nodes to NodeList is different orders, trying post and pre order recursion to parse my tree. 我尝试将节点添加到NodeList的顺序是不同的,尝试使用post和pre order递归来解析我的树。 I end up getting the exact same positioning. 我最终得到了完全相同的位置。

I'm at a loss on how to fix this. 我对如何解决这个问题不知所措。 Any tips about how DirectedGraph works and why it's placing nodes like this is appreciated. 感谢有关DirectedGraph的工作原理以及为什么放置这样的节点的任何技巧。

From the DirectedGraphLayout documentation, DirectedGraphLayout文档中,

[the layout algorithm will] assign x coordinates such that the graph is easily readable. [布局算法将]分配x坐标,以便图形易于阅读。 The exact behavior is undefined 确切的行为是不确定的

And further down 再往下走

This class is not guaranteed to produce the same results for each invocation. 不能保证此类每次调用都会产生相同的结果。

So I guess there is no way to "fix" this as the behavior is undefined. 所以我想没有办法解决这个问题,因为行为是不确定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM