public class Clock extends OMComponent implements RealTimeHandler, java.awt.event.ActionListener, java.beans.PropertyChangeListener, TimeBoundsHandler, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected int |
clockDirection |
static int |
DEFAULT_TIME_INTERVAL |
protected long |
endTime |
protected long |
simTime |
protected long |
startTime |
protected long |
systemTime |
protected long |
time |
protected java.util.List<TimeBoundsListener> |
timeBoundsListeners |
protected java.util.List<TimeBoundsProvider> |
timeBoundsProviders |
protected java.util.List<TimeEventListener> |
timeEventListeners |
protected java.text.SimpleDateFormat |
timeFormat
TimeFormat default is similar to IETF standard date syntax: "13:30:00"
represented by (HH:mm:ss).
|
static java.lang.String |
TimeFormatProperty
timeFormat, used for the times listed in properties for rates/pace.
|
protected int |
timeIncrement
The timeIncrement is the amount of time that passes for each clock tick.
|
protected javax.swing.Timer |
timer |
protected java.util.List<TimerRateHolder> |
timerRates |
protected boolean |
timeWrap |
protected int |
updateInterval
The delay between timer pulses, in milliseconds.
|
i18n, propertyPrefix
beanContextChildSupport, isolated
TIMER_STATUS
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
Constructor and Description |
---|
Clock() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent ae)
ActionListener interface, gets called when the timer goes ping if there
isn't a command with the ActionEvent.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds a PropertyChangeListener to this Clock, so that object can receive
time PropertyChangeEvents.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener pcl)
Method for BeanContextChild interface.
|
protected void |
addTime(long timeStamp)
Add a time to the time range.
|
void |
addTimeBoundsListener(TimeBoundsListener tbl)
Add a TimeBoundsListener to the clock, so it knows who to tell when the
time bounds change.
|
void |
addTimeBoundsProvider(TimeBoundsProvider tbp)
Add a TimeBoundsProvider to the clock, so it knows the bounds of it's
time range.
|
void |
addTimeEventListener(TimeEventListener tel)
Add a TimeEventListener to the clock, so it knows who to update when the
time changes.
|
void |
addTimeToBounds(long timeStamp)
Add a time to the time range, fire a TimeBoundsEvent if the time range
changes.
|
protected void |
changeTimeBy(long amount)
Call setTime with the amount given added to the current time.
|
protected void |
changeTimeBy(long amount,
boolean wrapAroundTimeLimits)
Call setTime with the amount given added to the current time.
|
protected void |
changeTimeBy(long amount,
boolean wrapAroundTimeLimits,
TimerStatus timeStatus)
Call setTime with the amount given added to the current time.
|
void |
clearTimeBoundsListeners() |
void |
clearTimeBoundsProviders() |
void |
clearTimeEventListeners() |
void |
createTimer()
Creates a timer with the current updateInterval and calls setTimer().
|
void |
findAndInit(java.lang.Object someObj)
OMComponent method, called when new components are added to the
MapHandler.
|
void |
findAndUndo(java.lang.Object someObj)
OMComponent method, called when new components are removed from the
MapHandler.
|
protected void |
fireClockUpdate(TimerStatus timerStatus)
The method that delivers the current time status to the
TimeEventListeners.
|
void |
fireUpdateTime(TimeEvent te) |
void |
fireUpdateTimeBounds(TimeBoundsEvent tbe) |
int |
getClockDirection()
Get whether time increases or decreases when the clock is run.
|
long |
getEndTime() |
int |
getPace()
Get the amount of simulation time that passes with each clock tick, in
milliseconds.
|
long |
getSimTime() |
long |
getStartTime() |
long |
getSystemTime() |
long |
getTime()
Get the current time.
|
javax.swing.Timer |
getTimer()
Get the timer being used for automatic updates.
|
java.util.List<TimerRateHolder> |
getTimerRates()
Get a list of TimerRateHolders.
|
int |
getUpdateInterval()
Return the real time interval between clock ticks, in milliseconds.
|
protected void |
initializePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Fires Propertyevents to new PropertyChangeListeners so they get the
latest info.
|
boolean |
isRunning() |
void |
propertyChange(java.beans.PropertyChangeEvent pce)
PropertyChangeListener method called when the bounds on a
TimeBoundsProvider changes, so so that the range of times can be
adjusted.
|
void |
removeTimeBoundsListener(TimeBoundsListener tbl) |
void |
removeTimeBoundsProvider(TimeBoundsProvider tbp) |
void |
removeTimeEventListener(TimeEventListener tel)
Remove a listener so it stops receiving TimeEvents.
|
void |
resetTimeBounds()
Method to call when TimeBoundsProviders change, in order to query them
and figure out what the new time range is.
|
void |
setBaseTimesForTimeEvent(long sysTime,
long simulationTime)
Set the system time and simulation time.
|
void |
setClockDirection(int direction)
Set whether time increases or decreases when the clock is run.
|
void |
setPace(int pace)
Set the amount of simulation time that passes with each clock tick, in
milliseconds.
|
void |
setProperties(java.lang.String prefix,
java.util.Properties properties)
Sets the properties for the OMComponent.
|
void |
setTime(long t)
Called to set the clock to a specific time, usually for jumps.
|
protected void |
setTime(long t,
TimerStatus timeStatus)
The call to set the clock for all reasons.
|
void |
setTimer(javax.swing.Timer t)
If you want the layer to update itself at certain intervals, you can set
the timer to do that.
|
void |
setTimerRates(java.util.List<TimerRateHolder> rates)
Make sure the List contains TimerRateHolders.
|
void |
setUpdateInterval(int delay)
Set the real time clock interval between clock ticks, in milliseconds.
|
void |
startClock()
Method to call to start the timer.
|
void |
stepBackward()
Move the clock back one time increment.
|
void |
stepForward()
Move the clock forward one time increment.
|
void |
stopClock()
Method to call to stop the timer.
|
getProperties, getPropertyInfo, getPropertyPrefix, setProperties, setPropertyPrefix
addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated
public static final int DEFAULT_TIME_INTERVAL
public static final java.lang.String TimeFormatProperty
protected java.text.SimpleDateFormat timeFormat
protected javax.swing.Timer timer
protected long startTime
protected long endTime
protected long time
protected int timeIncrement
protected boolean timeWrap
protected int clockDirection
protected java.util.List<TimerRateHolder> timerRates
protected transient java.util.List<TimeBoundsProvider> timeBoundsProviders
protected transient java.util.List<TimeBoundsListener> timeBoundsListeners
protected transient java.util.List<TimeEventListener> timeEventListeners
protected int updateInterval
protected long systemTime
protected long simTime
public void setUpdateInterval(int delay)
setUpdateInterval
in interface RealTimeHandler
delay
- number of milliseconds between updates.public int getUpdateInterval()
getUpdateInterval
in interface RealTimeHandler
public void setPace(int pace)
setPace
in interface RealTimeHandler
pace
- a number that means something to the
RealTimeHandler.public int getPace()
getPace
in interface RealTimeHandler
public void setTime(long t)
setTime
in interface RealTimeHandler
t
- the time in unix epoch termsprotected void setTime(long t, TimerStatus timeStatus)
t
- the time in unix epoch termstimeStatus
- TimerStatus indicating how the clock is changing.protected void fireClockUpdate(TimerStatus timerStatus)
public long getTime()
getTime
in interface RealTimeHandler
public void startClock()
startClock
in interface RealTimeHandler
public void stopClock()
stopClock
in interface RealTimeHandler
public void setClockDirection(int direction)
setClockDirection
in interface RealTimeHandler
public int getClockDirection()
getClockDirection
in interface RealTimeHandler
public void stepForward()
stepForward
in interface RealTimeHandler
public void stepBackward()
stepBackward
in interface RealTimeHandler
protected void changeTimeBy(long amount)
amount
- to change the current time by, in milliseconds.protected void changeTimeBy(long amount, boolean wrapAroundTimeLimits)
amount
- to change the current time by, in milliseconds.wrapAroundTimeLimits
- if true, the time will be set as if the start
and end times of the scenario are connected, so that moving the
time past the time scale in either direction will put the time at
the other end of the scale.protected void changeTimeBy(long amount, boolean wrapAroundTimeLimits, TimerStatus timeStatus)
amount
- to change the current time by, in milliseconds.wrapAroundTimeLimits
- if true, the time will be set as if the start
and end times of the scenario are connected, so that moving the
time past the time scale in either direction will put the time at
the other end of the scale.timeStatus
- the string given to the TimeEvent to let everyone know
why the time is changing. Usually TIMER_TIME_STATUS if the timer
went off normally, or TIME_SET_STATUS if the time is being
specifically set to something.public void actionPerformed(java.awt.event.ActionEvent ae)
actionPerformed
in interface java.awt.event.ActionListener
public void propertyChange(java.beans.PropertyChangeEvent pce)
propertyChange
in interface java.beans.PropertyChangeListener
public void addTimeBoundsProvider(TimeBoundsProvider tbp)
addTimeBoundsProvider
in interface TimeBoundsHandler
public void removeTimeBoundsProvider(TimeBoundsProvider tbp)
removeTimeBoundsProvider
in interface TimeBoundsHandler
public void clearTimeBoundsProviders()
clearTimeBoundsProviders
in interface TimeBoundsHandler
public void addTimeBoundsListener(TimeBoundsListener tbl)
public void removeTimeBoundsListener(TimeBoundsListener tbl)
public void clearTimeBoundsListeners()
public void fireUpdateTimeBounds(TimeBoundsEvent tbe)
public void addTimeEventListener(TimeEventListener tel)
addTimeEventListener
in interface RealTimeHandler
public void removeTimeEventListener(TimeEventListener tel)
RealTimeHandler
removeTimeEventListener
in interface RealTimeHandler
public void clearTimeEventListeners()
public void fireUpdateTime(TimeEvent te)
public void resetTimeBounds()
resetTimeBounds
in interface TimeBoundsHandler
public void addTimeToBounds(long timeStamp)
timeStamp
- in millisecondsprotected void addTime(long timeStamp)
timeStamp
- in millisecondspublic long getStartTime()
public long getEndTime()
public void setBaseTimesForTimeEvent(long sysTime, long simulationTime)
sysTime
- the system (computer) time used in TimeEvents.simulationTime
- the scenario time used in TimeEvents.public long getSimTime()
public long getSystemTime()
public javax.swing.Timer getTimer()
public void setTimer(javax.swing.Timer t)
public void createTimer()
public java.util.List<TimerRateHolder> getTimerRates()
public void setTimerRates(java.util.List<TimerRateHolder> rates)
public void setProperties(java.lang.String prefix, java.util.Properties properties)
OMComponent
setProperties
in interface PropertyConsumer
setProperties
in class OMComponent
prefix
- string prefix used in the properties file for this
component.properties
- the properties set in the properties file.public void findAndInit(java.lang.Object someObj)
findAndInit
in interface LightMapHandlerChild
findAndInit
in class MapHandlerChild
public void findAndUndo(java.lang.Object someObj)
findAndUndo
in interface LightMapHandlerChild
findAndUndo
in class MapHandlerChild
public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
MapHandlerChild
addPropertyChangeListener
in interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener
in class MapHandlerChild
protected void initializePropertyChangeListener(java.beans.PropertyChangeListener pcl)
public boolean isRunning()
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details