Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9156:568961ff709a | 9157:f9bb5d0a6ff3 |
---|---|
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.collision; | |
12 | |
13 import org.dive4elements.artifactdatabase.state.Facet; | |
14 import org.dive4elements.artifacts.Artifact; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.D4EArtifact; | |
17 import org.dive4elements.river.artifacts.model.CalculationResult; | |
18 import org.dive4elements.river.artifacts.model.DataFacet; | |
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
20 | |
21 /** | |
22 * Facet for calculated river bed collision counts | |
23 * | |
24 * @author Matthias Schäfer | |
25 */ | |
26 public class CollisionCalcFacet extends DataFacet { | |
27 | |
28 private static final long serialVersionUID = 1; | |
29 | |
30 public CollisionCalcFacet() { | |
31 // required for clone operation deepCopy() | |
32 } | |
33 | |
34 public CollisionCalcFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, | |
35 final String stateId, final String hash) { | |
36 super(idx, name, description, type, hash, stateId); | |
37 this.metaData.put("X", "sinfo.chart.km.xaxis.label"); | |
38 this.metaData.put("Y", yAxisLabelKey); | |
39 } | |
40 | |
41 @Override | |
42 public Object getData(final Artifact artifact, final CallContext context) { | |
43 | |
44 final D4EArtifact flys = (D4EArtifact) artifact; | |
45 | |
46 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); | |
47 | |
48 final CollisionCalculationResults data = (CollisionCalculationResults) res.getData(); | |
49 | |
50 return data.getResults().get(this.index); | |
51 } | |
52 | |
53 /** Copy deeply. */ | |
54 @Override | |
55 public Facet deepCopy() { | |
56 // FIXME: why not simply use the full constructor instead? | |
57 final CollisionCalcFacet copy = new CollisionCalcFacet(); | |
58 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! | |
59 copy.set(this); | |
60 copy.type = this.type; | |
61 copy.hash = this.hash; | |
62 copy.stateId = this.stateId; | |
63 return copy; | |
64 } | |
65 } |