changeset 3134:5a0aef74c316

Use different stylings for real and interpolated data points. flys-artifacts/trunk@4741 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 21 Jun 2012 13:15:48 +0000
parents 6f6a8e5fb7a4
children d7bc53701b08
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/Style.java flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java
diffstat 6 files changed, 92 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 21 13:15:48 2012 +0000
@@ -1,3 +1,21 @@
+2012-06-21  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
+	  Added attribution for single series styling.
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java:
+	  Skip legend items for interpolated point series.
+
+	* src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java:
+	  Split analysis and reference points into two chart series. Added attribute
+	  for interpolated points for different styling.
+
+	* src/main/java/de/intevation/flys/jfree/Style.java:
+	  Added getter for renderer.
+
+	* src/main/java/de/intevation/flys/jfree/XYStyle.java:
+	  Implemented getter for renderer.
+
 2012-06-21	Christian Lins <christian.lins@intevation.de>
 
 	* doc/conf/artifacts/fixanalysis.xml,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Thu Jun 21 13:15:48 2012 +0000
@@ -1193,6 +1193,9 @@
             }
 
             LegendItem legendItem = renderer.getLegendItem(idx, s);
+            if (legendItem.getLabel().endsWith("interpol")) {
+                legendItem = null;
+            }
             if (legendItem != null) {
                 legendItem.setLabelFont(legendFont);
                 lic.add(legendItem);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Thu Jun 21 13:15:48 2012 +0000
@@ -27,6 +27,8 @@
 import org.jfree.chart.LegendItemCollection;
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+
 import org.jfree.ui.Layer;
 
 import org.jfree.data.Range;
@@ -46,6 +48,7 @@
 import de.intevation.flys.jfree.StyledTimeSeries;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
+import de.intevation.flys.jfree.StyledSeries;
 
 import de.intevation.flys.utils.ThemeAccess;
 
@@ -152,6 +155,8 @@
 
     protected List<Marker> valueMarker;
 
+    protected Map<String, String> attributes;
+
     protected boolean domainZeroLineVisible;
 
     private static final Logger logger =
@@ -177,6 +182,7 @@
         yBounds = new HashMap<Integer, Bounds>();
         domainMarker = new ArrayList<Marker>();
         valueMarker = new ArrayList<Marker>();
+        attributes = new HashMap<String, String>();
     }
 
 
@@ -207,6 +213,7 @@
         addValueAxisMarker(plot);
         adaptZoom(plot);
 
+        applySeriesAttributes(plot);
         addAnnotationsToRenderer(plot);
         return chart;
     }
@@ -675,6 +682,36 @@
         valueMarker.clear();
     }
 
+    public void addAttribute(String seriesKey, String name) {
+        attributes.put(seriesKey, name);
+    }
+
+    protected void applySeriesAttributes(XYPlot plot) {
+        int count  = plot.getDatasetCount();
+        for (int i = 0; i < count; i++) {
+            XYDataset data = plot.getDataset(i);
+            int seriesCount = data.getSeriesCount();
+            for (int j = 0; j < seriesCount; j++) {
+                StyledTimeSeries series =
+                    (StyledTimeSeries)getSeriesOf(data, j);
+                String key = series.getKey().toString();
+                if (attributes.containsKey(key)) {
+                    if (attributes.get(key).equals("interpolate")) {
+                        XYLineAndShapeRenderer renderer =
+                            series.getStyle().getRenderer();
+                        renderer.setSeriesPaint(
+                            j,
+                            renderer.getSeriesFillPaint(j));
+                        renderer.setSeriesShapesFilled(j, false);
+                        renderer.setDrawOutlines(true);
+                        renderer.setSeriesVisibleInLegend(j, Boolean.FALSE, false);
+                        logger.debug("legend: " + renderer.getSeriesVisibleInLegend(j));
+                    }
+                }
+            }
+        }
+    }
+
     /** Two Ranges that span a rectangular area. */
     public static class Area {
         protected Range xRange;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Jun 21 13:15:48 2012 +0000
@@ -240,7 +240,9 @@
 
         QWD[] qwds = (QWD[]) data;
         TimeSeriesCollection tsc = new TimeSeriesCollection();
-        TimeSeries        series = new StyledTimeSeries(desc, theme);
+
+        TimeSeries   series = new StyledTimeSeries(desc, theme);
+        TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme);
 
         if (qwds == null) {
             return;
@@ -251,11 +253,18 @@
             }
             RegularTimePeriod rtp = new Day(qwds[i].getDate());
             double value =  qwds[i].getDeltaW();
-            series.add(rtp, value);
+            boolean interpolate = qwds[i].getInterpolated();
+            if (interpolate) {
+                interpol.add(rtp, value);
+            }
+            else {
+                series.add(rtp, value);
+            }
         }
         tsc.addSeries(series);
-
+        tsc.addSeries(interpol);
         addAxisDataset(tsc, 0, visible);
+        addAttribute(desc + "interpol", "interpolate");
 
     }
 
@@ -271,7 +280,9 @@
 
         QWD[] qwds = (QWD[]) data;
         TimeSeriesCollection tsc = new TimeSeriesCollection();
-        TimeSeries        series = new StyledTimeSeries(desc, theme);
+
+        TimeSeries   series = new StyledTimeSeries(desc, theme);
+        TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme);
 
         if (qwds == null) {
             return;
@@ -280,14 +291,21 @@
             if (qwds[i] == null) {
                 continue;
             }
-            logger.debug("adding..." + qwds[i].getDate() + "; val: " + qwds[i].getDeltaW());
             RegularTimePeriod rtp = new Day(qwds[i].getDate());
             double value =  qwds[i].getDeltaW();
-            series.addOrUpdate(rtp, value);
+            boolean interpolate = qwds[i].getInterpolated();
+            if (interpolate) {
+                interpol.addOrUpdate(rtp, value);
+            }
+            else {
+                series.addOrUpdate(rtp, value);
+            }
         }
         tsc.addSeries(series);
+        tsc.addSeries(interpol);
 
         addAxisDataset(tsc, 0, visible);
+        addAttribute(desc + "interpol", "interpolate");
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/Style.java	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/Style.java	Thu Jun 21 13:15:48 2012 +0000
@@ -9,5 +9,7 @@
 public interface Style {
 
     XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx);
+
+    XYLineAndShapeRenderer getRenderer();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java	Thu Jun 21 12:26:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java	Thu Jun 21 13:15:48 2012 +0000
@@ -20,9 +20,11 @@
 
     protected Document theme;
 
+    protected XYLineAndShapeRenderer renderer;
 
     public XYStyle(Document theme) {
         this.theme = theme;
+        this.renderer = null;
     }
 
 
@@ -31,6 +33,7 @@
      * whether to draw lines and/or points.
      */
     public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx){
+        this.renderer = r;
         applyLineColor(r, idx);
         applyLineSize(r, idx);
         applyLineType(r, idx);
@@ -192,5 +195,10 @@
         EnhancedLineAndShapeRenderer er = (EnhancedLineAndShapeRenderer) r;
         er.setIsMaximumShapeVisible(idx, visible);
     }
+
+
+    public XYLineAndShapeRenderer getRenderer() {
+        return this.renderer;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org