Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | e4606eae8ea5 |
children | 1cc7653ca84f 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
154 if (fixedWinMRange != null) { | 154 if (fixedWinMRange != null) { |
155 boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), | 155 boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), |
156 fixedWinMRange.getUpperBound()); | 156 fixedWinMRange.getUpperBound()); |
157 } | 157 } |
158 | 158 |
159 log.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + | 159 log.debug("Syncing Axis Bounds. Bounds W: " |
160 " Bounds Wcm: " + boundsInCM.toString()); | 160 + boundsInMGauge.toString() |
161 + " Bounds Wcm: " + boundsInCM.toString()); | |
161 | 162 |
162 double datum = getCurrentGaugeDatum(); | 163 double datum = getCurrentGaugeDatum(); |
163 | 164 |
164 // Convert boundsInMGauge to Datum+cm | 165 // Convert boundsInMGauge to Datum+cm |
165 double convertedLower = ((Double)boundsInMGauge.getLower() - datum) * 100; | 166 double convertedLower = |
166 double convertedUpper = ((Double)boundsInMGauge.getUpper() - datum) * 100; | 167 ((Double)boundsInMGauge.getLower() - datum) * 100; |
167 Bounds convertedBounds = new DoubleBounds(convertedLower, convertedUpper); | 168 double convertedUpper = |
169 ((Double)boundsInMGauge.getUpper() - datum) * 100; | |
170 Bounds convertedBounds = | |
171 new DoubleBounds(convertedLower, convertedUpper); | |
168 | 172 |
169 // Now combine both Ranges | 173 // Now combine both Ranges |
170 boundsInCM = boundsInCM.combine(convertedBounds); | 174 boundsInCM = boundsInCM.combine(convertedBounds); |
171 | 175 |
172 // Recalculate absolute bounds | 176 // Recalculate absolute bounds |
173 boundsInMGauge = new DoubleBounds((Double)boundsInCM.getLower() / 100d + datum, | 177 boundsInMGauge = new DoubleBounds( |
174 (Double)boundsInCM.getUpper() / 100d + datum); | 178 (Double)boundsInCM.getLower() / 100d + datum, |
179 (Double)boundsInCM.getUpper() / 100d + datum); | |
175 | 180 |
176 // Set the new combined bounds | 181 // Set the new combined bounds |
177 setYBounds(YAXIS.W.idx, boundsInMGauge); | 182 setYBounds(YAXIS.W.idx, boundsInMGauge); |
178 setYBounds(YAXIS.WCm.idx, boundsInCM); | 183 setYBounds(YAXIS.WCm.idx, boundsInCM); |
179 log.debug("Synced Bounds W: " + boundsInMGauge.toString() + | 184 log.debug("Synced Bounds W: " + boundsInMGauge.toString() + |
180 " Bounds Wcm: " + boundsInCM.toString()); | 185 " Bounds Wcm: " + boundsInCM.toString()); |
181 } | 186 } |
182 | 187 |
183 @Override | 188 @Override |
184 public void doOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 189 public void doOut( |
190 ArtifactAndFacet aaf, | |
191 ThemeDocument doc, | |
192 boolean visible | |
193 ) { | |
185 log.debug("doOut: " + aaf.getFacetName()); | 194 log.debug("doOut: " + aaf.getFacetName()); |
186 if (!prepareChartData(aaf, doc, visible)) { | 195 if (!prepareChartData(aaf, doc, visible)) { |
187 log.warn("Unknown facet, name " + aaf.getFacetName()); | 196 log.warn("Unknown facet, name " + aaf.getFacetName()); |
188 } | 197 } |
189 } | 198 } |
190 | 199 |
191 /** | 200 /** |
192 * Return true if data could be handled, | 201 * Return true if data could be handled, |
193 * to be overridden to add more handled data. | 202 * to be overridden to add more handled data. |
194 */ | 203 */ |
195 public boolean prepareChartData(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 204 public boolean prepareChartData( |
205 ArtifactAndFacet aaf, | |
206 ThemeDocument doc, | |
207 boolean visible | |
208 ) { | |
196 String name = aaf.getFacetName(); | 209 String name = aaf.getFacetName(); |
197 | 210 |
198 this.artifact = (D4EArtifact) aaf.getArtifact(); | 211 this.artifact = (D4EArtifact) aaf.getArtifact(); |
199 | 212 |
200 if(name.startsWith(FIX_SECTOR_AVERAGE_WQ)) { | 213 if(name.startsWith(FIX_SECTOR_AVERAGE_WQ)) { |
264 return true; | 277 return true; |
265 } | 278 } |
266 | 279 |
267 | 280 |
268 /** Add sector average points to chart. */ | 281 /** Add sector average points to chart. */ |
269 protected void doSectorAverageOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 282 protected void doSectorAverageOut( |
283 ArtifactAndFacet aaf, | |
284 ThemeDocument doc, | |
285 boolean visible | |
286 ) { | |
270 log.debug("doSectorAverageOut"); | 287 log.debug("doSectorAverageOut"); |
271 | 288 |
272 QWDDateRange qwdd = (QWDDateRange) aaf.getData(context); | 289 QWDDateRange qwdd = (QWDDateRange) aaf.getData(context); |
273 QWD qwd = qwdd != null ? qwdd.getQWD() : null; | 290 QWD qwd = qwdd != null ? qwdd.getQWD() : null; |
274 | 291 |
319 | 336 |
320 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); | 337 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); |
321 | 338 |
322 if (visible && doc.parseShowPointLabel()) { | 339 if (visible && doc.parseShowPointLabel()) { |
323 | 340 |
324 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); | 341 List<XYTextAnnotation> textAnnos = |
342 new ArrayList<XYTextAnnotation>(); | |
325 | 343 |
326 DateFormat dateFormat = DateFormat.getDateInstance( | 344 DateFormat dateFormat = DateFormat.getDateInstance( |
327 DateFormat.SHORT); | 345 DateFormat.SHORT); |
328 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( | 346 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( |
329 dateFormat.format(qwd.getDate()), | 347 dateFormat.format(qwd.getDate()), |
330 qwd.getQ(), | 348 qwd.getQ(), |
331 w); | 349 w); |
332 textAnnos.add(anno); | 350 textAnnos.add(anno); |
333 | 351 |
334 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc); | 352 RiverAnnotation flysAnno = |
353 new RiverAnnotation(null, null, null, doc); | |
335 flysAnno.setTextAnnotations(textAnnos); | 354 flysAnno.setTextAnnotations(textAnnos); |
336 addAnnotations(flysAnno); | 355 addAnnotations(flysAnno); |
337 } | 356 } |
338 } | 357 } |
339 | 358 |
340 | 359 |
341 /** Add reference event points to chart. */ | 360 /** Add reference event points to chart. */ |
342 protected void doReferenceEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 361 protected void doReferenceEventsOut( |
362 ArtifactAndFacet aaf, | |
363 ThemeDocument doc, | |
364 boolean visible | |
365 ) { | |
343 log.debug("doReferenceEventsOut"); | 366 log.debug("doReferenceEventsOut"); |
344 | 367 |
345 QWI qwd = (QWI)aaf.getData(context); | 368 QWI qwd = (QWI)aaf.getData(context); |
346 if (qwd == null) { | 369 if (qwd == null) { |
347 log.debug("doReferenceEventsOut: qwds == null"); | 370 log.debug("doReferenceEventsOut: qwds == null"); |
377 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( | 400 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( |
378 dateFormat.format(qwd.getDate()), | 401 dateFormat.format(qwd.getDate()), |
379 qwd.getQ(), | 402 qwd.getQ(), |
380 w); | 403 w); |
381 | 404 |
382 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); | 405 List<XYTextAnnotation> textAnnos = |
406 new ArrayList<XYTextAnnotation>(); | |
383 textAnnos.add(anno); | 407 textAnnos.add(anno); |
384 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc); | 408 RiverAnnotation flysAnno = |
409 new RiverAnnotation(null, null, null, doc); | |
385 flysAnno.setTextAnnotations(textAnnos); | 410 flysAnno.setTextAnnotations(textAnnos); |
386 addAnnotations(flysAnno); | 411 addAnnotations(flysAnno); |
387 } | 412 } |
388 | 413 |
389 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); | 414 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); |
407 for (int i = 0 ; i< kms.length; i++) { | 432 for (int i = 0 ; i< kms.length; i++) { |
408 if (Math.abs(kms[i] - ckm) <= EPSILON) { | 433 if (Math.abs(kms[i] - ckm) <= EPSILON) { |
409 series.add(wqkms.getQ(i), wqkms.getW(i), false); | 434 series.add(wqkms.getQ(i), wqkms.getW(i), false); |
410 addAxisSeries(series, YAXIS.W.idx, visible); | 435 addAxisSeries(series, YAXIS.W.idx, visible); |
411 if(visible && theme.parseShowPointLabel()) { | 436 if(visible && theme.parseShowPointLabel()) { |
412 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); | 437 List<XYTextAnnotation> textAnnos = |
438 new ArrayList<XYTextAnnotation>(); | |
413 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( | 439 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( |
414 title, | 440 title, |
415 wqkms.getQ(i), | 441 wqkms.getQ(i), |
416 factor*(wqkms.getW(i)-gaugeDatum)); | 442 factor*(wqkms.getW(i)-gaugeDatum)); |
417 textAnnos.add(anno); | 443 textAnnos.add(anno); |
418 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); | 444 RiverAnnotation flysAnno = |
445 new RiverAnnotation(null, null, null, theme); | |
419 flysAnno.setTextAnnotations(textAnnos); | 446 flysAnno.setTextAnnotations(textAnnos); |
420 addAnnotations(flysAnno); | 447 addAnnotations(flysAnno); |
421 } | 448 } |
422 return; | 449 return; |
423 } | 450 } |
424 } | 451 } |
425 } | 452 } |
426 | 453 |
427 protected void doEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 454 protected void doEventsOut( |
455 ArtifactAndFacet aaf, | |
456 ThemeDocument doc, | |
457 boolean visible | |
458 ) { | |
428 log.debug("doEventsOut"); | 459 log.debug("doEventsOut"); |
429 // Find W/Q at km. | 460 // Find W/Q at km. |
430 addPointFromWQKms((WQKms) aaf.getData(context), | 461 addPointFromWQKms((WQKms) aaf.getData(context), |
431 aaf.getFacetDescription(), doc, visible); | 462 aaf.getFacetDescription(), doc, visible); |
432 } | 463 } |
433 | 464 |
434 | 465 |
435 protected void doWQCurveOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 466 protected void doWQCurveOut( |
467 ArtifactAndFacet aaf, | |
468 ThemeDocument doc, | |
469 boolean visible | |
470 ) { | |
436 log.debug("doWQCurveOut"); | 471 log.debug("doWQCurveOut"); |
437 | 472 |
438 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); | 473 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); |
439 FixFunction func = (FixFunction)facet.getData( | 474 FixFunction func = (FixFunction)facet.getData( |
440 aaf.getArtifact(), context); | 475 aaf.getArtifact(), context); |
470 maxQ); // end | 505 maxQ); // end |
471 addAxisSeries(series2, YAXIS.W.idx, false); | 506 addAxisSeries(series2, YAXIS.W.idx, false); |
472 // Use second axis at cm if at gauge. | 507 // Use second axis at cm if at gauge. |
473 for (int i = 0, N = series.getItemCount(); i < N; i++) { | 508 for (int i = 0, N = series.getItemCount(); i < N; i++) { |
474 series.updateByIndex( | 509 series.updateByIndex( |
475 i, new Double(100d*(series.getY(i).doubleValue()-gaugeDatum))); | 510 i, |
511 new Double(100d * | |
512 (series.getY(i).doubleValue() - gaugeDatum)) | |
513 ); | |
476 } | 514 } |
477 addAxisSeries(series, YAXIS.WCm.idx, visible); | 515 addAxisSeries(series, YAXIS.WCm.idx, visible); |
478 } | 516 } |
479 } | 517 } |
480 else { | 518 else { |
481 log.warn("doWQCurveOut: maxQ <= 0"); | 519 log.warn("doWQCurveOut: maxQ <= 0"); |
482 } | 520 } |
483 } | 521 } |
484 | 522 |
485 protected void doOutlierOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 523 protected void doOutlierOut( |
524 ArtifactAndFacet aaf, | |
525 ThemeDocument doc, | |
526 boolean visible | |
527 ) { | |
486 log.debug("doOutlierOut"); | 528 log.debug("doOutlierOut"); |
487 | 529 |
488 QWI[] qws = (QWI[])aaf.getData(context); | 530 QWI[] qws = (QWI[])aaf.getData(context); |
489 addQWSeries(qws, aaf, doc, visible); | 531 addQWSeries(qws, aaf, doc, visible); |
490 } | 532 } |
491 | 533 |
492 | 534 |
493 /** Add markers for q sectors. */ | 535 /** Add markers for q sectors. */ |
494 protected void doQSectorOut(ArtifactAndFacet aaf, ThemeDocument theme, boolean visible) { | 536 protected void doQSectorOut( |
537 ArtifactAndFacet aaf, | |
538 ThemeDocument theme, | |
539 boolean visible | |
540 ) { | |
495 log.debug("doQSectorOut"); | 541 log.debug("doQSectorOut"); |
496 if (!visible) { | 542 if (!visible) { |
497 return; | 543 return; |
498 } | 544 } |
499 | 545 |
502 log.warn("No QSectors coming from data."); | 548 log.warn("No QSectors coming from data."); |
503 return; | 549 return; |
504 } | 550 } |
505 | 551 |
506 List<?> qsectorsList = (List<?>) qsectorsObj; | 552 List<?> qsectorsList = (List<?>) qsectorsObj; |
507 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { | 553 if (qsectorsList.size() == 0 |
554 || !(qsectorsList.get(0) instanceof NamedDouble) | |
555 ) { | |
508 log.warn("No QSectors coming from data."); | 556 log.warn("No QSectors coming from data."); |
509 return; | 557 return; |
510 } | 558 } |
511 | 559 |
512 @SuppressWarnings("unchecked") | 560 @SuppressWarnings("unchecked") |
569 if (wqkms instanceof double[][]) { | 617 if (wqkms instanceof double[][]) { |
570 log.debug("Got double[][]"); | 618 log.debug("Got double[][]"); |
571 double [][] data = (double [][]) wqkms; | 619 double [][] data = (double [][]) wqkms; |
572 for (int i = 0; i< data[0].length; i++) { | 620 for (int i = 0; i< data[0].length; i++) { |
573 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), | 621 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), |
574 (float) data[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); | 622 (float) data[1][i], |
623 StickyAxisAnnotation.SimpleAxis.Y_AXIS)); | |
575 } | 624 } |
576 | 625 |
577 doAnnotations(new RiverAnnotation(facet.getDescription(), xy), | 626 doAnnotations(new RiverAnnotation(facet.getDescription(), xy), |
578 aandf, theme, visible); | 627 aandf, theme, visible); |
579 } | 628 } |
658 if (wqkms instanceof WQKms) { | 707 if (wqkms instanceof WQKms) { |
659 // TODO As in doEventsOut, the value-searching should | 708 // TODO As in doEventsOut, the value-searching should |
660 // be delivered by the facet already (instead of in the Generator). | 709 // be delivered by the facet already (instead of in the Generator). |
661 log.debug("FixWQCurveGenerator: doWQOut: WQKms"); | 710 log.debug("FixWQCurveGenerator: doWQOut: WQKms"); |
662 | 711 |
663 addPointFromWQKms((WQKms) aaf.getData(context), aaf.getFacetDescription(), theme, visible); | 712 addPointFromWQKms((WQKms)aaf.getData(context), |
713 aaf.getFacetDescription(), theme, visible); | |
664 } | 714 } |
665 else { | 715 else { |
666 log.debug("FixWQCurveGenerator: doWQOut: double[][]"); | 716 log.debug("FixWQCurveGenerator: doWQOut: double[][]"); |
667 double [][] data = (double [][]) wqkms; | 717 double [][] data = (double [][]) wqkms; |
668 | 718 |
669 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, true, theme); | 719 XYSeries series = new StyledXYSeries( |
720 aaf.getFacetDescription(), false, true, theme); | |
670 StyledSeriesBuilder.addPoints(series, data, true); | 721 StyledSeriesBuilder.addPoints(series, data, true); |
671 | 722 |
672 addAxisSeries(series, YAXIS.W.idx, visible); | 723 addAxisSeries(series, YAXIS.W.idx, visible); |
673 } | 724 } |
674 } | 725 } |
800 | 851 |
801 String unit = pos == 0 | 852 String unit = pos == 0 |
802 ? "cm" | 853 ? "cm" |
803 : RiverUtils.getRiver(flys).getWstUnit().getName(); | 854 : RiverUtils.getRiver(flys).getWstUnit().getName(); |
804 | 855 |
805 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT, new Object[] { unit }); | 856 return msg( |
857 I18N_YAXIS_LABEL, | |
858 I18N_YAXIS_LABEL_DEFAULT, | |
859 new Object[] { unit }); | |
806 } | 860 } |
807 | 861 |
808 @Override | 862 @Override |
809 protected ChartGenerator.YAxisWalker getYAxisWalker() { | 863 protected ChartGenerator.YAxisWalker getYAxisWalker() { |
810 return new YAxisWalker() { | 864 return new YAxisWalker() { |