felix@6551: /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde felix@6551: * Software engineering by Intevation GmbH felix@6551: * felix@6551: * This file is Free Software under the GNU AGPL (>=v3) felix@6551: * and comes with ABSOLUTELY NO WARRANTY! Check out the felix@6551: * documentation coming with Dive4Elements River for details. felix@6551: */ felix@6551: felix@6551: package org.dive4elements.river.exports.minfo; felix@6551: felix@6551: import org.apache.log4j.Logger; felix@6551: felix@6551: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; felix@6551: import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; felix@6551: import org.dive4elements.river.jfree.Bounds; felix@6551: import org.dive4elements.river.jfree.DoubleBounds; felix@6551: import org.dive4elements.river.exports.fixings.FixChartGenerator; felix@6551: felix@6551: /** Base for BedDiff*Year*Generators, to avoid duplicate code of setContextBounds. */ felix@6551: public abstract class BedDiffBaseGenerator felix@6551: extends FixChartGenerator felix@6551: { felix@6551: /** The logger that is used in this generator. */ felix@6551: private static Logger logger = Logger.getLogger(BedDiffBaseGenerator.class); felix@6551: felix@6551: /** Set context values for something. */ felix@6551: public void setContextBounds(ArtifactAndFacet bundle) { felix@6551: Bounds xBounds = getXBounds(0); felix@6551: if (xBounds != null && getDomainAxisRange() != null) { felix@6551: Bounds bounds = felix@6551: calculateZoom(xBounds, getDomainAxisRange()); felix@6551: context.putContextValue("startkm", bounds.getLower()); felix@6551: context.putContextValue("endkm", bounds.getUpper()); felix@6551: } felix@6551: else if (xBounds != null && getDomainAxisRange() == null) { felix@6551: context.putContextValue("startkm", xBounds.getLower()); felix@6551: context.putContextValue("endkm", xBounds.getUpper()); felix@6551: } felix@6551: else if (xBounds == null && getDomainAxisRange() == null) { felix@6551: BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); felix@6551: if (data.getKms().size() > 0) { felix@6551: context.putContextValue("startkm", data.getKms().min()); felix@6551: context.putContextValue("endkm", data.getKms().max()); felix@6551: } felix@6551: else { felix@6551: logger.warn("No data to define start and end km"); felix@6551: } felix@6551: } felix@6551: else if (xBounds == null && getDomainAxisRange() != null){ felix@6551: BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); felix@6551: Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); felix@6551: Bounds bounds = felix@6551: calculateZoom(b, getDomainAxisRange()); felix@6551: context.putContextValue("startkm", bounds.getLower()); felix@6551: context.putContextValue("endkm", bounds.getUpper()); felix@6551: } felix@6551: } felix@6551: } felix@6577: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :