Class ALcdTimeIndexedSimulatorModel
- All Implemented Interfaces:
ILcdSimulatorModel
,ILcdPropertyChangeSource
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 Summary
ConstructorDescriptionCreates a newALcdTimeIndexedSimulatorModel
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given set of tracks to the simulation model.protected abstract long
getBeginTime
(Object aTrack) Retrieves the time the given track should start its simulation, for example the departure time of an airplane.protected abstract long
getEndTime
(Object aTrack) Retrieves the time the given track should end its simulation, for example the arrival time of an airplane.protected void
init
(ILcdModel aEmptyTrackModel, Collection aTracks) Initializes this simulator model with the given tracks and track model.void
removeTracks
(Set<?> aTracks, int aFireEventMode) Removes the given set of tracks from the simulation model.protected abstract boolean
updateTrackForDateSFCT
(ILcdModel aTrackModel, Object aTrackSFCT, Date aDate) Updates the given track for the given date.protected void
updateTrackModels
(Date aOldDate, Date aNewDate) Updates the track models of thisALcdSimulatorModel
to the given newDate
.Methods inherited from class com.luciad.realtime.ALcdSimulatorModel
addPropertyChangeListener, firePropertyChangeEvent, getBeginDate, getDate, getEndDate, getTrackModels, removePropertyChangeListener, setBeginDate, setDate, setEndDate, setTrackModels
-
Constructor Details
-
ALcdTimeIndexedSimulatorModel
public ALcdTimeIndexedSimulatorModel()Creates a newALcdTimeIndexedSimulatorModel
. One must callinit
before this instance is useful.- See Also:
-
-
Method Details
-
init
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 inaTracks
are added to and removed from this model according to the current date of this simulator model.aTracks
- The track objects. Subclasses must implement thegetBeginTime
,getEndTime
andupdateTrackForDateSFCT
methods for these track objects.- See Also:
-
addTracks
Adds the given set of tracks to the simulation model.- Parameters:
aTracks
- the tracks to addaFireEventMode
- the model fire event mode. This will be used when tracks are added to the actual track ILcdModel.
-
removeTracks
Removes the given set of tracks from the simulation model.- Parameters:
aTracks
- the tracks to removeaFireEventMode
- the model fire event mode. This will be used when tracks are removed from the actual track ILcdModel.
-
getBeginTime
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
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 callingelementChanged
on the model, it should simply returntrue
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
Description copied from class:ALcdSimulatorModel
Updates the track models of thisALcdSimulatorModel
to the given newDate
. This method is called bysetDate
.- Specified by:
updateTrackModels
in classALcdSimulatorModel
- Parameters:
aOldDate
- The old date, given as contextual information.aNewDate
- The date to update the track models of thisALcdSimulatorModel
to.
-