com.bbn.openmap.graphicLoader.scenario
Class ScenarioGraphicLoader

java.lang.Object
  extended bycom.bbn.openmap.MapHandlerChild
      extended bycom.bbn.openmap.OMComponent
          extended bycom.bbn.openmap.graphicLoader.AbstractGraphicLoader
              extended bycom.bbn.openmap.graphicLoader.MMLGraphicLoader
                  extended bycom.bbn.openmap.graphicLoader.scenario.ScenarioGraphicLoader
All Implemented Interfaces:
java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.awt.event.ComponentListener, DataBoundsProvider, java.util.EventListener, GraphicLoader, LightMapHandlerChild, MapMouseListener, PropertyConsumer, RealTimeHandler, TimeConstants, Tool

public class ScenarioGraphicLoader
extends MMLGraphicLoader
implements Tool, java.awt.event.ComponentListener, DataBoundsProvider, RealTimeHandler, TimeConstants

The ScenarioGraphicLoader contains all the ScenarioGraphics and manages the time for the scenario. The different organization objects are represented in a location file that lists a name and an icon URL. An activities file lists the different steps for the organizations - where they are (lat/lon) and when. A timer in the loader positions the organizations for that time, interpolating location for times between time/location definitions. If an organization stops to wait in a position, two activity locations should be defined for that stop, for when the organization arrived to that spot and when then left. Different properties need to be set for the ScenarioGraphicLoader to let it know how the files, Comma Separated Value (CSV) files, should be interpreted.

The ScenarioGraphicLoader also lets you define different steps for how to control the time, i.e. the timer rate. The clock interval for the timer rate is measured in milliseconds, specifying how often the map should be updated. Note that the more often the map is updated, the more unresponsive the map can become. The pace for the timer rate is how much 'senario time' passes for each time the clock updates. You can define those steps in different formats, but the default format for the pace is hh:mm:ss for hours:minutes:seconds.

Sample properties:

   
   
    scenario.class=com.bbn.openmap.graphicLoader.scenario.ScenarioGraphicLoader
    scenario.prettyName=Test Scenario
    scenario.locationFile=org-list.csv
    scenario.locationFileHasHeader=true
    scenario.nameIndex=0
    scenario.iconIndex=5
    scenario.activityFile=org-activities.csv
    scenario.activityFileHasHeader=true
    scenario.activityNameIndex=1
    scenario.latIndex=9
    scenario.lonIndex=10
    scenario.timeFormat=d-MMM-yyyy HH:mm
    scenario.timeIndex=7
    # If no icon defined, used for org. location markers edge.
    scenario.lineColor=aaaaaa33
    # If no icon defined, used for org. location markers fill.
    scenario.fillColor=aaaaaa33
    # Used for lines for total scenario paths
    scenario.selectColor=aaaa0000
    
    scenario.timerRates=vs s m a q f vf
    scenario.vs.prettyName=Very Slow
    scenario.vs.clockIntervalMillis=2000
    scenario.vs.pace=00:06:00
    scenario.s.prettyName=Slow
    scenario.s.clockIntervalMillis=1000
    scenario.s.pace=00:06:00
    scenario.m.prettyName=Moderate
    scenario.m.clockIntervalMillis=400
    scenario.m.pace=00:06:00
    scenario.a.prettyName=Average
    scenario.a.clockIntervalMillis=200
    scenario.a.pace=00:06:00
    scenario.q.prettyName=Quick
    scenario.q.clockIntervalMillis=100
    scenario.q.pace=00:06:00
    scenario.f.prettyName=Fast
    scenario.f.clockIntervalMillis=40
    scenario.f.pace=00:06:00
    scenario.vf.prettyName=Very Fast
    scenario.vf.clockIntervalMillis=10
    scenario.vf.pace=01:00:00
    
 


Nested Class Summary
 class ScenarioGraphicLoader.ScenarioGraphicList
          An OMGraphicList that knows what a ScenarioGraphic is, and knows when to tell it to draw itself at a particular time, or if it should draw its entire scenario path.
 class ScenarioGraphicLoader.TimerRateHolder
          A convenience class that keeps track of a relationship between real-time changes and scenario-time changes.
 
Field Summary
protected  java.lang.String activityFile
           
static java.lang.String ActivityFileProperty
          activityFile
protected  boolean activityHeader
           
static java.lang.String ActivityHeaderProperty
          activityFileHasHeader
protected  int activityNameIndex
           
static java.lang.String ActivityNameIndexProperty
          activityNameIndex
protected  int clockDirection
           
static java.lang.String ClockIntervalProperty
          clockIntervalMillis
protected  DataBounds dataBounds
           
protected  java.lang.String defaultIconURL
          Icon URL for points to use as default.
static java.lang.String DefaultIconURLProperty
          defaultURL
static java.lang.String DefaultPaceBaselineString
           
static java.lang.String DefaultTimerIntervalFormat
           
protected  DrawingAttributes drawingAttributes
           
protected  boolean eastIsNeg
           
static java.lang.String EastIsNegProperty
          eastIsNeg
protected  long endTime
           
protected  int iconIndex
           
static java.lang.String IconIndexProperty
          iconIndex
protected  int latIndex
           
static java.lang.String LatIndexProperty
          latIndex
protected  java.lang.String locationFile
           
static java.lang.String LocationFileProperty
          locationFile
protected  boolean locationHeader
           
static java.lang.String LocationHeaderProperty
          locationFileHasHeader
protected  int lonIndex
           
static java.lang.String LonIndexProperty
          lonIndex
protected  java.lang.String mode
           
protected  int nameIndex
           
static java.lang.String NameIndexProperty
          nameIndex
static java.lang.String PaceProperty
          pace
protected  java.beans.PropertyChangeSupport pcs
           
static java.lang.String SCENARIO_MODE_CMD
           
protected  ScenarioGraphicLoader.ScenarioGraphicList scenarioGraphics
           
protected  boolean showNames
           
static java.lang.String ShowNamesProperty
          showNames
static java.lang.String SNAPSHOT_SCENARIO_MODE
           
protected  java.lang.String snapshotIconName
           
protected  long startTime
           
protected  long time
           
protected  java.util.Date timeDate
           
protected  java.text.SimpleDateFormat timeFormat
          TimeFormat default is similar to IETF standard date syntax: "Sat, 12 Aug 1995 13:30:00 GMT" represented by (EEE, d MMM yyyy HH:mm:ss z), except for the local timezone.
static java.lang.String TimeFormatProperty
          timeFormat
protected  int timeIncrement
           
protected  int timeIndex
           
static java.lang.String TimeIndexProperty
          timeIndex
protected  javax.swing.JLabel timeLabel
           
protected  TimerControlButtonPanel timerControl
           
protected  java.text.SimpleDateFormat timerIntervalFormat
          The TimerIntervalFormat controls how the pace can be specified for the rate settings.
static java.lang.String TimerIntervalFormatProperty
          timerInvervalFormat
static java.lang.String TimerPaceBaselineProperty
          timerPaceBaseline
protected  java.lang.String timerPaceBaselineString
           
protected  TimerRateComboBox timerRateControl
           
protected  java.util.LinkedList timerRates
           
static java.lang.String TimerRatesProperty
          timerRates
protected  javax.swing.JSlider timeSlider
           
protected  TimeSliderSupport timeSliderSupport
           
protected  boolean timeWrap
           
protected  javax.swing.JToggleButton timeWrapToggle
           
static java.lang.String TOTAL_SCENARIO_MODE
           
protected  java.lang.String totalScenarioIconName
           
 
Fields inherited from class com.bbn.openmap.graphicLoader.AbstractGraphicLoader
DO_NOT_UPDATE_TIMER, name, NameProperty, proj, receiver, timer, TimerCmd, updateInterval
 
Fields inherited from class com.bbn.openmap.OMComponent
i18n, propertyPrefix
 
Fields inherited from class com.bbn.openmap.MapHandlerChild
beanContextChildSupport
 
Fields inherited from interface com.bbn.openmap.gui.time.TimeConstants
TIMER_BACKWARD, TIMER_FORWARD, TIMER_INACTIVE, TIMER_RUNNING_STATUS, TIMER_STEP_BACKWARD, TIMER_STEP_FORWARD, TIMER_STOPPED, TIMER_TIME_STATUS
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
ScenarioGraphicLoader()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          ActionListener interface, gets called when the timer goes ping if their isn't a command with the ActionEvent.
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.
 void componentHidden(java.awt.event.ComponentEvent ce)
           
 void componentMoved(java.awt.event.ComponentEvent ce)
           
 void componentResized(java.awt.event.ComponentEvent ce)
           
 void componentShown(java.awt.event.ComponentEvent ce)
           
 ScenarioGraphicLoader.ScenarioGraphicList createData()
          Read the data files and construct the ScenarioPoints.
 int getClockDirection()
          Get whether time increases or decreases when the clock is run.
 DataBounds getDataBounds()
          DataBoundsProvider method.
 java.awt.Container getFace()
          Tool Method.
 java.lang.String getKey()
          Tool Method.
 java.lang.String getMode()
           
 int getPace()
          Get the number of scenario units that pass when the timer updates within its interval.
 java.util.Properties getProperties(java.util.Properties props)
          PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
 long getTime()
          Get the current time value for the timer.
 void manageGraphics()
          The main method call in the ScenarioGraphicLoader that actually modifies the OMGraphics and updates the map.
 void setClockDirection(int direction)
          Set whether time increases or decreases when the clock is run.
 void setKey(java.lang.String aKey)
          Tool Method.
 void setMode(java.lang.String mode)
           
 void setPace(int pace)
          Set the number of scenario units that pass when the timer updates within its interval.
 void setProperties(java.lang.String prefix, java.util.Properties properties)
          The properties and prefix are managed and decoded here, for the standard uses of the ScenarioGraphicLoader.
 void setTime(long t)
          Set the current time value for the timer.
 void startClock()
          Start the timer.
 void stepBackward()
          Move the clock back one clock interval.
 void stepForward()
          Move the clock forward one clock interval.
 void stopClock()
          Stop the timer.
 
Methods inherited from class com.bbn.openmap.graphicLoader.MMLGraphicLoader
getMouseModeServiceList, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mouseReleased
 
Methods inherited from class com.bbn.openmap.graphicLoader.AbstractGraphicLoader
createTimer, getGUI, getName, getProjection, getReceiver, getTimer, getUpdateInterval, setName, setProjection, setReceiver, setTimer, setUpdateInterval
 
Methods inherited from class com.bbn.openmap.OMComponent
getPropertyPrefix, setProperties, setPropertyPrefix
 
Methods inherited from class com.bbn.openmap.MapHandlerChild
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndInit, findAndUndo, firePropertyChange, fireVetoableChange, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bbn.openmap.util.DataBoundsProvider
getName
 
Methods inherited from interface com.bbn.openmap.gui.time.RealTimeHandler
getUpdateInterval, setUpdateInterval
 

Field Detail

TOTAL_SCENARIO_MODE

public static final java.lang.String TOTAL_SCENARIO_MODE
See Also:
Constant Field Values

SNAPSHOT_SCENARIO_MODE

public static final java.lang.String SNAPSHOT_SCENARIO_MODE
See Also:
Constant Field Values

SCENARIO_MODE_CMD

public static final java.lang.String SCENARIO_MODE_CMD
See Also:
Constant Field Values

DefaultTimerIntervalFormat

public static final java.lang.String DefaultTimerIntervalFormat
See Also:
Constant Field Values

DefaultPaceBaselineString

public static final java.lang.String DefaultPaceBaselineString
See Also:
Constant Field Values

totalScenarioIconName

protected java.lang.String totalScenarioIconName

snapshotIconName

protected java.lang.String snapshotIconName

LocationFileProperty

public static final java.lang.String LocationFileProperty
locationFile

See Also:
Constant Field Values

LocationHeaderProperty

public static final java.lang.String LocationHeaderProperty
locationFileHasHeader

See Also:
Constant Field Values

IconIndexProperty

public static final java.lang.String IconIndexProperty
iconIndex

See Also:
Constant Field Values

NameIndexProperty

public static final java.lang.String NameIndexProperty
nameIndex

See Also:
Constant Field Values

ActivityFileProperty

public static final java.lang.String ActivityFileProperty
activityFile

See Also:
Constant Field Values

ActivityNameIndexProperty

public static final java.lang.String ActivityNameIndexProperty
activityNameIndex

See Also:
Constant Field Values

ActivityHeaderProperty

public static final java.lang.String ActivityHeaderProperty
activityFileHasHeader

See Also:
Constant Field Values

LatIndexProperty

public static final java.lang.String LatIndexProperty
latIndex

See Also:
Constant Field Values

LonIndexProperty

public static final java.lang.String LonIndexProperty
lonIndex

See Also:
Constant Field Values

TimeIndexProperty

public static final java.lang.String TimeIndexProperty
timeIndex

See Also:
Constant Field Values

EastIsNegProperty

public static final java.lang.String EastIsNegProperty
eastIsNeg

See Also:
Constant Field Values

ShowNamesProperty

public static final java.lang.String ShowNamesProperty
showNames

See Also:
Constant Field Values

DefaultIconURLProperty

public static final java.lang.String DefaultIconURLProperty
defaultURL

See Also:
Constant Field Values

TimeFormatProperty

public static final java.lang.String TimeFormatProperty
timeFormat

See Also:
Constant Field Values

TimerIntervalFormatProperty

public static final java.lang.String TimerIntervalFormatProperty
timerInvervalFormat

See Also:
Constant Field Values

TimerPaceBaselineProperty

public static final java.lang.String TimerPaceBaselineProperty
timerPaceBaseline

See Also:
Constant Field Values

ClockIntervalProperty

public static final java.lang.String ClockIntervalProperty
clockIntervalMillis

See Also:
Constant Field Values

PaceProperty

public static final java.lang.String PaceProperty
pace

See Also:
Constant Field Values

TimerRatesProperty

public static final java.lang.String TimerRatesProperty
timerRates

See Also:
Constant Field Values

locationFile

protected java.lang.String locationFile

locationHeader

protected boolean locationHeader

nameIndex

protected int nameIndex

iconIndex

protected int iconIndex

activityFile

protected java.lang.String activityFile

activityHeader

protected boolean activityHeader

activityNameIndex

protected int activityNameIndex

latIndex

protected int latIndex

lonIndex

protected int lonIndex

timeIndex

protected int timeIndex

eastIsNeg

protected boolean eastIsNeg

timeFormat

protected java.text.SimpleDateFormat timeFormat
TimeFormat default is similar to IETF standard date syntax: "Sat, 12 Aug 1995 13:30:00 GMT" represented by (EEE, d MMM yyyy HH:mm:ss z), except for the local timezone.


timerIntervalFormat

protected java.text.SimpleDateFormat timerIntervalFormat
The TimerIntervalFormat controls how the pace can be specified for the rate settings. The default is HH:mm:ss, you can use the timerIntervalFormat property to set it to something else.


timerPaceBaselineString

protected java.lang.String timerPaceBaselineString

startTime

protected long startTime

endTime

protected long endTime

time

protected long time

timeIncrement

protected int timeIncrement

mode

protected java.lang.String mode

timeWrap

protected boolean timeWrap

clockDirection

protected int clockDirection

defaultIconURL

protected java.lang.String defaultIconURL
Icon URL for points to use as default. May be null.


showNames

protected boolean showNames

pcs

protected java.beans.PropertyChangeSupport pcs

scenarioGraphics

protected ScenarioGraphicLoader.ScenarioGraphicList scenarioGraphics

timerRates

protected java.util.LinkedList timerRates

drawingAttributes

protected DrawingAttributes drawingAttributes

dataBounds

protected DataBounds dataBounds

timeDate

protected java.util.Date timeDate

timeWrapToggle

protected javax.swing.JToggleButton timeWrapToggle

timeLabel

protected javax.swing.JLabel timeLabel

timerControl

protected TimerControlButtonPanel timerControl

timerRateControl

protected TimerRateComboBox timerRateControl

timeSlider

protected javax.swing.JSlider timeSlider

timeSliderSupport

protected TimeSliderSupport timeSliderSupport
Constructor Detail

ScenarioGraphicLoader

public ScenarioGraphicLoader()
Method Detail

manageGraphics

public void manageGraphics()
The main method call in the ScenarioGraphicLoader that actually modifies the OMGraphics and updates the map.

Specified by:
manageGraphics in class AbstractGraphicLoader
See Also:
OMGraphicHandler.setList(OMGraphicList)

setPace

public void setPace(int pace)
Description copied from interface: RealTimeHandler
Set the number of scenario units that pass when the timer updates within its interval.

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

getPace

public int getPace()
Description copied from interface: RealTimeHandler
Get the number of scenario units that pass when the timer updates within its interval.

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

getTime

public long getTime()
Description copied from interface: RealTimeHandler
Get the current time value for the timer. The meaning of the time value depends on the RealTimeHandler.

Specified by:
getTime in interface RealTimeHandler
Returns:
time

setTime

public void setTime(long t)
Description copied from interface: RealTimeHandler
Set the current time value for the timer. The meaning of the time value depends on the RealTimeHandler.

Specified by:
setTime in interface RealTimeHandler
Parameters:
t -

startClock

public void startClock()
Description copied from interface: RealTimeHandler
Start the timer.

Specified by:
startClock in interface RealTimeHandler

stopClock

public void stopClock()
Description copied from interface: RealTimeHandler
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

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.

This method calls changeTimeBy(amount, wrapAroundTimeLimits), with wrapAroundTimeLimits being true of the mode of the ScenarioGraphicLoader is SNAPSHOT_SCENARIO_MODE.

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

stepForward

public void stepForward()
Move the clock forward one clock interval.

Specified by:
stepForward in interface RealTimeHandler

stepBackward

public void stepBackward()
Move the clock back one clock interval.

Specified by:
stepBackward in interface RealTimeHandler

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
ActionListener interface, gets called when the timer goes ping if their isn't a command with the ActionEvent. Otherwise, the command should be filled in.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class AbstractGraphicLoader

createData

public ScenarioGraphicLoader.ScenarioGraphicList createData()
Read the data files and construct the ScenarioPoints.


setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties properties)
The properties and prefix are managed and decoded here, for the standard uses of the ScenarioGraphicLoader.

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

getProperties

public java.util.Properties getProperties(java.util.Properties props)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer. If the layer has a propertyPrefix set, the property keys should have that prefix plus a separating '.' prepended to each propery key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class AbstractGraphicLoader
Parameters:
props - a Properties object to load the PropertyConsumer properties into.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties list)
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. The key for each property should be the raw property name (without a prefix) with a value that is a String that describes what the property key represents, along with any other information about the property that would be helpful (range, default value, etc.). This method takes care of the basic LocationHandler parameters, so any LocationHandlers that extend the AbstractLocationHandler should call this method, too, before adding any specific properties.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class AbstractGraphicLoader
Parameters:
list - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getFace

public java.awt.Container getFace()
Tool Method. The retrieval tool's interface. This is added to the tool bar.

Specified by:
getFace in interface Tool
Returns:
String The key for this tool.

getMode

public java.lang.String getMode()

setMode

public void setMode(java.lang.String mode)

getKey

public java.lang.String getKey()
Tool Method. The retrieval key for this tool.

Specified by:
getKey in interface Tool
Returns:
String The key for this tool.

setKey

public void setKey(java.lang.String aKey)
Tool Method. Set the retrieval key for this tool.

Specified by:
setKey in interface Tool
Parameters:
aKey - The key for this tool.

getDataBounds

public DataBounds getDataBounds()
DataBoundsProvider method.

Specified by:
getDataBounds in interface DataBoundsProvider

componentResized

public void componentResized(java.awt.event.ComponentEvent ce)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent ce)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent ce)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent ce)
Specified by:
componentShown in interface java.awt.event.ComponentListener


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