Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | 75ef6963f1c9 |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
68 */ | 68 */ |
69 public class FixWQCurveGenerator | 69 public class FixWQCurveGenerator |
70 extends FixChartGenerator | 70 extends FixChartGenerator |
71 implements FacetTypes | 71 implements FacetTypes |
72 { | 72 { |
73 /** Private logger. */ | 73 /** Private log. */ |
74 private static Logger logger = | 74 private static Logger log = |
75 Logger.getLogger(FixWQCurveGenerator.class); | 75 Logger.getLogger(FixWQCurveGenerator.class); |
76 | 76 |
77 public static final String I18N_CHART_TITLE = | 77 public static final String I18N_CHART_TITLE = |
78 "chart.fixings.wq.title"; | 78 "chart.fixings.wq.title"; |
79 | 79 |
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 logger.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + | 159 log.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + |
160 " Bounds Wcm: " + boundsInCM.toString()); | 160 " Bounds Wcm: " + boundsInCM.toString()); |
161 | 161 |
162 double datum = getCurrentGaugeDatum(); | 162 double datum = getCurrentGaugeDatum(); |
163 | 163 |
164 // Convert boundsInMGauge to Datum+cm | 164 // Convert boundsInMGauge to Datum+cm |
174 (Double)boundsInCM.getUpper() / 100d + datum); | 174 (Double)boundsInCM.getUpper() / 100d + datum); |
175 | 175 |
176 // Set the new combined bounds | 176 // Set the new combined bounds |
177 setYBounds(YAXIS.W.idx, boundsInMGauge); | 177 setYBounds(YAXIS.W.idx, boundsInMGauge); |
178 setYBounds(YAXIS.WCm.idx, boundsInCM); | 178 setYBounds(YAXIS.WCm.idx, boundsInCM); |
179 logger.debug("Synced Bounds W: " + boundsInMGauge.toString() + | 179 log.debug("Synced Bounds W: " + boundsInMGauge.toString() + |
180 " Bounds Wcm: " + boundsInCM.toString()); | 180 " Bounds Wcm: " + boundsInCM.toString()); |
181 } | 181 } |
182 | 182 |
183 @Override | 183 @Override |
184 public void doOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 184 public void doOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
185 logger.debug("doOut: " + aaf.getFacetName()); | 185 log.debug("doOut: " + aaf.getFacetName()); |
186 if (!prepareChartData(aaf, doc, visible)) { | 186 if (!prepareChartData(aaf, doc, visible)) { |
187 logger.warn("Unknown facet, name " + aaf.getFacetName()); | 187 log.warn("Unknown facet, name " + aaf.getFacetName()); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 /** | 191 /** |
192 * Return true if data could be handled, | 192 * Return true if data could be handled, |
235 || STATIC_WKMS_INTERPOL.equals(name) | 235 || STATIC_WKMS_INTERPOL.equals(name) |
236 || FIX_WQ_LS.equals(name)) { | 236 || FIX_WQ_LS.equals(name)) { |
237 doWQOut(aaf.getData(context), aaf, doc, visible); | 237 doWQOut(aaf.getData(context), aaf, doc, visible); |
238 } | 238 } |
239 else if (name.equals(DISCHARGE_CURVE)) { | 239 else if (name.equals(DISCHARGE_CURVE)) { |
240 logger.debug("diso " + name); | 240 log.debug("diso " + name); |
241 doDischargeOut( | 241 doDischargeOut( |
242 (WINFOArtifact) aaf.getArtifact(), | 242 (WINFOArtifact) aaf.getArtifact(), |
243 aaf.getData(context), | 243 aaf.getData(context), |
244 aaf.getFacetDescription(), | 244 aaf.getFacetDescription(), |
245 doc, | 245 doc, |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 /** Add sector average points to chart. */ | 268 /** Add sector average points to chart. */ |
269 protected void doSectorAverageOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 269 protected void doSectorAverageOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
270 logger.debug("doSectorAverageOut"); | 270 log.debug("doSectorAverageOut"); |
271 | 271 |
272 QWDDateRange qwdd = (QWDDateRange) aaf.getData(context); | 272 QWDDateRange qwdd = (QWDDateRange) aaf.getData(context); |
273 QWD qwd = qwdd != null ? qwdd.getQWD() : null; | 273 QWD qwd = qwdd != null ? qwdd.getQWD() : null; |
274 | 274 |
275 if(qwd != null) { | 275 if(qwd != null) { |
276 addQWSeries(new QWD[] { qwd }, aaf, doc, visible); | 276 addQWSeries(new QWD[] { qwd }, aaf, doc, visible); |
277 } | 277 } |
278 else { | 278 else { |
279 logger.debug("doSectorAverageOut: qwd == null"); | 279 log.debug("doSectorAverageOut: qwd == null"); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 /** Add analysis event points to chart. */ | 283 /** Add analysis event points to chart. */ |
284 protected void doAnalysisEventsOut( | 284 protected void doAnalysisEventsOut( |
285 ArtifactAndFacet aaf, | 285 ArtifactAndFacet aaf, |
286 ThemeDocument doc, | 286 ThemeDocument doc, |
287 boolean visible | 287 boolean visible |
288 ) { | 288 ) { |
289 logger.debug("doAnalysisEventsOut"); | 289 log.debug("doAnalysisEventsOut"); |
290 | 290 |
291 QWD qwd = (QWD)aaf.getData(context); | 291 QWD qwd = (QWD)aaf.getData(context); |
292 | 292 |
293 if (qwd == null) { | 293 if (qwd == null) { |
294 logger.debug("doAnalysisEventsOut: qwd == null"); | 294 log.debug("doAnalysisEventsOut: qwd == null"); |
295 return; | 295 return; |
296 } | 296 } |
297 | 297 |
298 double gaugeDatum = getCurrentGaugeDatum(); | 298 double gaugeDatum = getCurrentGaugeDatum(); |
299 boolean atGauge = gaugeDatum != 0d; | 299 boolean atGauge = gaugeDatum != 0d; |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 /** Add reference event points to chart. */ | 341 /** Add reference event points to chart. */ |
342 protected void doReferenceEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 342 protected void doReferenceEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
343 logger.debug("doReferenceEventsOut"); | 343 log.debug("doReferenceEventsOut"); |
344 | 344 |
345 QWI qwd = (QWI)aaf.getData(context); | 345 QWI qwd = (QWI)aaf.getData(context); |
346 if (qwd == null) { | 346 if (qwd == null) { |
347 logger.debug("doReferenceEventsOut: qwds == null"); | 347 log.debug("doReferenceEventsOut: qwds == null"); |
348 return; | 348 return; |
349 } | 349 } |
350 | 350 |
351 // Force empty symbol. | 351 // Force empty symbol. |
352 if (qwd.getInterpolated()) { | 352 if (qwd.getInterpolated()) { |
396 boolean visible | 396 boolean visible |
397 ) { | 397 ) { |
398 XYSeries series = new StyledXYSeries(title, theme); | 398 XYSeries series = new StyledXYSeries(title, theme); |
399 Double ckm = (Double) context.getContextValue(CURRENT_KM); | 399 Double ckm = (Double) context.getContextValue(CURRENT_KM); |
400 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { | 400 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { |
401 logger.info("addPointFromWQKms: No event data to show."); | 401 log.info("addPointFromWQKms: No event data to show."); |
402 return; | 402 return; |
403 } | 403 } |
404 double[] kms = wqkms.getKms(); | 404 double[] kms = wqkms.getKms(); |
405 double gaugeDatum = getCurrentGaugeDatum(); | 405 double gaugeDatum = getCurrentGaugeDatum(); |
406 double factor = (gaugeDatum == 0d) ? 1d : 100d; | 406 double factor = (gaugeDatum == 0d) ? 1d : 100d; |
423 } | 423 } |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 protected void doEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 427 protected void doEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
428 logger.debug("doEventsOut"); | 428 log.debug("doEventsOut"); |
429 // Find W/Q at km. | 429 // Find W/Q at km. |
430 addPointFromWQKms((WQKms) aaf.getData(context), | 430 addPointFromWQKms((WQKms) aaf.getData(context), |
431 aaf.getFacetDescription(), doc, visible); | 431 aaf.getFacetDescription(), doc, visible); |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 protected void doWQCurveOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 435 protected void doWQCurveOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
436 logger.debug("doWQCurveOut"); | 436 log.debug("doWQCurveOut"); |
437 | 437 |
438 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); | 438 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); |
439 FixFunction func = (FixFunction)facet.getData( | 439 FixFunction func = (FixFunction)facet.getData( |
440 aaf.getArtifact(), context); | 440 aaf.getArtifact(), context); |
441 | 441 |
442 if (func == null) { | 442 if (func == null) { |
443 logger.warn("doWQCurveOut: Facet does not contain FixFunction"); | 443 log.warn("doWQCurveOut: Facet does not contain FixFunction"); |
444 return; | 444 return; |
445 } | 445 } |
446 | 446 |
447 double maxQ = func.getMaxQ(); | 447 double maxQ = func.getMaxQ(); |
448 | 448 |
476 } | 476 } |
477 addAxisSeries(series, YAXIS.WCm.idx, visible); | 477 addAxisSeries(series, YAXIS.WCm.idx, visible); |
478 } | 478 } |
479 } | 479 } |
480 else { | 480 else { |
481 logger.warn("doWQCurveOut: maxQ <= 0"); | 481 log.warn("doWQCurveOut: maxQ <= 0"); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 protected void doOutlierOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { | 485 protected void doOutlierOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { |
486 logger.debug("doOutlierOut"); | 486 log.debug("doOutlierOut"); |
487 | 487 |
488 QWI[] qws = (QWI[])aaf.getData(context); | 488 QWI[] qws = (QWI[])aaf.getData(context); |
489 addQWSeries(qws, aaf, doc, visible); | 489 addQWSeries(qws, aaf, doc, visible); |
490 } | 490 } |
491 | 491 |
492 | 492 |
493 /** Add markers for q sectors. */ | 493 /** Add markers for q sectors. */ |
494 protected void doQSectorOut(ArtifactAndFacet aaf, ThemeDocument theme, boolean visible) { | 494 protected void doQSectorOut(ArtifactAndFacet aaf, ThemeDocument theme, boolean visible) { |
495 logger.debug("doQSectorOut"); | 495 log.debug("doQSectorOut"); |
496 if (!visible) { | 496 if (!visible) { |
497 return; | 497 return; |
498 } | 498 } |
499 | 499 |
500 Object qsectorsObj = aaf.getData(context); | 500 Object qsectorsObj = aaf.getData(context); |
501 if (qsectorsObj == null || !(qsectorsObj instanceof List)) { | 501 if (qsectorsObj == null || !(qsectorsObj instanceof List)) { |
502 logger.warn("No QSectors coming from data."); | 502 log.warn("No QSectors coming from data."); |
503 return; | 503 return; |
504 } | 504 } |
505 | 505 |
506 List<?> qsectorsList = (List<?>) qsectorsObj; | 506 List<?> qsectorsList = (List<?>) qsectorsObj; |
507 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { | 507 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { |
508 logger.warn("No QSectors coming from data."); | 508 log.warn("No QSectors coming from data."); |
509 return; | 509 return; |
510 } | 510 } |
511 | 511 |
512 @SuppressWarnings("unchecked") | 512 @SuppressWarnings("unchecked") |
513 List<NamedDouble> qsectors = (List<NamedDouble>) qsectorsList; | 513 List<NamedDouble> qsectors = (List<NamedDouble>) qsectorsList; |
565 ) { | 565 ) { |
566 Facet facet = aandf.getFacet(); | 566 Facet facet = aandf.getFacet(); |
567 | 567 |
568 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); | 568 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); |
569 if (wqkms instanceof double[][]) { | 569 if (wqkms instanceof double[][]) { |
570 logger.debug("Got double[][]"); | 570 log.debug("Got double[][]"); |
571 double [][] data = (double [][]) wqkms; | 571 double [][] data = (double [][]) wqkms; |
572 for (int i = 0; i< data[0].length; i++) { | 572 for (int i = 0; i< data[0].length; i++) { |
573 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), | 573 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), |
574 (float) data[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); | 574 (float) data[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); |
575 } | 575 } |
577 doAnnotations(new RiverAnnotation(facet.getDescription(), xy), | 577 doAnnotations(new RiverAnnotation(facet.getDescription(), xy), |
578 aandf, theme, visible); | 578 aandf, theme, visible); |
579 } | 579 } |
580 else { | 580 else { |
581 // Assume its WKms. | 581 // Assume its WKms. |
582 logger.debug("Got WKms"); | 582 log.debug("Got WKms"); |
583 WKms data = (WKms) wqkms; | 583 WKms data = (WKms) wqkms; |
584 | 584 |
585 Double ckm = (Double) context.getContextValue(CURRENT_KM); | 585 Double ckm = (Double) context.getContextValue(CURRENT_KM); |
586 double location = (ckm != null) | 586 double location = (ckm != null) |
587 ? ckm.doubleValue() | 587 ? ckm.doubleValue() |
611 String gaugeName = wqkms.getName(); | 611 String gaugeName = wqkms.getName(); |
612 | 612 |
613 River river = RiverUtils.getRiver(artifact); | 613 River river = RiverUtils.getRiver(artifact); |
614 | 614 |
615 if (river == null) { | 615 if (river == null) { |
616 logger.debug("no river found"); | 616 log.debug("no river found"); |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
620 Gauge gauge = river.determineGaugeByName(gaugeName); | 620 Gauge gauge = river.determineGaugeByName(gaugeName); |
621 | 621 |
622 if (gauge == null) { | 622 if (gauge == null) { |
623 logger.debug("no gauge found"); | 623 log.debug("no gauge found"); |
624 return; | 624 return; |
625 } | 625 } |
626 | 626 |
627 XYSeries series = new StyledXYSeries(description, theme); | 627 XYSeries series = new StyledXYSeries(description, theme); |
628 | 628 |
652 Object wqkms, | 652 Object wqkms, |
653 ArtifactAndFacet aaf, | 653 ArtifactAndFacet aaf, |
654 ThemeDocument theme, | 654 ThemeDocument theme, |
655 boolean visible | 655 boolean visible |
656 ) { | 656 ) { |
657 logger.debug("FixWQCurveGenerator: doWQOut"); | 657 log.debug("FixWQCurveGenerator: doWQOut"); |
658 if (wqkms instanceof WQKms) { | 658 if (wqkms instanceof WQKms) { |
659 // TODO As in doEventsOut, the value-searching should | 659 // TODO As in doEventsOut, the value-searching should |
660 // be delivered by the facet already (instead of in the Generator). | 660 // be delivered by the facet already (instead of in the Generator). |
661 logger.debug("FixWQCurveGenerator: doWQOut: WQKms"); | 661 log.debug("FixWQCurveGenerator: doWQOut: WQKms"); |
662 | 662 |
663 addPointFromWQKms((WQKms) aaf.getData(context), aaf.getFacetDescription(), theme, visible); | 663 addPointFromWQKms((WQKms) aaf.getData(context), aaf.getFacetDescription(), theme, visible); |
664 } | 664 } |
665 else { | 665 else { |
666 logger.debug("FixWQCurveGenerator: doWQOut: double[][]"); | 666 log.debug("FixWQCurveGenerator: doWQOut: double[][]"); |
667 double [][] data = (double [][]) wqkms; | 667 double [][] data = (double [][]) wqkms; |
668 | 668 |
669 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, true, theme); | 669 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, true, theme); |
670 StyledSeriesBuilder.addPoints(series, data, true); | 670 StyledSeriesBuilder.addPoints(series, data, true); |
671 | 671 |