diff flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java @ 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 0dd569e9b9f1
children 5888c4685701
line wrap: on
line diff
--- 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;

http://dive4elements.wald.intevation.org