# HG changeset patch # User Felix Wolfsteller # Date 1366183507 -7200 # Node ID 0516c1f8f6745b0a93eda4257d583d534510551d # Parent 9950cbb7dba3d89d00a69d5116ab1fb4c9d31a88 FixWQCurveGenerator: Minor Refactoring. diff -r 9950cbb7dba3 -r 0516c1f8f674 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Wed Apr 17 08:54:05 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Wed Apr 17 09:25:07 2013 +0200 @@ -249,14 +249,16 @@ } } - protected void doEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { - logger.debug("doEventsOut"); - // Find W/Q at km. - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); + + private void addPointFromWQKms(WQKms wqkms, + String title, + Document theme, + boolean visible + ) { + XYSeries series = new StyledXYSeries(title, theme); Double ckm = (Double) context.getContextValue(CURRENT_KM); - WQKms wqkms = (WQKms) aaf.getData(context); if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { - logger.info("doEventsOut: No event data to show."); + logger.info("addPointFromWQKms: No event data to show."); return; } double[] kms = wqkms.getKms(); @@ -269,6 +271,14 @@ } } + protected void doEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { + logger.debug("doEventsOut"); + // Find W/Q at km. + addPointFromWQKms((WQKms) aaf.getData(context), + aaf.getFacetDescription(), doc, visible); + } + + protected void doWQCurveOut(ArtifactAndFacet aaf, Document doc, boolean visible) { logger.debug("doWQCurveOut"); @@ -463,25 +473,10 @@ // be delivered by the facet already (instead of in the Generator). logger.debug("FixWQCurveGenerator: doWQOut: WQKms"); - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); - WQKms data = (WQKms) wqkms; - Double ckm = (Double) context.getContextValue(CURRENT_KM); - if (data == null || data.getKms().length == 0 || ckm == null) { - logger.info("doWQOut: No event data to show."); - return; - } - // Search for a close match. - double[] kms = data.getKms(); - for (int i = 0 ; i< kms.length; i++) { - if (Math.abs(kms[i] - ckm) <= EPSILON) { - series.add(data.getQ(i), data.getW(i)); - addAxisSeries(series, YAXIS.W.idx, visible); - return; - } - } - logger.info("doWQOut: No W/Q data for this km " + ckm); + addPointFromWQKms((WQKms) aaf.getData(context), aaf.getFacetDescription(), theme, visible); } else { + logger.debug("FixWQCurveGenerator: doWQOut: double[][]"); double [][] data = (double [][]) wqkms; XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);