Annotation of java/classes/org/w3c/tools/widgets/ImageCache.java, revision 1.3
1.1 abaird 1: // ImageCache.java
1.3 ! bmahe 2: // $Id: ImageCache.java,v 1.2 1997/05/21 15:43:49 ylafon Exp $
1.1 abaird 3: // Author: Jean-Michel.Leon@sophia.inria.fr
4: // (c) COPYRIGHT MIT and INRIA, 1997.
5: // Please first read the full copyright statement in file COPYRIGHT.html
6:
1.3 ! bmahe 7: package org.w3c.tools.widgets;
1.1 abaird 8:
9: import java.awt.*;
10: import java.util.*;
11:
12:
13: /**
14: * A Basic Image Cache class.
15: */
16: public class ImageCache {
17: private static Hashtable images = new Hashtable();
18:
19: /**
20: * Gets an Image of the requested size.
21: *
22: * Checks if an Image already exists in the cache for the current Thread and
23: * if this image is large enough. Else, creates a new Image and store it in
24: * the cache.
25: */
26: static public Image getImage(Component c, int w, int h) {
27: Image img = (Image)images.get(Thread.currentThread());
28: if((img == null) || (img.getWidth(c) < w) || (img.getHeight(c) < h)) {
29: img = c.createImage(w, h);
30: images.put(Thread.currentThread(), img);
31: }
32: return img;
33: }
34: }
Webmaster