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.StandardXYItemLabelGenerator; 35 import org.jfree.data.time.TimePeriodValuesCollection; 36 import org.jfree.data.xy.XYDataset; 37 38 39 43 public class TimePeriodDatasetLabelGenerator extends StandardXYItemLabelGenerator 44 { 45 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 46 47 private Map labelsMap = null; 48 49 public TimePeriodDatasetLabelGenerator(Map labelsMap) 50 { 51 this.labelsMap = labelsMap; 52 } 53 54 public String generateLabel(XYDataset dataset, int series, int item) 55 { 56 Comparable seriesName = dataset.getSeriesKey(series); 57 Map labels = (Map )labelsMap.get(seriesName); 58 if(labels != null) 59 { 60 return (String )labels.get(((TimePeriodValuesCollection)dataset).getSeries(series).getTimePeriod(item)); 61 } 62 return super.generateLabel( dataset, series, item ); 63 } 64 } | Popular Tags |