Mercurial > dive4elements > river
changeset 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 | e92f7ef455d6 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java |
diffstat | 2 files changed, 57 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu May 12 09:14:46 2011 +0000 +++ b/flys-client/ChangeLog Thu May 12 09:59:29 2011 +0000 @@ -1,3 +1,11 @@ +2011-05-12 Ingo Weinzierl <ingo@intevation.de> + + ISSUE-15 + + * src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java: + After resizing the chart panel, the chart/image is replaced by a new + chart with adjusted width and height (requested from server). + 2011-05-12 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java Thu May 12 09:14:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java Thu May 12 09:59:29 2011 +0000 @@ -12,10 +12,12 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; +import com.smartgwt.client.widgets.events.ResizedEvent; +import com.smartgwt.client.widgets.events.ResizedHandler; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; @@ -26,7 +28,10 @@ /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class ChartOutputTab extends OutputTab { +public class ChartOutputTab extends OutputTab implements ResizedHandler { + + public static final int DEFAULT_CHART_WIDTH = 600; + public static final int DEFAULT_CHART_HEIGHT = 500; /** The canvas that wraps the chart toolbar.*/ protected Canvas tbarPanel; @@ -83,6 +88,24 @@ vLayout.addMember(hLayout); setPane(vLayout); + + right.addResizedHandler(this); + } + + + /** + * This method is called after the chart panel has resized. It removes the + * chart - if existing - and requests a new one with adjusted size. + * + * @param event The resize event. + */ + public void onResized(ResizedEvent event) { + Canvas[] children = right.getChildren(); + for (Canvas child: children) { + right.removeChild(child); + } + + right.addChild(createChartPanel(right.getWidth(), right.getHeight())); } @@ -112,21 +135,27 @@ protected void openDatacageWindow(Artifact artifact) { final DatacageWindow dc = new DatacageWindow(artifact); - dc.addCloseClickHandler(new CloseClickHandler() { - public void onCloseClick(CloseClientEvent event) { - dc.destroy(); - } + dc.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent event) { + dc.destroy(); + } }); dc.show(); } protected Canvas createChartPanel() { - Img chart = getChartImg(); + return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); + } + + + protected Canvas createChartPanel(int width, int height) { + Img chart = getChartImg(width, height); chart.setWidth100(); chart.setHeight100(); return chart; + } @@ -142,19 +171,25 @@ /** * Builds the chart image and returns it. * + * @param width The chart width. + * @param height The chart height. + * * @return the chart image. */ - protected Img getChartImg() { - return new Img(getImgUrl()); + protected Img getChartImg(int width, int height) { + return new Img(getImgUrl(width, height)); } /** * Builds the URL that points to the chart image. * + * @param width The width of the requested chart. + * @param height The height of the requested chart. + * * @return the URL to the chart image. */ - protected String getImgUrl() { + protected String getImgUrl(int width, int height) { Config config = Config.getInstance(); String imgUrl = GWT.getModuleBaseURL(); @@ -164,8 +199,8 @@ imgUrl += "&server=" + config.getServerUrl(); imgUrl += "&locale=" + config.getLocale(); imgUrl += "×tamp=" + new Date().getTime(); - imgUrl += "&width=" + Integer.toString(600); - imgUrl += "&height=" + Integer.toString(500); + imgUrl += "&width=" + Integer.toString(width); + imgUrl += "&height=" + Integer.toString(height); return imgUrl; }