8854
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
6 * documentation coming with Dive4Elements River for details. |
|
7 */ |
|
8 |
|
9 package org.dive4elements.river.artifacts.sinfo.flowdepth; |
|
10 |
|
11 import org.apache.log4j.Logger; |
|
12 import org.dive4elements.artifactdatabase.state.Facet; |
|
13 import org.dive4elements.artifacts.Artifact; |
|
14 import org.dive4elements.artifacts.CallContext; |
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
|
16 import org.dive4elements.river.artifacts.model.CalculationResult; |
|
17 import org.dive4elements.river.artifacts.model.DataFacet; |
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
|
19 |
|
20 /** |
|
21 * Facet of a FlowDepth curve. |
|
22 */ |
8884
|
23 public class FlowDepthFacet extends DataFacet { |
8854
|
24 |
8884
|
25 private static final long serialVersionUID = 1L; |
8854
|
26 |
8884
|
27 private static Logger log = Logger.getLogger(FlowDepthFacet.class); |
|
28 |
|
29 public FlowDepthFacet() { |
8854
|
30 // required for clone operation deepCopy() |
|
31 } |
|
32 |
8884
|
33 public FlowDepthFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, final String stateId, |
|
34 final String hash) { |
8854
|
35 super(idx, name, description, type, hash, stateId); |
|
36 this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label"); |
8884
|
37 this.metaData.put("Y", yAxisLabelKey); |
8854
|
38 } |
|
39 |
|
40 @Override |
8884
|
41 public Object getData(final Artifact artifact, final CallContext context) { |
|
42 log.debug("Get data for flow velocity at index: " + this.index); |
8854
|
43 |
|
44 final D4EArtifact flys = (D4EArtifact) artifact; |
|
45 |
8884
|
46 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); |
8854
|
47 |
|
48 final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData(); |
8884
|
49 |
8891
|
50 return data.getResults().get(this.index); |
8854
|
51 } |
|
52 |
|
53 /** Copy deeply. */ |
|
54 @Override |
|
55 public Facet deepCopy() { |
8891
|
56 // FIXME: why not simply use the full constructor instead? |
8884
|
57 final FlowDepthFacet copy = new FlowDepthFacet(); |
8854
|
58 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! |
|
59 copy.set(this); |
8884
|
60 copy.type = this.type; |
|
61 copy.hash = this.hash; |
|
62 copy.stateId = this.stateId; |
8854
|
63 return copy; |
|
64 } |
|
65 } |