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
.
Constructor and Description |
---|
ALcdTimeIndexedSimulatorModel()
Creates a new
ALcdTimeIndexedSimulatorModel . |
Modifier and Type | Method and Description |
---|---|
void |
addTracks(Set<?> aTracks,
int aFireEventMode)
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 this
ALcdSimulatorModel to the given new
Date . |
addPropertyChangeListener, firePropertyChangeEvent, getBeginDate, getDate, getEndDate, getTrackModels, removePropertyChangeListener, setBeginDate, setDate, setEndDate, setTrackModels
public ALcdTimeIndexedSimulatorModel()
ALcdTimeIndexedSimulatorModel
. One must call
init
before this instance is useful.protected void init(ILcdModel aEmptyTrackModel, Collection aTracks)
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.getBeginTime(Object)
,
getEndTime(Object)
,
updateTrackForDateSFCT(com.luciad.model.ILcdModel, Object, java.util.Date)
public void addTracks(Set<?> aTracks, int aFireEventMode)
aTracks
- the tracks to addaFireEventMode
- the model fire event mode. This will be used when tracks are added
to the actual track ILcdModel.public void removeTracks(Set<?> aTracks, int aFireEventMode)
aTracks
- the tracks to removeaFireEventMode
- the model fire event mode. This will be used when tracks are removed
from the actual track ILcdModel.protected abstract long getBeginTime(Object aTrack)
aTrack
- The track to retrieve the begin time for.Date.getTime()
.protected abstract long getEndTime(Object aTrack)
aTrack
- The track to retrieve the end time for.Date.getTime()
.protected abstract boolean updateTrackForDateSFCT(ILcdModel aTrackModel, Object aTrackSFCT, Date aDate)
elementChanged
on the model, it should simply return
true
when the track is changed, false
otherwise.aTrackModel
- The track model, passed as contextual information.aTrackSFCT
- The track to update.aDate
- The date to update the track to.True
if the track was adapted, false
if the track was not adapted.protected void updateTrackModels(Date aOldDate, Date aNewDate)
ALcdSimulatorModel
ALcdSimulatorModel
to the given new
Date
. This method is called by setDate
.updateTrackModels
in class ALcdSimulatorModel
aOldDate
- The old date, given as contextual information.aNewDate
- The date to update the track models of this
ALcdSimulatorModel
to.