Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesWFacet.java @ 9257:ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Fri, 13 Jul 2018 18:38:05 +0200 |
parents | |
children | 66b003701546 |
rev | line source |
---|---|
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
3 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
7 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
8 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
10 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
12 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
14 import org.dive4elements.artifacts.CallContext; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
16 import org.dive4elements.river.artifacts.model.CalculationResult; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.WQDay; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
19 import org.dive4elements.river.jfree.StickyAxisAnnotation; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
20 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
21 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
22 * Facet to show Main W Values. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
23 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
24 public class FloodDurationMainValuesWFacet extends DefaultFacet { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
25 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
26 /** Own log. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
27 private static Logger log = Logger.getLogger(FloodDurationMainValuesWFacet.class); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
28 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
29 /** Trivial Constructor. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
30 public FloodDurationMainValuesWFacet(final String name, final String description) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
31 this.description = description; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
32 this.name = name; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
33 this.index = 0; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
34 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
35 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
36 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
37 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
38 * Set the hit-point in W where a line drawn from the axis would hit the |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
39 * curve in WQDay (if hit). |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
40 * Employ linear interpolation. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
41 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
42 protected static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
43 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
44 final float w = annotation.getPos(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
45 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
46 final Double day = wqday.interpolateDayByW(w); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
47 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
48 if (day != null) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
49 annotation.setHitPoint(day.floatValue()); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
50 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
51 else if (log.isDebugEnabled()) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
52 log.debug("StickyAnnotation does not hit wqday curve: " + w); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
53 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
54 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
55 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
56 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
57 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
58 * Returns the data this facet provides. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
59 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
60 * @param artifact the owner artifact. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
61 * @param context the CallContext (can be used to find out if in |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
62 * navigable fixation-setting, or durationcurve). |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
63 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
64 * @return the data. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
65 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
66 @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
67 public Object getData(final Artifact artifact, final CallContext context) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
68 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
69 log.debug("Get data for flood duration main value W data"); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
70 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
71 final D4EArtifact flys = (D4EArtifact) artifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
72 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
73 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
74 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
75 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
76 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
77 return data.getMainValueWAnnotation(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
78 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
79 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
80 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
81 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
82 * Create a deep copy of this Facet. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
83 * @return a deep copy. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
84 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
85 @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
86 public FloodDurationMainValuesWFacet deepCopy() { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
87 final FloodDurationMainValuesWFacet copy = new FloodDurationMainValuesWFacet(this.name, this.description); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
88 copy.set(this); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
89 return copy; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
90 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
91 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |