Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationInfrastructureFacet.java @ 9259:66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Mon, 16 Jul 2018 08:43:07 +0200 |
parents | |
children | 465347d12990 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationInfrastructureFacet.java Mon Jul 16 08:43:07 2018 +0200 @@ -0,0 +1,86 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.flood_duration; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.DefaultFacet; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; +import org.dive4elements.river.jfree.RiverAnnotation; +import org.dive4elements.river.jfree.StickyAxisAnnotation; + + +/** + * Facet to show W and Q annotation lines of an infrastructure height. + */ +public class FloodDurationInfrastructureFacet extends DefaultFacet { + + /** Own log. */ + private static Logger log = Logger.getLogger(FloodDurationInfrastructureFacet.class); + + /** Trivial Constructor. */ + public FloodDurationInfrastructureFacet(final String name, final String description) { + this.description = description; + this.name = name; + this.index = 0; + } + + + /** + * Returns the data this facet requires. + * + * @param artifact the owner artifact. + * @param context the CallContext (can be used to find out if in + * navigable fixation-setting, or durationcurve). + * + * @return the data. + */ + @Override + public Object getData(final Artifact artifact, final CallContext context) { + + log.debug("Get data for flood duration curve infrastructure"); + + final D4EArtifact flys = (D4EArtifact) artifact; + + final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); + + final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); + + final List<StickyAxisAnnotation> annotations = new ArrayList<>(); + annotations.add(data.getInfrastructureWAnnotation()); + annotations.add(data.getInfrastructureQAnnotation()); + if (annotations.get(0) != null) { + this.description = annotations.get(0).getText(); // TODO Diagramm-Aktualisierung auslösen + return new RiverAnnotation(this.description, annotations); + } + else + return null; + } + + + /** + * Create a deep copy of this Facet. + * @return a deep copy. + */ + @Override + public FloodDurationInfrastructureFacet deepCopy() { + final FloodDurationInfrastructureFacet copy = new FloodDurationInfrastructureFacet(this.name, this.description); + copy.set(this); + return copy; + } +} +