001 package com.croftsoft.apps.mars.controller;
002
003 import java.awt.*;
004 import java.awt.event.*;
005
006 import com.croftsoft.core.lang.NullArgumentException;
007
008 import com.croftsoft.apps.mars.view.GameAnimator;
009
010 /*********************************************************************
011 * Toggles planned path display.
012 *
013 * @version
014 * 2003-04-30
015 * @since
016 * 2003-04-30
017 * @author
018 * <a href="https://www.croftsoft.com/">David Wallace Croft</a>
019 *********************************************************************/
020
021 public final class GameAnimatorController
022 extends KeyAdapter
023 //////////////////////////////////////////////////////////////////////
024 //////////////////////////////////////////////////////////////////////
025 {
026
027 private final GameAnimator gameAnimator;
028
029 //////////////////////////////////////////////////////////////////////
030 //////////////////////////////////////////////////////////////////////
031
032 public GameAnimatorController (
033 GameAnimator gameAnimator,
034 Component component )
035 //////////////////////////////////////////////////////////////////////
036 {
037 NullArgumentException.check ( this.gameAnimator = gameAnimator );
038
039 component.addKeyListener ( this );
040
041 component.requestFocus ( );
042 }
043
044 //////////////////////////////////////////////////////////////////////
045 // interface KeyListener methods
046 //////////////////////////////////////////////////////////////////////
047
048 public void keyPressed ( KeyEvent keyEvent )
049 //////////////////////////////////////////////////////////////////////
050 {
051 if ( keyEvent.getKeyCode ( ) == KeyEvent.VK_P )
052 {
053 gameAnimator.togglePathAnimator ( );
054 }
055 }
056
057 //////////////////////////////////////////////////////////////////////
058 //////////////////////////////////////////////////////////////////////
059 }