comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationInfrastructureFacet.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
children 465347d12990
comparison
equal deleted inserted replaced
9258:d950c6055102 9259:66b003701546
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.artifacts.sinfo.flood_duration;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 import org.apache.log4j.Logger;
17 import org.dive4elements.artifactdatabase.state.DefaultFacet;
18 import org.dive4elements.artifacts.Artifact;
19 import org.dive4elements.artifacts.CallContext;
20 import org.dive4elements.river.artifacts.D4EArtifact;
21 import org.dive4elements.river.artifacts.model.CalculationResult;
22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
23 import org.dive4elements.river.jfree.RiverAnnotation;
24 import org.dive4elements.river.jfree.StickyAxisAnnotation;
25
26
27 /**
28 * Facet to show W and Q annotation lines of an infrastructure height.
29 */
30 public class FloodDurationInfrastructureFacet extends DefaultFacet {
31
32 /** Own log. */
33 private static Logger log = Logger.getLogger(FloodDurationInfrastructureFacet.class);
34
35 /** Trivial Constructor. */
36 public FloodDurationInfrastructureFacet(final String name, final String description) {
37 this.description = description;
38 this.name = name;
39 this.index = 0;
40 }
41
42
43 /**
44 * Returns the data this facet requires.
45 *
46 * @param artifact the owner artifact.
47 * @param context the CallContext (can be used to find out if in
48 * navigable fixation-setting, or durationcurve).
49 *
50 * @return the data.
51 */
52 @Override
53 public Object getData(final Artifact artifact, final CallContext context) {
54
55 log.debug("Get data for flood duration curve infrastructure");
56
57 final D4EArtifact flys = (D4EArtifact) artifact;
58
59 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false);
60
61 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData();
62
63 final List<StickyAxisAnnotation> annotations = new ArrayList<>();
64 annotations.add(data.getInfrastructureWAnnotation());
65 annotations.add(data.getInfrastructureQAnnotation());
66 if (annotations.get(0) != null) {
67 this.description = annotations.get(0).getText(); // TODO Diagramm-Aktualisierung auslösen
68 return new RiverAnnotation(this.description, annotations);
69 }
70 else
71 return null;
72 }
73
74
75 /**
76 * Create a deep copy of this Facet.
77 * @return a deep copy.
78 */
79 @Override
80 public FloodDurationInfrastructureFacet deepCopy() {
81 final FloodDurationInfrastructureFacet copy = new FloodDurationInfrastructureFacet(this.name, this.description);
82 copy.set(this);
83 return copy;
84 }
85 }
86

http://dive4elements.wald.intevation.org