Package gov.nasa.worldwind.cache
Class ShapeDataCache
- java.lang.Object
-
- gov.nasa.worldwind.cache.ShapeDataCache
-
- All Implemented Interfaces:
java.lang.Iterable<ShapeDataCache.ShapeDataCacheEntry>
public class ShapeDataCache extends java.lang.Object implements java.lang.Iterable<ShapeDataCache.ShapeDataCacheEntry>
Provides a mechanism to manage globe-specific representations of shapes. Typically used to manage per-globe state when the application associates the same shape with multipleWorldWindow
s.This cache limits the amount of time an entry remains in the cache unused. The maximum unused time may be specified. Entries unused within the specified duration are removed from the cache each time
getEntry(gov.nasa.worldwind.globes.Globe)
is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShapeDataCache.ShapeDataCacheEntry
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<GlobeStateKey,ShapeDataCache.ShapeDataCacheEntry>
entries
This cache's map of entries.protected long
maxTimeSinceLastUsed
The maximum number of milliseconds an entry may remain in the cache without being used.
-
Constructor Summary
Constructors Constructor Description ShapeDataCache(long maxTimeSinceLastUsed)
Construct a cache with a specified entry lifetime.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(ShapeDataCache.ShapeDataCacheEntry entry)
Adds a specified entry to the cache or replaces an entry associated with the same globe.void
clearExtents()
Set to null the extent field of all entries in this cache.ShapeDataCache.ShapeDataCacheEntry
getEntry(Globe globe)
Retrieves a specified entry from the cache.java.util.Iterator<ShapeDataCache.ShapeDataCacheEntry>
iterator()
void
removeAllEntries()
Remove all entries from this cache.void
setAllExpired(boolean isExpired)
Set all entries in this cache to a specified expiration state.
-
-
-
Field Detail
-
entries
protected java.util.HashMap<GlobeStateKey,ShapeDataCache.ShapeDataCacheEntry> entries
This cache's map of entries. Typically one entry per open window.
-
maxTimeSinceLastUsed
protected long maxTimeSinceLastUsed
The maximum number of milliseconds an entry may remain in the cache without being used.
-
-
Method Detail
-
iterator
public java.util.Iterator<ShapeDataCache.ShapeDataCacheEntry> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<ShapeDataCache.ShapeDataCacheEntry>
-
addEntry
public void addEntry(ShapeDataCache.ShapeDataCacheEntry entry)
Adds a specified entry to the cache or replaces an entry associated with the same globe.- Parameters:
entry
- the entry to add. If null, the cache remains unchanged.
-
getEntry
public ShapeDataCache.ShapeDataCacheEntry getEntry(Globe globe)
Retrieves a specified entry from the cache.Note: Each time this method is called the cache is cleared of dead entries, as defined by their last-used time relative to this cache's maximum unused time.
- Parameters:
globe
- the globe the entry is associated with.- Returns:
- the entry if it exists, otherwise null.
-
setAllExpired
public void setAllExpired(boolean isExpired)
Set all entries in this cache to a specified expiration state.- Parameters:
isExpired
- the expiration state.
-
clearExtents
public void clearExtents()
Set to null the extent field of all entries in this cache.
-
removeAllEntries
public void removeAllEntries()
Remove all entries from this cache.
-
-