comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterSubFacet.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 BedDiameterSubFacet extends DataFacet {
28
29 private static final long serialVersionUID = 1L;
30
31 private static Logger logger = Logger.getLogger(BedDiameterSubFacet.class);
32
33 public BedDiameterSubFacet() {
34 }
35
36 public BedDiameterSubFacet(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 =
53 ((BedQualityResult[]) res.getData())[ndx].getBedResults();
54
55 int ndy = index & 255;
56 if (raw != null && raw.length > ndy) {
57 BedDiameterResult data = (BedDiameterResult)raw[ndy];
58 return data.getDiameterSubData();
59 }
60 return null;
61 }
62
63 /** Copy deeply. */
64 @Override
65 public Facet deepCopy() {
66 BedDiameterSubFacet copy = new BedDiameterSubFacet();
67 copy.set(this);
68 copy.type = type;
69 copy.hash = hash;
70 copy.stateId = stateId;
71 return copy;
72 }
73 }
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org