Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionGenerator.java @ 7076:7f600001c807 generator-refactoring
Add LTR inversion code to diagram generator.
This code is used in serveral diagrams and as it modifies a
whole diagram it should be central. (This should also make
maintenance easier). This function can be called by processors
to make sure that their data is plotted with an LTR waterflow.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 16:33:22 +0200 |
parents | 2b022ca95b3b |
children |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * 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.exports; import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQCKms; import org.dive4elements.river.exports.process.Processor; import org.dive4elements.river.exports.process.QOutProcessor; import org.dive4elements.river.exports.process.WOutProcessor; import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; /** * An OutGenerator that generates discharge longitudinal section curves. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class DischargeLongitudinalSectionGenerator extends LongitudinalSectionGenerator implements FacetTypes { private static Logger logger = Logger.getLogger(DischargeLongitudinalSectionGenerator.class); public DischargeLongitudinalSectionGenerator() { super(); } @Override public void doOut( ArtifactAndFacet artifactFacet, ThemeDocument attr, boolean visible ) { logger.debug("DischargeLongitudinalSectionGenerator.doOut"); String name = artifactFacet.getFacetName(); if (name == null) { return; } Facet facet = artifactFacet.getFacet(); if (name.equals(DISCHARGE_LONGITUDINAL_C)) { doCorrectedWOut( (WQCKms) artifactFacet.getData(context), facet, attr, visible); } else if (name.equals(LONGITUDINAL_ANNOTATION)) { doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); } else if (FacetTypes.IS.MANUALPOINTS(name)) { doPoints(artifactFacet.getData(context), artifactFacet, attr, visible, YAXIS.W.idx); } else { Processor processor = new WOutProcessor(); Processor qProcessor = new QOutProcessor(); if (processor.canHandle(name)) { processor.doOut(this, artifactFacet, attr, visible, YAXIS.W.idx); } else if (qProcessor.canHandle(name)) { qProcessor.doOut(this, artifactFacet, attr, visible, YAXIS.Q.idx); } else { logger.warn("Unknown facet name: " + name); } } } /** * Adds a new series for the corrected W curve. * * @param wqckms The object that contains the corrected W values. * @param theme The theme that contains styling information. */ protected void doCorrectedWOut( WQCKms wqckms, Facet facet, ThemeDocument theme, boolean visible ) { logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut"); int size = wqckms.size(); if (size > 0) { XYSeries series = new StyledXYSeries( facet.getDescription(), theme); for (int i = 0; i < size; i++) { series.add(wqckms.getKm(i), wqckms.getC(i)); } addAxisSeries(series, YAXIS.W.idx, visible); } if (wqckms.guessWaterIncreasing()) { setInverted(true); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :