comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 7f1fb07e4e3d
children 1cc7653ca84f 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
79 79
80 80
81 /** 81 /**
82 * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise. 82 * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise.
83 */ 83 */
84 public static double getCurrentGaugeDatum(double km, D4EArtifact artifact, double tolerance) { 84 public static double getCurrentGaugeDatum(
85 double km,
86 D4EArtifact artifact,
87 double tolerance
88 ) {
85 // Look if there is a gauge at chosen km: 89 // Look if there is a gauge at chosen km:
86 // Get gauge which is defined for km 90 // Get gauge which is defined for km
87 Gauge gauge = new RiverAccess(artifact).getRiver() 91 Gauge gauge = new RiverAccess(artifact).getRiver()
88 .determineGaugeAtStation(km); 92 .determineGaugeAtStation(km);
89 if (gauge == null) { 93 if (gauge == null) {
152 if (fixedWinMRange != null) { 156 if (fixedWinMRange != null) {
153 boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), 157 boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(),
154 fixedWinMRange.getUpperBound()); 158 fixedWinMRange.getUpperBound());
155 } 159 }
156 160
157 log.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + 161 log.debug("Syncing Axis Bounds. Bounds W: "
158 " Bounds Wcm: " + boundsInCM.toString()); 162 + boundsInMGauge.toString()
163 + " Bounds Wcm: " + boundsInCM.toString());
159 164
160 double datum = getCurrentGaugeDatum(); 165 double datum = getCurrentGaugeDatum();
161 166
162 // Convert boundsInMGauge to Datum+cm 167 // Convert boundsInMGauge to Datum+cm
163 double convertedLower = ((Double)boundsInMGauge.getLower() - datum) * 100; 168 double convertedLower =
164 double convertedUpper = ((Double)boundsInMGauge.getUpper() - datum) * 100; 169 ((Double)boundsInMGauge.getLower() - datum) * 100;
165 Bounds convertedBounds = new DoubleBounds(convertedLower, convertedUpper); 170 double convertedUpper =
171 ((Double)boundsInMGauge.getUpper() - datum) * 100;
172 Bounds convertedBounds =
173 new DoubleBounds(convertedLower, convertedUpper);
166 174
167 // Now combine both Ranges 175 // Now combine both Ranges
168 boundsInCM = boundsInCM.combine(convertedBounds); 176 boundsInCM = boundsInCM.combine(convertedBounds);
169 177
170 // Recalculate absolute bounds 178 // Recalculate absolute bounds
171 boundsInMGauge = new DoubleBounds((Double)boundsInCM.getLower() / 100d + datum, 179 boundsInMGauge = new DoubleBounds(
172 (Double)boundsInCM.getUpper() / 100d + datum); 180 (Double)boundsInCM.getLower() / 100d + datum,
181 (Double)boundsInCM.getUpper() / 100d + datum);
173 182
174 // Set the new combined bounds 183 // Set the new combined bounds
175 setYBounds(YAXIS.W.idx, boundsInMGauge); 184 setYBounds(YAXIS.W.idx, boundsInMGauge);
176 setYBounds(YAXIS.WCm.idx, boundsInCM); 185 setYBounds(YAXIS.WCm.idx, boundsInCM);
177 log.debug("Synced Bounds W: " + boundsInMGauge.toString() + 186 log.debug("Synced Bounds W: " + boundsInMGauge.toString() +
220 } 229 }
221 230
222 231
223 /* TODO is this one really needed? */ 232 /* TODO is this one really needed? */
224 @Override 233 @Override
225 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { 234 protected boolean zoomX(
235 XYPlot plot,
236 ValueAxis axis,
237 Bounds bounds,
238 Range x
239 ) {
226 boolean zoomin = super.zoom(plot, axis, bounds, x); 240 boolean zoomin = super.zoom(plot, axis, bounds, x);
227 241
228 if (!zoomin) { 242 if (!zoomin) {
229 axis.setLowerBound(0d); 243 axis.setLowerBound(0d);
230 } 244 }
238 return; 252 return;
239 } 253 }
240 log.debug("Translate some river annotation."); 254 log.debug("Translate some river annotation.");
241 double translate = getCurrentGaugeDatum(); 255 double translate = getCurrentGaugeDatum();
242 double factor = 100d; 256 double factor = 100d;
243 for (StickyAxisAnnotation annotation: riverAnnotation.getAxisTextAnnotations()){ 257 for (StickyAxisAnnotation annotation:
258 riverAnnotation.getAxisTextAnnotations()
259 ){
244 if (!annotation.atX()) { 260 if (!annotation.atX()) {
245 annotation.setPos((annotation.getPos() - translate)*factor); 261 annotation.setPos((annotation.getPos() - translate)*factor);
246 } 262 }
247 } 263 }
248 for (XYTextAnnotation annotation: riverAnnotation.getTextAnnotations()) { 264 for (
265 XYTextAnnotation annotation: riverAnnotation.getTextAnnotations()
266 ) {
249 annotation.setY((annotation.getY() - translate)*factor); 267 annotation.setY((annotation.getY() - translate)*factor);
250 } 268 }
251 } 269 }
252 270
253 271
258 boolean visible 276 boolean visible
259 ) { 277 ) {
260 String name = artifactFacet.getFacetName(); 278 String name = artifactFacet.getFacetName();
261 log.debug("DischargeCurveGenerator.doOut: " + name); 279 log.debug("DischargeCurveGenerator.doOut: " + name);
262 280
263 MiscDischargeProcessor dProcessor = new MiscDischargeProcessor(getRange()[0]); 281 MiscDischargeProcessor dProcessor = new MiscDischargeProcessor(
282 getRange()[0]);
264 if (dProcessor.canHandle(name)) { 283 if (dProcessor.canHandle(name)) {
265 // In Base DischargeCurveGenerator, always at gauge, use WCm axis. 284 // In Base DischargeCurveGenerator, always at gauge, use WCm axis.
266 dProcessor.doOut(this, artifactFacet, theme, visible, YAXIS.WCm.idx); 285 dProcessor.doOut(
286 this, artifactFacet, theme, visible, YAXIS.WCm.idx);
267 } 287 }
268 else if (name.equals(DISCHARGE_CURVE) 288 else if (name.equals(DISCHARGE_CURVE)
269 || name.equals(GAUGE_DISCHARGE_CURVE)) { 289 || name.equals(GAUGE_DISCHARGE_CURVE)) {
270 doDischargeOut( 290 doDischargeOut(
271 (D4EArtifact)artifactFacet.getArtifact(), 291 (D4EArtifact)artifactFacet.getArtifact(),
284 artifactFacet, 304 artifactFacet,
285 theme, 305 theme,
286 visible); 306 visible);
287 } 307 }
288 else { 308 else {
289 log.warn("DischargeCurveGenerator.doOut: Unknown facet name: " + name); 309 log.warn("DischargeCurveGenerator.doOut: Unknown facet name: "
310 + name);
290 return; 311 return;
291 } 312 }
292 } 313 }
293 314
294 315
406 427
407 double translate = getCurrentGaugeDatum(); 428 double translate = getCurrentGaugeDatum();
408 429
409 // If no Q values (i.e. all -1) found, add annotations. 430 // If no Q values (i.e. all -1) found, add annotations.
410 if (hasNoDischarge(data)) { 431 if (hasNoDischarge(data)) {
411 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); 432 List<StickyAxisAnnotation> xy =
433 new ArrayList<StickyAxisAnnotation>();
412 434
413 for (double y: data[1]) { 435 for (double y: data[1]) {
414 if (translate != 0d) { 436 if (translate != 0d) {
415 y = (y-translate)*100d; 437 y = (y-translate)*100d;
416 } 438 }

http://dive4elements.wald.intevation.org