Class ALcdTimeIndexedSimulatorModel

java.lang.Object
com.luciad.realtime.ALcdSimulatorModel
com.luciad.realtime.ALcdTimeIndexedSimulatorModel
All Implemented Interfaces:
ILcdSimulatorModel, ILcdPropertyChangeSource

public abstract class ALcdTimeIndexedSimulatorModel extends ALcdSimulatorModel

Implementation of ILcdSimulatorModel whose time complexity for changing the date is generally related to the amount of changes that are required, not to the total amount of data. This offers high performance, even when working with large data sets.

It achieves this by indexing the begin and end times of all objects, so it does require some initial processing.

It keeps a given track model up to date by adding tracks to it, or by removing tracks from it, such that every track is part of the model if the current date lies within the interval [getBeginTime(track), getEndTime(track)]. Subclasses are responsible to update the track state (e.g. location) when the date is in that interval, by implementing the updateTrackForDateSFCT method.

Two methods are available to modify the data after the initial processing step (init(com.luciad.model.ILcdModel, java.util.Collection)). By using the method addTracks(java.util.Set<?>, int), extra tracks can be added to the simulator model. If necessary, when the current time is between the begin and end time of a new track, these tracks will also be added to the track model. By using the method removeTracks(java.util.Set<?>, int), tracks can be removed from the simulator model, and also from the track model if they are currently present there.

This implementation only supports one track model at a time. If multiple track models must be updated, one can for example combine them using a TLcdSimulatorModelList.

Since:
7.2
See Also:
  • Constructor Details

    • ALcdTimeIndexedSimulatorModel

      public ALcdTimeIndexedSimulatorModel()
      Creates a new ALcdTimeIndexedSimulatorModel. One must call init before this instance is useful.
      See Also:
  • Method Details

    • init

      protected void init(ILcdModel aEmptyTrackModel, Collection aTracks)
      Initializes this simulator model with the given tracks and track model.

      Note that this method can be called multiple times, for example when the begin/end times of the tracks have changed, or when new tracks were added etc.

      Parameters:
      aEmptyTrackModel - The track model. It should not contain any elements as the objects in aTracks are added to and removed from this model according to the current date of this simulator model.
      aTracks - The track objects. Subclasses must implement the getBeginTime, getEndTime and updateTrackForDateSFCT methods for these track objects.
      See Also:
    • addTracks

      public void addTracks(Set<?> aTracks, int aFireEventMode)
      Adds the given set of tracks to the simulation model.
      Parameters:
      aTracks - the tracks to add
      aFireEventMode - the model fire event mode. This will be used when tracks are added to the actual track ILcdModel.
    • removeTracks

      public void removeTracks(Set<?> aTracks, int aFireEventMode)
      Removes the given set of tracks from the simulation model.
      Parameters:
      aTracks - the tracks to remove
      aFireEventMode - the model fire event mode. This will be used when tracks are removed from the actual track ILcdModel.
    • getBeginTime

      protected abstract long getBeginTime(Object aTrack)
      Retrieves the time the given track should start its simulation, for example the departure time of an airplane. The track will be part of the track model if the current date lies within in the interval [getBeginTime(track), getEndTime(track)].

      This method called is always called on the AWT Event Dispatch Thread.

      Note that subsequent calls must yield equal return values for the same track. This method must be fast, as it can be called often.

      Parameters:
      aTrack - The track to retrieve the begin time for.
      Returns:
      The begin time of the track, as defined in Date.getTime().
    • getEndTime

      protected abstract long getEndTime(Object aTrack)
      Retrieves the time the given track should end its simulation, for example the arrival time of an airplane. The track will be part of the track model if the current date lies within in the interval [getBeginTime(track), getEndTime(track)].

      This method called is always called on the AWT Event Dispatch Thread.

      Note that subsequent calls must yield equal return values for the same track. This method must be fast, as it can be called often.

      Parameters:
      aTrack - The track to retrieve the end time for.
      Returns:
      The end time of the track, as defined in Date.getTime().
    • updateTrackForDateSFCT

      protected abstract boolean updateTrackForDateSFCT(ILcdModel aTrackModel, Object aTrackSFCT, Date aDate)
      Updates the given track for the given date. Note that the implementation of this method should not bother about calling elementChanged on the model, it should simply return true when the track is changed, false otherwise.
      Parameters:
      aTrackModel - The track model, passed as contextual information.
      aTrackSFCT - The track to update.
      aDate - The date to update the track to.
      Returns:
      True if the track was adapted, false if the track was not adapted.
    • updateTrackModels

      protected void updateTrackModels(Date aOldDate, Date aNewDate)
      Description copied from class: ALcdSimulatorModel
      Updates the track models of this ALcdSimulatorModel to the given new Date. This method is called by setDate.
      Specified by:
      updateTrackModels in class ALcdSimulatorModel
      Parameters:
      aOldDate - The old date, given as contextual information.
      aNewDate - The date to update the track models of this ALcdSimulatorModel to.