changeset 2711:fa8ae7dbcb72

More stable legend item aggregation. flys-artifacts/trunk@4433 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 16 May 2012 20:23:29 +0000
parents 013882485011
children ed612b85fb6d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 16 20:17:24 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed May 16 20:23:29 2012 +0000
@@ -1,3 +1,8 @@
+2012-05-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  Stabilized legend item aggregation.
+
 2012-05-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Wed May 16 20:17:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Wed May 16 20:23:29 2012 +0000
@@ -1097,7 +1097,18 @@
         // boolean isShapeFilled()
         // boolean isShapeOutlineVisible()
         // boolean isShapeVisible()
-        return li.getLinePaint().toString();
+        String hash = li.getLinePaint().toString();
+        String label = li.getLabel();
+        if (label.startsWith("W (") || label.startsWith("W(")) {
+            hash += "-W-";
+        }
+        else if (label.startsWith("Q(") || label.startsWith("Q (")) {
+            hash += "-Q-";
+        }
+
+        // WQ.java holds example of using regex Matcher/Pattern.
+
+        return hash;
     }
 
 
@@ -1150,8 +1161,17 @@
             else {
                 first = false;
             }
-            name += item.getLabel().substring(startPattern.length(),
-                    item.getLabel().length() - endPattern.length());
+            // Possible case in differences
+            if (startPattern.length() + endPattern.length() < item.getLabel().length()) {
+                // Note that we do not really want this.
+                logger.error("Legend aggregation does not cover case: " +
+                    startPattern + "  -- " + item.getLabel() + " -- " + endPattern);
+                name += item.getLabel();
+            }
+            else {
+                name += item.getLabel().substring(startPattern.length(),
+                        item.getLabel().length() - endPattern.length());
+            }
         }
         name += "} ";
         name += endPattern;

http://dive4elements.wald.intevation.org