comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesQFacet.java @ 9259:66b003701546

Added infrastructure height and Q annotation to S-Info flood duration curve chart
author mschaefer
date Mon, 16 Jul 2018 08:43:07 +0200
parents ef7b65576d4b
children 83ebeb620b5a
comparison
equal deleted inserted replaced
9258:d950c6055102 9259:66b003701546
14 import org.dive4elements.artifacts.CallContext; 14 import org.dive4elements.artifacts.CallContext;
15 import org.dive4elements.river.artifacts.D4EArtifact; 15 import org.dive4elements.river.artifacts.D4EArtifact;
16 import org.dive4elements.river.artifacts.model.CalculationResult; 16 import org.dive4elements.river.artifacts.model.CalculationResult;
17 import org.dive4elements.river.artifacts.model.WQDay; 17 import org.dive4elements.river.artifacts.model.WQDay;
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; 18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
19 import org.dive4elements.river.jfree.RiverAnnotation;
19 import org.dive4elements.river.jfree.StickyAxisAnnotation; 20 import org.dive4elements.river.jfree.StickyAxisAnnotation;
20 21
21 22
22 /** 23 /**
23 * Facet to show Main Q Values. 24 * Facet to show Main Q Values.
28 private static Logger log = Logger.getLogger(FloodDurationMainValuesQFacet.class); 29 private static Logger log = Logger.getLogger(FloodDurationMainValuesQFacet.class);
29 30
30 /** Trivial Constructor. */ 31 /** Trivial Constructor. */
31 public FloodDurationMainValuesQFacet(final String name, final String description) { 32 public FloodDurationMainValuesQFacet(final String name, final String description) {
32 this.description = description; 33 this.description = description;
33 this.name = name; 34 this.name = name;
34 this.index = 0; 35 this.index = 1;
35 } 36 }
36 37
37 /** 38 /**
38 * Set the hit-point in Q where a line drawn from the axis would hit the 39 * Set the hit-point in Q where a line drawn from the axis would hit the
39 * curve in WQDay (if hit). 40 * curve in WQDay (if hit).
40 * Employ linear interpolation. 41 * Employ linear interpolation.
41 */ 42 */
42 protected static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) { 43 public static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) {
43 44
44 final float q = annotation.getPos(); 45 final float q = annotation.getPos();
45 final Double day = wqday.interpolateDayByQ(q); 46 final Double day = wqday.interpolateDayByQ(q);
46 47 if (day != null)
47 if (day != null) {
48 annotation.setHitPoint(day.floatValue()); 48 annotation.setHitPoint(day.floatValue());
49 } 49 else
50 else if (log.isDebugEnabled()) {
51 log.debug("StickyAnnotation does not hit wqday curve: " + q); 50 log.debug("StickyAnnotation does not hit wqday curve: " + q);
52 }
53 } 51 }
54 52
55 53
56 /** 54 /**
57 * Returns the data this facet requires. 55 * Returns the data this facet requires.
71 69
72 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); 70 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false);
73 71
74 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); 72 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData();
75 73
76 return data.getMainValueQAnnotation(); 74 return new RiverAnnotation(this.description, data.getMainValueQAnnotations());
77 } 75 }
78 76
79 77
80 /** 78 /**
81 * Create a deep copy of this Facet. 79 * Create a deep copy of this Facet.

http://dive4elements.wald.intevation.org