comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java @ 3812:f788d2d901d6

merged flys-artifacts/pre2.6-2011-12-05
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:53 +0200
parents 1558ef7b0e7b
children c68f4f227c09
comparison
equal deleted inserted replaced
3808:5fab0fe3c445 3812:f788d2d901d6
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.jfree.chart.annotations.XYTextAnnotation;
7
8 import de.intevation.artifacts.Artifact;
9 import de.intevation.artifacts.CallContext;
10
11 import de.intevation.artifactdatabase.state.DefaultFacet;
12
13 import de.intevation.flys.artifacts.MainValuesArtifact;
14 import de.intevation.flys.artifacts.model.FacetTypes;
15 import de.intevation.flys.jfree.FLYSAnnotation;
16 import de.intevation.flys.jfree.StickyAxisAnnotation;
17
18 /**
19 * Facet to show Main W Values.
20 */
21 public class MainValuesWFacet
22 extends DefaultFacet
23 implements FacetTypes {
24
25 /** Do we want MainValues at Gauge (not interpolated)? */
26 protected boolean isAtGauge;
27
28 /** Trivial Constructor. */
29 public MainValuesWFacet(String name, String description, boolean atGauge) {
30 this.description = description;
31 this.name = name;
32 this.index = 0;
33 this.isAtGauge = atGauge;
34 }
35
36
37 /**
38 * Returns the data this facet requires.
39 *
40 * @param artifact the owner artifact.
41 * @param context the CallContext (ignored).
42 *
43 * @return the data.
44 */
45 @Override
46 public Object getData(Artifact artifact, CallContext context) {
47 MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact;
48
49 List<NamedDouble> ws = mvArtifact.getMainValuesW(isAtGauge);
50 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
51
52 for (NamedDouble w: ws) {
53 xy.add(new StickyAxisAnnotation(
54 w.getName(),
55 (float) w.getValue(),
56 StickyAxisAnnotation.SimpleAxis.Y_AXIS));
57 }
58
59 return new FLYSAnnotation(description, xy);
60 }
61
62
63 /**
64 * Create a deep copy of this Facet.
65 * @return a deep copy.
66 */
67 @Override
68 public MainValuesWFacet deepCopy() {
69 MainValuesWFacet copy = new MainValuesWFacet(this.name,
70 description, this.isAtGauge);
71 copy.set(this);
72 return copy;
73 }
74 }
75 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org