Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.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 | c68f4f227c09 |
children | 5016609663e2 |
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 | |
17 /** | |
18 * Facet to show Main W Values. | |
19 */ | |
20 public class MainValuesWFacet | |
21 extends DefaultFacet | |
22 implements FacetTypes { | |
23 | |
24 /** Do we want MainValues at Gauge (not interpolated)? */ | |
25 protected boolean isAtGauge; | |
26 | |
27 /** Trivial Constructor. */ | |
28 public MainValuesWFacet(String name, String description, boolean atGauge) { | |
29 this.description = description; | |
30 this.name = name; | |
31 this.index = 0; | |
32 this.isAtGauge = atGauge; | |
33 } | |
34 | |
35 | |
36 /** | |
37 * Returns the data this facet requires. | |
38 * | |
39 * @param artifact the owner artifact. | |
40 * @param context the CallContext (ignored). | |
41 * | |
42 * @return the data. | |
43 */ | |
44 @Override | |
45 public Object getData(Artifact artifact, CallContext context) { | |
46 MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact; | |
47 | |
48 List<NamedDouble> ws = mvArtifact.getMainValuesW(isAtGauge); | |
49 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); | |
50 | |
51 for (NamedDouble w: ws) { | |
52 xy.add(new StickyAxisAnnotation( | |
53 w.getName(), | |
54 (float) w.getValue(), | |
55 StickyAxisAnnotation.SimpleAxis.Y_AXIS)); | |
56 } | |
57 | |
58 return new FLYSAnnotation(description, xy); | |
59 } | |
60 | |
61 | |
62 /** | |
63 * Create a deep copy of this Facet. | |
64 * @return a deep copy. | |
65 */ | |
66 @Override | |
67 public MainValuesWFacet deepCopy() { | |
68 MainValuesWFacet copy = new MainValuesWFacet(this.name, | |
69 description, this.isAtGauge); | |
70 copy.set(this); | |
71 return copy; | |
72 } | |
73 } | |
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |