Skip to content

Commit

Permalink
Added ImageFactory.isInCache(String) method, changed member variable …
Browse files Browse the repository at this point in the history
…visibility to protected
  • Loading branch information
jheer committed Jul 15, 2006
1 parent 027536d commit 3122ba1
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/prefuse/render/ImageFactory.java
Expand Up @@ -29,23 +29,23 @@
*/
public class ImageFactory {

private int m_imageCacheSize = 3000;
private int m_maxImageWidth = 100;
private int m_maxImageHeight = 100;
private boolean m_asynch = true;
protected int m_imageCacheSize = 3000;
protected int m_maxImageWidth = 100;
protected int m_maxImageHeight = 100;
protected boolean m_asynch = true;

//a nice LRU cache courtesy of java 1.4
private Map imageCache =
protected Map imageCache =
new LinkedHashMap((int) (m_imageCacheSize + 1 / .75F), .75F, true) {
public boolean removeEldestEntry(Map.Entry eldest) {
return size() > m_imageCacheSize;
}
};
private Map loadMap = new HashMap(50);
protected Map loadMap = new HashMap(50);

private final Component component = new Component() {};
private final MediaTracker tracker = new MediaTracker(component);
private int nextTrackerID = 0;
protected final Component component = new Component() {};
protected final MediaTracker tracker = new MediaTracker(component);
protected int nextTrackerID = 0;

/**
* Create a new ImageFactory. Assumes no scaling of loaded images.
Expand Down Expand Up @@ -85,6 +85,17 @@ public void setImageCacheSize(int size) {
m_imageCacheSize = size;
}

/**
* Indicates if the given string location corresponds to an image
* currently stored in this ImageFactory's cache.
* @param imageLocation the image location string
* @return true if the location is a key for a currently cached image,
* false otherwise.
*/
public boolean isInCache(String imageLocation) {
return imageCache.containsKey(imageLocation);
}

/**
* <p>Get the image associated with the given location string. If the image
* has already been loaded, it simply will return the image, otherwise it
Expand Down

0 comments on commit 3122ba1

Please sign in to comment.