comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 552:6050d49eaba3

Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar. flys-client/trunk@2066 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 07 Jun 2011 13:26:24 +0000
parents e74bf6bfeeb6
children 33b86f5b1168
comparison
equal deleted inserted replaced
551:13c7f90917fc 552:6050d49eaba3
15 15
16 import com.smartgwt.client.widgets.events.ResizedEvent; 16 import com.smartgwt.client.widgets.events.ResizedEvent;
17 import com.smartgwt.client.widgets.events.ResizedHandler; 17 import com.smartgwt.client.widgets.events.ResizedHandler;
18 18
19 import de.intevation.flys.client.shared.Transform2D; 19 import de.intevation.flys.client.shared.Transform2D;
20 import de.intevation.flys.client.shared.model.Axis;
21 import de.intevation.flys.client.shared.model.ChartInfo;
20 import de.intevation.flys.client.shared.model.Collection; 22 import de.intevation.flys.client.shared.model.Collection;
21 import de.intevation.flys.client.shared.model.OutputMode; 23 import de.intevation.flys.client.shared.model.OutputMode;
22 import de.intevation.flys.client.client.Config; 24 import de.intevation.flys.client.client.Config;
23 import de.intevation.flys.client.client.event.OutputParameterChangeEvent; 25 import de.intevation.flys.client.client.event.OutputParameterChangeEvent;
24 import de.intevation.flys.client.client.event.OutputParameterChangeHandler; 26 import de.intevation.flys.client.client.event.OutputParameterChangeHandler;
27 import de.intevation.flys.client.client.event.PanEvent;
28 import de.intevation.flys.client.client.event.PanHandler;
25 import de.intevation.flys.client.client.event.ZoomEvent; 29 import de.intevation.flys.client.client.event.ZoomEvent;
26 import de.intevation.flys.client.client.event.ZoomHandler; 30 import de.intevation.flys.client.client.event.ZoomHandler;
27 import de.intevation.flys.client.client.services.ChartInfoService; 31 import de.intevation.flys.client.client.services.ChartInfoService;
28 import de.intevation.flys.client.client.services.ChartInfoServiceAsync; 32 import de.intevation.flys.client.client.services.ChartInfoServiceAsync;
29 import de.intevation.flys.client.client.ui.CollectionView; 33 import de.intevation.flys.client.client.ui.CollectionView;
33 /** 37 /**
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 38 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
35 */ 39 */
36 public class ChartOutputTab 40 public class ChartOutputTab
37 extends OutputTab 41 extends OutputTab
38 implements ResizedHandler, OutputParameterChangeHandler, ZoomHandler 42 implements ResizedHandler, OutputParameterChangeHandler, ZoomHandler,
43 PanHandler
39 { 44 {
40 public static final int DEFAULT_CHART_WIDTH = 600; 45 public static final int DEFAULT_CHART_WIDTH = 600;
41 public static final int DEFAULT_CHART_HEIGHT = 500; 46 public static final int DEFAULT_CHART_HEIGHT = 500;
42 47
43 public static final int THEMEPANEL_MIN_WIDTH = 200; 48 public static final int THEMEPANEL_MIN_WIDTH = 200;
44 49
45 50
46 /** The service that is used to fetch chart information.*/ 51 /** The service that is used to fetch chart information.*/
47 protected ChartInfoServiceAsync info = GWT.create(ChartInfoService.class); 52 protected ChartInfoServiceAsync info = GWT.create(ChartInfoService.class);
53
54
55 /** The ChartInfo object that provides information about the current
56 * chart.*/
57 protected ChartInfo chartInfo;
48 58
49 /** The transformer used to transform image pixels into chart coordinates.*/ 59 /** The transformer used to transform image pixels into chart coordinates.*/
50 protected Transform2D transformer; 60 protected Transform2D transformer;
51 61
52 /** The collection view.*/ 62 /** The collection view.*/
161 updateTransformer(); 171 updateTransformer();
162 updateChartPanel(); 172 updateChartPanel();
163 } 173 }
164 174
165 175
176 public void onPan(PanEvent event) {
177 int[] start = event.getStartPos();
178 int[] end = event.getEndPos();
179
180 double[] startPos = transformer.transform(start[0], start[1]);
181 double[] endPos = transformer.transform(end[0], end[1]);
182
183 double diffX = startPos[0] - endPos[0];
184 double diffY = startPos[1] - endPos[1];
185
186 panTo(diffX, diffY);
187 }
188
189
190 /**
191 * This method pans to chart with a given factor.
192 */
193 public void panTo(double diffX, double diffY) {
194 Axis xAxis = chartInfo.getXAxis(0);
195 Axis yAxis = chartInfo.getYAxis(0);
196
197 xrange[0] = xAxis.getFrom() + diffX;
198 xrange[1] = xAxis.getTo() + diffX;
199 yrange[0] = yAxis.getFrom() + diffY;
200 yrange[1] = yAxis.getTo() + diffY;
201
202 updateTransformer();
203 updateChartPanel();
204 }
205
206
166 public void resetRanges() { 207 public void resetRanges() {
167 xrange[0] = 0; 208 xrange[0] = 0;
168 xrange[1] = 0; 209 xrange[1] = 0;
169 yrange[0] = 0; 210 yrange[0] = 0;
170 yrange[1] = 0; 211 yrange[1] = 0;
171 212
213 updateTransformer();
172 updateChartPanel(); 214 updateChartPanel();
173 } 215 }
174 216
175 217
176 /** 218 /**
189 xrange[0] -= xadd; 231 xrange[0] -= xadd;
190 xrange[1] += xadd; 232 xrange[1] += xadd;
191 yrange[0] -= yadd; 233 yrange[0] -= yadd;
192 yrange[1] += yadd; 234 yrange[1] += yadd;
193 235
236 updateTransformer();
194 updateChartPanel(); 237 updateChartPanel();
195 } 238 }
196 239
197 240
198 /** 241 /**
207 view.getCollection(), 250 view.getCollection(),
208 url, 251 url,
209 locale, 252 locale,
210 mode.getName(), 253 mode.getName(),
211 getChartAttributes(), 254 getChartAttributes(),
212 new AsyncCallback<Transform2D>() { 255 new AsyncCallback<ChartInfo>() {
213 public void onFailure(Throwable caught) { 256 public void onFailure(Throwable caught) {
214 GWT.log("ERROR: " + caught.getMessage()); 257 GWT.log("ERROR: " + caught.getMessage());
215 } 258 }
216 259
217 public void onSuccess(Transform2D transformer) { 260 public void onSuccess(ChartInfo chartInfo) {
218 setTransformer(transformer); 261 setChartInfo(chartInfo);
219 } 262 }
220 }); 263 });
221 } 264 }
222 265
223 266
243 GWT.log("=> No chart image in the panel."); 286 GWT.log("=> No chart image in the panel.");
244 return right; 287 return right;
245 } 288 }
246 289
247 return children[0]; 290 return children[0];
291 }
292
293
294 public ChartInfo getChartInfo() {
295 return chartInfo;
296 }
297
298
299 protected void setChartInfo(ChartInfo chartInfo) {
300 this.chartInfo = chartInfo;
301 setTransformer(chartInfo.getTransformer());
248 } 302 }
249 303
250 304
251 /** 305 /**
252 * Returns the Transform2D object used to transform image coordinates into 306 * Returns the Transform2D object used to transform image coordinates into

http://dive4elements.wald.intevation.org