comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.model;
2
3 import java.io.Serializable;
4
5 import java.util.ArrayList;
6
7 import gnu.trove.TDoubleArrayList;
8
9 import org.dive4elements.artifacts.CallContext;
10
11 import org.dive4elements.river.artifacts.resources.Resources;
12
13 import org.apache.log4j.Logger;
14
15
16 public class MiddleBedHeightData implements Serializable {
17
18 /** Very private logger. */
19 private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
20
21 public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single";
22 public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch";
23
24 private int startYear;
25 private int endYear;
26 private String evaluatedBy;
27 private String description;
28
29 private TDoubleArrayList km;
30 private TDoubleArrayList middleHeight;
31 private TDoubleArrayList uncertainty;
32 private TDoubleArrayList soundingWidth;
33 private TDoubleArrayList dataGap;
34 private TDoubleArrayList width;
35 private ArrayList empty;
36
37
38 protected MiddleBedHeightData(int start, int end, String eval, String desc) {
39 this.startYear = start;
40 this.endYear = end;
41 this.evaluatedBy = eval;
42 this.description = desc;
43
44 this.km = new TDoubleArrayList();
45 this.middleHeight = new TDoubleArrayList();
46 this.uncertainty = new TDoubleArrayList();
47 this.soundingWidth = new TDoubleArrayList();
48 this.dataGap = new TDoubleArrayList();
49 this.width = new TDoubleArrayList();
50 this.empty = new ArrayList();
51 }
52
53 public void addAll(double station, double height, double uncertainty,
54 double soundingWidth, double dataGap, double width, boolean isEmpty) {
55 addKM(station);
56 addMiddleHeight(height);
57 addUncertainty(uncertainty);
58 addSoundingWidth(soundingWidth);
59 addDataGap(dataGap);
60 addWidth(width);
61 addIsEmpty(isEmpty);
62 }
63
64
65 public int getStartYear() {
66 return startYear;
67 }
68
69 public int getEndYear() {
70 return endYear;
71 }
72
73 public String getEvaluatedBy() {
74 return evaluatedBy;
75 }
76
77 public String getDescription() {
78 return description;
79 }
80
81
82 protected void addKM(double km) {
83 this.km.add(km);
84 }
85
86 public double getKM(int idx) {
87 return km.get(idx);
88 }
89
90 protected void addMiddleHeight(double middleHeight) {
91 this.middleHeight.add(middleHeight);
92 }
93
94 public double getMiddleHeight(int idx) {
95 return middleHeight.get(idx);
96 }
97
98 protected void addUncertainty(double uncertainty) {
99 this.uncertainty.add(uncertainty);
100 }
101
102 public double getUncertainty(int idx) {
103 return uncertainty.get(idx);
104 }
105
106 protected void addSoundingWidth(double soundingWidth) {
107 this.soundingWidth.add(soundingWidth);
108 }
109
110 public double getSoundingWidth(int idx) {
111 return soundingWidth.get(idx);
112 }
113
114 protected void addDataGap(double gap) {
115 this.dataGap.add(gap);
116 }
117
118 public double getDataGap(int idx) {
119 return dataGap.get(idx);
120 }
121
122 protected void addIsEmpty(boolean empty) {
123 this.empty.add(empty);
124 }
125
126 public boolean isEmpty(int idx) {
127 return (Boolean) empty.get(idx);
128 }
129
130
131 protected void addWidth(double width) {
132 this.width.add(width);
133 }
134
135 public double getWidth(int idx) {
136 return width.get(idx);
137 }
138
139 public int size() {
140 return km.size();
141 }
142
143
144 /**
145 * Get the points, ready to be drawn
146 * @return [[km1, km2,...],[height1,height2,...]]
147 */
148 public double[][] getMiddleHeightsPoints() {
149 double[][] points = new double[2][size()];
150
151 for (int i = 0, n = size(); i < n; i++) {
152 if (isEmpty(i)) {
153 points[0][i] = getKM(i);
154 points[1][i] = Double.NaN;
155 }
156 else {
157 points[0][i] = getKM(i);
158 points[1][i] = getMiddleHeight(i);
159 }
160 }
161
162 return points;
163 }
164
165
166 public String getSoundingName(CallContext context) {
167 if (getStartYear() == getEndYear()) {
168 return Resources.getMsg(
169 context.getMeta(),
170 I18N_SINGLE_NAME,
171 I18N_SINGLE_NAME,
172 new Object[] { getStartYear() }
173 );
174 }
175 else {
176 return Resources.getMsg(
177 context.getMeta(),
178 I18N_EPOCH_NAME,
179 I18N_EPOCH_NAME,
180 new Object[] { getStartYear(), getEndYear() }
181 );
182 }
183 }
184 }
185 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org