comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1089:e298c4d28927

Improved mainvalues rendering. flys-artifacts/trunk@2592 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 26 Aug 2011 11:15:24 +0000
parents 07878836ee0d
children 139e7df1787c
comparison
equal deleted inserted replaced
1088:1f5b92531f72 1089:e298c4d28927
15 import de.intevation.artifacts.Artifact; 15 import de.intevation.artifacts.Artifact;
16 import de.intevation.artifacts.ArtifactFactory; 16 import de.intevation.artifacts.ArtifactFactory;
17 import de.intevation.artifacts.CallMeta; 17 import de.intevation.artifacts.CallMeta;
18 import de.intevation.flys.artifacts.model.RiverFactory; 18 import de.intevation.flys.artifacts.model.RiverFactory;
19 19
20 import de.intevation.flys.artifacts.model.MainValuesQFacet;
20 import de.intevation.flys.artifacts.model.MainValuesWFacet; 21 import de.intevation.flys.artifacts.model.MainValuesWFacet;
21 import de.intevation.flys.artifacts.model.MainValuesQFacet; 22 import de.intevation.flys.artifacts.model.NamedDouble;
22 import de.intevation.artifactdatabase.data.DefaultStateData; 23 import de.intevation.artifactdatabase.data.DefaultStateData;
23 import de.intevation.flys.artifacts.states.StaticState; 24 import de.intevation.flys.artifacts.states.StaticState;
24 25
25 import de.intevation.flys.model.Gauge; 26 import de.intevation.flys.model.Gauge;
26 import de.intevation.flys.model.MainValue; 27 import de.intevation.flys.model.MainValue;
164 return dRiver != null 165 return dRiver != null
165 ? RiverFactory.getRiver((String) dRiver.getValue()) 166 ? RiverFactory.getRiver((String) dRiver.getValue())
166 : null; 167 : null;
167 } 168 }
168 169
170 /**
171 * Access the Gauge that the mainvalues are taken from.
172 * @return Gauge that main values are taken from or null in case of
173 * invalid parameterization.
174 */
169 protected Gauge getGauge() { 175 protected Gauge getGauge() {
170 River river = getRiver(); 176 River river = getRiver();
171 177
172 if (river == null) { 178 if (river == null) {
173 return null; 179 return null;
177 (String)getData("location").getValue()); 183 (String)getData("location").getValue());
178 184
179 return river.determineGaugeByPosition(location); 185 return river.determineGaugeByPosition(location);
180 } 186 }
181 187
182 public List<MainValue> getMainValuesQ() { 188
183 List<MainValue> filteredList = new ArrayList<MainValue>(); 189 /**
190 * Get datum of Gauge.
191 * @return datum of gauge.
192 */
193 public double getGaugeDatum() {
194 Gauge gauge = getGauge();
195 if (gauge == null) { return 0.0f; }
196 return gauge.getDatum().doubleValue();
197 }
198
199
200 /**
201 * Get a list of "Q" main values.
202 * @return list of Q main values.
203 */
204 public List<NamedDouble> getMainValuesQ() {
205 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
184 Gauge gauge = getGauge(); 206 Gauge gauge = getGauge();
185 if (gauge != null) { 207 if (gauge != null) {
186 List<MainValue> orig = gauge.getMainValues(); 208 List<MainValue> orig = gauge.getMainValues();
187 for (MainValue mv : orig) { 209 for (MainValue mv : orig) {
188 if (mv.getMainValue().getType().getName().equals("Q")) { 210 if (mv.getMainValue().getType().getName().equals("Q")) {
189 filteredList.add(mv); 211 filteredList.add(new NamedDouble(
212 mv.getMainValue().getName(),
213 mv.getValue().doubleValue()
214 ));
190 } 215 }
191 } 216 }
192 } 217 }
193 return filteredList; 218 return filteredList;
194 } 219 }
195 220
196 public List<MainValue> getMainValuesW() { 221
197 List<MainValue> filteredList = new ArrayList<MainValue>(); 222 /**
223 * Get a list of "W" main values.
224 * @return list of W main values.
225 */
226 public List<NamedDouble> getMainValuesW() {
227 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
198 Gauge gauge = getGauge(); 228 Gauge gauge = getGauge();
229 double datum = gauge.getDatum().doubleValue();
230 logger.debug("DATUM:: " + datum);
199 if (gauge != null) { 231 if (gauge != null) {
200 List<MainValue> orig = gauge.getMainValues(); 232 List<MainValue> orig = gauge.getMainValues();
201 for (MainValue mv : orig) { 233 for (MainValue mv : orig) {
202 if (mv.getMainValue().getType().getName().equals("W")) { 234 if (mv.getMainValue().getType().getName().equals("W")) {
203 filteredList.add(mv); 235 filteredList.add(new NamedDouble(
236 mv.getMainValue().getName(),
237 mv.getValue().doubleValue()/100.f + datum
238 ));
204 } 239 }
205 } 240 }
206 } 241 }
207 return filteredList; 242 return filteredList;
208 } 243 }

http://dive4elements.wald.intevation.org