package de.ivu.elect.presentation.charts;

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


import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.BLAU;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.CYAN;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.DUNKEL_BLAU;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.DUNKEL_GRUEN;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.DUNKEL_ORANGE;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.DUNKEL_ROT;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.GELB;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.GRAU;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.GRUEN;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.ORANGE;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.PINK;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.ROT;
import static de.ivu.elect.jee.presentation.charts.AbstractChartModelBuilder.WEISS;
import static java.util.Arrays.asList;

/**
 *  on 17.01.2017.
 */
public class ChartColor {

  public static final List<String> FARBEN = asList(GELB, GRUEN, DUNKEL_GRUEN, BLAU, DUNKEL_BLAU, GRAU, PINK, ORANGE, DUNKEL_ORANGE, CYAN, DUNKEL_ROT);

  public String getFarbe(Integer nummer) {
    if (nummer == null || nummer < 0) {
      return getNichtGesetztFarbe();
    }
    return FARBEN.get(nummer % FARBEN.size());
  }

  public String getNichtGesetztFarbe(){
    return WEISS;
  }

  public String getAchtungFarbe(){
    return ROT;
  }

  public  <E> Map<E, String> bestimmeFarben(List<E> dinge) {

    Map<E, String> result = new HashMap<>();
    for (E ding : dinge) {
      result.put(ding, getFarbe(dinge.indexOf(ding)));
    }
    return result;
  }
}
