package vismon.data;


import vismon.util.Util;

import java.util.HashMap;
import java.util.Map;


/*
    For one simulation run, this class keeps the values of all indicators.
 */
public class IndicatorValues {

    private Map<Indicator, Double>      values;

    public IndicatorValues(){
        values = new HashMap<Indicator, Double>();
    }

    public double getValue(Indicator ind) {
        return values.get(ind);
    }

    public void addValue(Indicator ind, double v) {
        values.put(ind, v);
    }

    public boolean hasValue(Indicator ind, double v) {
        if (values.get(ind) == v)
            return true;
        return false;
    }

    @Override
    public String toString() {
        String s = "< ";
        for (int i = 0; i < Session.getIndicatorNum() - 1; ++i) {
            Indicator d = Session.getIndicator(i);
            if (values.get(d) == null)
                s += "- | ";
            else
                s += Util.roundToOneTenth(values.get(d)) + " | ";
        }

        Indicator d = Session.getIndicator(Session.getIndicatorNum() - 1);
        if (values.get(d) == null)
            s += "- >";
        else
            s += Util.roundToOneTenth(values.get(d)) + " >";

        return s;
    }

}
