In this recipe, we will look at selecting data points in the graph. You can have a system to select one point at a time, or multiple points. In this recipe we will look at the more difficult, latter option.
We'll show how to implement a dragging action, where you drag the mouse, forming a rectangle around the points you want to select. Selecting multiple points can be used in several ways: if you are editing a graph and want to remove or changed multiple points at once or if you want to zoom in on a specific area.
The starting point is exactly the same as the previous recipe. To keep your workspace tidy, copy it into a new Recipe4
document class.
Implementing a select action involves two steps:
Let the user define the area in which we will have to select the items.
Calculate which items are in the selection area.
In order to manage everything we'll need a few variables. Add the following fields to the Recipe4
class:
private var _selection...