diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 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 772d0c8100d3
children 60f13d966ee3
line wrap: on
line diff
--- 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).

http://dive4elements.wald.intevation.org