Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java @ 2256:dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
flys-artifacts/trunk@3910 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 03 Feb 2012 18:03:26 +0000 |
parents | fdeb6d61c24c |
children | d4330439be3a |
comparison
equal
deleted
inserted
replaced
2255:eab357067e06 | 2256:dd93a8e1377a |
---|---|
1 package de.intevation.flys.artifacts.model; | 1 package de.intevation.flys.artifacts.model; |
2 | |
3 import java.util.List; | |
4 import java.util.Arrays; | |
2 | 5 |
3 import de.intevation.artifactdatabase.state.Facet; | 6 import de.intevation.artifactdatabase.state.Facet; |
4 | 7 |
5 import de.intevation.artifacts.Artifact; | 8 import de.intevation.artifacts.Artifact; |
6 import de.intevation.artifacts.CallContext; | 9 import de.intevation.artifacts.CallContext; |
13 | 16 |
14 /** Facet for W-over-Ws. */ | 17 /** Facet for W-over-Ws. */ |
15 public class ReferenceCurveFacet | 18 public class ReferenceCurveFacet |
16 extends DataFacet | 19 extends DataFacet |
17 { | 20 { |
21 public static final String BLACK_BOARD_KEY = "reference.curve.axis.scale"; | |
22 | |
23 public static final List BLACK_BOARD_KEY_LIST = | |
24 Arrays.asList(new String [] { BLACK_BOARD_KEY }); | |
25 | |
18 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class); | 26 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class); |
19 | 27 |
20 public ReferenceCurveFacet() { | 28 public ReferenceCurveFacet() { |
21 } | 29 } |
22 | 30 |
40 if (log.isDebugEnabled()) { | 48 if (log.isDebugEnabled()) { |
41 log.debug("Get data for reference curve at index: " + index + | 49 log.debug("Get data for reference curve at index: " + index + |
42 " /stateId: " + stateId); | 50 " /stateId: " + stateId); |
43 } | 51 } |
44 | 52 |
53 return getWW(artifact, context); | |
54 } | |
55 | |
56 protected WW getWW(Artifact artifact, CallContext context) { | |
45 FLYSArtifact winfo = (FLYSArtifact)artifact; | 57 FLYSArtifact winfo = (FLYSArtifact)artifact; |
46 | 58 |
47 CalculationResult res = (CalculationResult) | 59 CalculationResult res = (CalculationResult) |
48 winfo.compute(context, hash, stateId, type, false); | 60 winfo.compute(context, hash, stateId, type, false); |
49 | 61 |
50 return getInternalData((WW [])res.getData()); | 62 return ((WW [])res.getData())[index]; |
51 } | |
52 | |
53 /** To be overwritten by normalized reference curve. */ | |
54 protected Object getInternalData(WW [] wws) { | |
55 // Using the ApplyFunctionIterator to unify data processing. | |
56 return new WW.ApplyFunctionIterator(wws[index]); | |
57 } | 63 } |
58 | 64 |
59 @Override | 65 @Override |
60 public void set(Facet other) { | 66 public void set(Facet other) { |
61 super.set(other); | 67 super.set(other); |
70 public Facet deepCopy() { | 76 public Facet deepCopy() { |
71 ReferenceCurveFacet copy = new ReferenceCurveFacet(); | 77 ReferenceCurveFacet copy = new ReferenceCurveFacet(); |
72 copy.set(this); | 78 copy.set(this); |
73 return copy; | 79 return copy; |
74 } | 80 } |
81 | |
82 @Override | |
83 public List getDataProviderKeys(Artifact art) { | |
84 return BLACK_BOARD_KEY_LIST; | |
85 } | |
86 | |
87 @Override | |
88 public Object provideBlackboardData( | |
89 Artifact artifact, | |
90 Object key, | |
91 Object param, | |
92 CallContext context | |
93 ) { | |
94 if (!key.equals(BLACK_BOARD_KEY)) { | |
95 return null; | |
96 } | |
97 | |
98 Object obj = context.getContextValue("reference.curve.axis.scale"); | |
99 | |
100 if (!(obj instanceof WWAxisTypes)) { | |
101 obj = new WWAxisTypes(getWW(artifact, context)); | |
102 } | |
103 else { | |
104 ((WWAxisTypes)obj).classify(getWW(artifact, context)); | |
105 } | |
106 | |
107 return obj; | |
108 } | |
75 } | 109 } |
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |