|Re: Multiple connection layers [message #661492 is a reply to message #661077]
||Thu, 24 March 2011 22:06
|| Jens von Pilgrim
Registered: July 2009
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
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
|Re: Multiple connection layers [message #661514 is a reply to message #661492]
||Fri, 25 March 2011 02:35
Registered: March 2011
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.
Powered by FUDForum
. Page generated in 0.01607 seconds