changeset 3746:7bc61f4ab26b

Fix for #837 flys-artifacts/trunk@5431 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Tue, 11 Sep 2012 12:08:08 +0000
parents e86cd5176678
children a33df17ac9bb
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/default-themes.xml flys-artifacts/doc/conf/second-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java
diffstat 4 files changed, 115 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Sep 10 20:32:39 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Sep 11 12:08:08 2012 +0000
@@ -1,3 +1,10 @@
+2012-09-11	Christian Lins	<christian.lins@intevation.de>
+
+	* doc/conf/second-themes.xml,
+	  doc/conf/default-themes.xml,
+	  src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java:
+	  Fix for line text annotations in Delta W(t) charts (#837).
+
 2012-09-10	Christian Lins	<christian.lins@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/GaugeTimerangeState.java:
--- a/flys-artifacts/doc/conf/default-themes.xml	Mon Sep 10 20:32:39 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Tue Sep 11 12:08:08 2012 +0000
@@ -1272,6 +1272,7 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="0, 128, 0" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage1">
@@ -1283,6 +1284,7 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="0, 0, 255" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage2">
@@ -1294,6 +1296,7 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="255, 0, 255" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage3">
@@ -1305,6 +1308,7 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="255, 0, 0" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/doc/conf/second-themes.xml	Mon Sep 10 20:32:39 2012 +0000
+++ b/flys-artifacts/doc/conf/second-themes.xml	Tue Sep 11 12:08:08 2012 +0000
@@ -1275,6 +1275,7 @@
                 default="0, 128, 128" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="3" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage1">
@@ -1288,6 +1289,7 @@
                 default="128, 0, 255" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="3" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage2">
@@ -1301,6 +1303,7 @@
                 default="255, 128, 255" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="3" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
     <theme name="FixingDeltaWtAverage3">
@@ -1314,6 +1317,7 @@
                 default="255, 0, 0" />
             <field name="linesize" type="int" display="Liniendicke"
                 default="3" />
+            <field name="textorientation" type="boolean" default="true" display="Text horizontal"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Mon Sep 10 20:32:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Tue Sep 11 12:08:08 2012 +0000
@@ -1,5 +1,20 @@
 package de.intevation.flys.exports.fixings;
 
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.jfree.chart.annotations.XYTextAnnotation;
+import org.jfree.data.time.Day;
+import org.jfree.data.time.RegularTimePeriod;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+import org.w3c.dom.Document;
+
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.artifacts.CallContext;
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -17,21 +32,6 @@
 import de.intevation.flys.jfree.StyledValueMarker;
 import de.intevation.flys.utils.ThemeUtil;
 
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.jfree.chart.annotations.XYTextAnnotation;
-import org.jfree.data.time.Day;
-import org.jfree.data.time.RegularTimePeriod;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.w3c.dom.Document;
-
 
 /**
  * Generator for Delta W(t) charts.
@@ -43,22 +43,22 @@
 {
     /** Private logger. */
     private static Logger logger =
-        Logger.getLogger(FixDeltaWtGenerator.class);
+            Logger.getLogger(FixDeltaWtGenerator.class);
 
     public static final String I18N_CHART_TITLE =
-        "chart.fix.deltawt.title";
+            "chart.fix.deltawt.title";
 
     public static final String I18N_CHART_SUBTITLE =
-        "chart.fix.deltawt.subtitle";
+            "chart.fix.deltawt.subtitle";
 
     public static final String I18N_XAXIS_LABEL =
-        "chart.fix.deltawt.xaxis.label";
+            "chart.fix.deltawt.xaxis.label";
 
     public static final String I18N_YAXIS_LABEL =
-        "chart.fix.deltawt.yaxis.label";
+            "chart.fix.deltawt.yaxis.label";
 
     public static final String I18N_YAXIS_SECOND_LABEL =
-        "chart.fix.deltawt.yaxis.second.label";
+            "chart.fix.deltawt.yaxis.second.label";
 
 
     public static enum YAXIS {
@@ -103,7 +103,7 @@
                 I18N_CHART_TITLE,
                 "",
                 FixChartGenerator
-                    .getCurrentKmFromRequest(request).doubleValue());
+                .getCurrentKmFromRequest(request).doubleValue());
     }
 
 
@@ -145,10 +145,10 @@
 
     @Override
     public void doOut(
-        ArtifactAndFacet artifactFacet,
-        Document         theme,
-        boolean          visible
-    ) {
+            ArtifactAndFacet artifactFacet,
+            Document         theme,
+            boolean          visible
+            ) {
         String name = artifactFacet.getFacetName();
         logger.debug("FixDeltaWtGenerator.doOut: " + name);
         logger.debug("Theme description is: " + artifactFacet.getFacetDescription());
@@ -157,57 +157,57 @@
 
         if (name.contains(FIX_SECTOR_AVERAGE_DWT)) {
             doSectorAverageOut(
-                (FLYSArtifact) artifactFacet.getArtifact(),
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                theme,
-                visible);
+                    (FLYSArtifact) artifactFacet.getArtifact(),
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    theme,
+                    visible);
         }
         else if (name.equals(FIX_REFERENCE_EVENTS_DWT)) {
             doReferenceEventsOut(
-                (FLYSArtifact) artifactFacet.getArtifact(),
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                theme,
-                visible);
+                    (FLYSArtifact) artifactFacet.getArtifact(),
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    theme,
+                    visible);
         }
         else if (name.equals(FIX_ANALYSIS_EVENTS_DWT)) {
             doAnalysisEventsOut(
-                (FLYSArtifact) artifactFacet.getArtifact(),
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                theme,
-                visible);
+                    (FLYSArtifact) artifactFacet.getArtifact(),
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    theme,
+                    visible);
         }
         else if (name.equals(FIX_DEVIATION_DWT)) {
             doDeviationOut(
-                (FLYSArtifact) artifactFacet.getArtifact(),
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                theme,
-                visible);
+                    (FLYSArtifact) artifactFacet.getArtifact(),
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    theme,
+                    visible);
         }
         else if (name.equals(FIX_ANALYSIS_PERIODS_DWT)) {
             doAnalysisPeriodsOut(
-                (FLYSArtifact) artifactFacet.getArtifact(),
-                artifactFacet.getData(context),
-                artifactFacet.getFacetDescription(),
-                theme,
-                visible);
+                    (FLYSArtifact) artifactFacet.getArtifact(),
+                    artifactFacet.getData(context),
+                    artifactFacet.getFacetDescription(),
+                    theme,
+                    visible);
         }
         else {
-           logger.warn("doOut(): unknown facet name: " + name);
-           return;
+            logger.warn("doOut(): unknown facet name: " + name);
+            return;
         }
     }
 
 
     protected void doSectorAverageOut(
-        FLYSArtifact artifact,
-        Object       data,
-        String       desc,
-        Document     theme,
-        boolean      visible)
+            FLYSArtifact artifact,
+            Object       data,
+            String       desc,
+            Document     theme,
+            boolean      visible)
     {
         logger.debug("doSectorAverageOut(): description = " + desc);
 
@@ -231,19 +231,29 @@
         tsc.addSeries(series);
 
         addAxisDataset(tsc, 0, visible);
-        Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>();
-        annoIdxMap.put (0, new int[]{0,0});
-        doQWDTextAnnotations(annoIdxMap, tsc, qwd.qwd, theme, visible);
+
+        if (visible && ThemeUtil.parseShowLineLabel(theme)) {
+            List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
+            XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
+                    "\u0394 W(t) [cm] " + (float)Math.round(qwd.qwd.getDeltaW() * 10000) / 10000,
+                    tsc.getXValue(0, 0),
+                    qwd.qwd.getDeltaW());
+            textAnnos.add(anno);
+
+            FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme);
+            flysAnno.setTextAnnotations(textAnnos);
+            addAnnotations(flysAnno);
+        }
     }
 
 
     protected void doAnalysisEventsOut(
-        FLYSArtifact artifact,
-        Object       data,
-        String       desc,
-        Document     theme,
-        boolean      visible
-    ) {
+            FLYSArtifact artifact,
+            Object       data,
+            String       desc,
+            Document     theme,
+            boolean      visible
+            ) {
         logger.debug("doAnalysisEventsOut: desc = " + desc);
 
         QWD qwd = (QWD) data;
@@ -317,9 +327,9 @@
             int[] idxs = entry.getValue();
             double x = tsc.getXValue(idxs[0], idxs[1]);
             XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
-                qwd.getQ() + " m\u00B3/s",
-                x,
-                qwd.getDeltaW());
+                    qwd.getQ() + " m\u00B3/s",
+                    x,
+                    qwd.getDeltaW());
             textAnnos.add(anno);
         }
 
@@ -330,12 +340,12 @@
 
 
     protected void doReferenceEventsOut(
-        FLYSArtifact artifact,
-        Object       data,
-        String       desc,
-        Document     theme,
-        boolean      visible
-    ) {
+            FLYSArtifact artifact,
+            Object       data,
+            String       desc,
+            Document     theme,
+            boolean      visible
+            ) {
         logger.debug("doReferenceEventsOut: desc = " + desc);
 
         QWD qwd = (QWD) data;
@@ -344,12 +354,12 @@
 
 
     protected void doDeviationOut(
-        FLYSArtifact artifact,
-        Object       data,
-        String       desc,
-        Document     theme,
-        boolean      visible
-    ) {
+            FLYSArtifact artifact,
+            Object       data,
+            String       desc,
+            Document     theme,
+            boolean      visible
+            ) {
         logger.debug("doDeviationOut: desc = " + desc);
 
         if (data == null || !visible) {
@@ -366,12 +376,12 @@
 
 
     protected void doAnalysisPeriodsOut(
-        FLYSArtifact artifact,
-        Object       data,
-        String       desc,
-        Document     theme,
-        boolean      visible
-    ) {
+            FLYSArtifact artifact,
+            Object       data,
+            String       desc,
+            Document     theme,
+            boolean      visible
+            ) {
         logger.debug("doHistoricalDischargeDifferenceOut: desc = " + desc);
 
         DateRange[] ranges = (DateRange[]) data;
@@ -383,8 +393,8 @@
             RegularTimePeriod start = new Day(ranges[i].getFrom());
             RegularTimePeriod end = new Day(ranges[i].getTo());
             StyledDomainMarker marker =
-                new StyledDomainMarker(start.getMiddleMillisecond(),
-                                   end.getMiddleMillisecond(), theme);
+                    new StyledDomainMarker(start.getMiddleMillisecond(),
+                            end.getMiddleMillisecond(), theme);
             marker.useSecondColor(i % 2 == 0);
             domainMarker.add(marker);
         }

http://dive4elements.wald.intevation.org