Mercurial > dive4elements > river
changeset 6887:5a1078fd53e1
issue1378: Also add ability to add text-annotations.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 21 Aug 2013 12:24:45 +0200 |
parents | b410729bdcdd |
children | 281190b96f4d |
files | artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java |
diffstat | 1 files changed, 47 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Aug 21 12:01:50 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Aug 21 12:24:45 2013 +0200 @@ -8,10 +8,15 @@ package org.dive4elements.river.exports; +import java.util.ArrayList; +import java.util.List; + import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.exports.process.DischargeProcessor; +import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; import org.dive4elements.river.jfree.Bounds; import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.jfree.StickyAxisAnnotation; @@ -19,6 +24,7 @@ import org.dive4elements.river.model.Gauge; import org.dive4elements.river.model.River; import org.dive4elements.river.utils.RiverUtils; +import org.dive4elements.river.utils.ThemeUtil; import org.apache.log4j.Logger; import org.jfree.chart.annotations.XYTextAnnotation; @@ -279,6 +285,28 @@ addAxisSeries(series, YAXIS.W.idx, visible); } + + /** Add a point annotation at given x and y coordinates. */ + protected void addPointTextAnnotation( + String title, + double x, + double y, + Document theme + ) { + List<XYTextAnnotation> textAnnos = + new ArrayList<XYTextAnnotation>(); + XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( + title, + x, + y); + textAnnos.add(anno); + RiverAnnotation flysAnno = new RiverAnnotation( + null, null, null, theme); + flysAnno.setTextAnnotations(textAnnos); + addAnnotations(flysAnno); + } + + /** * Add WQ Data to plot. * @param wq data as double[][] @@ -291,8 +319,9 @@ ) { logger.debug("DischargeCurveGenerator: doWQOut"); double [][] data = (double [][]) wq; + String title = aaf.getFacetDescription(); - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + XYSeries series = new StyledXYSeries(title, theme); double translate = getCurrentGaugeDatum(); if (translate != 0d) { @@ -303,6 +332,23 @@ StyledSeriesBuilder.addPoints(series, data, true); addAxisSeries(series, YAXIS.W.idx, visible); } + + if(visible && ThemeUtil.parseShowPointLabel(theme) + && data != null && data.length != 0) { + + double[] xs = data[0]; + double[] ys = data[1]; + for (int i = 0; i < xs.length; i++) { + double x = xs[i]; + double y = ys[i]; + + if (translate != 0d) { + y = (y-translate)*100d; + } + + addPointTextAnnotation(title, x, y, theme); + } + } } }