public class WmsCache extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
WmsCache.CacheEntry |
private static class |
WmsCache.ProjectionEntries |
Modifier and Type | Field and Description |
---|---|
private java.util.Set<ProjectionBounds> |
areaToCache |
private java.io.File |
cacheDir |
private java.util.Map<java.lang.String,WmsCache.ProjectionEntries> |
entries |
private static java.lang.String |
INDEX_FILENAME |
private static java.lang.String |
LAYERS_INDEX_FILENAME |
private java.util.Map<WmsCache.CacheEntry,java.lang.ref.SoftReference<java.awt.image.BufferedImage>> |
memoryCache |
private static StringProperty |
PROP_CACHE_PATH |
private int |
tileSize |
private int |
totalFileSize |
private boolean |
totalFileSizeDirty |
Constructor and Description |
---|
WmsCache(java.lang.String url,
int tileSize) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
cacheDirPath() |
private int |
calculateTotalFileSize() |
void |
cleanSmallFiles(int size) |
private WmsCache.CacheEntry |
findEntry(WmsCache.ProjectionEntries projectionEntries,
double pixelPerDegree,
double east,
double north) |
private java.lang.String |
generateFileName(WmsCache.ProjectionEntries projectionEntries,
double pixelPerDegree,
Projection projection,
double east,
double north,
java.lang.String mimeType) |
private java.lang.String |
getCacheDirectory(java.lang.String url) |
java.awt.image.BufferedImage |
getExactMatch(Projection projection,
double pixelPerDegree,
double east,
double north) |
private java.io.File |
getImageFile(WmsCache.ProjectionEntries projection,
WmsCache.CacheEntry entry) |
java.awt.image.BufferedImage |
getPartialMatch(Projection projection,
double pixelPerDegree,
double east,
double north) |
private WmsCache.ProjectionEntries |
getProjectionEntries(Projection projection) |
private WmsCache.ProjectionEntries |
getProjectionEntries(java.lang.String projection,
java.lang.String cacheDirectory) |
boolean |
hasExactMatch(Projection projection,
double pixelPerDegree,
double east,
double north) |
private boolean |
isInsideAreaToCache(WmsCache.CacheEntry cacheEntry) |
private java.awt.image.BufferedImage |
loadImage(WmsCache.ProjectionEntries projectionEntries,
WmsCache.CacheEntry entry,
boolean enforceTransparency) |
void |
loadIndex() |
static java.lang.String |
printDate(java.util.Calendar c) |
private void |
removeNonReferencedFiles() |
void |
saveIndex() |
void |
saveToCache(java.awt.image.BufferedImage img,
java.io.InputStream imageData,
Projection projection,
double pixelPerDegree,
double east,
double north) |
void |
setAreaToCache(java.util.Set<ProjectionBounds> areaToCache) |
private static final StringProperty PROP_CACHE_PATH
private static final java.lang.String INDEX_FILENAME
private static final java.lang.String LAYERS_INDEX_FILENAME
private final java.util.Map<java.lang.String,WmsCache.ProjectionEntries> entries
private final java.io.File cacheDir
private final int tileSize
private int totalFileSize
private boolean totalFileSizeDirty
private java.util.Map<WmsCache.CacheEntry,java.lang.ref.SoftReference<java.awt.image.BufferedImage>> memoryCache
private java.util.Set<ProjectionBounds> areaToCache
public WmsCache(java.lang.String url, int tileSize)
protected java.lang.String cacheDirPath()
private java.lang.String getCacheDirectory(java.lang.String url)
private WmsCache.ProjectionEntries getProjectionEntries(Projection projection)
private WmsCache.ProjectionEntries getProjectionEntries(java.lang.String projection, java.lang.String cacheDirectory)
public void loadIndex()
private void removeNonReferencedFiles()
private int calculateTotalFileSize()
public void saveIndex()
private java.io.File getImageFile(WmsCache.ProjectionEntries projection, WmsCache.CacheEntry entry)
private java.awt.image.BufferedImage loadImage(WmsCache.ProjectionEntries projectionEntries, WmsCache.CacheEntry entry, boolean enforceTransparency) throws java.io.IOException
java.io.IOException
private WmsCache.CacheEntry findEntry(WmsCache.ProjectionEntries projectionEntries, double pixelPerDegree, double east, double north)
public boolean hasExactMatch(Projection projection, double pixelPerDegree, double east, double north)
public java.awt.image.BufferedImage getExactMatch(Projection projection, double pixelPerDegree, double east, double north)
public java.awt.image.BufferedImage getPartialMatch(Projection projection, double pixelPerDegree, double east, double north)
private java.lang.String generateFileName(WmsCache.ProjectionEntries projectionEntries, double pixelPerDegree, Projection projection, double east, double north, java.lang.String mimeType)
public void saveToCache(java.awt.image.BufferedImage img, java.io.InputStream imageData, Projection projection, double pixelPerDegree, double east, double north) throws java.io.IOException
img
- Used only when overlapping is used, when not used, used raw from imageDataimageData
- projection
- pixelPerDegree
- east
- north
- java.io.IOException
public void cleanSmallFiles(int size)
public static java.lang.String printDate(java.util.Calendar c)
private boolean isInsideAreaToCache(WmsCache.CacheEntry cacheEntry)
public void setAreaToCache(java.util.Set<ProjectionBounds> areaToCache)