j3d.org Code

org.j3d.renderer.java3d.texture
Interface J3DTextureCache

All Superinterfaces:
TextureCache
All Known Implementing Classes:
AbstractTextureCache

public interface J3DTextureCache
extends TextureCache

A representation of global cache for texture instance management.

The cache works at the Java3D Texture or ImageComponent instance level rather than down at the individual images. This allows the VM to discard the lower level image instances if needed, allowing Java3D to do its own management. In addition, it benefits runtime performance of the Java3D scene graph by allowing textures instances to be shared, rather than duplicated.

Different types of cache implementations are allowed (ie different ways of deciding when an texture no longer needs to be in the cache).

Internal storage and key management is using strings. The URLs are converted to string form as the key and used to look up items. The filenames are always relative to the classpath. If the filename/url has been loaded as an image component before and then a request is made for a texture, then the previously loaded component is used as the basis for the texture.

All fetch methods work in the same way - if the texture has not been previously loaded, then it will be loaded and converted to a BufferedImage using the utilities of this class.

Version:
$Revision: 1.2 $
Author:
Justin Couch

Method Summary
 boolean checkImageComponent(java.lang.String filename)
          Check to see if a filename is cached for an ImageComponent.
 javax.media.j3d.ImageComponent fetchImageComponent(java.lang.String filename)
          Param fetch the imagecomponent named by the filename.
 javax.media.j3d.ImageComponent fetchImageComponent(java.net.URL url)
          Fetch the image component named by the URL.
 javax.media.j3d.Texture fetchTexture(java.lang.String filename)
          Fetch the texture named by the filename.
 javax.media.j3d.Texture fetchTexture(java.net.URL url)
          Fetch the texture named by the URL.
 void registerImageComponent(javax.media.j3d.ImageComponent component, java.lang.String filename)
          Register an imagecomponent with the cache assigned to a filename.
 void registerTexture(javax.media.j3d.Texture texture, java.lang.String filename)
          Register a texture with the cache assigned to a filename.
 
Methods inherited from interface org.j3d.texture.TextureCache
checkTexture, clearAll, releaseTexture, releaseTexture
 

Method Detail

fetchTexture

public javax.media.j3d.Texture fetchTexture(java.lang.String filename)
                                     throws java.io.IOException
Fetch the texture named by the filename. The filename may be either absolute or relative to the classpath.

Parameters:
filename - The filename to fetch
Returns:
The texture instance for that filename
Throws:
java.io.IOException - An I/O error occurred during loading

fetchTexture

public javax.media.j3d.Texture fetchTexture(java.net.URL url)
                                     throws java.io.IOException
Fetch the texture named by the URL.

Parameters:
url - The URL to read data from
Returns:
The texture instance for that URL
Throws:
java.io.IOException - An I/O error occurred during loading

fetchImageComponent

public javax.media.j3d.ImageComponent fetchImageComponent(java.lang.String filename)
                                                   throws java.io.IOException
Param fetch the imagecomponent named by the filename. The filename may be either absolute or relative to the classpath.

Parameters:
filename - The filename to fetch
Returns:
The ImageComponent instance for that filename
Throws:
java.io.IOException - An I/O error occurred during loading

fetchImageComponent

public javax.media.j3d.ImageComponent fetchImageComponent(java.net.URL url)
                                                   throws java.io.IOException
Fetch the image component named by the URL.

Parameters:
url - The URL to read data from
Returns:
The ImageComponent instance for that URL
Throws:
java.io.IOException - An I/O error occurred during loading

checkImageComponent

public boolean checkImageComponent(java.lang.String filename)
Check to see if a filename is cached for an ImageComponent.

Parameters:
filename - The filename loaded
Returns:
Whether the filename is cached as an ImageComponent

registerTexture

public void registerTexture(javax.media.j3d.Texture texture,
                            java.lang.String filename)
Register a texture with the cache assigned to a filename.

Parameters:
texture - The texture to store
filename - The filename to register

registerImageComponent

public void registerImageComponent(javax.media.j3d.ImageComponent component,
                                   java.lang.String filename)
Register an imagecomponent with the cache assigned to a filename.

Parameters:
component - The texture component to store
filename - The filename to register

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org