comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 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 e97e710ecf3f
comparison
equal deleted inserted replaced
6888:281190b96f4d 6889:feaf76b70190
306 addAnnotations(flysAnno); 306 addAnnotations(flysAnno);
307 } 307 }
308 308
309 309
310 /** 310 /**
311 * Return true if all values in data[0] are zero or very close to it.
312 * Return false if data is null or empty
313 */
314 private boolean zeroQ(double[][] data) {
315 if (data == null || data.length == 0) {
316 return false;
317 }
318
319 boolean allZero = true;
320
321 double[] qs = data[0];
322 for (double q: qs) {
323 if (Math.abs(q) >= 0.01d) {
324 allZero = false;
325 }
326 }
327
328 return allZero;
329 }
330
331
332 /**
311 * Add WQ Data to plot. 333 * Add WQ Data to plot.
312 * @param wq data as double[][] 334 * @param wq data as double[][]
313 */ 335 */
314 protected void doWQOut( 336 protected void doWQOut(
315 Object wq, 337 Object wq,
319 ) { 341 ) {
320 logger.debug("DischargeCurveGenerator: doWQOut"); 342 logger.debug("DischargeCurveGenerator: doWQOut");
321 double [][] data = (double [][]) wq; 343 double [][] data = (double [][]) wq;
322 String title = aaf.getFacetDescription(); 344 String title = aaf.getFacetDescription();
323 345
346 double translate = getCurrentGaugeDatum();
347
348 // If no Q values (all zero) foud, add annotations
349 if (zeroQ(data)) {
350 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
351
352 for (double y: data[1]) {
353 if (translate != 0d) {
354 y = (y-translate)*100d;
355 }
356
357 xy.add(new StickyAxisAnnotation(
358 title,
359 (float) y,
360 StickyAxisAnnotation.SimpleAxis.Y_AXIS));
361 }
362
363 doAnnotations(
364 new RiverAnnotation(title, xy),
365 aaf, theme, visible);
366 return;
367 }
368
369 // Otherwise add points.
324 XYSeries series = new StyledXYSeries(title, theme); 370 XYSeries series = new StyledXYSeries(title, theme);
325 371
326 double translate = getCurrentGaugeDatum();
327 if (translate != 0d) { 372 if (translate != 0d) {
328 StyledSeriesBuilder.addPointsQW(series, data, -translate, 100d); 373 StyledSeriesBuilder.addPointsQW(series, data, -translate, 100d);
329 addAxisSeries(series, YAXIS.W.idx, visible); 374 addAxisSeries(series, YAXIS.W.idx, visible);
330 } 375 }
331 else { 376 else {

http://dive4elements.wald.intevation.org