Reputation: 81
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.
Upvotes: 1
Views: 2353
Reputation: 309
This is my solution in java:
void zoomIn(){
if(scale < 5 && scale > 0)
graph.getView.setScale(scale);
}
Upvotes: 0
Reputation: 2652
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);
}
}
Upvotes: 0