Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Using Zest LayoutAlgorithm in Graphiti
Using Zest LayoutAlgorithm in Graphiti [message #757201] Thu, 17 November 2011 04:45 Go to next message
Patrick Talbot is currently offline Patrick TalbotFriend
Messages: 36
Registered: November 2011
Member
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,
-Patrick
Re: Using Zest LayoutAlgorithm in Graphiti [message #757698 is a reply to message #757201] Mon, 21 November 2011 09:44 Go to previous messageGo to next message
Joerg Reichert is currently offline Joerg ReichertFriend
Messages: 78
Registered: July 2009
Location: Leipzig
Member
Hi Patrick,

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.

http://wiki.eclipse.org/GEF_Zest_Visualization

Regards,
Joerg


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Re: Using Zest LayoutAlgorithm in Graphiti [message #757789 is a reply to message #757698] Mon, 21 November 2011 17:09 Go to previous messageGo to next message
Patrick Talbot is currently offline Patrick TalbotFriend
Messages: 36
Registered: November 2011
Member
Thanks for your reply Joerg!

In the end I did it a little bit differently, using the LayoutAlgorithmn applyLayout method directly. This works very nicely though.

See attached my implementation in case others are interested.

Best,
-Patrick
Re: Using Zest LayoutAlgorithm in Graphiti [message #758573 is a reply to message #757789] Wed, 23 November 2011 17:56 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 360
Registered: July 2009
Location: Dortmund
Senior Member

Hi Patrick!

This looks promising. I will try to use your layout feature in my current project, and if it is like I expect, I would like to add it to the Spray project.

~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Using Zest LayoutAlgorithm in Graphiti [message #758628 is a reply to message #758573] Wed, 23 November 2011 23:41 Go to previous message
Patrick Talbot is currently offline Patrick TalbotFriend
Messages: 36
Registered: November 2011
Member
No problem, go ahead.

You will probably have to add some check of instanceof Connection: in my case I'm using FreeFormConnection so I didn't code for ManhattanConnection, but it should be easy to change.
Previous Topic:Best practice for own Shapes?
Next Topic:Text foreground color always red?
Goto Forum:
  


Current Time: Wed Dec 17 23:16:41 GMT 2014

Powered by FUDForum. Page generated in 0.05011 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software