Package ucar.nc2.ui.image
Class PictureCache
- java.lang.Object
-
- ucar.nc2.ui.image.PictureCache
-
public class PictureCache extends Object
class that manages the cache of pictures
-
-
Field Summary
Fields Modifier and Type Field Description static Vector
cacheLoadsInProgress
This Vector keeps track of which pictures the PictureCache has been requested to load in the background.
-
Constructor Summary
Constructors Constructor Description PictureCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
add(URL url, SourcePicture sp)
store an image in the cachestatic void
clear()
clears out all images in the cache.static SourcePicture
getSourcePicture(URL url)
returns a picture from the cache.static boolean
isInCache(String urlString)
returns whether an image is in the cache.static boolean
isInCache(URL url)
returns whether an image is in the cache.static void
remove(String urlString)
remove a picture from the cachestatic void
removeLeastPopular()
this method removes the least popular picture(s) in the cache.static void
reportCache()
method to inspect the cachestatic void
stopBackgroundLoading()
method to stop all background loadingstatic boolean
stopBackgroundLoadingExcept(URL exemptionURL)
method to stop all background loading except the indicated file.
-
-
-
Field Detail
-
cacheLoadsInProgress
public static Vector cacheLoadsInProgress
This Vector keeps track of which pictures the PictureCache has been requested to load in the background. They may have to be stopped in a hurry.
-
-
Method Detail
-
removeLeastPopular
public static void removeLeastPopular()
this method removes the least popular picture(s) in the cache. It first removes those pictures which have been suggested for removal. And then it picks any it can find As many pictures are removed as nescessary untill there are less pictures in the cache than the Settings.maxCache specifies. (If maxCache is 0 then the Enumeration finds no elements and we don't get an endless loop.
-
isInCache
public static boolean isInCache(URL url)
returns whether an image is in the cache.
-
isInCache
public static boolean isInCache(String urlString)
returns whether an image is in the cache.
-
add
public static void add(URL url, SourcePicture sp)
store an image in the cache- Parameters:
url
- The URL of the picturesp
- The picture to be stored
-
remove
public static void remove(String urlString)
remove a picture from the cache
-
getSourcePicture
public static SourcePicture getSourcePicture(URL url)
returns a picture from the cache. Returns null if image is not there- Parameters:
url
- The URL of the picture to be retrieved
-
clear
public static void clear()
clears out all images in the cache. Important after OutOfMemoryErrors
-
reportCache
public static void reportCache()
method to inspect the cache
-
stopBackgroundLoading
public static void stopBackgroundLoading()
method to stop all background loading
-
stopBackgroundLoadingExcept
public static boolean stopBackgroundLoadingExcept(URL exemptionURL)
method to stop all background loading except the indicated file. Returns whether the image is already being loaded. True = loading in progress, False = not in progress.
-
-