Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Multiple connection layers
Multiple connection layers [message #661077] Tue, 22 March 2011 21:49 Go to next message
Shab  is currently offline Shab
Messages: 2
Registered: March 2011
Junior Member
GEF default display architecture puts all the connections in one layer, the connection layer, which is on top of a primary layer that contains all the component figures.

My problem is that my model uses components, containers and subcontainers. Connections can be made between any components, whether they are in containers or not. So, basically I have connections that should be displayed on top of those containers and others that should be partly hidden by containers.

A unique connection layer doesn't let me display such a model, so I tried to build a layered pane like this:
- primary layer 1
- connection layer 1
- primary layer 2
- connection layer 2
...

And failed! Maybe it's the appropriate solution but I need advice on the right way to achieve it.

Did anyone find solutions to such a problem? This kind of question has been asked years ago but they haven't been answered, or people talked about connection routers and other unrelated topics.

If someone could point me to an open source project which achieved that, that would be fine too...
Re: Multiple connection layers [message #661492 is a reply to message #661077] Thu, 24 March 2011 18:06 Go to previous messageGo to next message
Jens von Pilgrim is currently offline Jens von Pilgrim
Messages: 293
Registered: July 2009
Senior Member
Hi,

I have implemented multiple connection layers in GEF3D.

Some background information: In GEF3D, each embedded 2D diagram is
"projected" onto a plane. The connections of each 2D diagram are to be
added to a connection layer specific to a single 2D diagram. 3D
connections are added to a 3D connection layer. In GEF3D I needed the
multiple connection layers mainly for rendering purposes, because the 2D
content was rendered on textures and then only projected onto 3D
surfaces (this has changed meanwhile, that is 2D content is rendered 3D
as well, but we still use multiple connectoin layers).

So, how do we do it in GEF3D: Since everything in GEF assumes only a
single connection layer to be present, GEF3D provides a so called
"DispatchingConnectionLayer". This is the single connection layer, and
all GEF classes only "see" this one layer. This layer manages a
collection of sub-connection layers. When a new connection is added to
the DispatchingConnectionLayer, it is (usually) not added to the
DispatchingConnectionLayer itself, but instead dispatched, that is,
added to a sub-layer. Note that the sub-layer is not a (contained) child
of the DispatchingConnectionLayer, but a child of some other element in
the figure tree.

The sub-layers are (in case of GEF3D) children of the 2D diagrams, but I
think you could use any other figure. In order to dispatch a new
connection to a sub-layer, the DispatchingConnectionLayer needs at least
one end of the connection to be set in order to retrieve the appropriate
sub-layer: The path from the connection end to the root of the figure
tree then has to contain one figure providing the sub-layer (you can use
a interface for marking such a figure). If you can derive the sub-layer
otherwise (e.g. by analyzing the connection type), it would make things
easier.

You may run into problems when a connection is connecting two nodes
related to different sublayers. In that case you have to find a solution
(e.g. by using the DispatchingConnectionLayer itself as top-level
layer). Another problem is that when the connection is added, it is
maybe not connected to any node at all. In this case, you cannot
determine the sublayer (assuming you use the strategy implemented in
GEF3D). In GEF3D I solved that problem by adding the connection to a
"pending" list, and when a node is attached to an end, is gets dispatched.

You maybe want to look into the DispatchingConnectionLayer, it is found
in the GEF3D svn repository at:

https://dev.eclipse.org/svnroot/technology/org.eclipse.gef3d /trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Dispat chingConnectionLayer.java

(Or simply checkout plugin org.eclipse.draw3d from there)
The GMF-enabled version DispatchingConnectionLayerEx can be found at:

https://dev.eclipse.org/svnroot/technology/org.eclipse.gef3d /trunk/org.eclipse.gef3d.gmf/src/java/org/eclipse/gef3d/gmf/ runtime/draw2d/ui/internal/figures/ConnectionLayerEx/Dispatc hingConnectionLayerEx.java

Cheers,

Jens
Re: Multiple connection layers [message #661514 is a reply to message #661492] Thu, 24 March 2011 22:35 Go to previous message
Shab  is currently offline Shab
Messages: 2
Registered: March 2011
Junior Member
First of all, thank you for your detailed and very interesting answer.

When I posted earlier, I'd been struggling on this for a few days already, but a day later I finally managed to make my solution work. As I described in the first post, I created component layers and connection layers on top of each other. So, on one hand I have the edit part structure matching my model, and on the other hand the figure tree which doesn't go deeper than one level, as every new container would provoke the creation of 2 layers (component and connection) in the printable layer pane, instead of continuously adding children to children...

As you say, issues like connections with source and target nodes in different layers were a bit tricky to handle (my solution was simply to put the connection figure in the "highest" layer by comparing the layers where the source and target lie). Updating the figure tree requires a way to find the layers containing the different nodes and to make the modification at the appropriate moment, as model parenting and figure parenting are two different beasts.

As for the connection dispatching layer solution, I will certainly take a look at GEF3D and see by how far it's better!

On a side note, I found many projects that use GEF (such as Papyrus and Unimod) which suffer from this one connection layer paradigm. I hope the GEF developers will find a way to make it easier in the future to use multiple connection layers.
Previous Topic:Polyline Edit
Next Topic:Show selection when a connection is selected
Goto Forum:
  


Current Time: Wed Jul 30 23:38:53 EDT 2014

Powered by FUDForum. Page generated in 0.01664 seconds