Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1100:29c67a76ad5d
Use new helper class FLYSUtils, minor refactorization.
flys-artifacts/trunk@2603 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 29 Aug 2011 09:04:48 +0000 |
parents | f465785ed1ae |
children | 82798c992975 |
rev | line source |
---|---|
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
1095
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
10 import de.intevation.artifactdatabase.data.DefaultStateData; |
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
11 import de.intevation.artifactdatabase.data.StateData; |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
12 import de.intevation.artifactdatabase.state.Facet; |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
13 import de.intevation.artifactdatabase.state.DefaultOutput; |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
14 import de.intevation.artifactdatabase.state.State; |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
15 |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
16 import de.intevation.artifacts.Artifact; |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.ArtifactFactory; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.CallMeta; |
1095
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
19 |
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
20 import de.intevation.flys.model.Gauge; |
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
21 import de.intevation.flys.model.MainValue; |
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
22 import de.intevation.flys.model.River; |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
23 |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
24 import de.intevation.flys.artifacts.model.MainValuesQFacet; |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
25 import de.intevation.flys.artifacts.model.MainValuesWFacet; |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
26 import de.intevation.flys.artifacts.model.NamedDouble; |
1095
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
27 import de.intevation.flys.artifacts.model.RiverFactory; |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
28 import de.intevation.flys.artifacts.states.StaticState; |
1095
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
29 import de.intevation.flys.utils.FLYSUtils; |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
30 |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 /** |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 * Artifact to access names of Points Of Interest along a segment of a river. |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
34 * This artifact neglects (Static)FLYSArtifacts capabilities of interaction |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
35 * with the StateEngine by overriding the getState*-methods. |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 */ |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 public class MainValuesArtifact |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 extends StaticFLYSArtifact |
1059
fdb0f4ef96f0
Made FLYS artifacts cloneable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1051
diff
changeset
|
39 { |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 /** The logger for this class. */ |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
41 private static Logger logger = Logger.getLogger(MainValuesArtifact.class); |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /** The name of the artifact. */ |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
44 public static final String ARTIFACT_NAME = "mainvalue"; |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
45 |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
46 /** One and only state to be in. */ |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
47 protected transient State state = null; |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
48 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
49 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
50 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
51 * Trivial Constructor. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
52 */ |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 public MainValuesArtifact() { |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
54 logger.debug("MainValuesArtifact.MainValuesartifact()"); |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 } |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
57 |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 /** |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 * Gets called from factory, to set things up. |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 */ |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 @Override |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 public void setup( |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 String identifier, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 ArtifactFactory factory, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 Object context, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 CallMeta callMeta, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 Document data) |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 { |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
69 logger.debug("MainValuesArtifact.setup"); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
70 super.setup(identifier, factory, context, callMeta, data); |
1080
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
71 } |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
72 |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
73 |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
74 @Override |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
75 protected void initialize(Artifact artifact, Object context, CallMeta meta) { |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
76 logger.debug("MainValuesArtifact.initialize"); |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
77 WINFOArtifact winfo = (WINFOArtifact) artifact; |
1095
f465785ed1ae
Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1093
diff
changeset
|
78 double location = FLYSUtils.getLocations(winfo)[0]; |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
79 addData("location", new DefaultStateData("location", null, null, |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
80 String.valueOf(location))); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
81 addData("river", winfo.getData("river")); |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 } |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 /** |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
86 * Get a list containing the one and only State. |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
87 * @param context ignored. |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
88 * @return list with one and only state. |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 */ |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
90 @Override |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
91 protected List<State> getStates(Object context) { |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
92 ArrayList<State> states = new ArrayList<State>(); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
93 states.add(getState(null,null)); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
94 return states; |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
95 } |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
98 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
99 * Get the "current" state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
100 * @param cc ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
101 * @return the "current" state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
102 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
103 @Override |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
104 protected State getCurrentState(Object cc) { |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
105 return getState(); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
106 } |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
107 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
108 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
109 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
110 * Get the only possible state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
111 * @return the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
112 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
113 protected State getState() { |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
114 return getState(null, null); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
115 } |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
116 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
117 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
118 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
119 * Get the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
120 * @param context ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
121 * @param stateID ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
122 * @return the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
123 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
124 @Override |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
125 protected State getState(Object context, String stateID) { |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
126 if (state != null) { |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
127 |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
128 } |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
129 else { |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
130 state = new StaticState(); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
131 List<Facet> fs = new ArrayList<Facet>(); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
132 Facet qfacet = new MainValuesQFacet(); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
133 Facet wfacet = new MainValuesWFacet(); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
134 fs.add(qfacet); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
135 fs.add(wfacet); |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
136 // TODO check if facets and outputs already exist. |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
137 // TODO also check, this is usually done in initialize, too. |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
138 facets.put(state.getID(), fs); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
139 DefaultOutput mainValuesOutput1 = new DefaultOutput( |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
140 "discharge_curve", "output.discharge_curve", "image/png", |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
141 fs, |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
142 "chart"); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
143 DefaultOutput mainValuesOutput2 = new DefaultOutput( |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
144 "computed_discharge_curve", |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
145 "output.computed_discharge_curve", "image/png", |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
146 fs, |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
147 "chart"); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
148 |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
149 state.getOutputs().add(mainValuesOutput1); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
150 state.getOutputs().add(mainValuesOutput2); |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
151 } |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
152 return state; |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
153 } |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
154 |
1093
139e7df1787c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1089
diff
changeset
|
155 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
156 /** |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
157 * Access the Gauge that the mainvalues are taken from. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
158 * @return Gauge that main values are taken from or null in case of |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
159 * invalid parameterization. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
160 */ |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
161 protected Gauge getGauge() { |
1100
29c67a76ad5d
Use new helper class FLYSUtils, minor refactorization.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1095
diff
changeset
|
162 River river = FLYSUtils.getRiver(this); |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
163 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
164 if (river == null) { |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
165 return null; |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
166 } |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
167 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
168 double location = Double.parseDouble( |
1100
29c67a76ad5d
Use new helper class FLYSUtils, minor refactorization.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1095
diff
changeset
|
169 getDataAsString("location")); |
1079
ef756e166154
Improved implementation of MainValueArtifact#MainValueFacet .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1078
diff
changeset
|
170 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
171 return river.determineGaugeByPosition(location); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
172 } |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
173 |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
174 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
175 /** |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
176 * Get datum of Gauge. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
177 * @return datum of gauge. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
178 */ |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
179 public double getGaugeDatum() { |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
180 Gauge gauge = getGauge(); |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
181 if (gauge == null) { return 0.0f; } |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
182 return gauge.getDatum().doubleValue(); |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
183 } |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
184 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
185 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
186 /** |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
187 * Get a list of "Q" main values. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
188 * @return list of Q main values. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
189 */ |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
190 public List<NamedDouble> getMainValuesQ() { |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
191 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
192 Gauge gauge = getGauge(); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
193 if (gauge != null) { |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
194 List<MainValue> orig = gauge.getMainValues(); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
195 for (MainValue mv : orig) { |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
196 if (mv.getMainValue().getType().getName().equals("Q")) { |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
197 filteredList.add(new NamedDouble( |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
198 mv.getMainValue().getName(), |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
199 mv.getValue().doubleValue() |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
200 )); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
201 } |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
202 } |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
203 } |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
204 return filteredList; |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
205 } |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
206 |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
207 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
208 /** |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
209 * Get a list of "W" main values. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
210 * @return list of W main values. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
211 */ |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
212 public List<NamedDouble> getMainValuesW() { |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
213 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
214 Gauge gauge = getGauge(); |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
215 double datum = gauge.getDatum().doubleValue(); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
216 if (gauge != null) { |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
217 List<MainValue> orig = gauge.getMainValues(); |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
218 for (MainValue mv : orig) { |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
219 if (mv.getMainValue().getType().getName().equals("W")) { |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
220 filteredList.add(new NamedDouble( |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
221 mv.getMainValue().getName(), |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
222 mv.getValue().doubleValue()/100.f + datum |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
223 )); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
224 } |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
225 } |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
226 } |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
227 return filteredList; |
1065
193c49b7f6a3
Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
228 } |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
229 } |