# HG changeset patch # User Ingo Weinzierl # Date 1318235730 0 # Node ID 5201173c3db5a4133a4a3a4d6d594e9b05f94d89 # Parent 17648043429f382e687353df78c2f777deef36d1 Bugfixes: #150 #345 Corrected the determination to invert the x axis in longitudinal section charts. flys-artifacts/trunk@2916 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 17648043429f -r 5201173c3db5 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Oct 10 07:47:30 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Oct 10 08:35:30 2011 +0000 @@ -1,3 +1,13 @@ +2011-10-10 Ingo Weinzierl + + flys/issue150 (Diagramm: Anzeige von W bergauf) + flys/issue345 (W-INFO / Wasserspiegellagenberechnung, Diagrammausgabe) + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java: + Corrected the determination to invert the x axis, so that waterlines + will start with their highest value at the left and end with their + lowest values at the right. + 2011-10-10 Felix Wolfsteller * src/main/java/de/intevation/flys/artifacts/math/DifferenceCurveFacet.java: diff -r 17648043429f -r 5201173c3db5 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Mon Oct 10 07:47:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Mon Oct 10 08:35:30 2011 +0000 @@ -173,7 +173,7 @@ protected void invertXAxis(ValueAxis xaxis) { if (inverted) { - logger.debug("Invert X-Axis."); + logger.debug("X-Axis.setInverted(true)"); xaxis.setInverted(true); } } @@ -245,29 +245,13 @@ int size = wqkms.size(); - boolean wsUp = wqkms.guessWaterIncreasing(); - boolean kmUp = DataUtil.guessWaterIncreasing(wqkms.allKms()); - boolean inv = !(kmUp && !wsUp); - - if (logger.isDebugEnabled()) { - logger.debug("Generate series: " + series.getKey()); - logger.debug("Values : " + size); - if (size > 0) { - logger.debug("Start km: " + wqkms.getKm(0)); - logger.debug("End km: " + wqkms.getKm(size-1)); - } - logger.debug("wsUp: " + wsUp); - logger.debug("kmUp: " + kmUp); - logger.debug("inv: " + inv); - } - for (int i = 0; i < size; i++) { series.add(wqkms.getKm(i), wqkms.getW(i)); } addFirstAxisSeries(series, visible); - if (inv) { + if (needInvertAxis(wqkms)) { setInverted(true); } } @@ -286,24 +270,45 @@ int size = wqkms.size(); - if (logger.isDebugEnabled()) { - if (wqkms.size() > 0) { - logger.debug("Generate series: " + series.getKey()); - logger.debug("Start km: " + wqkms.getKm(0)); - logger.debug("End km: " + wqkms.getKm(size-1)); - logger.debug("Values : " + size); - } - } - for (int i = 0; i < size; i++) { series.add(wqkms.getKm(i), wqkms.getQ(i)); } addSecondAxisSeries(series, visible); - //if (wqkms.guessWaterIncreasing()) { - // setInverted(true); - //} + if (needInvertAxis(wqkms)) { + setInverted(true); + } + } + + + /** + * This method determines - taking JFreeCharts auto x value ordering into + * account - if the x axis need to be inverted. Waterlines in these charts + * should decrease. + * + * @param wqkms The data object that stores the x and y values used for this + * chart. + */ + public boolean needInvertAxis(WQKms wqkms) { + boolean wsUp = wqkms.guessWaterIncreasing(); + boolean kmUp = DataUtil.guessWaterIncreasing(wqkms.allKms()); + boolean inv = (wsUp && kmUp) || (!wsUp && !kmUp); + + int size = wqkms.size(); + + if (logger.isDebugEnabled()) { + logger.debug("Values : " + size); + if (size > 0) { + logger.debug("Start km: " + wqkms.getKm(0)); + logger.debug("End km: " + wqkms.getKm(size-1)); + } + logger.debug("wsUp: " + wsUp); + logger.debug("kmUp: " + kmUp); + logger.debug("inv: " + inv); + } + + return inv; }