![]() |
![]() |
![]() |
![]() |
![]() |
|
Now it is time to consolidate what you have learned. One way to consolidate is to follow what happens when you click on the meter:
mouseClicked with the
listener connected to the meter instance as the target.
mouseClicked method fetches a value based
on mouse coordinates from the meter instance.
mouseClicked method relays a result to the movie
instance using the setters, setScript, setActing, and
setDirection, each of which calls setChanged and
notifyObservers.
notifyObservers method activates a mechanism
that calls the update method in the observer connected to the
movie instance.
update method fetches information from the
movie model and relays that information to the meter view.
The following diagram traces the call sequence:
Movie LocalMovieObserver LocalMeterListener Meter
instance instance instance instance
-------- ------------------ ------------------ --------
click event
|
*-----------------------*
|
v
mouseClicked
|
*-> getX
|
*-> getY
|
*-----------------------*
| v
| getValueAtCoordinates
|
*-----------------------------------*
|
v
setScript
|
*-> setChanged
|
*-> notifyObservers
|
*-------*
v
update
|
rating <--------*
|
*---------------------------------------------*
|
v
setValue
|
v
repaint
|
v
paint