how to zoom a graph using zest?
I am using RCP开发者_如何学Go and ZEST to create an application to visualize graphs. My question is: is it possible to zoom a graph drawn on ZEST (any ZEST or RCP api or plug-in)?
Thanks in advance -rajit
I had a look at the ZestZoomContributionViewItem and it seems to put a drop down list specifying "page width" and 200% options for zoom. I wanted to be able to use the mouse wheel to zoom in and out of my graph.
The following code will zet the zoom level to 500% on your Zest graph and give you fine grain control (it's a bit deprecated as these are internal eclipse classes.)
Graph myGraph = new Graph(parent, SWT.NONE);
ZoomManager zoomManager = new ZoomManager(
graph.getRootLayer(),
graph.getViewport() );
zoomManager.setZoomAsText("500%");
The simplest solution is to create a ZoomContributionViewItem. This item can be added to Menumanagers (in theory to toolbarmanagers also, but there is a nasty null-pointer exception related in Zest 1.1).
The constructor needs an IZoomableWorkbenchPart, where you need to provide a single method that returns the graph viewer.
If you need something more specific, look at the code of the Zest ZoomContributionViewItem code, how they had implemented it.
精彩评论