public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) {
   JRPrintHyperlink printHyperlink = null;
   if (hasHyperlinks() && entity instanceof XYItemEntity) {
     XYItemEntity itemEntity = (XYItemEntity) entity;
     XYDataset dataset = itemEntity.getDataset();
     Comparable serie = dataset.getSeriesKey(itemEntity.getSeriesIndex());
     Map serieHyperlinks = (Map) itemHyperlinks.get(serie);
     if (serieHyperlinks != null) {
       Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem());
       Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem());
       Object xyKey = new Pair(x, y);
       printHyperlink = (JRPrintHyperlink) serieHyperlinks.get(xyKey);
     }
   }
   return printHyperlink;
 }
 @Override
 public ChartView.Element getElementAt(int x, int y) {
   ChartView.Element element = new ChartView.Element(0, 0);
   ChartEntity chartEntity = getChartEntityAt(x, y);
   if (chartEntity instanceof CategoryItemEntity) {
     CategoryItemEntity categoryItemEntity = (CategoryItemEntity) chartEntity;
     CategoryDataset dataset = categoryItemEntity.getDataset();
     String columnKey = (String) categoryItemEntity.getColumnKey();
     int columnIndex = dataset.getColumnIndex(columnKey);
     String rowKey = (String) categoryItemEntity.getRowKey();
     int rowIndex = dataset.getRowIndex(rowKey);
     element = new ChartView.Element(rowIndex, columnIndex);
   } else if (chartEntity instanceof XYItemEntity) {
     XYItemEntity xyItemEntity = (XYItemEntity) chartEntity;
     element = new ChartView.Element(xyItemEntity.getSeriesIndex(), xyItemEntity.getItem());
   }
   return element;
 }
 private void populateInfo(final ChartRenderingInfo info) {
   if (urlTemplate == null) {
     return;
   }
   Iterator iter = info.getEntityCollection().iterator();
   while (iter.hasNext()) {
     ChartEntity entity = (ChartEntity) iter.next();
     if (entity instanceof XYItemEntity) {
       if (urlTemplate != null) {
         XYItemEntity xyItemEntity = (XYItemEntity) entity;
         if (paramName == null) {
           xyItemEntity.setURLText(urlTemplate);
         } else {
           try {
             int seriesIndex = xyItemEntity.getSeriesIndex();
             int itemIndex = xyItemEntity.getItem();
             String xySeriesKey =
                 (String)
                     ((XYZSeriesCollectionChartDefinition) xyItemEntity.getDataset())
                         .getSeriesKey(seriesIndex);
             String encodedVal = URLEncoder.encode(xySeriesKey, LocaleHelper.getSystemEncoding());
             String drillURL = TemplateUtil.applyTemplate(urlTemplate, paramName, encodedVal);
             String itemValueStr =
                 ((XYZSeriesCollectionChartDefinition) xyItemEntity.getDataset())
                     .getX(seriesIndex, itemIndex)
                     .toString();
             encodedVal = URLEncoder.encode(itemValueStr, LocaleHelper.getSystemEncoding());
             if (seriesName == null) {
               drillURL =
                   TemplateUtil.applyTemplate(drillURL, "SERIES", encodedVal); // $NON-NLS-1$
             } else {
               drillURL = TemplateUtil.applyTemplate(drillURL, seriesName, encodedVal);
             }
             xyItemEntity.setURLText(drillURL);
           } catch (UnsupportedEncodingException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
         }
       }
     }
   }
 }
  @SuppressWarnings("rawtypes")
  @Override
  public void zoom(Rectangle selection) {
    if (map == null || layer == null) {
      return;
    }
    Set<FeatureId> selected = new HashSet<FeatureId>();
    try {
      XYSeriesCollection ds = (XYSeriesCollection) getChart().getXYPlot().getDataset(2);
      XYSeries selectionSeries = ds.getSeries(0);
      selectionSeries.clear();

      EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
      Iterator iter = entities.iterator();
      while (iter.hasNext()) {
        ChartEntity entity = (ChartEntity) iter.next();
        if (entity instanceof XYItemEntity) {
          XYItemEntity item = (XYItemEntity) entity;
          if (item.getSeriesIndex() != 0) {
            continue;
          }

          java.awt.Rectangle bound = item.getArea().getBounds();
          if (selection.intersects(bound.x, bound.y, bound.width, bound.height)) {
            XYSeriesCollection dataSet = (XYSeriesCollection) item.getDataset();
            XYSeries xySeries = dataSet.getSeries(item.getSeriesIndex());
            XYDataItem xyDataItem = xySeries.getDataItem(item.getItem());
            if (xyDataItem instanceof XYDataItem2) {
              XYDataItem2 dataItem = (XYDataItem2) xyDataItem;
              selectionSeries.add(dataItem);
              selected.add(ff.featureId(dataItem.getFeature().getID()));
            }
          }
        }
      }
    } catch (Exception e) {
      // skip
    } finally {
      if (selected.size() > 0) {
        map.select(ff.id(selected), layer);
      } else {
        map.select(Filter.EXCLUDE, layer);
      }
      this.forceRedraw();
    }
  }