Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java @ 281:c271012a97a3
ISSUE-15 The charts in the chart panel are requested with the size of the parent panel.
flys-client/trunk@1910 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 12 May 2011 09:59:29 +0000 |
parents | b493d606fdef |
children | 3e99953bac8d |
comparison
equal
deleted
inserted
replaced
280:b493d606fdef | 281:c271012a97a3 |
---|---|
10 import com.smartgwt.client.widgets.IButton; | 10 import com.smartgwt.client.widgets.IButton; |
11 | 11 |
12 import com.smartgwt.client.widgets.layout.HLayout; | 12 import com.smartgwt.client.widgets.layout.HLayout; |
13 import com.smartgwt.client.widgets.layout.VLayout; | 13 import com.smartgwt.client.widgets.layout.VLayout; |
14 | 14 |
15 import com.smartgwt.client.widgets.events.ClickEvent; | 15 import com.smartgwt.client.widgets.events.ClickEvent; |
16 import com.smartgwt.client.widgets.events.ClickHandler; | 16 import com.smartgwt.client.widgets.events.ClickHandler; |
17 import com.smartgwt.client.widgets.events.CloseClickHandler; | 17 import com.smartgwt.client.widgets.events.CloseClickHandler; |
18 import com.smartgwt.client.widgets.events.CloseClientEvent; | 18 import com.smartgwt.client.widgets.events.CloseClientEvent; |
19 import com.smartgwt.client.widgets.events.ResizedEvent; | |
20 import com.smartgwt.client.widgets.events.ResizedHandler; | |
19 | 21 |
20 import de.intevation.flys.client.shared.model.Collection; | 22 import de.intevation.flys.client.shared.model.Collection; |
21 import de.intevation.flys.client.shared.model.OutputMode; | 23 import de.intevation.flys.client.shared.model.OutputMode; |
22 import de.intevation.flys.client.client.Config; | 24 import de.intevation.flys.client.client.Config; |
23 | 25 |
24 import de.intevation.flys.client.shared.model.Artifact; | 26 import de.intevation.flys.client.shared.model.Artifact; |
25 | 27 |
26 /** | 28 /** |
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
28 */ | 30 */ |
29 public class ChartOutputTab extends OutputTab { | 31 public class ChartOutputTab extends OutputTab implements ResizedHandler { |
32 | |
33 public static final int DEFAULT_CHART_WIDTH = 600; | |
34 public static final int DEFAULT_CHART_HEIGHT = 500; | |
30 | 35 |
31 /** The canvas that wraps the chart toolbar.*/ | 36 /** The canvas that wraps the chart toolbar.*/ |
32 protected Canvas tbarPanel; | 37 protected Canvas tbarPanel; |
33 | 38 |
34 /** The canvas that wraps the theme editor.*/ | 39 /** The canvas that wraps the theme editor.*/ |
81 | 86 |
82 vLayout.addMember(tbarPanel); | 87 vLayout.addMember(tbarPanel); |
83 vLayout.addMember(hLayout); | 88 vLayout.addMember(hLayout); |
84 | 89 |
85 setPane(vLayout); | 90 setPane(vLayout); |
91 | |
92 right.addResizedHandler(this); | |
93 } | |
94 | |
95 | |
96 /** | |
97 * This method is called after the chart panel has resized. It removes the | |
98 * chart - if existing - and requests a new one with adjusted size. | |
99 * | |
100 * @param event The resize event. | |
101 */ | |
102 public void onResized(ResizedEvent event) { | |
103 Canvas[] children = right.getChildren(); | |
104 for (Canvas child: children) { | |
105 right.removeChild(child); | |
106 } | |
107 | |
108 right.addChild(createChartPanel(right.getWidth(), right.getHeight())); | |
86 } | 109 } |
87 | 110 |
88 | 111 |
89 protected Canvas createTBarPanel( | 112 protected Canvas createTBarPanel( |
90 final CollectionView collectionView | 113 final CollectionView collectionView |
110 return hLayout; | 133 return hLayout; |
111 } | 134 } |
112 | 135 |
113 protected void openDatacageWindow(Artifact artifact) { | 136 protected void openDatacageWindow(Artifact artifact) { |
114 final DatacageWindow dc = new DatacageWindow(artifact); | 137 final DatacageWindow dc = new DatacageWindow(artifact); |
115 dc.addCloseClickHandler(new CloseClickHandler() { | 138 dc.addCloseClickHandler(new CloseClickHandler() { |
116 public void onCloseClick(CloseClientEvent event) { | 139 public void onCloseClick(CloseClientEvent event) { |
117 dc.destroy(); | 140 dc.destroy(); |
118 } | 141 } |
119 }); | 142 }); |
120 dc.show(); | 143 dc.show(); |
121 } | 144 } |
122 | 145 |
123 | 146 |
124 protected Canvas createChartPanel() { | 147 protected Canvas createChartPanel() { |
125 Img chart = getChartImg(); | 148 return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); |
149 } | |
150 | |
151 | |
152 protected Canvas createChartPanel(int width, int height) { | |
153 Img chart = getChartImg(width, height); | |
126 chart.setWidth100(); | 154 chart.setWidth100(); |
127 chart.setHeight100(); | 155 chart.setHeight100(); |
128 | 156 |
129 return chart; | 157 return chart; |
158 | |
130 } | 159 } |
131 | 160 |
132 | 161 |
133 protected Canvas createThemeControlPanel() { | 162 protected Canvas createThemeControlPanel() { |
134 Label label = new Label("Themensteuerung"); | 163 Label label = new Label("Themensteuerung"); |
140 | 169 |
141 | 170 |
142 /** | 171 /** |
143 * Builds the chart image and returns it. | 172 * Builds the chart image and returns it. |
144 * | 173 * |
174 * @param width The chart width. | |
175 * @param height The chart height. | |
176 * | |
145 * @return the chart image. | 177 * @return the chart image. |
146 */ | 178 */ |
147 protected Img getChartImg() { | 179 protected Img getChartImg(int width, int height) { |
148 return new Img(getImgUrl()); | 180 return new Img(getImgUrl(width, height)); |
149 } | 181 } |
150 | 182 |
151 | 183 |
152 /** | 184 /** |
153 * Builds the URL that points to the chart image. | 185 * Builds the URL that points to the chart image. |
154 * | 186 * |
187 * @param width The width of the requested chart. | |
188 * @param height The height of the requested chart. | |
189 * | |
155 * @return the URL to the chart image. | 190 * @return the URL to the chart image. |
156 */ | 191 */ |
157 protected String getImgUrl() { | 192 protected String getImgUrl(int width, int height) { |
158 Config config = Config.getInstance(); | 193 Config config = Config.getInstance(); |
159 | 194 |
160 String imgUrl = GWT.getModuleBaseURL(); | 195 String imgUrl = GWT.getModuleBaseURL(); |
161 imgUrl += "chart"; | 196 imgUrl += "chart"; |
162 imgUrl += "?uuid=" + collection.identifier(); | 197 imgUrl += "?uuid=" + collection.identifier(); |
163 imgUrl += "&type=" + mode.getName(); | 198 imgUrl += "&type=" + mode.getName(); |
164 imgUrl += "&server=" + config.getServerUrl(); | 199 imgUrl += "&server=" + config.getServerUrl(); |
165 imgUrl += "&locale=" + config.getLocale(); | 200 imgUrl += "&locale=" + config.getLocale(); |
166 imgUrl += "×tamp=" + new Date().getTime(); | 201 imgUrl += "×tamp=" + new Date().getTime(); |
167 imgUrl += "&width=" + Integer.toString(600); | 202 imgUrl += "&width=" + Integer.toString(width); |
168 imgUrl += "&height=" + Integer.toString(500); | 203 imgUrl += "&height=" + Integer.toString(height); |
169 | 204 |
170 return imgUrl; | 205 return imgUrl; |
171 } | 206 } |
172 } | 207 } |
173 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 208 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |