[PATCH 3 of 3] issue1378: Add axis markers for additional long-sect. without Q (e.g. dike heights)
Wald Commits
scm-commit at wald.intevation.org
Wed Aug 21 14:52:09 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377090040 -7200
# Node ID feaf76b70190114058f73756476f3d24c78c06c5
# Parent 281190b96f4dd6098e3879c71493322cd7ab11da
issue1378: Add axis markers for additional long-sect. without Q (e.g. dike heights).
diff -r 281190b96f4d -r feaf76b70190 artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java
--- 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);
More information about the Dive4elements-commits
mailing list