001: /*
002: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: */
032:
033: package com.db.utils;
034:
035: /**
036: * A texture loading utility that doesn't require an image observer
037: * for constructing objects. This class extends the TextureLoader
038: * class of the com.sun.j3d.utils.image package.
039: *
040: */
041:
042: import com.sun.j3d.utils.image.TextureLoader;
043: import javax.media.j3d.*;
044: import javax.vecmath.*;
045:
046: public class NewTextureLoader extends TextureLoader {
047:
048: static java.awt.Component observer;
049:
050: /**
051: * Specify an object to server as the image observer.
052: * Use this method once before constructing any texture loaders.
053: * @param imageObserver the object to be used in subsequent
054: * NewTextureLoader constuctions
055: */
056: public static void setImageObserver(java.awt.Component imageObserver) {
057:
058: observer = imageObserver;
059:
060: }
061:
062: /**
063: * Retreve the object used as the image observer for NewTextureLoader
064: * objects.
065: * Use this method when the image observer is needed.
066: * @return the object used in as the image observer in subsequent
067: * NewTextureLoader constuctions
068: */
069: public static java.awt.Component getImageObserver() {
070:
071: return observer;
072:
073: }
074:
075: // constructors without an image observer argument
076: /**
077: * Constructs a NewTextureLoader object loading the specified iamge in
078: * default (RGBA) format.
079: * The an image observer must be set using the setImageObserver() method
080: * before using this constructor.
081: * @param image the image object to load
082: */
083: public NewTextureLoader(java.awt.Image image) {
084:
085: super (image, observer);
086:
087: }
088:
089: /**
090: * Constructs a NewTextureLoader object loading the specified image
091: * and option flags in the default (RGBA) format.
092: * The an image observer must be set using the setImageObserver() method
093: * before using this constructor.
094: * @param image the image object to load
095: * @param flags the flags to use in construction (e.g. generate mipmap)
096: */
097: public NewTextureLoader(java.awt.Image image, int flags) {
098:
099: super (image, flags, observer);
100:
101: }
102:
103: /**
104: * Constructs a NewTextureLoader object loading the specified file
105: * using the specified format.
106: * The an image observer must be set using the setImageObserver() method
107: * before using this constructor.
108: * @param image the image object to load
109: * @param format specificaiton of which channels to use (e.g. RGB)
110: */
111: public NewTextureLoader(java.awt.Image image,
112: java.lang.String format) {
113:
114: super (image, format, observer);
115:
116: }
117:
118: /**
119: * Constructs a NewTextureLoader object loading the specified file
120: * with specified format and flags.
121: * The an image observer must be set using the setImageObserver() method
122: * before using this constructor.
123: * @param image the image object to load
124: * @param format specificaiton of which channels to use (e.g. RGB)
125: * @param flags the flags to use in construction (e.g. generate mipmap)
126: */
127: public NewTextureLoader(java.awt.Image image,
128: java.lang.String format, int flags) {
129:
130: super (image, format, flags, observer);
131:
132: }
133:
134: /**
135: * Constructs a NewTextureLoader object loading the specified file
136: * using the default format (RGBA).
137: * The an image observer must be set using the setImageObserver() method
138: * before using this constructor.
139: * @param fname the name of the file to load
140: */
141: public NewTextureLoader(java.lang.String fname) {
142:
143: super (fname, observer);
144:
145: }
146:
147: /**
148: * Constructs a NewTextureLoader object loading the specified file
149: * with the specified flags.
150: * The an image observer must be set using the setImageObserver() method
151: * before using this constructor.
152: * @param fname the name of the file to load
153: * @param flags the flags to use in construction (e.g. generate mipmap)
154: */
155: public NewTextureLoader(java.lang.String fname, int flags) {
156:
157: super (fname, flags, observer);
158:
159: }
160:
161: /**
162: * Constructs a NewTextureLoader object loading the specified file
163: * using the specified format.
164: * The an image observer must be set using the setImageObserver() method
165: * before using this constructor.
166: * @param fname the name of the file to load
167: * @param format specificaiton of which channels to use (e.g. RGB)
168: */
169: public NewTextureLoader(java.lang.String fname,
170: java.lang.String format) {
171:
172: super (fname, format, observer);
173:
174: }
175:
176: /**
177: * Constructs a NewTextureLoader object loading the specified file
178: * using the specified format and flags.
179: * The an image observer must be set using the setImageObserver() method
180: * before using this constructor.
181: * @param fname the name of the file to load
182: * @param format specificaiton of which channels to use (e.g. RGB)
183: * @param flags the flags to use in construction (e.g. generate mipmap)
184: */
185: public NewTextureLoader(java.lang.String fname,
186: java.lang.String format, int flags) {
187:
188: super (fname, format, flags, observer);
189:
190: }
191:
192: /**
193: * Constructs a NewTextureLoader object loading the specified URL
194: * using the default format.
195: * The an image observer must be set using the setImageObserver() method
196: * before using this constructor.
197: * @param url specifies the URL of the image to load
198: */
199: public NewTextureLoader(java.net.URL url) {
200:
201: super (url, observer);
202:
203: }
204:
205: /**
206: * Constructs a NewTextureLoader object loading the specified URL
207: * using the specified flags.
208: * The an image observer must be set using the setImageObserver() method
209: * before using this constructor.
210: * @param url specifies the URL of the image to load
211: * @param flags the flags to use in construction (e.g. generate mipmap)
212: */
213: public NewTextureLoader(java.net.URL url, int flags) {
214:
215: super (url, flags, observer);
216:
217: }
218:
219: /**
220: * Constructs a NewTextureLoader object loading the specified URL
221: * using the specified format.
222: * The an image observer must be set using the setImageObserver() method
223: * before using this constructor.
224: * @param url specifies the URL of the image to load
225: * @param format specificaiton of which channels to use (e.g. RGB)
226: */
227: public NewTextureLoader(java.net.URL url, java.lang.String format) {
228:
229: super (url, format, observer);
230:
231: }
232:
233: /**
234: * Constructs a NewTextureLoader object loading the specified URL
235: * using the specified format and flags.
236: * The an image observer must be set using the setImageObserver() method
237: * before using this constructor.
238: * @param url specifies the URL of the image to load
239: * @param format specificaiton of which channels to use (e.g. RGB)
240: * @param flags the flags to use in construction (e.g. generate mipmap)
241: */
242: public NewTextureLoader(java.net.URL url, java.lang.String format,
243: int flags) {
244:
245: super(url, format, flags, observer);
246:
247: }
248:
249: }
|