Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedloadCampaignChart.java @ 4205:0dd8963cec9c
Set also the width of the GaugeTree when resizing the GaugePanel
GWT is no longer able to calculate and set the correct width of the GaugeTree since
the GaugeTree is added via a Canvas wrapper. Therefore set the width manually
when resizing the GaugeTree.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 22 Oct 2012 15:33:16 +0200 |
parents | f84ed73311f2 |
children |
rev | line source |
---|---|
3705
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui.minfo; |
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 |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.client.client.Config; |
f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.client.shared.model.Artifact; |
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 BedloadCampaignChart 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 BedloadCampaignChart(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("bedload", 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 += "bedload-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 } |