TEntity
- The type of entity.public class HistoryGenerator<TEntity extends IEntityIdentifier & IEntityPosition & IEntityLastUpdate> extends Object implements IDisposable
In most cases, it is much more efficient to create a
single instance of HistoryGenerator with an
EntitySet
containing all entities
being visualized, rather than creating a unique instance for each
EntityVisualizer
that requires it. The amount
of history kept is specified by HistoryLength
(get
/ set
)
subtracted from the value of the current SceneManager
Time
(get
).
EntityHistory
,
HistoryVisualizer
,
WaypointVisualizer
Constructor and Description |
---|
HistoryGenerator(TypeLiteral<TEntity> typeLiteralTEntity,
EntitySet<TEntity> entities,
Duration historyLength)
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases any resources associated with this instance.
|
protected void |
dispose(boolean disposing)
Releases any resources associated with this instance.
|
EntitySet<TEntity> |
getEntities()
Gets the entities for which history is being maintained.
|
EntityHistory |
getHistory(TEntity entity)
Gets the
EntityHistory for the provided entity, or null
if no history is found. |
Duration |
getHistoryLength()
Gets the length of history to keep in memory for each track.
|
long |
getLastUpdate()
Gets the number of ticks returned by
Stopwatch.getTimestamp() at the time of the last history update. |
void |
setHistoryLength(Duration value)
Sets the length of history to keep in memory for each track.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public HistoryGenerator(TypeLiteral<TEntity> typeLiteralTEntity, @Nonnull EntitySet<TEntity> entities, @Nonnull Duration historyLength)
typeLiteralTEntity
- A TypeLiteral object representing the generic type TEntity
.entities
- The entities for which to track history.historyLength
- The length of history to keep in memory for each track.ArgumentNullException
- Thrown if entities is null
.ArgumentOutOfRangeException
- Thrown is historyLength
is negative.public final void dispose()
dispose
in interface IDisposable
protected void dispose(boolean disposing)
disposing
- true
to release both managed and unmanaged resources;
false
to release only unmanaged resources.@Nonnull public final Duration getHistoryLength()
ArgumentOutOfRangeException
- Thrown is value is negative.public final void setHistoryLength(@Nonnull Duration value)
ArgumentOutOfRangeException
- Thrown is value is negative.@Nonnull public final EntitySet<TEntity> getEntities()
public final long getLastUpdate()
Stopwatch.getTimestamp()
at the time of the last history update.@Nullable public final EntityHistory getHistory(@Nonnull TEntity entity)
EntityHistory
for the provided entity, or null
if no history is found.entity
- The entity whose history to access.null
if no history is found.