Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java @ 9312:740d65e4aa14
Q [m³/s] one message
author | gernotbelger |
---|---|
date | Thu, 26 Jul 2018 15:54:20 +0200 |
parents | da0bdbcd6f09 |
children | 5ce50640688c |
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.common; import java.text.NumberFormat; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.utils.Formatter; /** * @author Domenico Nardi Tironi */ public abstract class AbstractExportContext implements IExportContext { private NumberFormat qFormat = null; private NumberFormat flowDepthFormat = null; private NumberFormat salixScenFormat = null; private NumberFormat kmFormat = null; /** The CallContext object. */ private final CallContext context; private final AbstractCalculationResults<?> results; public AbstractExportContext(final CallContext context, final AbstractCalculationResults<?> results) { this.context = context; this.results = results; } protected final CallContext getContext() { return this.context; } @Override public final <RESULTS extends AbstractCalculationResults<?>> RESULTS getResults() { @SuppressWarnings("unchecked") final RESULTS resultsCast = (RESULTS) this.results; return resultsCast; } // copy from AbstractExporter TODO merge with ExportContextPDF protected NumberFormat getKmFormatter() { if (this.kmFormat == null) this.kmFormat = Formatter.getWaterlevelKM(getContext()); return this.kmFormat; } public NumberFormat getQFormatter() { if (this.qFormat == null) this.qFormat = Formatter.getWaterlevelQ(this.context); return this.qFormat; } public final NumberFormat getFlowDepthFormatter() { if (this.flowDepthFormat == null) this.flowDepthFormat = Formatter.getFlowDepth(this.context); return this.flowDepthFormat; } public final NumberFormat getSalixScenFormatter() { if (this.salixScenFormat == null) this.salixScenFormat = Formatter.getSalixLine(this.context); return this.salixScenFormat; } protected String msg(final String key) { return Resources.getMsg(this.context.getMeta(), key, key); } public final String msg(final String key, final Object... args) { return Resources.getMsg(this.context.getMeta(), key, key, args); } @Override public final String formatRowValue(final ResultRow row, final IResultType type) { return row.exportValue(this.context, type); } }