I'm currently working on a project where I have a need to segment a graph into different groups of nodes. Each group of node should be tightly knitted together and be able to connect to the other groups nodes. I found that Graph Containers would be able to do this for me.
Another part of this project is that each node should be able to be customized with a specific image, thus I am using Custom Nodes.
Now the problem I'm having is when populating the Graph Container with Custom Nodes the nodes get odd characteristics i.e. some nodes become unusually large and none of the custom nodes seem to become part of the Graph Container but rather float freely outside the container.
Is this a known issue or could there be a problem with my code?
My first issue was caused by a problem with my own code, simple mistake.
The second however I have tracked down to being caused in one of the constructors of GraphNode. The one I'm using is the one which takes IContainer, Style and IFugure. CGraphNode delegates this up to GraphNode which in turn delegates this up as well. But, GraphNode, instead of passing the graph (IContainer object) it takes container.getGraph() and thus use the underlying graph instead of the container. This would explain my behavior, the custom graph node becomes a part of the graph not the container .
I find this a bit odd however, is there a bug which this works around or is there some other issue which would explain this implementation?
I don't know the exact answer to your question (I was not too much connected to Zest when the containers were implemented), but I know this implementation dates to much later than the rest of Zest, and was about halfway to finish (e.g., the JFace Viewers only supported a *single* level of containment nesting).
I would guess, in some places to code assumed its container was the Graph itself, and this assumption was not thoroughly removed from the system.
I am sorry I cannot help you anymore about this,
I suppose it is not important as to the why, just got me curious once I found it I guess.
Anyway, I managed to get this working by migrating to Zest 2.0. The CGraphNode's are now displayed properly but this led to realize I probably can't use the GraphContainer for my intended use.
I want to be able to hold a group of GraphNodes at a fixed position in relation to each others but still be affected by the Graphs' LayoutAlgorithm as one object. This is why I felt GraphContainers would do well for me.
The problem is the GraphContainer adds a lot of things which cause problems for my needs.
All I really want in terms of displaying the nodes is a fixed object which the nodes relate to, perhaps a rectangle. And the could perhaps be a CGraphNode or Container as a part of the Graph.
I get a feeling I need to create a custom GraphContainer but I am fairly new to Zest and perhaps there is a much simple way that I'm unaware of.