comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 542:7c57149e8715

Append the x and y ranges determined after zooming with the ZoomboxControl to the attribute document used for the chart creation. flys-client/trunk@2045 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Jun 2011 06:34:32 +0000
parents ed29599e06e5
children 9c2cf4811a7d
comparison
equal deleted inserted replaced
541:ed29599e06e5 542:7c57149e8715
39 public static final int DEFAULT_CHART_HEIGHT = 500; 39 public static final int DEFAULT_CHART_HEIGHT = 500;
40 40
41 public static final int THEMEPANEL_MIN_WIDTH = 200; 41 public static final int THEMEPANEL_MIN_WIDTH = 200;
42 42
43 43
44
45 /** The service that is used to fetch chart information.*/ 44 /** The service that is used to fetch chart information.*/
46 protected ChartInfoServiceAsync info = GWT.create(ChartInfoService.class); 45 protected ChartInfoServiceAsync info = GWT.create(ChartInfoService.class);
47 46
48 /** The transformer used to transform image pixels into chart coordinates.*/ 47 /** The transformer used to transform image pixels into chart coordinates.*/
49 protected Transform2D transformer; 48 protected Transform2D transformer;
58 /** The canvas that wraps the theme editor.*/ 57 /** The canvas that wraps the theme editor.*/
59 protected Canvas left; 58 protected Canvas left;
60 59
61 /** The canvas that wraps the chart.*/ 60 /** The canvas that wraps the chart.*/
62 protected Canvas right; 61 protected Canvas right;
62
63
64 /** Chart zoom options.*/
65 protected double[] xrange;
66 protected double[] yrange;
63 67
64 68
65 /** 69 /**
66 * The default constructor to create a new ChartOutputTab. 70 * The default constructor to create a new ChartOutputTab.
67 * 71 *
79 83
80 view = collectionView; 84 view = collectionView;
81 left = new Canvas(); 85 left = new Canvas();
82 right = new Canvas(); 86 right = new Canvas();
83 tbarPanel = new ChartToolbar(collectionView, this); 87 tbarPanel = new ChartToolbar(collectionView, this);
88 xrange = new double[2];
89 yrange = new double[2];
84 90
85 left.setBorder("1px solid black"); 91 left.setBorder("1px solid black");
86 left.setWidth(THEMEPANEL_MIN_WIDTH); 92 left.setWidth(THEMEPANEL_MIN_WIDTH);
87 left.setMinWidth(THEMEPANEL_MIN_WIDTH); 93 left.setMinWidth(THEMEPANEL_MIN_WIDTH);
88 right.setWidth("*"); 94 right.setWidth("*");
143 */ 149 */
144 public void onZoom(ZoomEvent evt) { 150 public void onZoom(ZoomEvent evt) {
145 double[] lower = transformer.transform(evt.getStartX(), evt.getStartY()); 151 double[] lower = transformer.transform(evt.getStartX(), evt.getStartY());
146 double[] upper = transformer.transform(evt.getEndX(), evt.getEndY()); 152 double[] upper = transformer.transform(evt.getEndX(), evt.getEndY());
147 153
148 double xmin = lower[0]; 154 xrange[0] = lower[0];
149 double xmax = upper[0]; 155 xrange[1] = upper[0];
150 double ymin = upper[1]; 156 yrange[0] = upper[1];
151 double ymax = lower[1]; 157 yrange[1] = lower[1];
152 158
153 // TODO Trigger the recreation of the chart 159 updateChartPanel();
154 } 160 }
155 161
156 162
157 /** 163 /**
158 * Updates the Transform2D object using the chart info service. 164 * Updates the Transform2D object using the chart info service.
191 197
192 right.addChild(createChartPanel(right.getWidth(), right.getHeight())); 198 right.addChild(createChartPanel(right.getWidth(), right.getHeight()));
193 } 199 }
194 200
195 201
202 /**
203 * Returns the existing chart panel.
204 *
205 * @return the existing chart panel.
206 */
196 public Canvas getChartPanel() { 207 public Canvas getChartPanel() {
197 Canvas[] children = right.getChildren(); 208 Canvas[] children = right.getChildren();
198 209
199 if (children == null || children.length == 0) { 210 if (children == null || children.length == 0) {
200 GWT.log("=> No chart image in the panel."); 211 GWT.log("=> No chart image in the panel.");
225 protected void setTransformer(Transform2D transformer) { 236 protected void setTransformer(Transform2D transformer) {
226 this.transformer = transformer; 237 this.transformer = transformer;
227 } 238 }
228 239
229 240
241 /**
242 * Creates a new chart panel with default size.
243 *
244 * @return the created chart panel.
245 */
230 protected Canvas createChartPanel() { 246 protected Canvas createChartPanel() {
231 return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); 247 return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT);
232 } 248 }
233 249
234 250
251 /**
252 * Creates a new chart panel with specified width and height.
253 *
254 * @param width The width for the chart panel.
255 * @param height The height for the chart panel.
256 *
257 * @return the created chart panel.
258 */
235 protected Canvas createChartPanel(int width, int height) { 259 protected Canvas createChartPanel(int width, int height) {
236 Img chart = getChartImg(width, height); 260 Img chart = getChartImg(width, height);
237 chart.setWidth100(); 261 chart.setWidth100();
238 chart.setHeight100(); 262 chart.setHeight100();
239 263
240 return chart; 264 return chart;
241
242 } 265 }
243 266
244 267
245 /** 268 /**
246 * Builds the chart image and returns it. 269 * Builds the chart image and returns it.
258 /** 281 /**
259 * Builds the URL that points to the chart image. 282 * Builds the URL that points to the chart image.
260 * 283 *
261 * @param width The width of the requested chart. 284 * @param width The width of the requested chart.
262 * @param height The height of the requested chart. 285 * @param height The height of the requested chart.
286 * @param xr Optional x range (used for zooming).
287 * @param yr Optional y range (used for zooming).
263 * 288 *
264 * @return the URL to the chart image. 289 * @return the URL to the chart image.
265 */ 290 */
266 protected String getImgUrl(int width, int height) { 291 protected String getImgUrl(int width, int height) {
267 Config config = Config.getInstance(); 292 Config config = Config.getInstance();
274 imgUrl += "&locale=" + config.getLocale(); 299 imgUrl += "&locale=" + config.getLocale();
275 imgUrl += "&timestamp=" + new Date().getTime(); 300 imgUrl += "&timestamp=" + new Date().getTime();
276 imgUrl += "&width=" + Integer.toString(width); 301 imgUrl += "&width=" + Integer.toString(width);
277 imgUrl += "&height=" + Integer.toString(height); 302 imgUrl += "&height=" + Integer.toString(height);
278 303
304 if (xrange != null) {
305 GWT.log("Zoom to xrange.");
306 imgUrl += "&minx=" + Double.toString(xrange[0]);
307 imgUrl += "&maxx=" + Double.toString(xrange[1]);
308 }
309
310 if (yrange != null) {
311 GWT.log("Zoom to xrange.");
312 imgUrl += "&miny=" + Double.toString(yrange[0]);
313 imgUrl += "&maxy=" + Double.toString(yrange[1]);
314 }
315
279 return imgUrl; 316 return imgUrl;
280 } 317 }
281 } 318 }
282 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 319 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org