diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java @ 2743:10e6400d4166

Added (dummy-) implementation of relative point facet in staticwkms case. flys-artifacts/trunk@4478 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 23 May 2012 13:48:20 +0000
parents
children 94c6f4ad9b98
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java	Wed May 23 13:48:20 2012 +0000
@@ -0,0 +1,91 @@
+package de.intevation.flys.artifacts.model;
+
+import java.util.List;
+import java.awt.geom.Point2D;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.DataProvider;
+
+import de.intevation.flys.artifacts.StaticWKmsArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
+
+/**
+ * Facet to access a point
+ */
+public class RelativePointFacet
+extends      BlackboardDataFacet
+implements   FacetTypes {
+
+    private static Logger logger = Logger.getLogger(RelativePointFacet.class);
+
+    /** Trivial Constructor. */
+    public RelativePointFacet(String description) {
+        this(RELATIVE_POINT, description);
+    }
+
+    public RelativePointFacet(String name, String description) {
+        this.name        = name;
+        this.description = description;
+        this.index       = 0;
+    }
+
+
+    /**
+     * Returns the data this facet requires.
+     *
+     * @param artifact the owner artifact.
+     * @param context  the CallContext (ignored).
+     *
+     * @return the data.
+     */
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        /* CrossSectionWaterLineFacet:
+        List<DataProvider> providers = context.
+            getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA);
+        if (providers.size() < 1) {
+            logger.warn("Could not find Cross-Section data provider.");
+            return new Lines.LineData(new double[][] {}, 0d, 0d);
+        }
+        
+        Object crossSection = providers.get(0)
+            .provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA, null, context);
+
+        WaterLineArtifact winfo = (WaterLineArtifact)artifact;
+        */
+        // Find out whether we live in a duration curve context, there we would
+        // provide only a single point.
+        List<DataProvider> providers = context.
+            getDataProvider("durationcurve");
+        if (providers.size() < 1) {
+            logger.debug("Could not find durationcurve data provider.");
+            //return new Lines.LineData(new double[][] {}, 0d, 0d);
+        }
+        else {
+        Object crossSection = providers.get(0)
+            .provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA, null, context);
+        
+        }
+        
+        StaticWKmsArtifact staticData =
+            (StaticWKmsArtifact) artifact;
+        //return staticData.getWKms(0);
+        return new Point2D.Double(10d,180d);
+    }
+
+
+    /**
+     * Create a deep copy of this Facet.
+     * @return a deep copy.
+     */
+    @Override
+    public RelativePointFacet deepCopy() {
+        RelativePointFacet copy = new RelativePointFacet(description);
+        copy.set(this);
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org