Of course you can, let me explain how to achieve both of your goals:
GEF/Draw2d uses distinct layers for shapes/connections, they are identified respectively by LayerConstants.PRIMARY_LAYER
and LayerConstants.CONNECTION_LAYER
constants. You can change the Z-order between shapes and connections by changing the order their layers are added to the LayeredPane
in your RootEditPart
.
As an example, override ScalableRootEditPart.createPrintableLayers()
the following way to invert layer drawing:
protected LayeredPane createPrintableLayers() {
LayeredPane pane = new LayeredPane();
Layer layer = new ConnectionLayer();
layer.setPreferredSize(new Dimension(5, 5));
pane.add(layer, CONNECTION_LAYER);
layer = new Layer();
layer.setLayoutManager(new StackLayout());
pane.add(layer, PRIMARY_LAYER);
return pane;
}
To achieve your second goal, you have to modify the connections paint algorithm by overriding the ConnectionLayer.paintChidren()
because all the connection figures are child figure of the ConnectionLayer
(note that the default implementation inherits from Figure.paintChidren()
).
I suggest you to add an integer Z-order property to the connection figures (those created by your connection parts) to be used by the algorithm to actually paint them in the correct order. Then implement in your connection parts the relative ordering strategy, which will have the responsibility to update the Z-order property in their respective figures.