Clock (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.time
Class Clock

    java.lang.Object
      com.bbn.openmap.MapHandlerChild
          com.bbn.openmap.OMComponent
              com.bbn.openmap.time.Clock

All Implemented Interfaces:
  LightMapHandlerChild, PropertyConsumer, RealTimeHandler, TimeBoundsHandler, java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

    public class Clock

extends OMComponent
implements RealTimeHandler, java.awt.event.ActionListener, java.beans.PropertyChangeListener, TimeBoundsHandler, java.io.Serializable

The Clock is a controller that manages a Timer in order to support the notion of a time range and a list of objects that can contribute to that time range. The clock can count forward and backward, can wrap around the time limits, and can be set to any time between the time range limits. The clock sends out time notifications as PropertyChangeEvents.

See Also:
  Serialized Form

Field Summary
`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.

Fields inherited from class com.bbn.openmap.OMComponent
`i18n, propertyPrefix`

Fields inherited from class com.bbn.openmap.MapHandlerChild
`beanContextChildSupport, isolated`

Fields inherited from interface com.bbn.openmap.time.RealTimeHandler
`TIMER_STATUS`

Fields inherited from interface com.bbn.openmap.PropertyConsumer
`EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty`

Constructor Summary
`Clock()`

Method Summary
`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.

Methods inherited from class com.bbn.openmap.OMComponent
`getProperties, getPropertyInfo, getPropertyPrefix, setProperties, setPropertyPrefix`

Methods inherited from class com.bbn.openmap.MapHandlerChild
`addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_TIME_INTERVAL

    public static final int DEFAULT_TIME_INTERVAL

See Also:
  Constant Field Values

### TimeFormatProperty

    public static final java.lang.String TimeFormatProperty

  timeFormat, used for the times listed in properties for rates/pace.

  See Also:
    Constant Field Values

### timeFormat

    protected java.text.SimpleDateFormat timeFormat

  TimeFormat default is similar to IETF standard date syntax: "13:30:00" represented by (HH:mm:ss).

### timer

    protected javax.swing.Timer timer

### startTime

    protected long startTime

### endTime

    protected long endTime

### time

    protected long time

### timeIncrement

    protected int timeIncrement

  The timeIncrement is the amount of time that passes for each clock tick. This sets up the ratio for slow and fast motion changes for a set clock update rate. Can be modified with the pace accessors.

### timeWrap

    protected boolean timeWrap

### clockDirection

    protected int clockDirection

### timerRates

    protected java.util.List<TimerRateHolder> timerRates

### timeBoundsProviders

    protected transient java.util.List<TimeBoundsProvider> timeBoundsProviders

### timeBoundsListeners

    protected transient java.util.List<TimeBoundsListener> timeBoundsListeners

### timeEventListeners

    protected transient java.util.List<TimeEventListener> timeEventListeners

### updateInterval

    protected int updateInterval

  The delay between timer pulses, in milliseconds.

### systemTime

    protected long systemTime

### simTime

    protected long simTime

Constructor Detail

### Clock

    public Clock()

Method Detail

### setUpdateInterval

    public void setUpdateInterval(int delay)

  Set the real time clock interval between clock ticks, in milliseconds.

  Specified by:
    `setUpdateInterval` in interface `RealTimeHandler`
  Parameters:
    `delay` - number of milliseconds between updates.

### getUpdateInterval

    public int getUpdateInterval()

  Return the real time interval between clock ticks, in milliseconds.

  Specified by:
    `getUpdateInterval` in interface `RealTimeHandler`
  Returns:
    interval number of milliseconds between updates.

### setPace

    public void setPace(int pace)

  Set the amount of simulation time that passes with each clock tick, in milliseconds.

  Specified by:
    `setPace` in interface `RealTimeHandler`
  Parameters:
    `pace` - a number that means something to the RealTimeHandler.

### getPace

    public int getPace()

  Get the amount of simulation time that passes with each clock tick, in milliseconds.

  Specified by:
    `getPace` in interface `RealTimeHandler`
  Returns:
    a number that means something to the RealTimeHandler.

### setTime

    public void setTime(long t)

  Called to set the clock to a specific time, usually for jumps.

  Specified by:
    `setTime` in interface `RealTimeHandler`
  Parameters:
    `t` - the time in unix epoch terms

### setTime

    protected void setTime(long t,
                           TimerStatus timeStatus)

  The call to set the clock for all reasons.

  Parameters:
    `t` - the time in unix epoch terms
    `timeStatus` - TimerStatus indicating how the clock is changing.

### fireClockUpdate

    protected void fireClockUpdate(TimerStatus timerStatus)

  The method that delivers the current time status to the TimeEventListeners.

### getTime

    public long getTime()

  Get the current time.

  Specified by:
    `getTime` in interface `RealTimeHandler`
  Returns:
    time

### startClock

    public void startClock()

  Method to call to start the timer.

  Specified by:
    `startClock` in interface `RealTimeHandler`

### stopClock

    public void stopClock()

  Method to call to stop the timer.

  Specified by:
    `stopClock` in interface `RealTimeHandler`

### setClockDirection

    public void setClockDirection(int direction)

  Set whether time increases or decreases when the clock is run. If direction is zero or greater, clock runs forward. If direction is negative, clock runs backward.

  Specified by:
    `setClockDirection` in interface `RealTimeHandler`

### getClockDirection

    public int getClockDirection()

  Get whether time increases or decreases when the clock is run. If direction is zero or greater, clock runs forward. If direction is negative, clock runs backward.

  Specified by:
    `getClockDirection` in interface `RealTimeHandler`

### stepForward

    public void stepForward()

  Move the clock forward one time increment.

  Specified by:
    `stepForward` in interface `RealTimeHandler`

### stepBackward

    public void stepBackward()

  Move the clock back one time increment.

  Specified by:
    `stepBackward` in interface `RealTimeHandler`

### changeTimeBy

    protected void changeTimeBy(long amount)

  Call setTime with the amount given added to the current time. The amount should be negative if you are going backward through time. You need to make sure manageGraphics is called for the map to update.

  Parameters:
    `amount` - to change the current time by, in milliseconds.

### changeTimeBy

    protected void changeTimeBy(long amount,
                                boolean wrapAroundTimeLimits)

  Call setTime with the amount given added to the current time. The amount should be negative if you are going backward through time. You need to make sure manageGraphics is called for the map to update.

  Parameters:
    `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.

### changeTimeBy

    protected void changeTimeBy(long amount,
                                boolean wrapAroundTimeLimits,
                                TimerStatus timeStatus)

  Call setTime with the amount given added to the current time. The amount should be negative if you are going backward through time. You need to make sure manageGraphics is called for the map to update.

  Parameters:
    `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.

### actionPerformed

    public 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. Otherwise, the command should be filled in.

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

### propertyChange

    public 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.

  Specified by:
    `propertyChange` in interface `java.beans.PropertyChangeListener`

### addTimeBoundsProvider

    public void addTimeBoundsProvider(TimeBoundsProvider tbp)

  Add a TimeBoundsProvider to the clock, so it knows the bounds of it's time range.

  Specified by:
    `addTimeBoundsProvider` in interface `TimeBoundsHandler`

### removeTimeBoundsProvider

    public void removeTimeBoundsProvider(TimeBoundsProvider tbp)

  Specified by:
    `removeTimeBoundsProvider` in interface `TimeBoundsHandler`

### clearTimeBoundsProviders

    public void clearTimeBoundsProviders()

  Specified by:
    `clearTimeBoundsProviders` in interface `TimeBoundsHandler`

### addTimeBoundsListener

    public void addTimeBoundsListener(TimeBoundsListener tbl)

  Add a TimeBoundsListener to the clock, so it knows who to tell when the time bounds change.

### removeTimeBoundsListener

    public void removeTimeBoundsListener(TimeBoundsListener tbl)

### clearTimeBoundsListeners

    public void clearTimeBoundsListeners()

### fireUpdateTimeBounds

    public void fireUpdateTimeBounds(TimeBoundsEvent tbe)

### addTimeEventListener

    public void addTimeEventListener(TimeEventListener tel)

  Add a TimeEventListener to the clock, so it knows who to update when the time changes.

  Specified by:
    `addTimeEventListener` in interface `RealTimeHandler`

### removeTimeEventListener

    public void removeTimeEventListener(TimeEventListener tel)

  Description copied from interface: `RealTimeHandler`
  Remove a listener so it stops receiving TimeEvents.

  Specified by:
    `removeTimeEventListener` in interface `RealTimeHandler`

### clearTimeEventListeners

    public void clearTimeEventListeners()

### fireUpdateTime

    public void fireUpdateTime(TimeEvent te)

### resetTimeBounds

    public void resetTimeBounds()

  Method to call when TimeBoundsProviders change, in order to query them and figure out what the new time range is.

  Specified by:
    `resetTimeBounds` in interface `TimeBoundsHandler`

### addTimeToBounds

    public void addTimeToBounds(long timeStamp)

  Add a time to the time range, fire a TimeBoundsEvent if the time range changes.

  Parameters:
    `timeStamp` - in milliseconds

### addTime

    protected void addTime(long timeStamp)

  Add a time to the time range.

  Parameters:
    `timeStamp` - in milliseconds

### getStartTime

    public long getStartTime()

### getEndTime

    public long getEndTime()

### setBaseTimesForTimeEvent

    public void setBaseTimesForTimeEvent(long sysTime,
                                         long simulationTime)

  Set the system time and simulation time. These times are used in relation to any offsets. System time usually gets reset when the time bounds are reset.

  Parameters:
    `sysTime` - the system (computer) time used in TimeEvents.
    `simulationTime` - the scenario time used in TimeEvents.

### getSimTime

    public long getSimTime()

### getSystemTime

    public long getSystemTime()

### getTimer

    public javax.swing.Timer getTimer()

  Get the timer being used for automatic updates. May be null if a timer is not set.

### setTimer

    public 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. Set it to null to disable it. If the current timer is not null, the graphic loader is removed as an ActionListener. If the new one is not null, the graphic loader is added as an ActionListener.

### createTimer

    public void createTimer()

  Creates a timer with the current updateInterval and calls setTimer().

### getTimerRates

    public java.util.List<TimerRateHolder> getTimerRates()

  Get a list of TimerRateHolders.

### setTimerRates

    public void setTimerRates(java.util.List<TimerRateHolder> rates)

  Make sure the List contains TimerRateHolders.

### setProperties

    public void setProperties(java.lang.String prefix,
                              java.util.Properties properties)

  Description copied from class: `OMComponent`
  Sets the properties for the OMComponent.

  Specified by:
    `setProperties` in interface `PropertyConsumer`
  Overrides:
    `setProperties` in class `OMComponent`
  Parameters:
    `prefix` - string prefix used in the properties file for this component.
    `properties` - the properties set in the properties file.

### findAndInit

    public void findAndInit(java.lang.Object someObj)

  OMComponent method, called when new components are added to the MapHandler. Lets the Clock find TimeBoundsProviders that have been added to the application, so that the Clock can register itself as a PropertyChangeListener.

  Specified by:
    `findAndInit` in interface `LightMapHandlerChild`
  Overrides:
    `findAndInit` in class `MapHandlerChild`

### findAndUndo

    public void findAndUndo(java.lang.Object someObj)

  OMComponent method, called when new components are removed from the MapHandler. Lets the Clock unregister itself as PropertyChangeListener to TimeBoundsProviders.

  Specified by:
    `findAndUndo` in interface `LightMapHandlerChild`
  Overrides:
    `findAndUndo` in class `MapHandlerChild`

### addPropertyChangeListener

    public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)

  Adds a PropertyChangeListener to this Clock, so that object can receive time PropertyChangeEvents.

### addPropertyChangeListener

    public void addPropertyChangeListener(java.lang.String propertyName,
                                          java.beans.PropertyChangeListener pcl)

  Description copied from class: `MapHandlerChild`
  Method for BeanContextChild interface. Uses the BeanContextChildSupport to add a listener to this object's property. You don't need this function for objects that extend java.awt.Component.

  Specified by:
    `addPropertyChangeListener` in interface `java.beans.beancontext.BeanContextChild`
  Overrides:
    `addPropertyChangeListener` in class `MapHandlerChild`

### initializePropertyChangeListener

    protected void initializePropertyChangeListener(java.beans.PropertyChangeListener pcl)

  Fires Propertyevents to new PropertyChangeListeners so they get the latest info.

### isRunning

    public boolean isRunning()

  Returns:
    true if timer is running.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details