private static GridPointInfo getGridPointInfo(XYItemEntity en, Chart chart) {
ChartModel model = chart.getModel();
if (model == null)
return null;
GridPointInfo info = new GridPointInfoImpl();
info.setSeries(new SeriesInfoImpl());
info.getSeries().setIndex(en.getSeriesIndex());
info.setIndex(en.getItem());
ModelInfo modelInfo = new ModelInfo(model);
if (!modelInfo.isDataEmpty()) {
if (modelInfo.getModelType() == ModelType.Date) {
TimeSeriesCollection ds = ModelConverter.toTimeSeriesCollection(chart, modelInfo);
Comparable seriesKey = ds.getSeriesKey(en.getSeriesIndex());
Number tupleKey = ds.getX(en.getSeriesIndex(), en.getItem());
if (tupleKey instanceof Long) {
info.setKey(new Date(tupleKey.longValue()));
} else {
info.setKey(tupleKey);
}
Object tupleValue = ds.getY(en.getSeriesIndex(), en.getItem());
info.setValue(tupleValue);
info.getSeries().setKey(seriesKey);
} else {
XYDataset ds = ModelConverter.toXYSeriesCollection(modelInfo);
Comparable seriesKey = ds.getSeriesKey(en.getSeriesIndex());
Number tupleKey = ds.getX(en.getSeriesIndex(), en.getItem());
info.setKey(tupleKey);
Object tupleValue = ds.getY(en.getSeriesIndex(), en.getItem());
info.setValue(tupleValue);
info.getSeries().setKey(seriesKey);
}
}
return info;
}