|Using Zest LayoutAlgorithm in Graphiti [message #757201]
||Thu, 17 November 2011 04:45
| Patrick Talbot
Registered: November 2011
I am new to Graphiti and like it a lot so far.|
Please excuse me if this topic was already addressed somewhere, I couldn't find anything though in the tutorial nor on this forum...
I would like to use Zest's LayoutAlgorithm in an auto layout Feature in Graphiti.
I've seen the FAQ about integrating an arbitrary automatic layouter and have tested the TutorialLayoutDiagramFeature, but I'm unsure how this relates to Zest LayoutAlgorithmn.
Will I have to create an offscreen GraphViewer and layout my elements there, getting back the coordinates to feed the Graphiti Diagram? Or is there any way to use LayoutAlgorithmn directly in Graphiti?
Has anyone here ever achieved something like that and if so, could you tell me more?
Any pointers will be greatly appreciated!
Thanks in advance,
|Re: Using Zest LayoutAlgorithm in Graphiti [message #757698 is a reply to message #757201]
||Mon, 21 November 2011 09:44
| Joerg Reichert
Registered: July 2009
I think you have to map
* the org.eclipse.graphiti.mm.pictograms.Diagram to org.to the org.eclipse.draw2d.graph.CompoundDirectedGraph, like shown in the TutorialLayoutDiagramFeature.java
* map the org.eclipse.draw2d.graph.CompoundDirectedGraph to org.eclipse.zest.core.widgets.Graph
* org.eclipse.draw2d.graph.Node -> org.eclipse.zest.core.widgets.GraphNode
* org.eclipse.draw2d.graph.Edge -> org.eclipse.zest.core.widgets.GraphConnection
* apply the Zest layout algorithm, e.g.
graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
* map the org.eclipse.zest.core.widgets.Graph back to org.eclipse.draw2d.graph.CompoundDirectedGraph
* map the org.eclipse.draw2d.graph.CompoundDirectedGraph back to org.eclipse.graphiti.mm.pictograms.Diagram
I think you can even skip the mapping to CompoundDirectedGraph and map the Diagram directly to Graph, as org.eclipse.zest.core.widgets.GraphNode has a method getLocation() : Point, where you can map the coordinates.
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Powered by FUDForum
. Page generated in 0.02085 seconds