X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTTimer.java;h=8007153d679543d17b74fc51cb14663c262ac866;hb=929409950e82914aa3cee323cfa7c5007585d2ea;hp=2e0ed4277ce742d81b7fb070787bcfb25559f8d0;hpb=8582f35a3ffb8212463076217eb89278f42331d4;p=nikiroo-utils.git diff --git a/src/jexer/TTimer.java b/src/jexer/TTimer.java deleted file mode 100644 index 2e0ed42..0000000 --- a/src/jexer/TTimer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Jexer - Java Text User Interface - * - * License: LGPLv3 or later - * - * This module is licensed under the GNU Lesser General Public License - * Version 3. Please see the file "COPYING" in this directory for more - * information about the GNU Lesser General Public License Version 3. - * - * Copyright (C) 2015 Kevin Lamonte - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see - * http://www.gnu.org/licenses/, or write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - * @author Kevin Lamonte [kevin.lamonte@gmail.com] - * @version 1 - */ -package jexer; - -import java.util.Date; - -/** - * TTimer implements a simple timer. - */ -public final class TTimer { - - /** - * If true, re-schedule after every tick. Note package private access. - */ - boolean recurring = false; - - /** - * Duration (in millis) between ticks if this is a recurring timer. - */ - private long duration = 0; - - /** - * The next time this timer needs to be ticked. - */ - private Date nextTick; - - /** - * Get the next time this timer needs to be ticked. Note package private - * access. - * - * @return time at which action should be called - */ - Date getNextTick() { - return nextTick; - } - - /** - * The action to perfom on a tick. - */ - private TAction action; - - /** - * Tick this timer. Note package private access. - */ - void tick() { - if (action != null) { - action.DO(); - } - // Set next tick - Date ticked = new Date(); - if (recurring) { - nextTick = new Date(ticked.getTime() + duration); - } - } - - /** - * Package private constructor. - * - * @param duration number of milliseconds to wait between ticks - * @param recurring if true, re-schedule this timer after every tick - * @param action to perform on next tick - */ - TTimer(final long duration, final boolean recurring, final TAction action) { - - this.recurring = recurring; - this.duration = duration; - this.action = action; - - Date now = new Date(); - nextTick = new Date(now.getTime() + duration); - } - -}