Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedloadCampaignChart.java @ 3705:f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
charts.
flys-client/trunk@5444 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 12 Sep 2012 14:32:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3704:1ea53a363db4 | 3705:f84ed73311f2 |
---|---|
1 package de.intevation.flys.client.client.ui.minfo; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.google.gwt.json.client.JSONNumber; | |
5 import com.google.gwt.json.client.JSONObject; | |
6 import com.google.gwt.json.client.JSONString; | |
7 import com.smartgwt.client.types.Alignment; | |
8 import com.smartgwt.client.widgets.Img; | |
9 import com.smartgwt.client.widgets.events.ResizedHandler; | |
10 import com.smartgwt.client.widgets.layout.VLayout; | |
11 | |
12 import de.intevation.flys.client.client.Config; | |
13 import de.intevation.flys.client.shared.model.Artifact; | |
14 | |
15 public class BedloadCampaignChart extends VLayout { | |
16 | |
17 private final Artifact artifact; | |
18 | |
19 protected Img chartImg; | |
20 | |
21 public BedloadCampaignChart(Artifact artifact, ResizedHandler resizeHandler) { | |
22 super(); | |
23 | |
24 this.artifact = artifact; | |
25 this.chartImg = new Img(); | |
26 | |
27 addResizedHandler(resizeHandler); | |
28 setAlign(Alignment.CENTER); | |
29 } | |
30 | |
31 public void update() { | |
32 Config config = Config.getInstance(); | |
33 String locale = config.getLocale(); | |
34 | |
35 int hWidth = getWidth() - 12; | |
36 int hHeight = getHeight() - 12; | |
37 | |
38 if ((int) (hHeight * 4f / 3) < hWidth) { | |
39 hWidth = (int) (hHeight * 4f / 3); | |
40 } | |
41 else { | |
42 hHeight = (int) (hWidth * 3f / 4); | |
43 } | |
44 | |
45 String river = artifact.getArtifactDescription().getRiver(); | |
46 | |
47 JSONObject jfix = new JSONObject(); | |
48 JSONObject jfilter = new JSONObject(); | |
49 JSONObject jrName = new JSONObject(); | |
50 JSONString jrValue = new JSONString(river); | |
51 JSONObject jextent = new JSONObject(); | |
52 JSONNumber jwidth = new JSONNumber(hWidth); | |
53 JSONNumber jheight = new JSONNumber(hHeight); | |
54 | |
55 jrName.put("name", jrValue); | |
56 jfilter.put("river", jrName); | |
57 jextent.put("width", jwidth); | |
58 jextent.put("height", jheight); | |
59 jfilter.put("extent", jextent); | |
60 jfix.put("bedload", jfilter); | |
61 String filter = jfix.toString(); | |
62 | |
63 String imgUrl = GWT.getModuleBaseURL(); | |
64 imgUrl += "bedload-km-chart"; | |
65 imgUrl += "?locale=" + locale; | |
66 imgUrl += "&filter=" + filter; | |
67 | |
68 if (chartImg != null && hasMember(chartImg)) { | |
69 chartImg.setWidth(hWidth); | |
70 chartImg.setHeight(hHeight); | |
71 chartImg.setSrc(imgUrl); | |
72 } | |
73 else { | |
74 chartImg = new Img(imgUrl, hWidth, hHeight); | |
75 addMember(chartImg); | |
76 } | |
77 } | |
78 } |