view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9070:611a523fc42f

VegetationZoneAccessHelper, VegetationTablePanels verbessert
author gernotbelger
date Tue, 15 May 2018 18:04:36 +0200
parents 1ffd38826175
children 9b4f5e61c02e
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.uinfo.inundationduration;

import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;

/**
 * Access to the flow depth calculation type specific SInfo artifact data.
 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
 * reference to the artifact instance.
 * Hence we do NOT cache any data.
 *
 * @author Gernot Belger
 */
final class InundationDurationAccess extends RangeAccess {

    // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR
    public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
    public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";

    private final EpochYearAccessHelper helper;

    // Fields from state:
    //
    // calculation_mode (String)
    // ld_from, ld_to
    // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year)
    // singleyear (String)
    // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier))
    // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe)
    // sedimentheight String
    //
    // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen

    public InundationDurationAccess(final UINFOArtifact uinfo) {
        super(uinfo);
        /* assert calculation mode */
        final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
        this.helper = new EpochYearAccessHelper(uinfo);
        assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration);
    }

    public Double getSedimentHeight() {
        if (super.getBoolean("use_scenario")) {
            return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung)
        }
        return null;
    }

    public Integer getYear() {
        final int[] years = this.helper.getYears("state.uinfo.year", "singleyear");
        if (years != null) {
            return years[0];
        }
        return null;
    }

    public int[] getTotalEpoch() {
        final int[][] epochs = this.helper.getEpochs("state.uinfo.totalepoch", "totalepoch");
        if (epochs != null) {
            return epochs[0];
        }
        return null;
    }

    public String getVegZones() {
        // MIT VegetationzonesAccess zusammenlegen (eine Zeile sparen...)
        return super.getString("vegzones");
    }

}

http://dive4elements.wald.intevation.org