Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 1282:3904519ec161
Bugfix: #179 Repaired broken zoom-out-by-factor function for charts.
flys-client/trunk@2864 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 29 Sep 2011 14:52:29 +0000 |
parents | 4782c0ce9cec |
children | 95ecb98c6015 |
comparison
equal
deleted
inserted
replaced
1281:4782c0ce9cec | 1282:3904519ec161 |
---|---|
350 double[] x = zoomAxis(xAxis, factor); | 350 double[] x = zoomAxis(xAxis, factor); |
351 double[] y = zoomAxis(yAxis, factor); | 351 double[] y = zoomAxis(yAxis, factor); |
352 | 352 |
353 zoom[0] = x[0]; | 353 zoom[0] = x[0]; |
354 zoom[1] = x[1]; | 354 zoom[1] = x[1]; |
355 zoom[2] = x[0]; | 355 zoom[2] = y[0]; |
356 zoom[3] = y[1]; | 356 zoom[3] = y[1]; |
357 | 357 |
358 updateChartInfo(); | 358 updateChartInfo(); |
359 updateChartPanel(); | 359 updateChartPanel(); |
360 } | 360 } |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 public double[] zoomAxis(Axis axis, int factor) { | 380 public double[] zoomAxis(Axis axis, int factor) { |
381 double min = axis.getFrom(); | 381 GWT.log("Prepare Axis for zooming (factor: " + factor + ")"); |
382 double max = axis.getTo(); | 382 |
383 | 383 double min = axis.getMin(); |
384 double add = (max - min) / 100 * factor; | 384 double max = axis.getMax(); |
385 add = add < 0 ? (-1) * add : add; | 385 double range = max > min ? max - min : min - max; |
386 | 386 |
387 min -= add; | 387 double curFrom = axis.getFrom(); |
388 max += add; | 388 double curTo = axis.getTo(); |
389 | 389 |
390 return computeZoom(axis, min, max); | 390 double diff = curTo > curFrom ? curTo - curFrom : curFrom - curTo; |
391 | |
392 GWT.log(" max from : " + min); | |
393 GWT.log(" max to : " + max); | |
394 GWT.log(" max range : " + range); | |
395 GWT.log(" current from: " + curFrom); | |
396 GWT.log(" current to : " + curTo); | |
397 GWT.log(" current diff: " + diff); | |
398 | |
399 double newFrom = curFrom - (diff * factor / 100); | |
400 double newTo = curTo + (diff * factor / 100); | |
401 | |
402 GWT.log(" new from: " + newFrom); | |
403 GWT.log(" new to : " + newTo); | |
404 | |
405 return new double[] { | |
406 (newFrom - min) / range, | |
407 (newTo - min) / range | |
408 }; | |
391 } | 409 } |
392 | 410 |
393 | 411 |
394 public static double[] computeZoom(Axis axis, double min, double max) { | 412 public static double[] computeZoom(Axis axis, double min, double max) { |
395 double[] zoom = new double[2]; | 413 double[] zoom = new double[2]; |