Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/AbstractSInfoProcessor.java @ 8890:90b7f45ff4ae
Calculating moving average of flow depth output
author | gernotbelger |
---|---|
date | Wed, 14 Feb 2018 18:45:42 +0100 |
parents | cc86b0f9b3c3 |
children |
line wrap: on
line source
/* 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.flowdepth; import java.util.Set; import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.process.DefaultProcessor; import org.dive4elements.river.themes.ThemeDocument; /** * Abstraction for some processor implementation within S-INFO. Probably this abstraction could also be used for other * cases as well. * * @author Gernot Belger * */ abstract class AbstractSInfoProcessor extends DefaultProcessor { private final static Logger log = Logger.getLogger(AbstractSInfoProcessor.class); private String yAxisLabel; private final Set<String> handled_facet_types; private final String i18n_axis_label; public AbstractSInfoProcessor(final String i18n_axis_label, final Set<String> handled_facet_types) { this.i18n_axis_label = i18n_axis_label; this.handled_facet_types = handled_facet_types; } @Override public final void doOut(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { try { this.yAxisLabel = generateSeries(generator, bundle, theme, visible); } catch (final Exception e) { log.error(e.getMessage(), e); } } /** * @return The axis label */ protected abstract String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible); @Override public final boolean canHandle(final String facettype) { return this.handled_facet_types.contains(facettype); } @Override public final String getAxisLabel(final DiagramGenerator generator) { if (this.yAxisLabel != null && !this.yAxisLabel.isEmpty()) { // REMARK/UNINTENDED: yAxisLabel may also be a resolved message (side-effect of StyledXYSeries#putMetadata), // and cannot be resolved, so we need to give the resolved value as default // FIXME: In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here, // probably the English version will also show German (CHECK) return generator.msg(this.yAxisLabel, this.yAxisLabel); } return generator.msg(this.i18n_axis_label, "MISSING"); } }