gov.sns.tools.correlator
Class PeriodicPoster

java.lang.Object
  |
  +--gov.sns.tools.correlator.PeriodicPoster
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class PeriodicPoster
extends java.lang.Object
implements java.awt.event.ActionListener

PerodicPoster is an auxiliary class for posting correlations periodically. Unlike the TimedBroadcaster, it strictly only posts the most recent best correlation within a given time interval. Other correlations within that same time period will be dropped. The poster will repeat forever until it is stopped.


Field Summary
protected  gov.sns.tools.correlator.PassiveBroadcaster broadcaster
           
protected  Correlator correlator
           
protected  javax.swing.Timer timer
           
 
Constructor Summary
PeriodicPoster(Correlator aCorrelator, double period)
          Creates a new instance of PeriodicPoster
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Implement ActionListener interface to rebroadcast the best correlation.
 void addCorrelationNoticeListener(CorrelationNotice listener)
          Add the listener of re-broadcast correlation notices.
 void dispose()
          Dispose of the poster
 Correlator getCorrelator()
          Get the associated correlator
 double getPeriod()
          Get the timer period
 boolean isRunning()
          Determine if the poster is running
 void removeCorrelationNoticeListener(CorrelationNotice listener)
          Remove the listener of re-broadcast correlations
 void restart()
          Restart posting
 void setPeriod(double period)
          Set the timer period
 void start()
          Start the timer
 void stop()
          Stop posting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

correlator

protected Correlator correlator

broadcaster

protected gov.sns.tools.correlator.PassiveBroadcaster broadcaster

timer

protected javax.swing.Timer timer
Constructor Detail

PeriodicPoster

public PeriodicPoster(Correlator aCorrelator,
                      double period)
Creates a new instance of PeriodicPoster

Parameters:
aCorrelator - The correlator providing the correlations.
period - The posting period.
Method Detail

getCorrelator

public Correlator getCorrelator()
Get the associated correlator

Returns:
the correlator providing the correlations.

getPeriod

public double getPeriod()
Get the timer period

Returns:
The timer period.

setPeriod

public void setPeriod(double period)
Set the timer period

Parameters:
period - The new timer period.

isRunning

public boolean isRunning()
Determine if the poster is running

Returns:
true if the poster is running and false if not.

start

public void start()
Start the timer


stop

public void stop()
Stop posting


restart

public void restart()
Restart posting


dispose

public void dispose()
Dispose of the poster


addCorrelationNoticeListener

public void addCorrelationNoticeListener(CorrelationNotice listener)
Add the listener of re-broadcast correlation notices.

Parameters:
listener - A listener of the correlation notice.

removeCorrelationNoticeListener

public void removeCorrelationNoticeListener(CorrelationNotice listener)
Remove the listener of re-broadcast correlations

Parameters:
listener - A listener of the correlation notice.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Implement ActionListener interface to rebroadcast the best correlation.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The timer event indicating that it is time to post a correlation.