Mercurial > dive4elements > river
changeset 6889:feaf76b70190
issue1378: Add axis markers for additional long-sect. without Q (e.g. dike heights).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 21 Aug 2013 15:00:40 +0200 |
parents | 281190b96f4d |
children | 8efef772a488 |
files | artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java |
diffstat | 1 files changed, 46 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Aug 21 15:00:04 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Aug 21 15:00:40 2013 +0200 @@ -308,6 +308,28 @@ /** + * Return true if all values in data[0] are zero or very close to it. + * Return false if data is null or empty + */ + private boolean zeroQ(double[][] data) { + if (data == null || data.length == 0) { + return false; + } + + boolean allZero = true; + + double[] qs = data[0]; + for (double q: qs) { + if (Math.abs(q) >= 0.01d) { + allZero = false; + } + } + + return allZero; + } + + + /** * Add WQ Data to plot. * @param wq data as double[][] */ @@ -321,9 +343,32 @@ double [][] data = (double [][]) wq; String title = aaf.getFacetDescription(); + double translate = getCurrentGaugeDatum(); + + // If no Q values (all zero) foud, add annotations + if (zeroQ(data)) { + List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); + + for (double y: data[1]) { + if (translate != 0d) { + y = (y-translate)*100d; + } + + xy.add(new StickyAxisAnnotation( + title, + (float) y, + StickyAxisAnnotation.SimpleAxis.Y_AXIS)); + } + + doAnnotations( + new RiverAnnotation(title, xy), + aaf, theme, visible); + return; + } + + // Otherwise add points. XYSeries series = new StyledXYSeries(title, theme); - double translate = getCurrentGaugeDatum(); if (translate != 0d) { StyledSeriesBuilder.addPointsQW(series, data, -translate, 100d); addAxisSeries(series, YAXIS.W.idx, visible);