// make it appear last in the image map (which is important,
// because browsers process the image map areas in the order that
// they appear; having the entire chart area listed first would
// obscure all of the other image map areas).
EntityCollection entities = new StandardEntityCollection();
entities.add(new ChartEntity(info.getChartArea(), tooltip, href));
if (info.getEntityCollection() != null)
entities.addAll(info.getEntityCollection());
// Next: most of our chart entities will not have URLs. URL values
// don't inherit in the imagemap, so if we want the entire image
// to have a single URL, we need to assign that URL to every
// area in the chart.
for (Iterator i = entities.iterator(); i.hasNext();) {
ChartEntity ce = (ChartEntity) i.next();
// check for no-op chart entity - these won't appear in the
// image map anyway, so they don't need to be adjusted
if (ce.getToolTipText() == null && ce.getURLText() == null)
continue;
// for other entities, add a tooltip and a URL as needed.
if (!StringUtils.hasValue(ce.getToolTipText()))
ce.setToolTipText(tooltip);
if (!StringUtils.hasValue(ce.getURLText()))
ce.setURLText(href);
}
// install our modified version of the entity collection into
// the chart info object, so it will be used when generating
// the image map later.