annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcFacet.java @ 9157:f9bb5d0a6ff3

Added the S-Info collision calculation and chart output
author mschaefer
date Tue, 19 Jun 2018 14:19:32 +0200
parents
children 4f411c6ee3ae
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 */
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
26 public class CollisionCalcFacet extends DataFacet {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
27
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
28 private static final long serialVersionUID = 1;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
29
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
30 public CollisionCalcFacet() {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
31 // required for clone operation deepCopy()
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
32 }
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 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
35 final String stateId, final String hash) {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
36 super(idx, name, description, type, hash, stateId);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
37 this.metaData.put("X", "sinfo.chart.km.xaxis.label");
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
38 this.metaData.put("Y", yAxisLabelKey);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
39 }
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 @Override
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
42 public Object getData(final Artifact artifact, final CallContext context) {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
43
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
44 final D4EArtifact flys = (D4EArtifact) artifact;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
45
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
46 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
47
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
48 final CollisionCalculationResults data = (CollisionCalculationResults) res.getData();
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
49
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
50 return data.getResults().get(this.index);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
51 }
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 /** Copy deeply. */
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
54 @Override
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
55 public Facet deepCopy() {
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
56 // FIXME: why not simply use the full constructor instead?
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
57 final CollisionCalcFacet copy = new CollisionCalcFacet();
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
58 // 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
59 copy.set(this);
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
60 copy.type = this.type;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
61 copy.hash = this.hash;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
62 copy.stateId = this.stateId;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
63 return copy;
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
64 }
f9bb5d0a6ff3 Added the S-Info collision calculation and chart output
mschaefer
parents:
diff changeset
65 }

http://dive4elements.wald.intevation.org