Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Segment.java @ 655:913b52064449
Refactored version of "Berechnung 4"
flys-artifacts/trunk@2053 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 05 Jun 2011 18:24:46 +0000 |
parents | 6695e03e9b82 |
children | 8124ca1ecaaa |
comparison
equal
deleted
inserted
replaced
654:bbc966c81809 | 655:913b52064449 |
---|---|
7 | 7 |
8 import org.apache.log4j.Logger; | 8 import org.apache.log4j.Logger; |
9 | 9 |
10 import gnu.trove.TDoubleArrayList; | 10 import gnu.trove.TDoubleArrayList; |
11 | 11 |
12 import de.intevation.flys.utils.DoubleUtil; | |
13 | |
12 public class Segment | 14 public class Segment |
13 implements Serializable | 15 implements Serializable |
14 { | 16 { |
15 private static Logger logger = Logger.getLogger(Segment.class); | 17 private static Logger logger = Logger.getLogger(Segment.class); |
16 | 18 |
17 protected double from; | 19 protected double from; |
18 protected double to; | 20 protected double to; |
19 protected double [] values; | 21 protected double [] values; |
22 protected double [] backup; | |
23 protected double referencePoint; | |
20 | 24 |
21 public Segment() { | 25 public Segment() { |
26 } | |
27 | |
28 public Segment(double referencePoint) { | |
29 this.referencePoint = referencePoint; | |
22 } | 30 } |
23 | 31 |
24 public Segment(double from, double to, double [] values) { | 32 public Segment(double from, double to, double [] values) { |
25 this.from = from; | 33 this.from = from; |
26 this.to = to; | 34 this.to = to; |
41 } | 49 } |
42 sb.append(")]"); | 50 sb.append(")]"); |
43 return sb.toString(); | 51 return sb.toString(); |
44 } | 52 } |
45 | 53 |
54 public void setFrom(double from) { | |
55 this.from = from; | |
56 } | |
57 | |
58 public void backup() { | |
59 backup = (double [])values.clone(); | |
60 } | |
61 | |
62 public double getFrom() { | |
63 return from; | |
64 } | |
65 | |
66 public void setTo(double to) { | |
67 this.to = to; | |
68 } | |
69 | |
70 public double getTo() { | |
71 return to; | |
72 } | |
73 | |
74 public void setValues(double [] values) { | |
75 this.values = values; | |
76 } | |
77 | |
78 public double [] getValues() { | |
79 return values; | |
80 } | |
81 | |
82 public void setReferencePoint(double referencePoint) { | |
83 this.referencePoint = referencePoint; | |
84 } | |
85 | |
86 public double getReferencePoint() { | |
87 return referencePoint; | |
88 } | |
89 | |
46 public static List<Segment> parseSegments(String input) { | 90 public static List<Segment> parseSegments(String input) { |
47 | 91 |
48 ArrayList<Segment> segments = new ArrayList<Segment>(); | 92 ArrayList<Segment> segments = new ArrayList<Segment>(); |
49 | 93 |
50 TDoubleArrayList vs = new TDoubleArrayList(); | 94 TDoubleArrayList vs = new TDoubleArrayList(); |
60 double to = Double.parseDouble(parts[1].trim()); | 104 double to = Double.parseDouble(parts[1].trim()); |
61 | 105 |
62 vs.clear(); | 106 vs.clear(); |
63 | 107 |
64 for (String valueStr: parts[2].split(",")) { | 108 for (String valueStr: parts[2].split(",")) { |
65 vs.add(Double.parseDouble(valueStr.trim())); | 109 vs.add(DoubleUtil.round( |
110 Double.parseDouble(valueStr.trim()))); | |
66 } | 111 } |
67 | 112 |
68 double [] values = vs.toNativeArray(); | 113 double [] values = vs.toNativeArray(); |
69 segments.add(new Segment(from, to, values)); | 114 segments.add(new Segment(from, to, values)); |
70 } | 115 } |