Mercurial > dive4elements > river
comparison 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 |
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 * Facet to show Main W Values. | |
23 */ | |
24 public class FloodDurationMainValuesWFacet extends DefaultFacet { | |
25 | |
26 /** Own log. */ | |
27 private static Logger log = Logger.getLogger(FloodDurationMainValuesWFacet.class); | |
28 | |
29 /** Trivial Constructor. */ | |
30 public FloodDurationMainValuesWFacet(final String name, final String description) { | |
31 this.description = description; | |
32 this.name = name; | |
33 this.index = 0; | |
34 } | |
35 | |
36 | |
37 /** | |
38 * Set the hit-point in W 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 w = annotation.getPos(); | |
45 | |
46 final Double day = wqday.interpolateDayByW(w); | |
47 | |
48 if (day != null) { | |
49 annotation.setHitPoint(day.floatValue()); | |
50 } | |
51 else if (log.isDebugEnabled()) { | |
52 log.debug("StickyAnnotation does not hit wqday curve: " + w); | |
53 } | |
54 } | |
55 | |
56 | |
57 /** | |
58 * Returns the data this facet provides. | |
59 * | |
60 * @param artifact the owner artifact. | |
61 * @param context the CallContext (can be used to find out if in | |
62 * navigable fixation-setting, or durationcurve). | |
63 * | |
64 * @return the data. | |
65 */ | |
66 @Override | |
67 public Object getData(final Artifact artifact, final CallContext context) { | |
68 | |
69 log.debug("Get data for flood duration main value W data"); | |
70 | |
71 final D4EArtifact flys = (D4EArtifact) artifact; | |
72 | |
73 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | |
74 | |
75 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | |
76 | |
77 return data.getMainValueWAnnotation(); | |
78 } | |
79 | |
80 | |
81 /** | |
82 * Create a deep copy of this Facet. | |
83 * @return a deep copy. | |
84 */ | |
85 @Override | |
86 public FloodDurationMainValuesWFacet deepCopy() { | |
87 final FloodDurationMainValuesWFacet copy = new FloodDurationMainValuesWFacet(this.name, this.description); | |
88 copy.set(this); | |
89 return copy; | |
90 } | |
91 } | |
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |