1

I am using mxGraph to create some workflows in my application. By default the zoom In factor is 1.2. I want to restrict zooming after a certain level. How can this be achieved ?

Here goes my JSNI code:

  private native void zoomInGraph(JavaScriptObject graph) /*-{
        var scale = $wnd.mxGraphView.prototype.getScale();
        if (scale != null && scale < 5){
             graph.zoomIn();
  }
         }-*/;

Everytime scale returns the value as 1. I assumed after zooming in the scale value would change. Please suggest how can I achieve it.

asdf
  • 246
  • 3
  • 12
user2368558
  • 81
  • 2
  • 6
  • Don.t know anything about JSNI, but it looks like the problem is that you're calling `getScale` on a mxGraphView prototype instead of the actual instance. It should be `graph.view.getScale()` instead. – Vsevolod Golovanov Oct 18 '17 at 11:32

2 Answers2

0

I figured out the solution to this question in Java.

@Override
public void zoomIn()
{
    mxGraphView view = graph.getView();
    double scale = view.getScale();
    if (scale > ZOOM_IN_THRESHOLD)
    { 
        // Don't zoom in past a certain point.
        return;
    }
    else
    {
        zoom(zoomFactor);
    }
}
Lucas
  • 2,514
  • 4
  • 27
  • 37
0

This is my solution in java:

void zoomIn(){
   if(scale < 5 && scale > 0)
       graph.getView.setScale(scale);
}