felix@1122: package de.intevation.flys.artifacts.model; felix@1122: felix@1122: import org.apache.log4j.Logger; felix@1122: felix@2002: import java.util.ArrayList; felix@1975: import java.util.List; felix@1975: felix@1975: import de.intevation.flys.model.CrossSectionLine; felix@1975: felix@1122: import de.intevation.artifacts.Artifact; felix@1122: import de.intevation.artifacts.CallContext; felix@1122: felix@1122: import de.intevation.artifactdatabase.state.DefaultFacet; felix@1122: import de.intevation.artifactdatabase.state.Facet; felix@1975: import de.intevation.artifacts.DataProvider; felix@1122: felix@1981: import de.intevation.flys.artifacts.WaterLineArtifact; felix@1122: felix@1122: felix@1122: /** felix@1122: * Facet for Waterlines in Cross Sections. felix@1122: */ felix@1122: public class CrossSectionWaterLineFacet felix@1122: extends DefaultFacet felix@1122: implements FacetTypes { felix@1122: felix@1122: private static Logger logger = Logger.getLogger(CrossSectionWaterLineFacet.class); felix@1122: felix@1122: felix@1122: /** Trivial constructor, set (maybe localized) description. */ felix@1802: public CrossSectionWaterLineFacet(int idx, String description) { felix@1802: super(idx, CROSS_SECTION_WATER_LINE, description); felix@1122: } felix@1122: felix@1122: felix@1122: /** felix@1975: * Gets waterline (crossed with cross section) of waterlevel. felix@1122: */ felix@1122: public Object getData(Artifact artifact, CallContext context) { felix@1122: logger.debug("Get data for cross section water line"); felix@1122: felix@1975: List providers = context. felix@1975: getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA); felix@1975: if (providers.size() < 1) { felix@1975: logger.warn("Could not find Cross-Section data provider."); felix@1975: return new double[][] {}; felix@1975: } felix@1975: felix@1975: Object crossSection = providers.get(0) felix@1975: .provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA, null, context); felix@1975: felix@1981: WaterLineArtifact winfo = (WaterLineArtifact)artifact; felix@1122: felix@1975: return winfo.getWaterLines(this.getIndex(), (CrossSectionLine) crossSection); felix@1122: } felix@1122: felix@1136: felix@2002: public List getDataProviderKeys(Artifact art) { felix@2002: List list = new ArrayList(); felix@2002: list.add(art.identifier() + getIndex()); felix@2002: return list; felix@2002: } felix@2002: felix@2002: felix@2002: /** felix@2002: * Can provide the master cross section lines or its index. felix@2002: * @param artifact crosssection-artifact felix@2002: * @param key will respond on BLACKBOARD_CS_MASTER_DATA felix@2002: * @param param ignored felix@2002: * @param context ignored felix@2002: * @return data from artifact (cross section master track). felix@2002: */ felix@2002: public Object provideBlackboardData(Artifact artifact, felix@2002: Object key, felix@2002: Object param, felix@2002: CallContext context felix@2002: ) { felix@2002: if (key.equals(artifact.identifier() + getIndex())) { felix@2002: return getData(artifact, context); felix@2002: } felix@2002: else { felix@2002: logger.warn("Cannot provide data for key: " + key); felix@2002: return null; felix@2002: } felix@2002: } felix@2002: felix@2002: felix@1136: /** Do a deep copy. */ felix@1122: @Override felix@1122: public Facet deepCopy() { felix@1975: CrossSectionWaterLineFacet copy = new CrossSectionWaterLineFacet( felix@1975: this.getIndex(), felix@1975: this.description); felix@1122: copy.set(this); felix@1122: return copy; felix@1122: } felix@1122: } felix@1122: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :