changeset 1711:f708120cb7bc

Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering). flys-artifacts/trunk@2975 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 17 Oct 2011 08:45:26 +0000
parents 055f32a5388a
children 7e19449d7826
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 4 files changed, 51 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Oct 14 11:13:04 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Oct 17 08:45:26 2011 +0000
@@ -1,3 +1,16 @@
+2011-10-17	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java:
+	  (parseLineWidth): New. Get line width from Document.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  When adding annotations, parse line width from theme, set it.
+
+	* src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java:
+	  When painting, set Paint and stroke early enough.
+
 2011-10-14  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Put the
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Oct 14 11:13:04 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Mon Oct 17 08:45:26 2011 +0000
@@ -238,6 +238,9 @@
     }
 
 
+    /**
+     * Adds annotations to list (if visible is true).
+     */
     public void addAnnotations(FLYSAnnotation annotation, boolean visible) {
         if (!visible) {
             return;
@@ -414,10 +417,15 @@
                 color = Color.black;
             }
 
+            int lineWidth = theme != null
+                ? ThemeUtil.parseLineWidth(theme)
+                : 1;
+
             lic.add(new LegendItem(fa.getLabel(), color));
 
             for (XYTextAnnotation ta: fa.getAnnotations()) {
                 ta.setPaint(color);
+                ta.setOutlineStroke(new BasicStroke((float) lineWidth));
                 renderer.addAnnotation(ta);
             }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java	Fri Oct 14 11:13:04 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java	Mon Oct 17 08:45:26 2011 +0000
@@ -277,6 +277,8 @@
         }
 
         // Always draw the small line at axis.
+        g2.setStroke(getOutlineStroke());
+        g2.setPaint(getPaint());
         drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge,
                 rangeEdge, orientation);
 
@@ -301,7 +303,7 @@
 
         // Actuall drawing.
         if (getBackgroundPaint() != null) {
-        g2.setPaint(getBackgroundPaint());
+            g2.setPaint(getBackgroundPaint());
             g2.fill(hotspot);
         }
         g2.setPaint(getPaint());
@@ -318,5 +320,4 @@
         addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL());
     }
 }
-
-
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Fri Oct 14 11:13:04 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Mon Oct 17 08:45:26 2011 +0000
@@ -11,7 +11,32 @@
  * Utility to deal with themes and their representations.
  */
 public class ThemeUtil {
-    public final static String XPATH_LINE_COLOR = "/theme/field[@name='linecolor']/@default";
+    public final static String XPATH_LINE_COLOR =
+        "/theme/field[@name='linecolor']/@default";
+
+    public static final String XPATH_LINE_SIZE =
+        "/theme/field[@name='linesize']/@default";
+
+
+    /**
+     * Parses line width, defaulting to 0.
+     * @param theme the theme
+     */
+    public static int parseLineWidth(Document theme) {
+        String size = XMLUtils.xpathString(theme, XPATH_LINE_SIZE, null);
+        if (size == null || size.length() == 0) {
+            return 0;
+        }
+
+        try {
+            return Integer.valueOf(size);
+        }
+        catch (NumberFormatException nfe) {
+            //logger.warn("Unable to set line size from string: '" + size + "'");
+        }
+        return 0;
+    }
+
 
     /**
      * Parse a string like "103, 100, 0" and return a corresping color.

http://dive4elements.wald.intevation.org