fsteeg.com | notes | tags

∞ /notes/dot-for-zest-on-eclipse-4 | 2010-07-27 | graphviz programming eclipse soc zest

DOT for Zest on Eclipse 4

Cross-posted to: https://fsteeg.wordpress.com/2010/07/27/dot-for-zest-on-eclipse-4/

I recently checked out the latest RC of the Eclipse 4.0 SDK and was excited to see that I could basically install any Helios software without issues. So I thought why not do some work on dot4zest using Eclipse 4.

I was amazed to see that Eclipse 4.0 (labeled Early Adopter Release) is already completely usable for me (even if it doesn't yet offer all the things I'm used to in the current version - perspective customization and custom key bindings are things I hit). And I really like that fresh look - a whole new Eclipse, after all these years!

So here is a quick tour of some new dot4zest features, running on Eclipse 4.

A new feature in the DOT to Zest interpreter (which now uses the Xtext switch API generated for the DOT grammar) is support for ad-hoc DOT edge definitions, without having to declare the nodes before using them in an edge, e.g.

digraph { node[label="Node"] 1->2; 2->3; 2->4 }

Also new is support for the rankdir=LR attribute in the DOT input, e.g.

digraph { rankdir=LR; 1->2; 2->3; 2->4 }

The rankdir=LR setting is supported in Zest to DOT export, too: if a Zest graph using the horizontal layout is exported to DOT and rendered with Graphviz, the direction will be correct for the result, e.g. if we hit the export button in the view above, this is opened:

If the DOT input contains features that are not yet supported in the Zest representation created by dot4zest, the import will now handle the input better and try to display the parts it can make sense of, e.g. DOT with subgraphs can be rendered with Zest, but subgraphs are ignored:

digraph { subgraph cluster_1 {1->2} subgraph cluster_2 {1->3} }

The Graphviz image export can be customized (see toggle above) to use the original DOT input instead of a DOT representation generated from the Zest graph, e.g. with the view and the input above, the export will render the subgraphs from the original DOT input:

Finally, the graph view now contains a toggle button (enabled in all screenshots above) to switch between different modes: listen to changes made to DOT graphs in workspace files and visualize them with Zest automatically (useful for programs outputting DOT or for live preview during DOT editing), or visualize only files loaded explicitly.

The dot4zest code is part of Zest (a GEF component) and available from the Tools repository. It is not available from an eclipse.org update site yet, but can be easily installed (for Eclipse 3.6 and 4.0) from the marketplace (Help > Eclipse Marketplace).