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

http://dive4elements.wald.intevation.org