comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 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 a0d9a99a5d17
children bfbd478bd607
comparison
equal deleted inserted replaced
3438:b9aff8d6ff74 3439:cb11919cccf9
1 package de.intevation.flys.artifacts.model; 1 package de.intevation.flys.artifacts.model;
2 2
3 import java.util.List; 3 import java.util.List;
4 import java.util.Arrays; 4 import java.util.Arrays;
5 import java.util.Comparator;
6 import java.util.Collections; 5 import java.util.Collections;
7 6
8 import de.intevation.flys.utils.DoubleUtil; 7 import de.intevation.flys.utils.DoubleUtil;
9 8
10 import de.intevation.flys.model.River; 9 import de.intevation.flys.model.River;
24 extends Calculation 23 extends Calculation
25 { 24 {
26 private static Logger logger = Logger.getLogger(Calculation4.class); 25 private static Logger logger = Logger.getLogger(Calculation4.class);
27 26
28 public static final double MINIMAL_STEP_WIDTH = 1e-5; 27 public static final double MINIMAL_STEP_WIDTH = 1e-5;
29
30 public static final Comparator<Segment> REF_CMP =
31 new Comparator<Segment>() {
32 public int compare(Segment a, Segment b) {
33 double d = a.referencePoint - b.referencePoint;
34 if (d < 0d) return -1;
35 return d > 0d ? +1 : 0;
36 }
37 };
38 28
39 protected List<Segment> segments; 29 protected List<Segment> segments;
40 30
41 protected boolean isQ; 31 protected boolean isQ;
42 32
104 } 94 }
105 } 95 }
106 } 96 }
107 } // for all segments 97 } // for all segments
108 98
109 Collections.sort(segments, REF_CMP); 99 Collections.sort(segments, Segment.REF_CMP);
110 } 100 }
111 101
112 public CalculationResult calculate( 102 public CalculationResult calculate(
113 WstValueTable table, 103 WstValueTable table,
114 double from, double to, double step 104 double from, double to, double step

http://dive4elements.wald.intevation.org