Graphics Reference
In-Depth Information
Figure
.
.
Classes for selecting observations
structor. We can easily replace a selector by using
RectangleSelector
instead
of
PointSelector
.his is the advantage of the strategy pattern. hecontext (ab-
stract) class
BasicPlotModel
has a
selector
field in order to reference a con-
crete strategy class such as
PointSelector
.Wealwaysusemethodsofthestrat-
egy class through the
selector
field, for example,
selector.create
.
Wenowexplainhowthe
PointSelector
objectisusedin
HistogramPlot-
Model
. When we press the mouse button on the histogram graphic, the
mouse-
Pressed
method in the
MouseInputHandler
class that implements the
MouseInputListener
interface defined in
JasplotPanelDragLayerUI
detectstheevent.he
mousePressed
methodcallsthe
state.mousePressed
method, and then it calls the
createSelector
method and executes the
selector.create
method to create a
PointSelector
object. When we re-
leasethemousebutton(aterdragging),the
mouseReleased
method in the
MouseInputHandler
classdetectstheevent,andthe
mouseReleased
method
calls
state.mouseReleased
,anditexecutes the
mouseReleased
methodin
the
SelectingState
class. his method performs the
getIndexFor-
Location
method that checks whether representations of all observations are in-
cluded in the selector box just defined or not. Selected observations are drawn in
different colors by the
repaint
method. See Fig.
.
.
As a selection operation is dynamic, the graphic must change dynamically. We
must then be careful about the time taken to repaint. If the number of observa-
tions is huge, repainting will require a considerable period of time. In Jasplot, we
can choose between two approaches to repainting. One is real-time repainting; that
is, repainting many times during mouse operation. his may be natural if we use
RectangularSelector
and dragit. We wish to select observations in the selec-
tor box at each moment of dragging. If we drag the selector box and one selected ob-