changeset 1452:fa63366ba115

Improved area creation GUI. flys-client/trunk@3477 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 06:54:49 +0000
parents bc830e564b6d
children e8aec81af22b
files flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java
diffstat 1 files changed, 98 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Mon Dec 19 16:34:41 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Tue Dec 20 06:54:49 2011 +0000
@@ -121,24 +121,46 @@
 
         Data[] feedData;
 
-        if (over != null) {
+        if (over != null && under != null) {
             feedData = new Data[] {
                 DefaultData.createSimpleStringData("area.curve_under",
                     under.getArtifact() + under.getIndex()),
-                DefaultData.createSimpleStringData("area.curve_under",
-                      under.getArtifact() + under.getIndex()),
+                DefaultData.createSimpleStringData("area.curve_over",
+                    over.getArtifact() + over.getIndex()),
                 DefaultData.createSimpleStringData("area.name",
-                    over.getDescription() + " / " + under.getDescription())
+                    over.getDescription() + " / " + under.getDescription()),
+                DefaultData.createSimpleStringData("area.facet",
+                    "cross_section.area")
             };
+            GWT.log("Have over and under");
         }
-        else {
+        else if (over == null && under != null) {
             feedData = new Data[] {
                 DefaultData.createSimpleStringData("area.curve_under",
                     under.getArtifact() + under.getIndex()),
                 DefaultData.createSimpleStringData("area.name",
-                    under.getDescription() + " / " + MSG.getString("x_axis"))
+                    under.getDescription() + " / " + MSG.getString("x_axis")),
+                DefaultData.createSimpleStringData("area.facet",
+                    "cross_section.area")
             };
+            GWT.log("Have under only");
         }
+        else if (over != null && under == null) {
+            feedData = new Data[] {
+                DefaultData.createSimpleStringData("area.curve_over",
+                    over.getArtifact() + over.getIndex()),
+                DefaultData.createSimpleStringData("area.name",
+                    MSG.getString("x_axis") + " / " + over.getDescription()),
+                DefaultData.createSimpleStringData("area.facet",
+                    "cross_section.area")
+            };
+            GWT.log("Have over only");
+        }
+        else {
+            GWT.log("Missing Data for area painting.");
+            return;
+        }
+
 
         feedService.feed(
             Config.getInstance().getLocale(),
@@ -552,7 +574,11 @@
      * @param under
      * @param over if null, something.
      */
-    public void createAreaArtifact(final Theme under, final Theme over) {
+    public void createAreaArtifact(
+        final Theme under,
+        final Theme over,
+        boolean between
+    ) {
         Config config = Config.getInstance();
         String locale = config.getLocale();
 
@@ -592,7 +618,9 @@
 
         final Theme facetTheme = ((FacetRecord)records[0]).getTheme();
         String thisItem = facetTheme.getDescription();
-        if (facetTheme.getFacet().equals("area")) {
+        if (facetTheme.getFacet().equals("area") ||
+            facetTheme.getFacet().equals("cross_section.area")
+        ) {
             return menu;
         }
         
@@ -605,40 +633,88 @@
 
         ThemeList themes = getThemeList();
         int nThemes      = themes.getThemeCount();
+
+        MenuItem underMenuItem = new MenuItem("Under ...");
+        Menu underMenu = new Menu();
         for (int i = 0; i < nThemes; i++)  {
             final Theme theme = themes.getThemeAt(i+1);
             if (theme.getDescription().equals(thisItem)
-                || theme.getFacet().equals("area")) {
+                || theme.getFacet().equals("area")
+                || theme.getFacet().equals("cross_section.area")
+            ) {
                 continue;
             }
             MenuItem againster = new MenuItem(theme.getDescription());
-            areaMenu.addItem(againster);
+            underMenu.addItem(againster);
 
             againster.addClickHandler(new ClickHandler() {
                 public void onClick(MenuItemClickEvent evt) {
                     disable();
-                    createAreaArtifact(facetTheme, theme);
+                    createAreaArtifact(theme, facetTheme, false);
                 }
             });
         }
 
-        MenuItem underMenuItem = new MenuItem("Under ...");
-        underMenuItem.addClickHandler(new ClickHandler() {
+        MenuItem overMenuItem = new MenuItem("Over ...");
+        Menu overMenu = new Menu();
+        for (int i = 0; i < nThemes; i++)  {
+            final Theme theme = themes.getThemeAt(i+1);
+            if (theme.getDescription().equals(thisItem)
+                || theme.getFacet().equals("area")
+                || theme.getFacet().equals("cross_section.area")
+            ) {
+                continue;
+            }
+            MenuItem againster = new MenuItem(theme.getDescription());
+            overMenu.addItem(againster);
+
+            againster.addClickHandler(new ClickHandler() {
+                public void onClick(MenuItemClickEvent evt) {
+                    disable();
+                    createAreaArtifact(facetTheme, theme, false);
+                }
+            });
+        }
+        overMenu.addItem(createSeparator());
+        MenuItem againstAxis = new MenuItem(MSG.getString("x_axis"));
+        againstAxis.addClickHandler(new ClickHandler() {
             public void onClick(MenuItemClickEvent evt) {
                 disable();
-                createAreaArtifact(facetTheme, null);
+                createAreaArtifact(facetTheme, null, false);
             }
         });
-        MenuItem overMenuItem = new MenuItem("Over ...");
-        overMenuItem.addClickHandler(new ClickHandler() {
-            public void onClick(MenuItemClickEvent evt) {
-                disable();
-                createAreaArtifact(facetTheme, null);
+        overMenu.addItem(againstAxis);
+
+        MenuItem betweenMenuItem = new MenuItem("Between ...");
+        Menu betweenMenu = new Menu();
+        for (int i = 0; i < nThemes; i++)  {
+            final Theme theme = themes.getThemeAt(i+1);
+            if (theme.getDescription().equals(thisItem)
+                || theme.getFacet().equals("area")
+                || theme.getFacet().equals("cross_section.area")
+            ) {
+                continue;
             }
-        });
-        areaMenu.addItem(createSeparator());
+            MenuItem againster = new MenuItem(theme.getDescription());
+            betweenMenu.addItem(againster);
+
+            againster.addClickHandler(new ClickHandler() {
+                public void onClick(MenuItemClickEvent evt) {
+                    disable();
+                    createAreaArtifact(facetTheme, theme, true);
+                }
+            });
+        }
+        betweenMenu.addItem(createSeparator());
+        betweenMenu.addItem(againstAxis);
+
+        overMenuItem.setSubmenu(overMenu);
+        underMenuItem.setSubmenu(underMenu);
+        betweenMenuItem.setSubmenu(betweenMenu);
+
+        areaMenu.addItem(overMenuItem);
         areaMenu.addItem(underMenuItem);
-        areaMenu.addItem(overMenuItem);
+        areaMenu.addItem(betweenMenuItem);
 
         areaMenuItem.setSubmenu(areaMenu);
         menu.addItem(areaMenuItem);

http://dive4elements.wald.intevation.org