|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.file.icon.CachedFileIconProvider
public class CachedFileIconProvider
CachedFileIconProvider is a FileIconProvider with caching capabilities.
This class does not actually provide icons nor does it manage the contents of the cache ; it delegates these tasks
to a CacheableFileIconProvider instance. All this class does is use the cache implementation to harness its
befinits and take all the credit for it.
When an icon is requested, a cache lookup is performed. If a cached value is found, it is returned. If not, the icon
is fetched from the underlying provider and added to the cache.
| Field Summary | |
|---|---|
protected CacheableFileIconProvider |
cacheableFip
The underlying icon provider and cache manager |
protected static int |
cacheCapacity
Current capacity of icon caches |
static int |
DEFAULT_FILE_CACHE_CAPACITY
Default capacity of icon caches |
| Constructor Summary | |
|---|---|
CachedFileIconProvider(CacheableFileIconProvider cacheableFip)
Creates a new CachedFileIconProvider that uses the given CacheableFileIconProvider to access the cache
and retrieve the icons. |
|
| Method Summary | |
|---|---|
static LRUCache |
createCache()
Creates and returns an LRUCache instance with a capacity equal to
getCacheCapacity(). |
static int |
getCacheCapacity()
Returns the capacity of the LRUCache that caches frequently accessed icon instances. |
javax.swing.Icon |
getFileIcon(AbstractFile file,
java.awt.Dimension preferredResolution)
Implementation notes: this method first calls CacheableFileIconProvider.isCacheable(com.mucommander.file.AbstractFile, java.awt.Dimension)
to determine if the icon cache is used. |
static void |
setCacheCapacity(int capacity)
Sets the capacity of the LRUCache that caches frequently accessed file instances. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CacheableFileIconProvider cacheableFip
public static final int DEFAULT_FILE_CACHE_CAPACITY
protected static int cacheCapacity
| Constructor Detail |
|---|
public CachedFileIconProvider(CacheableFileIconProvider cacheableFip)
CacheableFileIconProvider to access the cache
and retrieve the icons.
cacheableFip - the underlying icon provider and cache manager| Method Detail |
|---|
public static LRUCache createCache()
LRUCache instance with a capacity equal to
getCacheCapacity().
public static void setCacheCapacity(int capacity)
LRUCache that caches frequently accessed file instances. The more the capacity,
the more frequent the cache is hit but the higher the memory usage. By default, the capacity is
DEFAULT_FILE_CACHE_CAPACITY.
Note that calling this method does not change the capacity of existing caches so to be effective, this method
must be called before createCache() is called.
capacity - the capacity of the LRU cache that caches frequently accessed icon instancesLRUCachepublic static int getCacheCapacity()
LRUCache that caches frequently accessed icon instances. By default, the
capacity is DEFAULT_FILE_CACHE_CAPACITY.
public javax.swing.Icon getFileIcon(AbstractFile file,
java.awt.Dimension preferredResolution)
CacheableFileIconProvider.isCacheable(com.mucommander.file.AbstractFile, java.awt.Dimension)
to determine if the icon cache is used.
If the file icon is cacheable, CacheableFileIconProvider.lookupCache(com.mucommander.file.AbstractFile, java.awt.Dimension)
is called to look for a previously cached icon. If a value is found, it is returned. If not,
getFileIcon(com.mucommander.file.AbstractFile, java.awt.Dimension) is called on the CacheableFileIconProvider
to retrieve the icon. This icon is then added to the cache by calling
CacheableFileIconProvider.addToCache(com.mucommander.file.AbstractFile, javax.swing.Icon, java.awt.Dimension).
If the file icon is not cacheable, getFileIcon(com.mucommander.file.AbstractFile, java.awt.Dimension)
is simply called on the CacheableFileIconProvider and its value returned.
getFileIcon in interface FileIconProviderfile - the AbstractFile instance for which an icon is requestedpreferredResolution - the preferred icon resolution
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard