Mercurial > dive4elements > river
changeset 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 | faf73245ec73 |
children | c1f2e792704a |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java |
diffstat | 5 files changed, 113 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed May 23 11:02:50 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed May 23 13:48:20 2012 +0000 @@ -1,3 +1,17 @@ +2012-05-23 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java: + Add (dummy-) implementation of a relative point facet. + + * src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java: + Use superclass infrastructure. Spawn RelativePointFacet. + + * doc/conf/winfo.xml: Add relativepoint facet to compatibility list + of duration curve out. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: + Add RELATIVE_POINT Facet Type. + 2012-05-23 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java,
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Wed May 23 11:02:50 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Wed May 23 13:48:20 2012 +0000 @@ -258,6 +258,7 @@ <facet name="duration_curve.mainvalues.q" description="Q Main Values at optional second axis"/> <facet name="computed_discharge_curve.mainvalues.w" description="W Main Values"/> <facet name="duration_curve.manualpoints" description="Manuelle Punkte"/> + <facet name="relativepoint" description="Points at curve"/> </facets> </outputmode> <outputmode name="durationcurve_export" description="output.durationcurve_export" mime-type="text/plain" type="export">
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Wed May 23 11:02:50 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Wed May 23 13:48:20 2012 +0000 @@ -20,6 +20,7 @@ import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.RelativePointFacet; import de.intevation.flys.artifacts.model.WKms; import de.intevation.flys.artifacts.model.WKmsFacet; import de.intevation.flys.artifacts.model.WKmsFactory; @@ -48,10 +49,6 @@ private static Logger logger = Logger.getLogger(StaticWKmsArtifact.class); - /** XPath to access initial parameter. */ - public static final String XPATH_DATA = - "/art:action/art:ids/@value"; - public static final String STATIC_STATE_NAME = "state.additional_wkms.static"; @@ -84,8 +81,7 @@ List<Facet> fs = new ArrayList<Facet>(); logger.debug(XMLUtils.toString(data)); - String code = XMLUtils.xpathString( - data, XPATH_DATA, ArtifactNamespaceContext.INSTANCE); + String code = getDatacageIDValue(data); // TODO Go for JSON, one day. //ex.: flood_protection-wstv-114-12 @@ -126,8 +122,11 @@ facetDescription); Facet csFacet = new CrossSectionWaterLineFacet(0, facetDescription); + Facet rpFacet = new RelativePointFacet(facetDescription); + fs.add(wKmsFacet); fs.add(csFacet); + fs.add(rpFacet); facets.put(state.getID(), fs); } }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed May 23 11:02:50 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed May 23 13:48:20 2012 +0000 @@ -155,5 +155,7 @@ String MIDDLE_BED_HEIGHT_SINGLE = "bedheight_middle.single"; String MIDDLE_BED_HEIGHT_EPOCH = "bedheight_middle.epoch"; String MIDDLE_BED_HEIGHT_ANNOTATION = "bedheight_middle.annotation"; + + String RELATIVE_POINT = "relativepoint"; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /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 :