⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timecontroller.java

📁 CroftSoft Code Library是一个开源的可移植的纯Java游戏库
💻 JAVA
字号:
     package com.croftsoft.apps.mars.controller;     import java.awt.*;     import java.awt.event.*;     import com.croftsoft.core.animation.clock.Timekeeper;     import com.croftsoft.core.lang.NullArgumentException;     /*********************************************************************     * Adjusts the time factor.     *     * @version     *   2003-04-18     * @since     *   2003-04-02     * @author     *   <a href="http://www.croftsoft.com/">David Wallace Croft</a>     *********************************************************************/     public final class  TimeController       extends KeyAdapter     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     {     private final Timekeeper  timekeeper;     private final double      timeFactorDefault;     private final double      timeFactorDelta;     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     public  TimeController (       Timekeeper  timekeeper,       double      timeFactorDefault,       double      timeFactorDelta,       Component   component )     //////////////////////////////////////////////////////////////////////     {       NullArgumentException.check ( this.timekeeper = timekeeper );       this.timeFactorDefault = timeFactorDefault;       this.timeFactorDelta   = timeFactorDelta;       component.addKeyListener ( this );       component.requestFocus ( );     }     //////////////////////////////////////////////////////////////////////     // interface KeyListener methods     //////////////////////////////////////////////////////////////////////     public void  keyPressed ( KeyEvent  keyEvent )     //////////////////////////////////////////////////////////////////////     {       char  keyChar = keyEvent.getKeyChar ( );       if ( ( keyChar == '+' )         || ( keyChar == '=' )         || ( keyChar == '-' ) )       {         double  timeFactor = timekeeper.getTimeFactor ( );         if ( keyChar == '+' )         {           timeFactor += timeFactorDelta;         }         else if ( keyChar == '-' )         {           timeFactor -= timeFactorDelta;         }         else         {           timeFactor = timeFactorDefault;         }         timekeeper.setTimeFactor ( timeFactor );         System.out.println ( "Time Factor:  " + timeFactor );       }     }     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -