# HG changeset patch # User Raimund Renkert # Date 1340284548 0 # Node ID 5a0aef74c3163a634cd092740f2a63bffe68751f # Parent 6f6a8e5fb7a4df17f4644fafb8178d2eef8034f9 Use different stylings for real and interpolated data points. flys-artifacts/trunk@4741 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/ChangeLog --- 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 + + * 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 * doc/conf/artifacts/fixanalysis.xml, diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java --- 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); diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java --- 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 valueMarker; + protected Map attributes; + protected boolean domainZeroLineVisible; private static final Logger logger = @@ -177,6 +182,7 @@ yBounds = new HashMap(); domainMarker = new ArrayList(); valueMarker = new ArrayList(); + attributes = new HashMap(); } @@ -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; diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java --- 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"); } diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/src/main/java/de/intevation/flys/jfree/Style.java --- 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 : diff -r 6f6a8e5fb7a4 -r 5a0aef74c316 flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java --- 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 :