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