package com.onaro.util.chart; import ilog.views.chart.IlvDisplayPoint; import ilog.views.chart.IlvStyle; import ilog.views.chart.event.ChartHighlightInteractionEvent; import ilog.views.chart.event.ChartInteractionEvent; import ilog.views.chart.event.ChartInteractionListener; import ilog.views.chart.graphic.IlvDataRenderingHint; /** * Associates a HighlightHint with the current highlighted point. * This listener will be notified each time the highlighted state of * a data point changes. */ public class HighlightListener implements ChartInteractionListener { /** * The rendering hint used to set a patterned style. */ IlvDataRenderingHint highlightHint = new HighlightHint(); /** * Called when an interaction has been performed. */ public void interactionPerformed(ChartInteractionEvent evt) { // The IlvChartHighlightInteractor fires a specific type of event // to get information on the highlighted state of the point. ChartHighlightInteractionEvent hevt = (ChartHighlightInteractionEvent) evt; IlvDisplayPoint dp = hevt.getDisplayPoint(); if (hevt.isHighlighted()) { // A new point has been highlighted. In this case, we set a // rendering hint only for this given data point. This rendering hint // will be used each time the data point is drawn by the renderer. // Moreover, a data label annotation is set to display the data value. dp.getRenderer().setRenderingHint(dp.getDataSet(), dp.getIndex(), highlightHint); } else { // A previously highlighted point has been unselected. We remove the // rendering hint and data annotation previously set. dp.getRenderer().setRenderingHint(dp.getDataSet(), dp.getIndex(), null); } } /** * A rendering hint associated with highlighted data points. */ private static class HighlightHint implements IlvDataRenderingHint { IlvStyle.Change change = new IlvStyle.IntensityChange(1); /** * Returns the rendering style used to display the specified display point. * This implementation returns a brighter version of the default style. */ public IlvStyle getStyle(IlvDisplayPoint dp, IlvStyle defaultStyle) { return change.change(defaultStyle); } } }