ch.sahits.game.openpatrician.model.time
Class PeriodicalTimeUpdater

java.lang.Object
  extended by ch.sahits.game.openpatrician.model.time.PeriodicalTimeUpdater
All Implemented Interfaces:
IClockUpdateListener

public class PeriodicalTimeUpdater
extends Object
implements IClockUpdateListener

The periodical time updater encapsules clock ticks of instances that are interested in notification but only on a periodical level. The period may vary but the implementation is always the same. The periods as defined in EUpdateIntervalRegistration are possible, where as a year is composed by 365 days and a month has always 30 days. So these periods are not really exact.

Author:
Andi Hotz, (c) Sahits GmbH, 2012 Created on Jul 22, 2012

Field Summary
private  Date date
           
private  IPeriodicalUpdate listener
          Instance that is to be notified
private  int tickInterval
          Period of the clock ticking
private  int timePassed
          Time passed since the last notification
private  int updateInterval
          Period that the listener should be notified
 
Constructor Summary
PeriodicalTimeUpdater(EUpdateIntervalRegistration intervall, IPeriodicalUpdate listener)
           
 
Method Summary
 void stop()
          Stop notifiyng the listener
 void ticked()
          Clock ticked once
 void updateTick(int minutes)
          The update size of a tick changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tickInterval

private int tickInterval
Period of the clock ticking


date

private final Date date

updateInterval

private final int updateInterval
Period that the listener should be notified


timePassed

private int timePassed
Time passed since the last notification


listener

private IPeriodicalUpdate listener
Instance that is to be notified

Constructor Detail

PeriodicalTimeUpdater

public PeriodicalTimeUpdater(EUpdateIntervalRegistration intervall,
                             IPeriodicalUpdate listener)
Method Detail

stop

public void stop()
Stop notifiyng the listener


updateTick

public void updateTick(int minutes)
Description copied from interface: IClockUpdateListener
The update size of a tick changed.

Specified by:
updateTick in interface IClockUpdateListener
Parameters:
minutes - new tick size in minutes

ticked

public void ticked()
Description copied from interface: IClockUpdateListener
Clock ticked once

Specified by:
ticked in interface IClockUpdateListener


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.