location.generators
Class FakeGPSMonitor

java.lang.Object
  extended bylocation.generators.FakeGPSMonitor
All Implemented Interfaces:
LocationGenerator, java.io.Serializable

public class FakeGPSMonitor
extends java.lang.Object
implements LocationGenerator, java.io.Serializable

This class reads the data comming from a simulated GPS system.

Version:
3.0
Author:
Chien-Liang Fok
See Also:
Serialized Form

Nested Class Summary
private  class FakeGPSMonitor.LocationTimer
          This class is responsible for firing the location changed events at a periodic interval.
 
Field Summary
(package private)  Latitude currLat
           
(package private)  Longitude currLong
           
static long DEFAULT_INTERVAL
          The default interval between generating points is 1000ms.
static double DEFAULT_LAT_STEP_SIZE
          The default latitude step size in sexagesimal units.
static Latitude DEFAULT_LATITUDE
          The default latitude is (38 38.8935' N)
static double DEFAULT_LONG_STEP_SIZE
          The default longitude step size in sexagesimal units.
static Longitude DEFAULT_LONGITUDE
          The default longitude is (90 18.389986' W)
(package private)  Latitude defaultLat
           
(package private)  Longitude defaultLong
           
private  java.util.Vector gps_listeners
          The GPSListeners that are waiting for GPSInfoEvents.
(package private)  GpsInfoEvent gpsinfo
          The fake GPS Info sent to the user.
(package private)  FakeGPSgui gui
          The GUI that allows the user to specifiy the direction of motion.
(package private)  long interval
          How often in milliseconds the user wants to receive a LocationEvent
(package private)  double latStep
          The step size of the latitude and longitude in sexigesimal units.
(package private)  java.util.Vector listeners
          Holds the listeners.
(package private)  double longStep
          The step size of the latitude and longitude in sexigesimal units.
(package private)  LocationEvent prevLE
          The previous LocationEvent that was broadcasted
(package private)  java.util.Timer timer
          The timer used to generate location events.
 
Constructor Summary
FakeGPSMonitor()
          Creates a FakeGPSMonitor with all the default settings.
FakeGPSMonitor(boolean showGUI)
          Creates a FakeGPSMonitor with all of the default settings except for the showGUI.
FakeGPSMonitor(long updatePeriod)
          Creates a FakeGPSMonitor starting at the default location with the specified update period.
FakeGPSMonitor(long updatePeriod, double latStep, double longStep)
          Creates a FakeGPSMonitor starting at a default location.
FakeGPSMonitor(long updatePeriod, Latitude defaultLat, Longitude defaultLong)
          Creates a FakeGPSMonitor with the starting location as specified by the parameter without reporting its location to a RoutSimulatorServer and default increment.
FakeGPSMonitor(long interval, Latitude defaultLat, Longitude defaultLong, double latStep, double longStep, boolean showGUI)
          Creates a FakeGPSMonitor with the starting location as specified by the parameter.
 
Method Summary
 void addGpsInfoListener(GpsInfoListener gps)
          Add a GpsInfo listener.
 void addLocationListener(LocationListener ll)
          Add a Location listener.
(package private)  void broadcastInformation()
          Send a new location information to the registered listeners.
(package private)  double calcSpeed(Location currLoc, java.util.Date time)
          Calculates the speed in meters per second the user is traveling.
(package private)  void decLat()
          Decrements the latitude.
(package private)  void decLong()
          Decrements the longitude.
(package private)  Latitude getDefaultLatitude()
          Returns the default (starting) latitude.
(package private)  Longitude getDefaultLongitude()
          Returns the default (starting) longitude.
 LocationEvent getLocation()
          Returns the most previously current location
(package private)  void incLat()
          Increments the latitude.
(package private)  void incLong()
          Increments the longitude.
 void kill()
          Stops this class from generating location events.
 void removeGpsInfoListener(GpsInfoListener gps)
          Remove a GpsInfo listener.
 void removeLocationListener(LocationListener ll)
          Remove a location listener.
(package private)  void reset()
          Resets this FakeGPSMonitor to be at the default (starting) location.
 void setGPSInfo(GpsInfoEvent gpsinfo)
          Sets the GpsInfoEvent to be broadcasted with the location event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LATITUDE

public static final Latitude DEFAULT_LATITUDE
The default latitude is (38 38.8935' N)


DEFAULT_LONGITUDE

public static final Longitude DEFAULT_LONGITUDE
The default longitude is (90 18.389986' W)


DEFAULT_LAT_STEP_SIZE

public static final double DEFAULT_LAT_STEP_SIZE
The default latitude step size in sexagesimal units. The default value is 0.43065.

See Also:
Constant Field Values

DEFAULT_LONG_STEP_SIZE

public static final double DEFAULT_LONG_STEP_SIZE
The default longitude step size in sexagesimal units. The default value is 0.43065.

See Also:
Constant Field Values

DEFAULT_INTERVAL

public static final long DEFAULT_INTERVAL
The default interval between generating points is 1000ms.

See Also:
Constant Field Values

interval

long interval
How often in milliseconds the user wants to receive a LocationEvent


timer

java.util.Timer timer
The timer used to generate location events.


gui

FakeGPSgui gui
The GUI that allows the user to specifiy the direction of motion.


listeners

java.util.Vector listeners
Holds the listeners.


currLat

Latitude currLat

defaultLat

Latitude defaultLat

currLong

Longitude currLong

defaultLong

Longitude defaultLong

latStep

double latStep
The step size of the latitude and longitude in sexigesimal units.


longStep

double longStep
The step size of the latitude and longitude in sexigesimal units.


prevLE

LocationEvent prevLE
The previous LocationEvent that was broadcasted


gps_listeners

private java.util.Vector gps_listeners
The GPSListeners that are waiting for GPSInfoEvents.


gpsinfo

GpsInfoEvent gpsinfo
The fake GPS Info sent to the user.

Constructor Detail

FakeGPSMonitor

public FakeGPSMonitor()
Creates a FakeGPSMonitor with all the default settings. Shows the GUI.


FakeGPSMonitor

public FakeGPSMonitor(boolean showGUI)
Creates a FakeGPSMonitor with all of the default settings except for the showGUI.


FakeGPSMonitor

public FakeGPSMonitor(long updatePeriod)
Creates a FakeGPSMonitor starting at the default location with the specified update period. Shows the GUI.

Parameters:
updatePeriod - the period of updating in milliseconds.

FakeGPSMonitor

public FakeGPSMonitor(long updatePeriod,
                      double latStep,
                      double longStep)
Creates a FakeGPSMonitor starting at a default location. Shows the GUI.

Parameters:
updatePeriod - the period of updating in milliseconds
latStep - the latitude step size in sexagesimal units
longStep - the longitude step size in sexagesimal units

FakeGPSMonitor

public FakeGPSMonitor(long updatePeriod,
                      Latitude defaultLat,
                      Longitude defaultLong)
Creates a FakeGPSMonitor with the starting location as specified by the parameter without reporting its location to a RoutSimulatorServer and default increment.

Parameters:
updatePeriod - the period of updating.
defaultLat - the default Latitude.
defaultLong - the default Longitude.

FakeGPSMonitor

public FakeGPSMonitor(long interval,
                      Latitude defaultLat,
                      Longitude defaultLong,
                      double latStep,
                      double longStep,
                      boolean showGUI)
Creates a FakeGPSMonitor with the starting location as specified by the parameter. Note: if this FakeGPSMonitor report to a server, then the default location will be set by the server.

Parameters:
interval - the period of updating
defaultLat - the default Latitude
defaultLong - the default Longitude
latStep - the latitude step size in sexagesimal units
longStep - the longitude step size in sexagesimal units
showGUI - determines whether the GUI that allows the user to change the data to be displayed.
Method Detail

addLocationListener

public void addLocationListener(LocationListener ll)
Add a Location listener.

Specified by:
addLocationListener in interface LocationGenerator
Parameters:
ll - the new location listener.
Returns:
true if the operation was successful.

removeLocationListener

public void removeLocationListener(LocationListener ll)
Remove a location listener.

Specified by:
removeLocationListener in interface LocationGenerator
Parameters:
ll - the location listener to remove.
Returns:
true if the operation was successful.

addGpsInfoListener

public void addGpsInfoListener(GpsInfoListener gps)
Add a GpsInfo listener.

Specified by:
addGpsInfoListener in interface LocationGenerator
Parameters:
gps - the new GpsInfo listener.
Returns:
true if the operation was successful.

removeGpsInfoListener

public void removeGpsInfoListener(GpsInfoListener gps)
Remove a GpsInfo listener.

Specified by:
removeGpsInfoListener in interface LocationGenerator
Parameters:
gps - the GpsInfo listener to remove.
Returns:
true if the operation was successful.

kill

public void kill()
Stops this class from generating location events.

Specified by:
kill in interface LocationGenerator

getDefaultLatitude

Latitude getDefaultLatitude()
Returns the default (starting) latitude.


getDefaultLongitude

Longitude getDefaultLongitude()
Returns the default (starting) longitude.


reset

void reset()
Resets this FakeGPSMonitor to be at the default (starting) location.


incLat

void incLat()
Increments the latitude.


decLat

void decLat()
Decrements the latitude.


incLong

void incLong()
Increments the longitude.


decLong

void decLong()
Decrements the longitude.


calcSpeed

double calcSpeed(Location currLoc,
                 java.util.Date time)
Calculates the speed in meters per second the user is traveling.


setGPSInfo

public void setGPSInfo(GpsInfoEvent gpsinfo)
Sets the GpsInfoEvent to be broadcasted with the location event.


broadcastInformation

void broadcastInformation()
Send a new location information to the registered listeners.


getLocation

public LocationEvent getLocation()
Returns the most previously current location

Specified by:
getLocation in interface LocationGenerator