Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDerivedCurveGenerator.java @ 6601:5ecc6d4d73f2
Add official fixings to Waterlevel CSV Export (issue1384)
This searches the collection for staticwqkms artifacts that
contain official data and adds that data to the export.
The data is filtered by the calculation range and sorted by the
calculation direction.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 18 Jul 2013 13:16:33 +0200 |
parents | af13ceeba52a |
children | 1b35b2ddfc28 |
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.fixings; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.fixings.FixDerivateFacet; import org.dive4elements.river.artifacts.model.fixings.FixFunction; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.ChartGenerator; import org.dive4elements.river.jfree.JFreeUtil; import org.dive4elements.river.jfree.StyledXYSeries; /** * Generator for fixation derived function curve. * * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a> */ public class FixDerivedCurveGenerator extends FixChartGenerator implements FacetTypes { /** Private logger. */ private static Logger logger = Logger.getLogger(FixDerivedCurveGenerator.class); public static final String I18N_CHART_TITLE = "chart.fixings.derivedcurve.title"; public static final String I18N_CHART_SUBTITLE = "chart.fixings.derivedcurve.subtitle"; public static final String I18N_XAXIS_LABEL = "chart.fixings.derivedcurve.xaxis.label"; public static final String I18N_YAXIS_LABEL = "chart.fixings.derivedcurve.yaxis.label"; public static final String I18N_CHART_TITLE_DEFAULT = "Ableitungskurve"; public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00B3/s]"; public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; public static enum YAXIS { W(0), Q(1); public int idx; private YAXIS(int c) { idx = c; } } @Override public void doOut(ArtifactAndFacet aaf, Document doc, boolean visible) { logger.debug("doOut"); if (FacetTypes.IS.MANUALPOINTS(aaf.getFacetName())) { doPoints(aaf.getData(context), aaf, doc, visible, YAXIS.W.idx); } else { FixDerivateFacet facet = (FixDerivateFacet)aaf.getFacet(); FixFunction func = (FixFunction)facet.getData( aaf.getArtifact(), context); if (func == null) { logger.warn("doOut: Facet does not contain FixFunction"); return; } double maxQ = func.getMaxQ(); if (maxQ > 0) { StyledXYSeries series = JFreeUtil.sampleFunction2D( func.getFunction(), doc, aaf.getFacetDescription(), 500, // number of samples 0.0 , // start maxQ); // end addAxisSeries(series, 0, visible); } } } @Override protected String getDefaultChartTitle() { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } @Override protected String getChartTitle() { return Resources.format( context.getMeta(), I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, context.getContextValue(CURRENT_KM)); } @Override protected String getDefaultXAxisLabel() { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); } @Override protected String getDefaultYAxisLabel(int pos) { return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); } @Override protected ChartGenerator.YAxisWalker getYAxisWalker() { return new YAxisWalker() { @Override public int length() { return YAXIS.values().length; } @Override public String getId(int idx) { YAXIS[] yaxes = YAXIS.values(); return yaxes[idx].toString(); } }; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :