1 28 package net.sf.jasperreports.charts.util; 29 30 import java.util.Map ; 31 32 import net.sf.jasperreports.engine.JRConstants; 33 34 import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; 35 import org.jfree.data.category.CategoryDataset; 36 37 38 42 public class CategoryLabelGenerator extends StandardCategoryItemLabelGenerator 43 { 44 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 45 46 private Map labelsMap = null; 47 48 public CategoryLabelGenerator(Map labelsMap) 49 { 50 this.labelsMap = labelsMap; 51 } 52 53 public String generateLabel(CategoryDataset dataset, int series, int category) 54 { 55 Comparable seriesName = dataset.getRowKey(series); 56 Map labels = (Map )labelsMap.get(seriesName); 57 if(labels != null) 58 { 59 return (String )labels.get(dataset.getColumnKey(category)); 60 } 61 return super.generateLabel(dataset, series, category); 62 } 63 } | Popular Tags |