changeset 3254:9a4707ec7800

Add styles for W(t) chart domain markers flys-artifacts/trunk@4888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Fri, 06 Jul 2012 14:45:23 +0000
parents 209d50ee8e9f
children 4246851312e6
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/default-themes.xml flys-artifacts/doc/conf/second-themes.xml flys-artifacts/doc/conf/virtual-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledValueMarker.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 14 files changed, 177 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jul 06 14:45:23 2012 +0000
@@ -1,3 +1,20 @@
+2012-07-07	Christian Lins <christian.lins@intevation.de>
+
+	* doc/conf/*-themes.xml,
+	  src/main/java/de/intevation/flys/utils/ThemeUtil.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java,
+	  src/main/java/de/intevation/flys/jfree/StyledValueMarker.java,
+	  src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java,
+	  src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties:
+	  Add styles for W(t) domain markers.
+
+	* src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java:
+	  Remove false @override.
+
 2012-07-07	Christian Lins <christian.lins@intevation.de>
 
 	* doc/conf/themes.xml,
--- a/flys-artifacts/doc/conf/default-themes.xml	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Fri Jul 06 14:45:23 2012 +0000
@@ -1449,5 +1449,24 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
         </fields>
     </theme>
+    <theme name="FixDeltaWtDeviation">
+    	<inherits>
+    		<inherit from="Areas"/>
+    	</inherits>
+    	<fields>
+    		<field name="alpha" type="int" default="50" disply="Alpha-Transparenz"/>
+    		<field name="fillcolor" type="Color" default="0, 0, 0" display="Füllfarbe"/>
+    	</fields>
+    </theme>
+    <theme name="FixingDeltaWtAnalysisPeriods">
+        <inherits>
+    		<inherit from="Areas"/>
+    	</inherits>
+    	<fields>
+    		<field name="alpha" type="int" default="80" disply="Alpha-Transparenz"/>
+    		<field name="fillcolor" type="Color" default="255, 0, 0" display="Hauptfarbe"/>
+    		<field name="backgroundcolor" type="Color" default="0, 0, 255" display="Wechselfarbe"/>
+    	</fields>
+    </theme>
 
 </themegroup>
--- a/flys-artifacts/doc/conf/second-themes.xml	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/doc/conf/second-themes.xml	Fri Jul 06 14:45:23 2012 +0000
@@ -1448,5 +1448,24 @@
             <field name="linecolor" type="Color" default="227, 27, 162" />
         </fields>
     </theme>
+    <theme name="FixDeltaWtDeviation">
+    	<inherits>
+    		<inherit from="Areas"/>
+    	</inherits>
+    	<fields>
+    		<field name="alpha" type="int" default="50" disply="Alpha-Transparenz"/>
+    		<field name="fillcolor" type="Color" default="0, 0, 0" display="Füllfarbe"/>
+    	</fields>
+    </theme>
+    <theme name="FixingDeltaWtAnalysisPeriods">
+        <inherits>
+    		<inherit from="Areas"/>
+    	</inherits>
+    	<fields>
+    		<field name="alpha" type="int" default="80" disply="Alpha-Transparenz"/>
+    		<field name="fillcolor" type="Color" default="255, 0, 0" display="Hauptfarbe"/>
+    		<field name="backgroundcolor" type="Color" default="0, 0, 255" display="Wechselfarbe"/>
+    	</fields>
+    </theme>
 
 </themegroup>
--- a/flys-artifacts/doc/conf/virtual-themes.xml	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/doc/conf/virtual-themes.xml	Fri Jul 06 14:45:23 2012 +0000
@@ -140,6 +140,7 @@
                 display="Flaechebegrenzungslinie anzeigen" default="false" />
             <field name="transparent" type="boolean" display="Transparenz"
                 default="false" />
+            <field name="alpha" type="int" default="255" display="Alpha-Transparenzwert" />
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Fri Jul 06 14:45:23 2012 +0000
@@ -1,15 +1,15 @@
 package de.intevation.flys.exports;
 
+import au.com.bytecode.opencsv.CSVWriter;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.WQCKms;
+import de.intevation.flys.artifacts.model.WQKms;
+
 import java.text.NumberFormat;
 
 import org.apache.log4j.Logger;
 
-import au.com.bytecode.opencsv.CSVWriter;
-
-import de.intevation.flys.artifacts.model.WQCKms;
-import de.intevation.flys.artifacts.model.WQKms;
-import de.intevation.flys.artifacts.model.CalculationResult;
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -66,7 +66,6 @@
     }
 
 
-    @Override
     protected void wQKms2CSV(
         CSVWriter writer,
         WQKms     wqkms,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Fri Jul 06 14:45:23 2012 +0000
@@ -11,12 +11,12 @@
 import de.intevation.flys.exports.TimeseriesChartGenerator;
 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
 import de.intevation.flys.jfree.FLYSAnnotation;
+import de.intevation.flys.jfree.StyledDomainMarker;
 import de.intevation.flys.jfree.StyledTimeSeries;
+import de.intevation.flys.jfree.StyledValueMarker;
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.ThemeUtil;
 
-import java.awt.BasicStroke;
-import java.awt.Color;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -29,8 +29,6 @@
 import org.apache.log4j.Logger;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.annotations.XYTextAnnotation;
-import org.jfree.chart.plot.IntervalMarker;
-import org.jfree.chart.plot.ValueMarker;
 import org.jfree.chart.title.TextTitle;
 import org.jfree.data.time.Day;
 import org.jfree.data.time.Month;
@@ -317,8 +315,6 @@
                 qwd.getQ() + " m\u00B3/s",
                 x,
                 qwd.getDeltaW());
-            //anno.setRotationAngle(200f*Math.PI/180f);
-            //anno.setRotationAnchor(TextAnchor.CENTER_LEFT);
             textAnnos.add(anno);
             logger.debug("annotation: " + x + "/" + qwd.getDeltaW());
         }
@@ -403,12 +399,8 @@
             return;
         }
         double[] value = (double[]) data;
-        IntervalMarker lower = new IntervalMarker((value[0] * -1), 0);
-        lower.setAlpha(0.2f);
-        lower.setPaint(Color.BLACK);
-        IntervalMarker upper = new IntervalMarker(0, value[0]);
-        upper.setAlpha(0.2f);
-        upper.setPaint(Color.BLACK);
+        StyledDomainMarker lower = new StyledDomainMarker((value[0] * -1), 0, theme);
+        StyledDomainMarker upper = new StyledDomainMarker(0, value[0], theme);
 
         valueMarker.add(lower);
         valueMarker.add(upper);
@@ -432,16 +424,10 @@
             logger.debug("creating domain marker");
             RegularTimePeriod start = new Month(ranges[i].getFrom());
             RegularTimePeriod end = new Month(ranges[i].getTo());
-            IntervalMarker marker =
-                new IntervalMarker(start.getMiddleMillisecond(),
-                                   end.getMiddleMillisecond());
-            marker.setAlpha(0.3f);
-            if ((i % 2) == 0) {
-                marker.setPaint(Color.RED);
-            }
-            else {
-                marker.setPaint(Color.BLUE);
-            }
+            StyledDomainMarker marker =
+                new StyledDomainMarker(start.getMiddleMillisecond(),
+                                   end.getMiddleMillisecond(), theme);
+            marker.useSecondColor(i % 2 == 0);
             domainMarker.add(marker);
         }
         logger.debug("domainmarkers: " + domainMarker.size());
@@ -455,9 +441,7 @@
         logger.debug("currentKm = " + new Double(getCurrentKmFromRequest()));
         context.putContextValue("currentKm", new Double(getCurrentKmFromRequest()));
 
-        ValueMarker marker = new ValueMarker(0);
-        marker.setPaint(Color.black);
-        marker.setStroke(new BasicStroke(2));
+        StyledValueMarker marker = new StyledValueMarker(0, request);
         valueMarker.add(marker);
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Fri Jul 06 14:45:23 2012 +0000
@@ -1,34 +1,30 @@
 package de.intevation.flys.exports.fixings;
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-
 import de.intevation.flys.artifacts.model.FacetTypes;
-
 import de.intevation.flys.artifacts.model.fixings.FixFunction;
 import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet;
 import de.intevation.flys.artifacts.model.fixings.QW;
 import de.intevation.flys.artifacts.model.fixings.QWD;
-
 import de.intevation.flys.exports.ChartGenerator;
-
 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.JFreeUtil;
 import de.intevation.flys.jfree.StyledXYSeries;
 
 import java.text.DateFormat;
-
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
-
 import org.jfree.chart.annotations.XYTextAnnotation;
-
 import org.jfree.data.xy.XYSeries;
-
 import org.w3c.dom.Document;
 
+/**
+ * 
+ * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a>
+ */
 public class FixWQCurveGenerator
 extends      FixChartGenerator
 implements   FacetTypes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java	Fri Jul 06 14:45:23 2012 +0000
@@ -0,0 +1,46 @@
+package de.intevation.flys.jfree;
+
+import de.intevation.flys.utils.ThemeUtil;
+
+import java.awt.Color;
+
+import org.jfree.chart.plot.IntervalMarker;
+import org.w3c.dom.Document;
+
+/**
+ * Marker that represents a highlighted interval.
+ * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a>
+ */
+public class StyledDomainMarker extends IntervalMarker {
+
+    private static final long serialVersionUID = -4369410661339512342L;
+    
+    private final Color fillColor, backgroundColor;
+    
+    public StyledDomainMarker(double start, double end, Document theme) {
+        super(start, end);
+        
+        backgroundColor = ThemeUtil.parseColor(
+                ThemeUtil.getBackgroundColorString(theme));
+        fillColor = ThemeUtil.parseColor(
+                ThemeUtil.getFillColorString(theme));
+        useSecondColor(false);
+        
+        int alpha = ThemeUtil.parseInteger(ThemeUtil.getTransparencyAlpha(theme), 128);
+        setAlpha(alpha / 255.0f);
+    }
+    
+    /**
+     * To properly differentiate several styled domain markers side by side,
+     * we can use this switch to toggle between two colors.
+     * @param secondColor
+     */
+    public void useSecondColor(boolean secondColor) {
+        if(secondColor) {
+            setPaint(backgroundColor);
+        }
+        else {
+            setPaint(fillColor);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledValueMarker.java	Fri Jul 06 14:45:23 2012 +0000
@@ -0,0 +1,32 @@
+package de.intevation.flys.jfree;
+
+import de.intevation.flys.utils.ThemeUtil;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+
+import org.jfree.chart.plot.ValueMarker;
+import org.w3c.dom.Document;
+
+/**
+ * Marker that represents a single value.
+ * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a>
+ */
+public class StyledValueMarker extends ValueMarker {
+
+    private static final long serialVersionUID = -3607777705307785140L;
+
+    public StyledValueMarker(double value, Document theme) {
+        super(value);
+        
+        Color color = ThemeUtil.parsePointColor(theme);
+        if(color == null) {
+            color = Color.BLACK;
+        }
+        this.setPaint(color);
+        
+        int size = ThemeUtil.parsePointWidth(theme);
+        setStroke(new BasicStroke(size));
+    }
+
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Fri Jul 06 14:45:23 2012 +0000
@@ -1,24 +1,22 @@
 package de.intevation.flys.utils;
 
-import org.apache.log4j.Logger;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.flys.artifacts.model.MapserverStyle;
+import de.intevation.flys.artifacts.model.MapserverStyle.Clazz;
+import de.intevation.flys.artifacts.model.MapserverStyle.Expression;
+import de.intevation.flys.artifacts.model.MapserverStyle.Label;
+import de.intevation.flys.artifacts.model.MapserverStyle.Style;
 
 import java.awt.Color;
 import java.awt.Font;
 
 import javax.xml.xpath.XPathConstants;
 
+import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-import de.intevation.artifacts.common.utils.XMLUtils;
-
-import de.intevation.flys.artifacts.model.MapserverStyle;
-import de.intevation.flys.artifacts.model.MapserverStyle.Clazz;
-import de.intevation.flys.artifacts.model.MapserverStyle.Expression;
-import de.intevation.flys.artifacts.model.MapserverStyle.Style;
-import de.intevation.flys.artifacts.model.MapserverStyle.Label;
-
 
 /**
  * Utility to deal with themes and their representations.
@@ -90,6 +88,9 @@
 
     public final static String XPATH_TRANSPARENCY =
         "/theme/field[@name='transparent']/@default";
+    
+    public final static String XPATH_TRANSPARENCY_ALPHA =
+        "/theme/field[@name='alpha']/@default";
 
     public final static String XPATH_SHOW_AREA =
         "/theme/field[@name='showarea']/@default";
@@ -558,12 +559,17 @@
     public static String getTransparencyString(Document theme) {
         return XMLUtils.xpathString(theme, XPATH_TRANSPARENCY, null);
     }
+    
+    
+    public static String getTransparencyAlpha(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_TRANSPARENCY_ALPHA, null);
+    }
 
 
     public static String getShowMinimum(Document theme) {
         return XMLUtils.xpathString(theme, XPATH_SHOW_MINIMUM, null);
     }
-
+    
 
     public static String getShowMaximum(Document theme) {
         return XMLUtils.xpathString(theme, XPATH_SHOW_MAXIMUM, null);
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Jul 06 14:45:23 2012 +0000
@@ -337,8 +337,8 @@
 fix.deviation=Standard deviation
 fix.reference.deviation=Reference deviation
 
-chart.fix.deltawt.title=\u0394 W(t) (Please change...)
-chart.fix.deltawt.subtitle=add subtitle
+chart.fix.deltawt.title=Difference from compensating curve
+chart.fix.deltawt.subtitle=Water: %1; Period:  %2
 chart.fix.deltawt.xaxis.label=Date
 chart.fix.deltawt.yaxis.label=\u0394 W(t) [cm]
 
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Jul 06 14:45:23 2012 +0000
@@ -338,8 +338,8 @@
 fix.deviation=Standardabweichung
 fix.reference.deviation=Abweichung im Bezugszeitraum
 
-chart.fix.deltawt.title=\u0394W(t) (Bitte aendern...)
-chart.fix.deltawt.subtitle=add subtitle
+chart.fix.deltawt.title=Abweichungen von der Ausgleichskurve
+chart.fix.deltawt.subtitle=Gewässer: %1; Darstellungszeitraum: %2
 chart.fix.deltawt.xaxis.label=Datum
 chart.fix.deltawt.yaxis.label=\u0394 W(t) [cm]
 
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Jul 06 14:45:23 2012 +0000
@@ -337,8 +337,8 @@
 fix.deviation=Standardabweichung
 fix.reference.deviation=Abweichung im Bezugszeitraum
 
-chart.fix.deltawt.title=\u0394 W(t) (Bitte aendern...)
-chart.fix.deltawt.subtitle=add subtitle
+chart.fix.deltawt.title=Abweichungen von der Ausgleichskurve
+chart.fix.deltawt.subtitle=Gewässer: %1; Darstellungszeitraum: %2
 chart.fix.deltawt.xaxis.label=Datum
 chart.fix.deltawt.yaxis.label=\u0394 W(t) [cm]
 
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Jul 06 13:02:35 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Jul 06 14:45:23 2012 +0000
@@ -337,8 +337,8 @@
 fix.deviation=Standard deviation
 fix.reference.deviation=Reference deviation
 
-chart.fix.deltawt.title=Delta W(t) (Please change...)
-chart.fix.deltawt.subtitle=add subtitle
+chart.fix.deltawt.title=Difference from compensating curve
+chart.fix.deltawt.subtitle=Water: %1; Period:  %1
 chart.fix.deltawt.xaxis.label=Date
 chart.fix.deltawt.yaxis.label=\u0394 W(t) [cm]
 

http://dive4elements.wald.intevation.org