3

I am using RCP 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

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
rajit
  • 31
  • 2

2 Answers2

2

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%");
Will
  • 6,179
  • 4
  • 31
  • 49
1

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.

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37