changeset 2996:55f91fae8a7b

Respect new theme setting when drawing line to curve. flys-artifacts/trunk@4551 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 29 May 2012 08:23:03 +0000
parents 7d33aec0b61d
children 60f13d966ee3
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 3 files changed, 68 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 29 07:37:46 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 29 08:23:03 2012 +0000
@@ -1,3 +1,10 @@
+2012-05-29	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  Consider theme setting before drawing line to curve.
+
 2012-05-29	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* doc/conf/themes.xml: Donate own theme for mainvalues.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 29 07:37:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 29 08:23:03 2012 +0000
@@ -50,6 +50,7 @@
 import de.intevation.flys.jfree.StyledXYSeries;
 
 import de.intevation.flys.utils.ThemeAccess;
+import de.intevation.flys.utils.ThemeUtil;
 
 import de.intevation.flys.artifacts.model.HYKFactory;
 
@@ -768,13 +769,15 @@
     /**
      * Add a text and a line annotation.
      * @param area convenience to determine positions in plot.
+     * @param theme (optional) theme document
      */
     public void addStickyAnnotation(
         StickyAxisAnnotation annotation,
         XYPlot plot,
         Area area,
         ThemeAccess.LineStyle lineStyle,
-        ThemeAccess.TextStyle textStyle
+        ThemeAccess.TextStyle textStyle,
+        Document theme
     ) {
         // OPTIMIZE pre-calculate area-related values
         final float TEXT_OFF = 0.03f;
@@ -823,19 +826,23 @@
                 lineAnnotation = createRightStickAnnotation(
                     area2, annotation.getPos(), lineStyle);
                 // TODO line to curve
-                if (!Float.isNaN(annotation.getHitPoint())) {
-                    // TODO let line be styled and respect X/Y-ness.
+                if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
                     // New line annotation to hit curve.
-                    XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(
-                        area2.atRight(), annotation.getPos(),
-                        annotation.getHitPoint(), annotation.getPos());
-                    XYLineAnnotation lineBackAnnotation = new XYLineAnnotation(
-                        annotation.getHitPoint(), annotation.getPos(),
-                        annotation.getHitPoint(), area2.atGround());
-                    plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
-                        org.jfree.ui.Layer.BACKGROUND);
-                    plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
-                        org.jfree.ui.Layer.BACKGROUND);
+                    // TODO include more style information
+                    if (ThemeUtil.parseShowVerticalLine(theme)) {
+                        XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(
+                            area2.atRight(), annotation.getPos(),
+                            annotation.getHitPoint(), annotation.getPos());
+                        plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
+                            org.jfree.ui.Layer.BACKGROUND);
+                    }
+                    if (ThemeUtil.parseShowHorizontalLine(theme)) {
+                        XYLineAnnotation lineBackAnnotation = new XYLineAnnotation(
+                            annotation.getHitPoint(), annotation.getPos(),
+                            annotation.getHitPoint(), area2.atGround());
+                        plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
+                            org.jfree.ui.Layer.BACKGROUND);
+                    }
                 }
             }
             else {
@@ -844,19 +851,22 @@
                 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT);
                 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT);
                 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle);
-                // TODO line to curve
-                if (!Float.isNaN(annotation.getHitPoint())) {
-                    // TODO let line be styled and respect X/Y-ness.
+                if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
+                    // TODO include more style information
                     // New line annotation to hit curve.
-                    XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(),
-                        annotation.getPos(), annotation.getHitPoint(), annotation.getPos());
-                    XYLineAnnotation lineBackAnnotation = new XYLineAnnotation(
-                        annotation.getHitPoint(), annotation.getPos(),
-                        annotation.getHitPoint(), area.atGround());
-                    plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
-                        org.jfree.ui.Layer.BACKGROUND);
-                    plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
-                        org.jfree.ui.Layer.BACKGROUND);
+                    if (ThemeUtil.parseShowHorizontalLine(theme)) {
+                        XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(),
+                            annotation.getPos(), annotation.getHitPoint(), annotation.getPos());
+                        plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
+                            org.jfree.ui.Layer.BACKGROUND);
+                    }
+                    if (ThemeUtil.parseShowVerticalLine(theme)) {
+                        XYLineAnnotation lineBackAnnotation = new XYLineAnnotation(
+                            annotation.getHitPoint(), annotation.getPos(),
+                            annotation.getHitPoint(), area.atGround());
+                        plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
+                            org.jfree.ui.Layer.BACKGROUND);
+                    }
                 }
             }
         }
@@ -928,7 +938,8 @@
 
             // The 'Sticky' Annotations (at axis, with line and text).
             for (StickyAxisAnnotation sta: fa.getAxisTextAnnotations()) {
-                addStickyAnnotation(sta, plot, area, lineStyle, textStyle);
+                addStickyAnnotation(
+                    sta, plot, area, lineStyle, textStyle, theme);
             }
 
             // Other Text Annotations (e.g. labels of manual points).
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue May 29 07:37:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue May 29 08:23:03 2012 +0000
@@ -52,6 +52,12 @@
     public final static String XPATH_SHOW_LINE =
         "/theme/field[@name='showlines']/@default";
 
+    public final static String XPATH_SHOW_VERTICAL_LINE =
+        "/theme/field[@name='showverticalline']/@default";
+
+    public final static String XPATH_SHOW_HORIZONTAL_LINE =
+        "/theme/field[@name='showhorizontalline']/@default";
+
     public final static String XPATH_SHOW_LINE_LABEL =
         "/theme/field[@name='showlinelabel']/@default";
 
@@ -270,6 +276,24 @@
     }
 
     /**
+     * Parses the attribute 'showverticalline', defaults to true.
+     * @param theme The theme.
+     */
+    public static boolean parseShowVerticalLine(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_VERTICAL_LINE, null);
+        return parseBoolean(show, true);
+    }
+
+    /**
+     * Parses the attribute 'showhorizontalline', defaults to true.
+     * @param theme The theme.
+     */
+    public static boolean parseShowHorizontalLine(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_HORIZONTAL_LINE, null);
+        return parseBoolean(show, true);
+    }
+
+    /**
      * Parses the attribute 'showlines', defaults to true.
      * @param theme The theme.
      */

http://dive4elements.wald.intevation.org