Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterTopFacet.java @ 7987:98ca61cb58fb facet-metadata
Split bed quality facets and updated processors and state.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 09:31:14 +0200 |
parents | |
children | 5acaf44062b5 |
comparison
equal
deleted
inserted
replaced
7986:b0cee7dfd6fe | 7987:98ca61cb58fb |
---|---|
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.model.minfo; | |
10 | |
11 import org.apache.log4j.Logger; | |
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 /** | |
23 * Facet for serving bed diameter data. | |
24 * | |
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
26 */ | |
27 public class BedDiameterTopFacet extends DataFacet { | |
28 | |
29 private static final long serialVersionUID = 1L; | |
30 | |
31 private static Logger logger = Logger.getLogger(BedDiameterTopFacet.class); | |
32 | |
33 public BedDiameterTopFacet() { | |
34 } | |
35 | |
36 public BedDiameterTopFacet(int idx, String name, String description, | |
37 ComputeType type, String stateId, String hash) { | |
38 super(idx, name, description, type, hash, stateId); | |
39 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | |
40 this.metaData.put("Y", "chart.bedquality.yaxis.label.diameter"); | |
41 } | |
42 | |
43 public Object getData(Artifact artifact, CallContext context) { | |
44 logger.debug("Get data for bed diameter at index: " + index); | |
45 | |
46 D4EArtifact flys = (D4EArtifact) artifact; | |
47 | |
48 CalculationResult res = (CalculationResult) flys.compute(context, hash, | |
49 stateId, type, false); | |
50 | |
51 int ndx = index >> 8; | |
52 Object[] raw = ((BedQualityResult[]) res.getData())[ndx].getBedResults(); // TODO CAST TO SPECIFIC CLASS | |
53 | |
54 int ndy = index & 255; | |
55 if (raw != null && raw.length > ndy) { | |
56 BedDiameterResult data = (BedDiameterResult)raw[ndy]; | |
57 return data.getDiameterCapData(); | |
58 } | |
59 return null; | |
60 } | |
61 | |
62 /** Copy deeply. */ | |
63 @Override | |
64 public Facet deepCopy() { | |
65 BedDiameterTopFacet copy = new BedDiameterTopFacet(); | |
66 copy.set(this); | |
67 copy.type = type; | |
68 copy.hash = hash; | |
69 copy.stateId = stateId; | |
70 return copy; | |
71 } | |
72 } | |
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |