Graphics Reference
In-Depth Information
servation movesoutsidetheselectorbox,weexpectthat theobservation isdeselected
assoonaspossible.histypeofrepainting requiresmuchcomputation andworksfor
only a limited number of observations. Another natural approach is to repaint when
the mouse button is released. If we use
PointSelector
and specify a rectangular
area, it is reasonable to repaint at the last moment of specifying the selector box; that
is,whenthe mousebutton isreleased.hisapproach iscomputationally light andap-
propriate when the number of observations is huge. We can choose these timings by
using the
setDynamicChange
method defined in the
JasplotPanel
class. If
we execute
setDynamicChange(true)
, real time repainting is executed. If we
execute
setDynamicChange(false)
,repainting isperformedwhenwerelease
the mouse button.
Classes for Linked Views
We have explained mechanisms of selecting or brushing observations in a single sta-
tistical graphic. It is also important, however, to connect such operations across sev-
eral graphics; that is, to realize linked views or linked highlighting and linked brush-
ing. To do this, we must inform other graphics of changes in selected observations in
one graphic. his can be realized by the “Observer” and “Mediator” design patterns.
he Observer pattern defines a one-to-many dependency between objects so
thatwhenoneobjectchangesstate,allitsdependantsarenotifiedandupdated
automatically (Gamma et al.,
).
heobserver pattern allows one object (the observer) towatch another (the subject).
It forms a publish-subscribe relationship between the subject and the observer. Ob-
servers can register to receive events from the subject. When the subject needs to
inform its observers of an event, it simply sends the event to each observer.
In Jasplot, the
PlotModelHandler
object, accompanied by the
DataModel
object, behaves as a subject. Observers are other graphics'
JasplotPanel-
PaletteLayer
objects that implement the
PlotModelListener
interface.
Observers can be registered by using the
addPlotModelListener
method in
the
PlotModelHandler
class. See Fig.
.
.
Consider that selected observations are changed by a selector operation. he
SelectingState
object creates a
PlotModelEvent
object in which the se-
lected/unselected information for each observation is stored, and sets it by using
the
setSelectedObservation
method in the
PlotModelHandler
class.
It informs registered
JasplotPanelPaletteLayer
objects of the new
Plot-
ModelEvent
object. It executes the
observationSelected(Plot-
ModelEvent e)
method in the
JasplotPanelPaletteLayer
.Asthis
method executes the
repaint
method, each
JasplotPanelPaletteLayer
object is repainted according to the new information.
We know that
PlotModelEvent
,
PlotModelHandler
and
PlotModel-
Listener
areassociatedwithchangesinthe
PlotModel
object.herearesimilar
classes, such as
DataModelEvent
,
DataModelHandler
and
DataModel-
Listener
, which can handle changes in
DataModel
objects; that is, changes in
datavalues,theadditionanddeletionofobservationsandvariables.A
DataModel-