Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 1280:66192d170c79
Bugfix: #179 and #198 Zoom-out will no longer work with a factor but with stacked chart extents.
flys-client/trunk@2862 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 29 Sep 2011 11:12:04 +0000 |
parents | 4668357b255e |
children | 4782c0ce9cec |
comparison
equal
deleted
inserted
replaced
1279:af6ad7522351 | 1280:66192d170c79 |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | 1 package de.intevation.flys.client.client.ui.chart; |
2 | 2 |
3 import java.util.Date; | 3 import java.util.Date; |
4 import java.util.HashMap; | 4 import java.util.HashMap; |
5 import java.util.Map; | 5 import java.util.Map; |
6 import java.util.Stack; | |
6 | 7 |
7 import com.google.gwt.core.client.GWT; | 8 import com.google.gwt.core.client.GWT; |
8 import com.google.gwt.user.client.rpc.AsyncCallback; | 9 import com.google.gwt.user.client.rpc.AsyncCallback; |
9 | 10 |
10 import com.smartgwt.client.types.Overflow; | 11 import com.smartgwt.client.types.Overflow; |
21 import de.intevation.flys.client.shared.Transform2D; | 22 import de.intevation.flys.client.shared.Transform2D; |
22 import de.intevation.flys.client.shared.model.Axis; | 23 import de.intevation.flys.client.shared.model.Axis; |
23 import de.intevation.flys.client.shared.model.ChartInfo; | 24 import de.intevation.flys.client.shared.model.ChartInfo; |
24 import de.intevation.flys.client.shared.model.Collection; | 25 import de.intevation.flys.client.shared.model.Collection; |
25 import de.intevation.flys.client.shared.model.OutputMode; | 26 import de.intevation.flys.client.shared.model.OutputMode; |
27 import de.intevation.flys.client.shared.model.ZoomObj; | |
26 import de.intevation.flys.client.client.Config; | 28 import de.intevation.flys.client.client.Config; |
27 import de.intevation.flys.client.client.event.OutputParameterChangeEvent; | 29 import de.intevation.flys.client.client.event.OutputParameterChangeEvent; |
28 import de.intevation.flys.client.client.event.OutputParameterChangeHandler; | 30 import de.intevation.flys.client.client.event.OutputParameterChangeHandler; |
29 import de.intevation.flys.client.client.event.PanEvent; | 31 import de.intevation.flys.client.client.event.PanEvent; |
30 import de.intevation.flys.client.client.event.PanHandler; | 32 import de.intevation.flys.client.client.event.PanHandler; |
87 | 89 |
88 /** Chart zoom options. */ | 90 /** Chart zoom options. */ |
89 protected int[] xrange; | 91 protected int[] xrange; |
90 protected int[] yrange; | 92 protected int[] yrange; |
91 | 93 |
92 protected double[] zoom; | 94 protected Stack<ZoomObj> zoomStack; |
95 protected double[] zoom; | |
93 | 96 |
94 | 97 |
95 /** | 98 /** |
96 * The default constructor to create a new ChartOutputTab. | 99 * The default constructor to create a new ChartOutputTab. |
97 * | 100 * |
112 left = new Canvas(); | 115 left = new Canvas(); |
113 right = new Canvas(); | 116 right = new Canvas(); |
114 xrange = new int[2]; | 117 xrange = new int[2]; |
115 yrange = new int[2]; | 118 yrange = new int[2]; |
116 zoom = new double[4]; | 119 zoom = new double[4]; |
120 zoomStack = new Stack<ZoomObj>(); | |
117 | 121 |
118 left.setBorder("1px solid black"); | 122 left.setBorder("1px solid black"); |
119 left.setWidth(THEMEPANEL_MIN_WIDTH); | 123 left.setWidth(THEMEPANEL_MIN_WIDTH); |
120 left.setMinWidth(THEMEPANEL_MIN_WIDTH); | 124 left.setMinWidth(THEMEPANEL_MIN_WIDTH); |
121 right.setWidth("*"); | 125 right.setWidth("*"); |
198 * Listens to zoom events and refreshes the current chart in such case. | 202 * Listens to zoom events and refreshes the current chart in such case. |
199 * | 203 * |
200 * @param evt The ZoomEvent that stores the coordinates for zooming. | 204 * @param evt The ZoomEvent that stores the coordinates for zooming. |
201 */ | 205 */ |
202 public void onZoom(ZoomEvent evt) { | 206 public void onZoom(ZoomEvent evt) { |
207 zoomStack.push(new ZoomObj(zoom[0], zoom[1], zoom[2], zoom[3])); | |
208 | |
203 xrange[0] = evt.getStartX(); | 209 xrange[0] = evt.getStartX(); |
204 xrange[1] = evt.getEndX(); | 210 xrange[1] = evt.getEndX(); |
205 yrange[0] = evt.getStartY(); | 211 yrange[0] = evt.getStartY(); |
206 yrange[1] = evt.getEndY(); | 212 yrange[1] = evt.getEndY(); |
207 | 213 |
323 updateChartPanel(); | 329 updateChartPanel(); |
324 } | 330 } |
325 | 331 |
326 | 332 |
327 /** | 333 /** |
328 * This method is used to zoom out. | 334 * This method is used to zoom out. Zooming out is realizied with a stacked |
329 * | 335 * logic. Initially, you cannot zoom out. For each time you start a zoom-in |
330 * @param factor The factor should be between 0-100. | 336 * action, the extent of the chart is stored and pushed onto a stack. A |
331 */ | 337 * zoom-out will now lead you to the last extent that is poped from stack. |
332 public void zoomOut(int factor) { | 338 * |
333 if (factor < 0 || factor > 100 || chartInfo == null) { | 339 */ |
334 return; | 340 public void zoomOut() { |
335 } | 341 if (!zoomStack.empty()) { |
336 | 342 zoom = zoomStack.pop().getZoom(); |
337 Axis xAxis = chartInfo.getXAxis(0); | 343 |
338 Axis yAxis = chartInfo.getYAxis(0); | 344 updateChartInfo(); |
339 | 345 updateChartPanel(); |
340 GWT.log("ZOOM X"); | 346 } |
341 double[] x = zoomAxis(xAxis, factor); | |
342 | |
343 GWT.log("ZOOM Y"); | |
344 double[] y = zoomAxis(yAxis, factor); | |
345 | |
346 zoom[0] = x[0]; | |
347 zoom[1] = x[1]; | |
348 zoom[2] = x[0]; | |
349 zoom[3] = y[1]; | |
350 | |
351 updateChartInfo(); | |
352 updateChartPanel(); | |
353 } | 347 } |
354 | 348 |
355 | 349 |
356 public double[] zoomAxis(Axis axis, int factor) { | 350 public double[] zoomAxis(Axis axis, int factor) { |
357 double min = axis.getFrom(); | 351 double min = axis.getFrom(); |