01: /*
02: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
03: *
04: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
05: * royalty free, license to use, modify and redistribute this
06: * software in source and binary code form,
07: * provided that i) this copyright notice and license appear on all copies of
08: * the software; and ii) Licensee does not utilize the software in a manner
09: * which is disparaging to Silvere Martin-Michiellot.
10: *
11: * This software is provided "AS IS," without a warranty of any kind. ALL
12: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
13: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
14: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
15: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
16: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
17: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
18: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
19: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
20: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
21: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
22: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
23: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
24: *
25: * This software is not designed or intended for use in on-line control of
26: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
27: * the design, construction, operation or maintenance of any nuclear
28: * facility. Licensee represents and warrants that it will not use or
29: * redistribute the Software for such purposes.
30: *
31: */
32:
33: // This code is repackaged after the driver from the National Center for Supercomputing Applications, University of Illinois Urbana-Champaign
34: // Site http://www.ncsa.uiuc.edu/~srp/Java3D/portfolio/
35: // Email srp@ncsa.uiuc.edu
36: package com.db.utils;
37:
38: import com.sun.j3d.utils.image.TextureLoader;
39: import java.awt.Component;
40: import java.io.PrintStream;
41: import java.util.Hashtable;
42:
43: public class TextureCache extends Hashtable {
44:
45: Component comp;
46:
47: public TextureCache(Component component) {
48:
49: comp = component;
50:
51: }
52:
53: public Object get(String s) {
54:
55: Object obj = super .get(s);
56: if (obj == null) {
57: System.out.println("loading " + s);
58: TextureLoader textureloader = new TextureLoader(s, comp);
59: if (textureloader == null) {
60: System.out.println("Couldn't load " + s);
61: return null;
62: } else {
63: javax.media.j3d.Texture texture = textureloader
64: .getTexture();
65: put(s, texture);
66: return texture;
67: }
68: } else {
69: return obj;
70: }
71:
72: }
73:
74: public Object put(Object obj, Object obj1) {
75:
76: System.err.println("Don't use the TextureCache.put method;");
77: System.err.println("Use the TextureCache.get method instead.");
78:
79: return null;
80:
81: }
82:
83: }
|