Class PictureCache


  • public class PictureCache
    extends Object
    class that manages the cache of pictures
    • 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.
    • Constructor Detail

      • PictureCache

        public PictureCache()
    • 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 picture
        sp - 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.