org.openstreetmap.josm.data.imagery
Class WmsCache

java.lang.Object
  extended by org.openstreetmap.josm.data.imagery.WmsCache

public class WmsCache
extends java.lang.Object


Nested Class Summary
private static class WmsCache.CacheEntry
           
private static class WmsCache.ProjectionEntries
           
 
Field Summary
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 Summary
WmsCache(java.lang.String url, int tileSize)
           
 
Method Summary
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)
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_CACHE_PATH

private static final StringProperty PROP_CACHE_PATH

INDEX_FILENAME

private static final java.lang.String INDEX_FILENAME
See Also:
Constant Field Values

LAYERS_INDEX_FILENAME

private static final java.lang.String LAYERS_INDEX_FILENAME
See Also:
Constant Field Values

entries

private final java.util.Map<java.lang.String,WmsCache.ProjectionEntries> entries

cacheDir

private final java.io.File cacheDir

tileSize

private final int tileSize

totalFileSize

private int totalFileSize

totalFileSizeDirty

private boolean totalFileSizeDirty

memoryCache

private java.util.Map<WmsCache.CacheEntry,java.lang.ref.SoftReference<java.awt.image.BufferedImage>> memoryCache

areaToCache

private java.util.Set<ProjectionBounds> areaToCache
Constructor Detail

WmsCache

public WmsCache(java.lang.String url,
                int tileSize)
Method Detail

cacheDirPath

protected java.lang.String cacheDirPath()

getCacheDirectory

private java.lang.String getCacheDirectory(java.lang.String url)

getProjectionEntries

private WmsCache.ProjectionEntries getProjectionEntries(Projection projection)

getProjectionEntries

private WmsCache.ProjectionEntries getProjectionEntries(java.lang.String projection,
                                                        java.lang.String cacheDirectory)

loadIndex

public void loadIndex()

removeNonReferencedFiles

private void removeNonReferencedFiles()

calculateTotalFileSize

private int calculateTotalFileSize()

saveIndex

public void saveIndex()

getImageFile

private java.io.File getImageFile(WmsCache.ProjectionEntries projection,
                                  WmsCache.CacheEntry entry)

loadImage

private java.awt.image.BufferedImage loadImage(WmsCache.ProjectionEntries projectionEntries,
                                               WmsCache.CacheEntry entry)
                                        throws java.io.IOException
Throws:
java.io.IOException

findEntry

private WmsCache.CacheEntry findEntry(WmsCache.ProjectionEntries projectionEntries,
                                      double pixelPerDegree,
                                      double east,
                                      double north)

hasExactMatch

public boolean hasExactMatch(Projection projection,
                             double pixelPerDegree,
                             double east,
                             double north)

getExactMatch

public java.awt.image.BufferedImage getExactMatch(Projection projection,
                                                  double pixelPerDegree,
                                                  double east,
                                                  double north)

getPartialMatch

public java.awt.image.BufferedImage getPartialMatch(Projection projection,
                                                    double pixelPerDegree,
                                                    double east,
                                                    double north)

generateFileName

private java.lang.String generateFileName(WmsCache.ProjectionEntries projectionEntries,
                                          double pixelPerDegree,
                                          Projection projection,
                                          double east,
                                          double north,
                                          java.lang.String mimeType)

saveToCache

public void saveToCache(java.awt.image.BufferedImage img,
                        java.io.InputStream imageData,
                        Projection projection,
                        double pixelPerDegree,
                        double east,
                        double north)
                 throws java.io.IOException
Parameters:
img - Used only when overlapping is used, when not used, used raw from imageData
imageData -
projection -
pixelPerDegree -
east -
north -
Throws:
java.io.IOException

cleanSmallFiles

public void cleanSmallFiles(int size)

printDate

public static java.lang.String printDate(java.util.Calendar c)

isInsideAreaToCache

private boolean isInsideAreaToCache(WmsCache.CacheEntry cacheEntry)

setAreaToCache

public void setAreaToCache(java.util.Set<ProjectionBounds> areaToCache)


JOSM