Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java @ 2424:092e519ff461
merged flys-artifacts/2.6.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:26 +0200 |
parents | 105097966111 |
children | 26f2e7e500dd |
comparison
equal
deleted
inserted
replaced
2392:8112ec686a9a | 2424:092e519ff461 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import de.intevation.artifacts.Artifact; | |
7 import de.intevation.artifacts.CallContext; | |
8 | |
9 import de.intevation.artifactdatabase.state.DefaultFacet; | |
10 | |
11 import de.intevation.flys.artifacts.MainValuesArtifact; | |
12 import de.intevation.flys.artifacts.model.FacetTypes; | |
13 import de.intevation.flys.jfree.FLYSAnnotation; | |
14 import de.intevation.flys.jfree.StickyAxisAnnotation; | |
15 | |
16 import de.intevation.flys.exports.DurationCurveGenerator; | |
17 | |
18 /** | |
19 * Facet to show Main Q Values. | |
20 * TODO Join with W implementation. | |
21 */ | |
22 public class MainValuesQFacet | |
23 extends DefaultFacet | |
24 implements FacetTypes { | |
25 | |
26 /** Do we want MainValues at Gauge (not interpolated)? */ | |
27 protected boolean isAtGauge; | |
28 | |
29 /** Trivial Constructor. */ | |
30 public MainValuesQFacet(String name, String description, boolean atGauge) { | |
31 this.description = description; | |
32 this.name = name; | |
33 this.index = 0; | |
34 this.isAtGauge = atGauge; | |
35 } | |
36 | |
37 | |
38 /** | |
39 * Returns the data this facet requires. | |
40 * | |
41 * @param artifact the owner artifact. | |
42 * @param context the CallContext (ignored). | |
43 * | |
44 * @return the data. | |
45 */ | |
46 @Override | |
47 public Object getData(Artifact artifact, CallContext context) { | |
48 MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact; | |
49 | |
50 List<NamedDouble> qs = mvArtifact.getMainValuesQ(isAtGauge); | |
51 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); | |
52 | |
53 // Rather specific case, Q-Annotations at a maybe second yaxis. | |
54 if (this.name.equals(DURATION_MAINVALUES_Q)) { | |
55 for (NamedDouble q: qs) { | |
56 xy.add(new StickyAxisAnnotation( | |
57 q.getName(), | |
58 (float) q.getValue(), | |
59 StickyAxisAnnotation.SimpleAxis.Y_AXIS, | |
60 DurationCurveGenerator.YAXIS.Q.idx)); | |
61 } | |
62 } | |
63 else { | |
64 for (NamedDouble q: qs) { | |
65 xy.add(new StickyAxisAnnotation( | |
66 q.getName(), | |
67 (float) q.getValue(), | |
68 StickyAxisAnnotation.SimpleAxis.X_AXIS)); | |
69 } | |
70 } | |
71 | |
72 return new FLYSAnnotation(description, xy); | |
73 } | |
74 | |
75 | |
76 /** | |
77 * Create a deep copy of this Facet. | |
78 * @return a deep copy. | |
79 */ | |
80 @Override | |
81 public MainValuesQFacet deepCopy() { | |
82 MainValuesQFacet copy = new MainValuesQFacet(this.name, | |
83 description, this.isAtGauge); | |
84 copy.set(this); | |
85 return copy; | |
86 } | |
87 } | |
88 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |