1 28 package net.sf.jasperreports.renderers; 29 30 import java.util.Map ; 31 32 import net.sf.jasperreports.engine.JRConstants; 33 import net.sf.jasperreports.engine.JRPrintHyperlink; 34 import net.sf.jasperreports.engine.util.Pair; 35 36 import org.jfree.chart.JFreeChart; 37 import org.jfree.chart.entity.ChartEntity; 38 import org.jfree.chart.entity.XYItemEntity; 39 import org.jfree.data.xy.XYDataset; 40 41 42 48 public class JRXYChartImageMapRenderer extends JRAbstractChartImageMapRenderer 49 { 50 51 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 52 53 private Map itemHyperlinks; 54 55 public JRXYChartImageMapRenderer(JFreeChart chart, Map itemHyperlinks) 56 { 57 super(chart); 58 59 this.itemHyperlinks = itemHyperlinks; 60 } 61 62 63 protected JRPrintHyperlink getEntityHyperlink(ChartEntity entity) 64 { 65 JRPrintHyperlink printHyperlink = null; 66 if (entity instanceof XYItemEntity) 67 { 68 XYItemEntity itemEntity = (XYItemEntity) entity; 69 XYDataset dataset = itemEntity.getDataset(); 70 Comparable serie = dataset.getSeriesKey(itemEntity.getSeriesIndex()); 71 Map serieHyperlinks = (Map ) itemHyperlinks.get(serie); 72 if (serieHyperlinks != null) 73 { 74 Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem()); 75 Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem()); 76 Object xyKey = new Pair(x, y); 77 printHyperlink = (JRPrintHyperlink) serieHyperlinks.get(xyKey); 78 } 79 } 80 return printHyperlink; 81 } 82 83 } 84 | Popular Tags |