changeset 3578:bae185bf9d2d

Theme the qsector markers. flys-artifacts/trunk@5193 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 13 Aug 2012 07:35:57 +0000
parents 25cce741d03c
children accb64be866c
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/default-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java
diffstat 3 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Aug 10 14:09:32 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Aug 13 07:35:57 2012 +0000
@@ -1,3 +1,11 @@
+2012-08-13	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* doc/conf/themes.xml, doc/conf/default-themes.xml:
+	  Added theme fields for qsectors label.
+
+	* src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java:
+	  Add markers for the qsectors.
+
 2012-08-10	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* doc/conf/themes.xml, doc/conf/default-themes.xml:
--- a/flys-artifacts/doc/conf/default-themes.xml	Fri Aug 10 14:09:32 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Mon Aug 13 07:35:57 2012 +0000
@@ -1471,6 +1471,14 @@
                 default="10" hidden="true" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="1" hidden="true" />
+            <field name="labelfontface" type="Font"
+                display="Beschriftung: Schriftart" default="arial" />
+            <field name="labelfontcolor" type="Color"
+                display="Beschriftung: Schriftfarbe" default="0, 0, 0" />
+            <field name="labelfontsize" type="int"
+                display="Beschriftung: Schriftgröße" default="10" />
+            <field name="labelfontstyle" type="Style"
+                display="Beschriftung: Schriftstil" default="standard" />
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Fri Aug 10 14:09:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Mon Aug 13 07:35:57 2012 +0000
@@ -5,6 +5,7 @@
 import de.intevation.flys.artifacts.access.FixAnalysisAccess;
 import de.intevation.flys.artifacts.model.DateRange;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.NamedDouble;
 import de.intevation.flys.artifacts.model.QWDDateRange;
 import de.intevation.flys.artifacts.model.fixings.FixFunction;
 import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet;
@@ -18,6 +19,15 @@
 import de.intevation.flys.jfree.StyledXYSeries;
 import de.intevation.flys.utils.ThemeUtil;
 
+import org.jfree.chart.plot.Marker;
+import org.jfree.chart.plot.ValueMarker;
+import org.jfree.ui.RectangleAnchor;
+import org.jfree.ui.TextAnchor;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+
+
 import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -99,6 +109,9 @@
         else if(FIX_OUTLIER.equals(name)) {
             doOutlierOut(aaf, doc, visible);
         }
+        else if(QSECTOR.equals(name)) {
+            doQSectorOut(aaf, doc, visible);
+        }
         else {
             logger.warn("Unknown facet name " + name);
             return;
@@ -178,6 +191,58 @@
         addQWSeries(qws, aaf, doc, visible);
     }
 
+
+    /** Add markers for q sectors. */
+    protected void doQSectorOut(ArtifactAndFacet aaf, Document theme, boolean visible) {
+        logger.debug("doQSectorOut");
+        if (!visible) {
+            return;
+        }
+
+        List<NamedDouble> qsectors = (List<NamedDouble>) aaf.getData(context);
+
+        if (qsectors == null) {
+            logger.warn("No QSectors coming from data.");
+            return;
+        }
+        for (NamedDouble qsector : qsectors) {
+            if (Double.isNaN(qsector.getValue())) {
+                continue;
+            }
+            Marker m = new ValueMarker(qsector.getValue());
+            m.setPaint(Color.black);
+
+            float[] dashes = ThemeUtil.parseLineStyle(theme);
+            int size       = ThemeUtil.parseLineWidth(theme);
+            BasicStroke stroke; 
+            if (dashes.length <= 1) {
+                stroke = new BasicStroke(Integer.valueOf(size));
+            }
+            else {
+                stroke = new BasicStroke(Integer.valueOf(size),
+                    BasicStroke.CAP_BUTT,
+                    BasicStroke.JOIN_ROUND,
+                    1.0f,
+                    dashes,
+                    0.0f);
+            } 
+            m.setStroke(stroke);
+
+            if (ThemeUtil.parseShowLineLabel(theme)) {
+                m.setLabel(qsector.getName());
+                m.setPaint(ThemeUtil.parseTextColor(theme));
+                m.setLabelFont(ThemeUtil.parseTextFont(theme));
+            }
+            Color paint = ThemeUtil.parseLineColorField(theme);
+            if (paint != null) {
+                m.setPaint(paint);
+            }
+            m.setLabelAnchor(RectangleAnchor.TOP_LEFT);
+            m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
+            addDomainMarker(m);
+        }
+    }
+
     protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document theme, boolean visible) {
          if(qws != null) {
             XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);

http://dive4elements.wald.intevation.org