comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 1281:4782c0ce9cec

Re-added the function to zoom-out charts by a given factor (10%). flys-client/trunk@2863 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 29 Sep 2011 12:55:17 +0000
parents 66192d170c79
children 3904519ec161
comparison
equal deleted inserted replaced
1280:66192d170c79 1281:4782c0ce9cec
318 return computeZoom(axis, min, max); 318 return computeZoom(axis, min, max);
319 } 319 }
320 320
321 321
322 public void resetRanges() { 322 public void resetRanges() {
323 zoomStack.push(new ZoomObj(zoom[0], zoom[1], zoom[2], zoom[3]));
324
323 zoom[0] = 0d; 325 zoom[0] = 0d;
324 zoom[1] = 1d; 326 zoom[1] = 1d;
325 zoom[2] = 0d; 327 zoom[2] = 0d;
326 zoom[3] = 1d; 328 zoom[3] = 1d;
327 329
329 updateChartPanel(); 331 updateChartPanel();
330 } 332 }
331 333
332 334
333 /** 335 /**
336 * This method zooms the current chart out by a given <i>factor</i>.
337 *
338 * @param factor The factor should be between 0-100.
339 */
340 public void zoomOut(int factor) {
341 if (factor < 0 || factor > 100 || chartInfo == null) {
342 return;
343 }
344
345 zoomStack.push(new ZoomObj(zoom[0], zoom[1], zoom[2], zoom[3]));
346
347 Axis xAxis = chartInfo.getXAxis(0);
348 Axis yAxis = chartInfo.getYAxis(0);
349
350 double[] x = zoomAxis(xAxis, factor);
351 double[] y = zoomAxis(yAxis, factor);
352
353 zoom[0] = x[0];
354 zoom[1] = x[1];
355 zoom[2] = x[0];
356 zoom[3] = y[1];
357
358 updateChartInfo();
359 updateChartPanel();
360 }
361
362
363 /**
334 * This method is used to zoom out. Zooming out is realizied with a stacked 364 * This method is used to zoom out. Zooming out is realizied with a stacked
335 * logic. Initially, you cannot zoom out. For each time you start a zoom-in 365 * logic. Initially, you cannot zoom out. For each time you start a zoom-in
336 * action, the extent of the chart is stored and pushed onto a stack. A 366 * action, the extent of the chart is stored and pushed onto a stack. A
337 * zoom-out will now lead you to the last extent that is poped from stack. 367 * zoom-out will now lead you to the last extent that is poped from stack.
338 * 368 *
349 379
350 public double[] zoomAxis(Axis axis, int factor) { 380 public double[] zoomAxis(Axis axis, int factor) {
351 double min = axis.getFrom(); 381 double min = axis.getFrom();
352 double max = axis.getTo(); 382 double max = axis.getTo();
353 383
354 GWT.log("ZOOM CURRENT: " + min + " - " + max);
355
356 double add = (max - min) / 100 * factor; 384 double add = (max - min) / 100 * factor;
357 add = add < 0 ? (-1) * add : add; 385 add = add < 0 ? (-1) * add : add;
358 386
359 min -= add; 387 min -= add;
360 max += add; 388 max += add;
361
362 GWT.log("ZOOM TO: " + min + " - " + max);
363 389
364 return computeZoom(axis, min, max); 390 return computeZoom(axis, min, max);
365 } 391 }
366 392
367 393

http://dive4elements.wald.intevation.org