Setting an Interactor on an IlvChart
Several interactors can be used at the same time to interact with a given chart object. These interactors are managed by the
IlvChart object on which the interactions are performed and cannot be shared among several charts.
All the predefined
IlvChartInteractor objects are stored in an internal repository that performs associations between a string and an interactor class. When an interactor class is registered in the repository, it can be instantiated using its associated string (hereafter named “short name”). All the interactors provided in the JViews Charts package have an associated short name.
Two methods are available to add an interactor on an IlvChart:
void addInteractor(IlvChartInteractor) void addInteractor(String) The first method is used to add an interactor when an instance has explicitly been created and the second method to add an interactor using its short name.
Note that there is priority among the interactors in the event dispatching process due to the way interactors are managed by an
IlvChart (see
Handling interactions for more details): the last added interactor is the last interactor to receive events.
For example, assume that you want to add a zoom interactor and an edit-point interactor. Both the interactors use the left mouse button to perform their interaction. If the zoom interactor is added before the edit-point interactor, all the left mouse button events will be sent first to the zoom interactor. Since the zoom interactor handles this event to start its interaction, the edit-point interactor will never receive a left button pressed event. To be able to use both the interactors, the correct order is to add the edit-point interactor first, and then the zoom interactor. Indeed, the edit-point interactor only handles mouse pressed event if the user clicked on a data point. If it is not the case, the event is not handled (that is, not consumed), and the chart submits it to the next interactor in the list, the zoom interactor.
The basic steps to set an interactor on a given chart object are:
Create an interactor instance.
Add the interactor to be used to the chart.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.