Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthWaterlevelProcessor.java @ 9707:23702537fb4f
zu 2.1 y-Achsenbeschriftung Sohlhöhen
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Fri, 22 Jan 2021 15:47:55 +0100 |
parents | 1d4262a68f1f |
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.common; import java.util.HashSet; import java.util.Set; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.common.AbstractCalculationResult; import org.dive4elements.river.artifacts.common.AbstractProcessor; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.themes.ThemeDocument; public final class FlowDepthWaterlevelProcessor extends AbstractProcessor { /* waterlevel */ public static final String FACET_FLOW_DEPTH_BEDHEIGHT_MIN = "sinfo_facet_flow_depth_bedheight_min"; public static final String FACET_FLOW_DEPTH_BEDHEIGHT_MAX = "sinfo_facet_flow_depth_bedheight_max"; public static final String FACET_FLOW_DEPTH_BEDHEIGHT = "sinfo_facet_flow_depth_bedheight"; public static final String FACET_FLOW_DEPTH_WATER_LEVEL = "sinfo_facet_flow_depth_waterlevel"; private static final String FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL = "chart.longitudinal.section.yaxis.label"; private static final String FACET_BEDHEIGHT_Y_AXIS_LABEL = "chart.bedheight_middle.section.yaxis.label"; public static final String FACET_FLOW_DEPTH_WATER_LEVEL_DESCRIPTION = "facet.flow_depth.waterlevel"; public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION = "facet.flow_depth.bedheight"; public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MIN = "facet.flow_depth.bedheight.min"; public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MAX = "facet.flow_depth.bedheight.max"; private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); static { HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_WATER_LEVEL); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT_MIN); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT_MAX); } public FlowDepthWaterlevelProcessor() { super(FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, HANDLED_FACET_TYPES); } protected SInfoResultType doGetType(final String facetName) { if (FACET_FLOW_DEPTH_WATER_LEVEL.contentEquals(facetName)) return SInfoResultType.waterlevel; if (FACET_FLOW_DEPTH_BEDHEIGHT.contentEquals(facetName)) return SInfoResultType.meanBedHeight; if (FACET_FLOW_DEPTH_BEDHEIGHT_MIN.contentEquals(facetName)) return SInfoResultType.minBedHeight; if (FACET_FLOW_DEPTH_BEDHEIGHT_MAX.contentEquals(facetName)) return SInfoResultType.maxBedHeight; final String error = String.format("Unknown facet name: %s", facetName); throw new UnsupportedOperationException(error); } private static Facet createFlowDepthBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index, final String unit, final String facetLabel, final String facetName, final String description) { final CallMeta meta = context.getMeta(); final String yAxisLabel = Resources.getMsg(meta, FACET_BEDHEIGHT_Y_AXIS_LABEL, FACET_BEDHEIGHT_Y_AXIS_LABEL, unit); return AbstractProcessor.createFacet(context, hash, id, result, index, yAxisLabel, facetName, description, facetLabel); } public static Facet createFlowDepthMeanBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index, final String unit, final String facetLabel) { return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT, FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION); } public static Facet createFlowDepthMinBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index, final String unit, final String facetLabel) { return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT_MIN, FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MIN); } public static Facet createFlowDepthMaxBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index, final String unit, final String facetLabel) { return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT_MAX, FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MAX); } public static Facet createFlowDepthWaterlevelFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index, final String unit, final String wstLabel) { final CallMeta meta = context.getMeta(); final String yAxisLabel = Resources.getMsg(meta, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, unit); return AbstractProcessor.createFacet(context, hash, id, result, index, yAxisLabel, FACET_FLOW_DEPTH_WATER_LEVEL, FACET_FLOW_DEPTH_WATER_LEVEL_DESCRIPTION, wstLabel); } @Override protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE); } }