Mercurial > dive4elements > river
changeset 3439:cb11919cccf9
FixA 'ausgelagerte Wasserspiegellagen' move comparator code into segment class.
flys-artifacts/trunk@5102 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 23 Jul 2012 10:11:15 +0000 |
parents | b9aff8d6ff74 |
children | fed6685692d2 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Segment.java |
diffstat | 3 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Jul 23 09:37:12 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jul 23 10:11:15 2012 +0000 @@ -1,3 +1,10 @@ +2012-07-23 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/Calculation4.java + src/main/java/de/intevation/flys/artifacts/model/Segment.java: + Moved reference point comparator to segment class be be reusable + in FixA 'ausgelagerte Wasserspiegellagen'. + 2012-07-23 Christian Lins <christian.lins@intevation.de> * src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Mon Jul 23 09:37:12 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Mon Jul 23 10:11:15 2012 +0000 @@ -2,7 +2,6 @@ import java.util.List; import java.util.Arrays; -import java.util.Comparator; import java.util.Collections; import de.intevation.flys.utils.DoubleUtil; @@ -27,15 +26,6 @@ public static final double MINIMAL_STEP_WIDTH = 1e-5; - public static final Comparator<Segment> REF_CMP = - new Comparator<Segment>() { - public int compare(Segment a, Segment b) { - double d = a.referencePoint - b.referencePoint; - if (d < 0d) return -1; - return d > 0d ? +1 : 0; - } - }; - protected List<Segment> segments; protected boolean isQ; @@ -106,7 +96,7 @@ } } // for all segments - Collections.sort(segments, REF_CMP); + Collections.sort(segments, Segment.REF_CMP); } public CalculationResult calculate(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Segment.java Mon Jul 23 09:37:12 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Segment.java Mon Jul 23 10:11:15 2012 +0000 @@ -7,6 +7,7 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import org.apache.log4j.Logger; @@ -16,6 +17,16 @@ { private static Logger logger = Logger.getLogger(Segment.class); + public static final Comparator<Segment> REF_CMP = + new Comparator<Segment>() { + @Override + public int compare(Segment a, Segment b) { + double d = a.referencePoint - b.referencePoint; + if (d < 0d) return -1; + return d > 0d ? +1 : 0; + } + }; + protected double from; protected double to; protected double [] values;