Aviatrix3D
2.1.0

org.j3d.renderer.aviatrix3d.texture
Class AVTextureCacheFactory

java.lang.Object
  extended by org.j3d.renderer.aviatrix3d.texture.AVTextureCacheFactory
All Implemented Interfaces:
org.j3d.texture.TextureCacheFactory

public class AVTextureCacheFactory
extends java.lang.Object
implements org.j3d.texture.TextureCacheFactory

A representation of global cache for texture instance management.

The cache works at the Aviatrix3D Texture or TextureComponent 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).

The factory also supports the concept of the "default cache". This is used when you want a simple system that doesn't really care about the cache type used and just wants to use this class as a global singleton for storing the texture information. The default cache type can be controlled through either directly setting the value in this class, or using a system property. By defining a value for the property

   org.j3d.texture.DefaultCacheType
 
with one of the values (case-sensitive) fixed, lru or weakref. Setting the type through the method call will override this setting. However, the cache type can only be set once. All further attempts will result in an exception.

Version:
$Revision: 1.4 $
Author:
Alan Hudson

Field Summary
 
Fields inherited from interface org.j3d.texture.TextureCacheFactory
DEFAULT_CACHE_PROP, FIXED_CACHE, LAST_CACHE_ID, LRU_CACHE, WEAKREF_CACHE
 
Method Summary
static AVTextureCache getCache()
          Fetch the default cache provided by the factory.
static AVTextureCache getCache(int cacheType)
          Fetch the cache instance for the given type, creating a new instance if necessary.
static void registerCacheType(int cacheType, AVTextureCache cache)
          Register your custom instance of a texture cache.
static void setDefaultCacheType(int type)
          Set the default cache type to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setDefaultCacheType

public static void setDefaultCacheType(int type)
                                throws org.j3d.texture.CacheAlreadySetException
Set the default cache type to be used.

Parameters:
type - The default type ID
Throws:
org.j3d.texture.CacheAlreadySetException - The default type has already been set

getCache

public static AVTextureCache getCache()
Fetch the default cache provided by the factory. The type may be previously specified using the system property or the setDefaultCacheType(int) method.

Returns:
The default cache implementation

getCache

public static AVTextureCache getCache(int cacheType)
Fetch the cache instance for the given type, creating a new instance if necessary. If the cacheType refers to one of the standard, inbuilt types then it will be automatically generated. If it is not a standard type, an exception will be generated.

Parameters:
cacheType - An identifier of the required caching algorithm
Returns:
A reference to the global cache of that type
Throws:
java.lang.IllegalArgumentException - The cacheType is not a valid type

registerCacheType

public static void registerCacheType(int cacheType,
                                     AVTextureCache cache)
Register your custom instance of a texture cache. If the cacheType has a value less than or equal to the last ID then an exception will be generated. The ID, if it already exists will replace the existing instance with the new one. Passing a value of null will de-register the existing cache if previously registered. Standard types cannot be re-registered.

Parameters:
cacheType - The ID to associate with this cache
cache - The instance of the cache to register
Throws:
java.lang.IllegalArgumentException - The cacheType is invalid

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org