skip to main content
Programmer's documentation > Developing with the JViews Charts SDK > Interacting With Charts > Handling interactions
 
Handling interactions
Interactors are handled by a chart as an ordered list, the last element of the list is the last interactor that has been added. This order allows the user to define priorities among interactors during the event dispatching process: each time an event occurs, it is sent to all the interactors until one consumes it, beginning with the first interactor in the list.
The event dispatching process
When an event occurs on the chart area, the event is sent to all the interactors handled by the chart, beginning with the first interactor in the list. Depending on its type, the event is dispatched to the interactor by calling the processMouseEvent, processMouseMotionEvent, and processKeyEvent methods. If the first interactor does not consume the event, then the event is sent to the second interactor in the list, and so on, until either one of the interactors consumes the event or the end of the list is reached. To mark an event as consumed, the interactor should call the java.awt.AWTEvent.consume method on the input event.
Handling events at interactor level
An IlvChartInteractor object can handle two types of input events:
*the mouse events,
*the key events.
To be able to handle these events, the interactor has to notify the chart that events of a given type should be caught and sent to it. This is done by means of the enableEvents method. This method enables the specified events on the chart area, if not already done.
Filtering events
An interactor has the possibility to filter the events it receives according to their position (for example an interactor may be interested in events occurring only on the plot area). This event filtering is the purpose of the isHandling method, which returns a Boolean value indicating whether the event should be processed by the interactor or not. When a chart is about to send an event to an interactor, it first invokes the interactor isHandling method, and depending on the returned value, propagates the event to the interactor.
Processing events
Once enabled, the events are handled by specialized IlvChartInteractor methods depending on their types:
*processMouseMotionEvent for mouse motion events.
*processMouseEvent for mouse events.
*processKeyEvent for key events.
NOTE By default, the implementation of these methods is empty. You should override them to add your own event handling code.
During the interaction, the IlvChartInteractor API defines the following three states:
*the interaction start,
*the interaction stop,
*the interaction abortion.
These three steps are defined at the programming level for each interactor class by calling the corresponding startOperation, endOperation, and abort methods when appropriate.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.