26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1460 Eleva<strong>to</strong>r View (on CD) Appendix I<br />

firstFloorBut<strong>to</strong>nPanel : AnimatedPanel<br />

secondFloorBut<strong>to</strong>nPanel : AnimatedPanel<br />

firstFloorLightPanel : AnimatedPanel<br />

secondFloorLightPanel : AnimatedPanel<br />

eleva<strong>to</strong>rPanel : MovingPanel<br />

: Eleva<strong>to</strong>rMusic<br />

lightPanel : AnimatedPanel<br />

bellPanel : AnimatedPanel<br />

doorPanel : AnimatedPanel<br />

eleva<strong>to</strong>rBut<strong>to</strong>nPanel : AnimatedPanel<br />

Fig. Fig. I.4 I.4 Object diagram for the Eleva<strong>to</strong>rView after initialization.<br />

The Eleva<strong>to</strong>rView object links (contains an association) with all objects presented<br />

in Fig. I.4. The eleva<strong>to</strong>rPanel links with objects eleva<strong>to</strong>rLightPanel, bell-<br />

Panel, doorPanel and eleva<strong>to</strong>rBut<strong>to</strong>nPanel. This association provides a visualization<br />

of what is happening in the model—the Eleva<strong>to</strong>r contains a Light, Bell,<br />

Door and But<strong>to</strong>n. The SoundEffects object links with the AudioClip objects,<br />

because the SoundEffects object generates the AudioClip objects.<br />

I.5 Event Handling<br />

: Eleva<strong>to</strong>rView<br />

: SoundEffects<br />

firstFloorPanel : ImagePanel<br />

secondFloorPanel : ImagePanel<br />

eleva<strong>to</strong>rShaftPanel : ImagePanel<br />

ceilingPanel : ImagePanel<br />

wallPanel : ImagePanel<br />

bellClip : AudioClip<br />

doorOpenClip : AudioClip<br />

doorCloseClip : AudioClip<br />

eleva<strong>to</strong>rClip : AudioClip<br />

but<strong>to</strong>nClip : AudioClip<br />

walkClip : AudioClip<br />

Figure 13.19 specified that the Eleva<strong>to</strong>rView implements interface Eleva<strong>to</strong>rModelListener,<br />

which implements all interfaces in the simulation. The Eleva<strong>to</strong>rSimulation<br />

registers the Eleva<strong>to</strong>rView as a listener for events from the<br />

Eleva<strong>to</strong>rModel; in other words, the Eleva<strong>to</strong>rModel sends all events generated in<br />

the model <strong>to</strong> the Eleva<strong>to</strong>rView.<br />

Every method implementing an interface receives an event object of type Eleva<strong>to</strong>rModelEvent<br />

(or a subclass) as a parameter. For example, the doorOpened method

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!