Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/widgets/DischargeTablesChart.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/widgets/DischargeTablesChart.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.client.client.widgets; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.smartgwt.client.widgets.Canvas; | |
5 import com.smartgwt.client.widgets.Img; | |
6 import com.smartgwt.client.widgets.events.ResizedEvent; | |
7 import com.smartgwt.client.widgets.events.ResizedHandler; | |
8 | |
9 import org.dive4elements.river.client.shared.model.Artifact; | |
10 import org.dive4elements.river.client.shared.model.ArtifactDescription; | |
11 | |
12 | |
13 public class DischargeTablesChart extends Canvas implements ResizedHandler { | |
14 | |
15 protected Artifact artifact; | |
16 | |
17 protected Img img; | |
18 | |
19 public DischargeTablesChart() { | |
20 super(); | |
21 } | |
22 | |
23 public DischargeTablesChart(Artifact artifact) { | |
24 super(); | |
25 this.artifact = artifact; | |
26 init(); | |
27 } | |
28 | |
29 private void init() { | |
30 addChild(createImage()); | |
31 addResizedHandler(this); | |
32 setSize("100%", "100%"); | |
33 } | |
34 | |
35 protected Img createImage() { | |
36 img = new Img(getUrl()); | |
37 img.setSize("100%", "100%"); | |
38 | |
39 return img; | |
40 } | |
41 | |
42 protected String getUrl() { | |
43 String url = GWT.getModuleBaseURL(); | |
44 url += "dischargetablesoverview"; | |
45 url += "?gauge=" + getGauge(); | |
46 url += "&format=png"; | |
47 | |
48 String[] timerange = getTimerange(); | |
49 url += "&lower=" + timerange[0]; | |
50 url += "&upper=" + timerange[1]; | |
51 | |
52 int width = 600; | |
53 int height = 400; | |
54 if (img != null) { | |
55 width = img.getWidth(); | |
56 height = img.getHeight(); | |
57 } | |
58 | |
59 url += "&width=" + String.valueOf(width); | |
60 url += "&height=" + String.valueOf(height); | |
61 | |
62 // add time millis to 'deactivate' caching | |
63 url += "&timemillis" + System.currentTimeMillis(); | |
64 | |
65 GWT.log("DischargeTablesService URL = '" + url + "'"); | |
66 return url; | |
67 } | |
68 | |
69 protected String getGauge() { | |
70 ArtifactDescription desc = artifact.getArtifactDescription(); | |
71 return desc.getReferenceGauge(); | |
72 } | |
73 | |
74 protected String[] getTimerange() { | |
75 ArtifactDescription desc = artifact.getArtifactDescription(); | |
76 String yearStr = desc.getDataValueAsString("year_range"); | |
77 | |
78 if (yearStr != null && yearStr.length() > 0) { | |
79 return yearStr.split(";"); | |
80 } | |
81 | |
82 return new String[2]; | |
83 } | |
84 | |
85 @Override | |
86 public void onResized(ResizedEvent event) { | |
87 GWT.log("resized discharge tables overview chart"); | |
88 img.setSrc(getUrl()); | |
89 } | |
90 } |