Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedCampaignChart.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedCampaignChart.java@821a02bbfb4e |
children | 172338b1407f |
rev | line source |
---|---|
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
1 package org.dive4elements.river.client.client.ui.minfo; |
3705
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import com.google.gwt.core.client.GWT; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import com.google.gwt.json.client.JSONNumber; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.json.client.JSONObject; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.json.client.JSONString; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import com.smartgwt.client.types.Alignment; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import com.smartgwt.client.widgets.Img; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import com.smartgwt.client.widgets.events.ResizedHandler; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import com.smartgwt.client.widgets.layout.VLayout; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
12 import org.dive4elements.river.client.client.Config; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
13 import org.dive4elements.river.client.shared.model.Artifact; |
3705
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 public class BedCampaignChart extends VLayout { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 private final Artifact artifact; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 protected Img chartImg; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 public BedCampaignChart(Artifact artifact, ResizedHandler resizeHandler) { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 super(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 this.artifact = artifact; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 this.chartImg = new Img(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 addResizedHandler(resizeHandler); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 setAlign(Alignment.CENTER); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 public void update() { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 Config config = Config.getInstance(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 String locale = config.getLocale(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 int hWidth = getWidth() - 12; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 int hHeight = getHeight() - 12; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 if ((int) (hHeight * 4f / 3) < hWidth) { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 hWidth = (int) (hHeight * 4f / 3); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 else { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 hHeight = (int) (hWidth * 3f / 4); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 String river = artifact.getArtifactDescription().getRiver(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 JSONObject jfix = new JSONObject(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 JSONObject jfilter = new JSONObject(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 JSONObject jrName = new JSONObject(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 JSONString jrValue = new JSONString(river); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 JSONObject jextent = new JSONObject(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 JSONNumber jwidth = new JSONNumber(hWidth); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 JSONNumber jheight = new JSONNumber(hHeight); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 jrName.put("name", jrValue); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 jfilter.put("river", jrName); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 jextent.put("width", jwidth); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 jextent.put("height", jheight); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 jfilter.put("extent", jextent); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 jfix.put("bed", jfilter); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 String filter = jfix.toString(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 String imgUrl = GWT.getModuleBaseURL(); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 imgUrl += "bed-km-chart"; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 imgUrl += "?locale=" + locale; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 imgUrl += "&filter=" + filter; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 if (chartImg != null && hasMember(chartImg)) { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 chartImg.setWidth(hWidth); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 chartImg.setHeight(hHeight); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 chartImg.setSrc(imgUrl); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 else { |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 chartImg = new Img(imgUrl, hWidth, hHeight); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 addMember(chartImg); |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 } |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |