Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoCalculationResult.java @ 8948:a4f1ac81f26d
Work on SINFO-FlowDepthMinMax.
Also rework of result row stuff, in order to reduce abstraction, using result type concept
author | gernotbelger |
---|---|
date | Wed, 14 Mar 2018 14:10:32 +0100 |
parents | 5d5d482da3e9 |
children | b194fa64506a |
comparison
equal
deleted
inserted
replaced
8947:86650594f051 | 8948:a4f1ac81f26d |
---|---|
11 | 11 |
12 import java.io.Serializable; | 12 import java.io.Serializable; |
13 import java.util.ArrayList; | 13 import java.util.ArrayList; |
14 import java.util.Collection; | 14 import java.util.Collection; |
15 import java.util.Collections; | 15 import java.util.Collections; |
16 import java.util.List; | |
16 | 17 |
17 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | 18 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; |
19 | |
20 import gnu.trove.TDoubleArrayList; | |
18 | 21 |
19 /** | 22 /** |
20 * @author Gernot Belger | 23 * @author Gernot Belger |
21 */ | 24 */ |
22 public abstract class AbstractSInfoCalculationResult<ROW extends AbstractSInfoResultRow> implements Serializable { | 25 public abstract class AbstractSInfoCalculationResult implements Serializable { |
23 | 26 |
24 private static final long serialVersionUID = 1L; | 27 private static final long serialVersionUID = 1L; |
25 | 28 |
26 private final Collection<ROW> rows; | 29 private final Collection<SInfoResultRow> rows; |
27 | 30 |
28 private final String label; | 31 private final String label; |
29 | 32 |
30 private final WstInfo wst; | 33 private final WstInfo wst; |
31 | 34 |
32 public AbstractSInfoCalculationResult(final String label, final WstInfo wst, final Collection<ROW> rows) { | 35 public AbstractSInfoCalculationResult(final String label, final WstInfo wst, final Collection<SInfoResultRow> rows) { |
33 this.label = label; | 36 this.label = label; |
34 this.wst = wst; | 37 this.wst = wst; |
35 this.rows = new ArrayList<>(rows); | 38 this.rows = new ArrayList<>(rows); |
36 } | 39 } |
37 | 40 |
41 | 44 |
42 public final WstInfo getWst() { | 45 public final WstInfo getWst() { |
43 return this.wst; | 46 return this.wst; |
44 } | 47 } |
45 | 48 |
46 public final void addRow(final ROW resultRow) { | 49 public final void addRow(final SInfoResultRow resultRow) { |
47 this.rows.add(resultRow); | 50 this.rows.add(resultRow); |
48 } | 51 } |
49 | 52 |
50 public final Collection<ROW> getRows() { | 53 public final Collection<SInfoResultRow> getRows() { |
51 return Collections.unmodifiableCollection(this.rows); | 54 return Collections.unmodifiableCollection(this.rows); |
52 } | 55 } |
56 | |
57 public final double[][] getStationPoints(final SInfoResultType type) { | |
58 | |
59 final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size()); | |
60 final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size()); | |
61 | |
62 for (final SInfoResultRow row : this.rows) { | |
63 | |
64 final double station = row.getDoubleValue(SInfoResultType.station); | |
65 final double value = row.getDoubleValue(type); | |
66 | |
67 xPoints.add(station); | |
68 yPoints.add(value); | |
69 } | |
70 | |
71 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; | |
72 } | |
73 | |
74 protected final <TYPE> List<TYPE> getValues(final SInfoResultType type) { | |
75 | |
76 final List<TYPE> values = new ArrayList<>(); | |
77 | |
78 for (final SInfoResultRow row : this.rows) { | |
79 @SuppressWarnings("unchecked") | |
80 final TYPE value = (TYPE) row.getValue(type); | |
81 values.add(value); | |
82 } | |
83 | |
84 return values; | |
85 } | |
53 } | 86 } |