Mercurial > dive4elements > river
changeset 5740:0516c1f8f674
FixWQCurveGenerator: Minor Refactoring.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Apr 2013 09:25:07 +0200 |
parents | 9950cbb7dba3 |
children | 6e6753b9757f a4a894b15c35 |
files | flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java |
diffstat | 1 files changed, 18 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- 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);