# HG changeset patch # User Ingo Weinzierl # Date 1306310582 0 # Node ID fc60822e9c89f0ee7fd852bb9ae2fbdd2732dca4 # Parent 9e2b151770bd98fca259845d2662447e7ae77e86 Added a new package 'chart' that should be the place where chart relevant classes should be stored. Moved ChartOutputTab into that package. flys-client/trunk@2000 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9e2b151770bd -r fc60822e9c89 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed May 25 07:05:22 2011 +0000 +++ b/flys-client/ChangeLog Wed May 25 08:03:02 2011 +0000 @@ -1,3 +1,16 @@ +2011-05-25 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/chart: A new package + for all chart relevant classes. + + * src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java, + src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + Moved the ChartOutputTab to the chart package. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Adapted imports - added ChartOutputTab that has been moved to chart + subpackage. + 2011-05-25 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java: diff -r 9e2b151770bd -r fc60822e9c89 flys-client/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 Wed May 25 07:05:22 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -package de.intevation.flys.client.client.ui; - -import java.util.Date; - -import com.google.gwt.core.client.GWT; - -import com.smartgwt.client.types.Alignment; - -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.Img; -import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.IButton; - -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.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; -import de.intevation.flys.client.client.Config; - -import de.intevation.flys.client.shared.model.Artifact; - -/** - * @author Ingo Weinzierl - */ -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; - - /** The canvas that wraps the theme editor.*/ - protected Canvas left; - - /** The canvas that wraps the chart.*/ - protected Canvas right; - - - /** - * The default constructor to create a new ChartOutputTab. - * - * @param title The title of this tab. - * @param collection The Collection which this chart belongs to. - * @param mode The OutputMode. - */ - public ChartOutputTab( - String title, - Collection collection, - OutputMode mode, - CollectionView collectionView - ){ - super(title, collection, mode); - - tbarPanel = new Canvas(); - left = new Canvas(); - right = new Canvas(); - - tbarPanel.setBorder("1px solid black"); - tbarPanel.setHeight(30); - left.setBorder("1px solid black"); - left.setWidth("25%"); - right.setWidth("*"); - - VLayout vLayout = new VLayout(); - vLayout.setMembersMargin(2); - - HLayout hLayout = new HLayout(); - hLayout.setWidth100(); - hLayout.setHeight100(); - hLayout.setMembersMargin(10); - - hLayout.addMember(left); - hLayout.addMember(right); - - right.addChild(createChartPanel()); - left.addChild(createThemeControlPanel()); - tbarPanel.addChild( - createTBarPanel(collectionView)); - - vLayout.addMember(tbarPanel); - 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())); - } - - - protected Canvas createTBarPanel( - final CollectionView collectionView - ) { - HLayout hLayout = new HLayout(); - hLayout.setWidth100(); - hLayout.setHeight100(); - hLayout.setMembersMargin(10); - - Label datacage = new Label("Datenkorb"); - datacage.setHeight(20); - datacage.setBackgroundColor("#BED730"); - datacage.setBorder("1px solid black"); - datacage.setAlign(Alignment.CENTER); - - hLayout.setMargin(5); - hLayout.addMember(datacage); - datacage.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - GWT.log("Clicked 'datacage' button."); - openDatacageWindow( - collectionView.getArtifact()); - } - }); - - return hLayout; - } - - protected void openDatacageWindow(Artifact artifact) { - final DatacageWindow dc = new DatacageWindow(artifact); - dc.addCloseClickHandler(new CloseClickHandler() { - public void onCloseClick(CloseClientEvent event) { - dc.destroy(); - } - }); - dc.show(); - } - - - protected Canvas createChartPanel() { - 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; - - } - - - protected Canvas createThemeControlPanel() { - Label label = new Label("Themensteuerung"); - label.setHeight(25); - label.setMargin(5); - - return label; - } - - - /** - * Builds the chart image and returns it. - * - * @param width The chart width. - * @param height The chart height. - * - * @return the chart image. - */ - 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(int width, int height) { - Config config = Config.getInstance(); - - String imgUrl = GWT.getModuleBaseURL(); - imgUrl += "chart"; - imgUrl += "?uuid=" + collection.identifier(); - imgUrl += "&type=" + mode.getName(); - imgUrl += "&server=" + config.getServerUrl(); - imgUrl += "&locale=" + config.getLocale(); - imgUrl += "×tamp=" + new Date().getTime(); - imgUrl += "&width=" + Integer.toString(width); - imgUrl += "&height=" + Integer.toString(height); - - return imgUrl; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9e2b151770bd -r fc60822e9c89 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 25 07:05:22 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 25 08:03:02 2011 +0000 @@ -39,6 +39,7 @@ import de.intevation.flys.client.client.services.CreateCollectionServiceAsync; import de.intevation.flys.client.client.services.DescribeCollectionService; import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync; +import de.intevation.flys.client.client.ui.chart.ChartOutputTab; /** @@ -284,7 +285,7 @@ * * @return the artifact that is used for the parameterization. */ - protected Artifact getArtifact() { + public Artifact getArtifact() { return artifact; } @@ -294,7 +295,7 @@ * * @param artifact The new artifact. */ - protected void setArtifact(Artifact artifact) { + public void setArtifact(Artifact artifact) { this.artifact = artifact; } diff -r 9e2b151770bd -r fc60822e9c89 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Wed May 25 08:03:02 2011 +0000 @@ -0,0 +1,215 @@ +package de.intevation.flys.client.client.ui.chart; + +import java.util.Date; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.Alignment; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Img; +import com.smartgwt.client.widgets.Label; + +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.CloseClientEvent; +import com.smartgwt.client.widgets.events.ResizedEvent; +import com.smartgwt.client.widgets.events.ResizedHandler; + +import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.OutputMode; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.ui.CollectionView; +import de.intevation.flys.client.client.ui.DatacageWindow; +import de.intevation.flys.client.client.ui.OutputTab; + + +/** + * @author Ingo Weinzierl + */ +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; + + /** The canvas that wraps the theme editor.*/ + protected Canvas left; + + /** The canvas that wraps the chart.*/ + protected Canvas right; + + + /** + * The default constructor to create a new ChartOutputTab. + * + * @param title The title of this tab. + * @param collection The Collection which this chart belongs to. + * @param mode The OutputMode. + */ + public ChartOutputTab( + String title, + Collection collection, + OutputMode mode, + CollectionView collectionView + ){ + super(title, collection, mode); + + tbarPanel = new Canvas(); + left = new Canvas(); + right = new Canvas(); + + tbarPanel.setBorder("1px solid black"); + tbarPanel.setHeight(30); + left.setBorder("1px solid black"); + left.setWidth("25%"); + right.setWidth("*"); + + VLayout vLayout = new VLayout(); + vLayout.setMembersMargin(2); + + HLayout hLayout = new HLayout(); + hLayout.setWidth100(); + hLayout.setHeight100(); + hLayout.setMembersMargin(10); + + hLayout.addMember(left); + hLayout.addMember(right); + + right.addChild(createChartPanel()); + left.addChild(createThemeControlPanel()); + tbarPanel.addChild( + createTBarPanel(collectionView)); + + vLayout.addMember(tbarPanel); + 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())); + } + + + protected Canvas createTBarPanel( + final CollectionView collectionView + ) { + HLayout hLayout = new HLayout(); + hLayout.setWidth100(); + hLayout.setHeight100(); + hLayout.setMembersMargin(10); + + Label datacage = new Label("Datenkorb"); + datacage.setHeight(20); + datacage.setBackgroundColor("#BED730"); + datacage.setBorder("1px solid black"); + datacage.setAlign(Alignment.CENTER); + + hLayout.setMargin(5); + hLayout.addMember(datacage); + datacage.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + GWT.log("Clicked 'datacage' button."); + openDatacageWindow( + collectionView.getArtifact()); + } + }); + + return hLayout; + } + + protected void openDatacageWindow(Artifact artifact) { + final DatacageWindow dc = new DatacageWindow(artifact); + dc.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent event) { + dc.destroy(); + } + }); + dc.show(); + } + + + protected Canvas createChartPanel() { + 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; + + } + + + protected Canvas createThemeControlPanel() { + Label label = new Label("Themensteuerung"); + label.setHeight(25); + label.setMargin(5); + + return label; + } + + + /** + * Builds the chart image and returns it. + * + * @param width The chart width. + * @param height The chart height. + * + * @return the chart image. + */ + 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(int width, int height) { + Config config = Config.getInstance(); + + String imgUrl = GWT.getModuleBaseURL(); + imgUrl += "chart"; + imgUrl += "?uuid=" + collection.identifier(); + imgUrl += "&type=" + mode.getName(); + imgUrl += "&server=" + config.getServerUrl(); + imgUrl += "&locale=" + config.getLocale(); + imgUrl += "×tamp=" + new Date().getTime(); + imgUrl += "&width=" + Integer.toString(width); + imgUrl += "&height=" + Integer.toString(height); + + return imgUrl; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :