comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java @ 5740:0516c1f8f674

FixWQCurveGenerator: Minor Refactoring.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 09:25:07 +0200
parents 9950cbb7dba3
children
comparison
equal deleted inserted replaced
5739:9950cbb7dba3 5740:0516c1f8f674
247 else { 247 else {
248 logger.debug("doReferenceEventsOut: qwds == null"); 248 logger.debug("doReferenceEventsOut: qwds == null");
249 } 249 }
250 } 250 }
251 251
252 protected void doEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { 252
253 logger.debug("doEventsOut"); 253 private void addPointFromWQKms(WQKms wqkms,
254 // Find W/Q at km. 254 String title,
255 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); 255 Document theme,
256 boolean visible
257 ) {
258 XYSeries series = new StyledXYSeries(title, theme);
256 Double ckm = (Double) context.getContextValue(CURRENT_KM); 259 Double ckm = (Double) context.getContextValue(CURRENT_KM);
257 WQKms wqkms = (WQKms) aaf.getData(context);
258 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { 260 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
259 logger.info("doEventsOut: No event data to show."); 261 logger.info("addPointFromWQKms: No event data to show.");
260 return; 262 return;
261 } 263 }
262 double[] kms = wqkms.getKms(); 264 double[] kms = wqkms.getKms();
263 for (int i = 0 ; i< kms.length; i++) { 265 for (int i = 0 ; i< kms.length; i++) {
264 if (Math.abs(kms[i] - ckm) <= EPSILON) { 266 if (Math.abs(kms[i] - ckm) <= EPSILON) {
266 addAxisSeries(series, YAXIS.W.idx, visible); 268 addAxisSeries(series, YAXIS.W.idx, visible);
267 return; 269 return;
268 } 270 }
269 } 271 }
270 } 272 }
273
274 protected void doEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
275 logger.debug("doEventsOut");
276 // Find W/Q at km.
277 addPointFromWQKms((WQKms) aaf.getData(context),
278 aaf.getFacetDescription(), doc, visible);
279 }
280
271 281
272 protected void doWQCurveOut(ArtifactAndFacet aaf, Document doc, boolean visible) { 282 protected void doWQCurveOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
273 logger.debug("doWQCurveOut"); 283 logger.debug("doWQCurveOut");
274 284
275 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); 285 FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet();
461 if (wqkms instanceof WQKms) { 471 if (wqkms instanceof WQKms) {
462 // TODO As in doEventsOut, the value-searching should 472 // TODO As in doEventsOut, the value-searching should
463 // be delivered by the facet already (instead of in the Generator). 473 // be delivered by the facet already (instead of in the Generator).
464 logger.debug("FixWQCurveGenerator: doWQOut: WQKms"); 474 logger.debug("FixWQCurveGenerator: doWQOut: WQKms");
465 475
466 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); 476 addPointFromWQKms((WQKms) aaf.getData(context), aaf.getFacetDescription(), theme, visible);
467 WQKms data = (WQKms) wqkms;
468 Double ckm = (Double) context.getContextValue(CURRENT_KM);
469 if (data == null || data.getKms().length == 0 || ckm == null) {
470 logger.info("doWQOut: No event data to show.");
471 return;
472 }
473 // Search for a close match.
474 double[] kms = data.getKms();
475 for (int i = 0 ; i< kms.length; i++) {
476 if (Math.abs(kms[i] - ckm) <= EPSILON) {
477 series.add(data.getQ(i), data.getW(i));
478 addAxisSeries(series, YAXIS.W.idx, visible);
479 return;
480 }
481 }
482 logger.info("doWQOut: No W/Q data for this km " + ckm);
483 } 477 }
484 else { 478 else {
479 logger.debug("FixWQCurveGenerator: doWQOut: double[][]");
485 double [][] data = (double [][]) wqkms; 480 double [][] data = (double [][]) wqkms;
486 481
487 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); 482 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
488 StyledSeriesBuilder.addPoints(series, data, true); 483 StyledSeriesBuilder.addPoints(series, data, true);
489 484

http://dive4elements.wald.intevation.org