annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcFacet.java @ 9205:3dae6b78e1da

inundationDuration/floodDuration multiple columns+chartLines refactoring
author gernotbelger
date Mon, 02 Jul 2018 19:01:09 +0200
parents 4f411c6ee3ae
children 0fc9c82e744e
rev   line source
9157
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
2 * Software engineering by
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
5 *
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
9 */
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
10
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
11 package org.dive4elements.river.artifacts.sinfo.collision;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
12
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
13 import org.dive4elements.artifactdatabase.state.Facet;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
14 import org.dive4elements.artifacts.Artifact;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
15 import org.dive4elements.artifacts.CallContext;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
16 import org.dive4elements.river.artifacts.D4EArtifact;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
17 import org.dive4elements.river.artifacts.model.CalculationResult;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
18 import org.dive4elements.river.artifacts.model.DataFacet;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
20
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
21 /**
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
22 * Facet for calculated river bed collision counts
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
23 *
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
24 * @author Matthias Schäfer
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
25 */
9205
3dae6b78e1da inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents: 9204
diff changeset
26 // FIXME: remove
9157
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
27 public class CollisionCalcFacet extends DataFacet {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
28
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
29 private static final long serialVersionUID = 1;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
30
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
31 public CollisionCalcFacet() {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
32 // required for clone operation deepCopy()
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
33 }
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
34
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
35 public CollisionCalcFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type,
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
36 final String stateId, final String hash) {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
37 super(idx, name, description, type, hash, stateId);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
38 this.metaData.put("X", "sinfo.chart.km.xaxis.label");
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
39 this.metaData.put("Y", yAxisLabelKey);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
40 }
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
41
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
42 @Override
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
43 public Object getData(final Artifact artifact, final CallContext context) {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
44
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
45 final D4EArtifact flys = (D4EArtifact) artifact;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
46
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
47 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
48
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
49 final CollisionCalculationResults data = (CollisionCalculationResults) res.getData();
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
50
9204
4f411c6ee3ae Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents: 9157
diff changeset
51 return data.getResults().get(0); // first result is always the one and only CollisionCalcOverviewResult
9157
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
52 }
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
53
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
54 /** Copy deeply. */
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
55 @Override
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
56 public Facet deepCopy() {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
57 // FIXME: why not simply use the full constructor instead?
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
58 final CollisionCalcFacet copy = new CollisionCalcFacet();
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
59 // FIXME: why does DataFacet does not override set? Bad access to variables of parent!
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
60 copy.set(this);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
61 copy.type = this.type;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
62 copy.hash = this.hash;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
63 copy.stateId = this.stateId;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
64 return copy;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
65 }
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
66 }

http://dive4elements.wald.intevation.org