package net.sf.jasperreports.charts.util;

import java.util.Map;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.data.category.CategoryDataset;

public class CategoryLabelGenerator extends StandardCategoryItemLabelGenerator {
  private static final long serialVersionUID = 10200L;
  
  private Map labelsMap = null;
  
  public CategoryLabelGenerator(Map labelsMap) {
    this.labelsMap = labelsMap;
  }
  
  public String generateLabel(CategoryDataset dataset, int series, int category) {
    Comparable seriesName = dataset.getRowKey(series);
    Map labels = (Map)this.labelsMap.get(seriesName);
    if (labels != null)
      return (String)labels.get(dataset.getColumnKey(category)); 
    return super.generateLabel(dataset, series, category);
  }
}
