1

I am working through the examples in 'The Eclipse Graphical Framework (GEF)' book and the included Genealogy example(Draw2d chapters) seems to have the z order of figures messed up. When a figure is dragged or selected its z order remains unchanged which causes strange/unnatural behavior where the dragged figure can be dragged under other figures.

I would like to be able to change figures' z order when the figures are selected so they are moved to the top of the children list and appear at the top of the z dimension of the chart. What is the best way to do that?

4

2 回答 2

0

我发现删除图形并添加回来会搞砸事件系统,例如,如果您的意图是,当一个图形被拖动到另一个位置时,您想将该图形带到前面,拖动被中断并且您将不再获得该数字的任何事件。要将图形置于顶部,请使用以下代码:

final IFigure child = <figure you want to bring to the front>;
final IFigure parent = child.getParent();
final List children = child.getParent().getChildren();
children.remove( child );
children.add( child );
child.repaint();

这是操纵子元素的原始列表,将特定子元素移动到 z 顺序的前面。然后,重新绘制孩子以显示此更改。该解决方案是 Draw2d 特有的,与 GEF 无关。

于 2013-02-19T12:19:24.567 回答
0

The z-order of the figures in draw2d is defined either by order of addition (last figure on top) or can be set in Figure.add.

I guess the easiest (but probably not very efficient) way of doing what you want is removing the figure from the parent and adding it again. This will make it the last figure added, therefore also the top figure

于 2012-02-25T17:59:33.697 回答