Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/sq/SQMultiPeriodPanel.java @ 2953:75e9eab05ee4
Added overview chart to sq relation period input panel.
flys-client/trunk@4932 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 11 Jul 2012 11:24:27 +0000 |
parents | |
children | b7aab14310cb |
comparison
equal
deleted
inserted
replaced
2952:3cacd42a0336 | 2953:75e9eab05ee4 |
---|---|
1 package de.intevation.flys.client.client.ui.sq; | |
2 | |
3 import com.google.gwt.json.client.JSONObject; | |
4 import com.google.gwt.json.client.JSONNumber; | |
5 import com.google.gwt.json.client.JSONString; | |
6 | |
7 import com.google.gwt.core.client.GWT; | |
8 | |
9 import com.smartgwt.client.types.Alignment; | |
10 | |
11 import com.smartgwt.client.widgets.Img; | |
12 import com.smartgwt.client.widgets.Canvas; | |
13 import com.smartgwt.client.widgets.layout.VLayout; | |
14 import com.smartgwt.client.widgets.events.ResizedHandler; | |
15 import com.smartgwt.client.widgets.events.ResizedEvent; | |
16 | |
17 import de.intevation.flys.client.client.ui.MultiPeriodPanel; | |
18 | |
19 import de.intevation.flys.client.shared.model.DataList; | |
20 | |
21 import de.intevation.flys.client.client.Config; | |
22 /** | |
23 * This UIProvider creates helper panel for sq relation. | |
24 * | |
25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
26 */ | |
27 public class SQMultiPeriodPanel | |
28 extends MultiPeriodPanel | |
29 implements ResizedHandler | |
30 { | |
31 protected VLayout chartContainer; | |
32 | |
33 protected Img chartImg; | |
34 | |
35 public SQMultiPeriodPanel() { | |
36 chartImg = new Img(); | |
37 } | |
38 | |
39 | |
40 protected Canvas createHelper() { | |
41 Config config = Config.getInstance(); | |
42 String locale = config.getLocale (); | |
43 | |
44 chartContainer = new VLayout(); | |
45 chartContainer.addResizedHandler(this); | |
46 chartContainer.setAlign(Alignment.CENTER); | |
47 | |
48 return chartContainer; | |
49 } | |
50 | |
51 | |
52 protected void updateChart() { | |
53 Config config = Config.getInstance(); | |
54 String locale = config.getLocale (); | |
55 | |
56 int hWidth = chartContainer.getWidth() - 12; | |
57 int hHeight = chartContainer.getHeight() - 12; | |
58 | |
59 if ((int)(hHeight *4f/3) < hWidth) { | |
60 hWidth = (int)(hHeight * 4f/3); | |
61 } | |
62 else { | |
63 hHeight = (int)(hWidth *3f/4); | |
64 } | |
65 String river = artifact.getArtifactDescription().getRiver(); | |
66 | |
67 JSONObject jfix = new JSONObject(); | |
68 JSONObject jfilter = new JSONObject(); | |
69 JSONObject jrName = new JSONObject(); | |
70 JSONString jrValue = new JSONString(river); | |
71 JSONObject jextent = new JSONObject(); | |
72 JSONNumber jwidth = new JSONNumber(hWidth); | |
73 JSONNumber jheight = new JSONNumber(hHeight); | |
74 | |
75 jrName.put("name", jrValue); | |
76 jfilter.put("river", jrName); | |
77 jextent.put("width", jwidth); | |
78 jextent.put("height", jheight); | |
79 jfilter.put("extent", jextent); | |
80 jfix.put("sq", jfilter); | |
81 String filter = jfix.toString(); | |
82 | |
83 String imgUrl = GWT.getModuleBaseURL(); | |
84 imgUrl += "sq-km-chart"; | |
85 imgUrl += "?locale=" + locale; | |
86 imgUrl += "&filter=" + filter; | |
87 if (chartContainer.hasMember(chartImg)) { | |
88 chartImg.setWidth(hWidth); | |
89 chartImg.setHeight(hHeight); | |
90 chartImg.setSrc(imgUrl); | |
91 } | |
92 else { | |
93 chartImg = new Img(imgUrl, hWidth, hHeight); | |
94 chartContainer.addMember(chartImg); | |
95 } | |
96 } | |
97 | |
98 | |
99 public void onResized(ResizedEvent re) { | |
100 updateChart(); | |
101 } | |
102 } |