teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5863: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5863: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.exports; ingo@403: ingo@403: import org.apache.log4j.Logger; ingo@403: ingo@403: import org.jfree.data.xy.XYSeries; ingo@403: ingo@403: import org.w3c.dom.Document; ingo@403: teichmann@5831: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; ingo@695: teichmann@5831: import org.dive4elements.river.artifacts.model.FacetTypes; teichmann@5831: import org.dive4elements.river.artifacts.model.WQCKms; teichmann@5831: import org.dive4elements.river.artifacts.model.WQKms; teichmann@5831: import org.dive4elements.river.exports.process.Processor; teichmann@5831: import org.dive4elements.river.exports.process.WOutProcessor; ingo@403: teichmann@5831: import org.dive4elements.river.jfree.FLYSAnnotation; teichmann@5831: import org.dive4elements.river.jfree.StyledXYSeries; felix@1862: ingo@403: felix@2206: ingo@403: /** ingo@403: * An OutGenerator that generates discharge longitudinal section curves. ingo@403: * ingo@403: * @author Ingo Weinzierl ingo@403: */ ingo@403: public class DischargeLongitudinalSectionGenerator ingo@403: extends LongitudinalSectionGenerator felix@2206: implements FacetTypes ingo@403: { ingo@403: private static Logger logger = ingo@403: Logger.getLogger(DischargeLongitudinalSectionGenerator.class); ingo@403: ingo@403: ingo@420: public DischargeLongitudinalSectionGenerator() { ingo@420: super(); ingo@420: } ingo@420: ingo@420: sascha@719: @Override ingo@1684: public void doOut( felix@1944: ArtifactAndFacet artifactFacet, felix@1944: Document attr, felix@1944: boolean visible ingo@1684: ) { ingo@403: logger.debug("DischargeLongitudinalSectionGenerator.doOut"); ingo@403: felix@1944: String name = artifactFacet.getFacetName(); sascha@719: sascha@719: if (name == null) { sascha@719: return; sascha@719: } ingo@696: felix@1944: Facet facet = artifactFacet.getFacet(); ingo@696: rrenkert@5138: if (name.contains(DISCHARGE_LONGITUDINAL_Q)) { ingo@2325: doQOut( ingo@2325: (WQKms) artifactFacet.getData(context), ingo@2325: artifactFacet, ingo@2325: attr, ingo@2325: visible); ingo@696: } felix@1867: else if (name.equals(DISCHARGE_LONGITUDINAL_C)) { ingo@1684: doCorrectedWOut( felix@1944: (WQCKms) artifactFacet.getData(context), ingo@1712: facet, ingo@1684: attr, ingo@1684: visible); ingo@403: } felix@1867: else if (name.equals(LONGITUDINAL_ANNOTATION)) { felix@1944: doAnnotations((FLYSAnnotation) artifactFacet.getData(context), ingo@2325: artifactFacet, attr, visible); felix@1867: } felix@2206: else if (FacetTypes.IS.MANUALPOINTS(name)) { felix@2206: doPoints(artifactFacet.getData(context), ingo@2325: artifactFacet, felix@2206: attr, visible, YAXIS.W.idx); felix@2206: } ingo@403: else { bjoern@4448: Processor processor = new WOutProcessor(); bjoern@4448: if (processor.canHandle(name)) { bjoern@4448: processor.doOut(this, artifactFacet, attr, visible, YAXIS.W.idx); bjoern@4448: } bjoern@4448: else { bjoern@4448: logger.warn("Unknown facet name: " + name); bjoern@4448: } ingo@403: } ingo@403: } ingo@403: ingo@403: ingo@403: /** ingo@403: * Adds a new series for the corrected W curve. ingo@403: * ingo@403: * @param wqckms The object that contains the corrected W values. ingo@924: * @param theme The theme that contains styling information. ingo@403: */ ingo@1684: protected void doCorrectedWOut( ingo@1684: WQCKms wqckms, ingo@1712: Facet facet, ingo@1684: Document theme, ingo@1684: boolean visible ingo@1684: ) { ingo@403: logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut"); ingo@403: sascha@719: int size = wqckms.size(); ingo@403: sascha@719: if (size > 0) { ingo@924: XYSeries series = new StyledXYSeries( ingo@1712: facet.getDescription(), ingo@924: theme); ingo@924: sascha@719: for (int i = 0; i < size; i++) { sascha@925: series.add(wqckms.getKm(i), wqckms.getC(i)); sascha@719: } ingo@923: felix@1933: addAxisSeries(series, YAXIS.W.idx, visible); ingo@403: } sascha@745: sascha@745: if (wqckms.guessWaterIncreasing()) { sascha@745: setInverted(true); sascha@745: } ingo@403: } ingo@403: } ingo@403: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :