Class TextureCache
java.lang.Object
org.web3d.vrml.renderer.ogl.nodes.TextureCache
A cache for Texture instance management where the objects stay according
to Java's WeakReference system.
- Version:
- $Revision: 1.1 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static TextureCache
The instanceprotected boolean
Enabled flagprotected HashMap
<String, ArrayList<WeakReference<org.j3d.aviatrix3d.Texture>>> The cache map -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a new instance of the empty cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the cache.static TextureCache
Return the TextureCache instanceorg.j3d.aviatrix3d.Texture
Register a Texture in the cache with the argument id.org.j3d.aviatrix3d.Texture
Register a Texture in the cache with the argument id.void
Explicitly remove the Texture from the cache.void
Explicitly remove the Texture from the cache.void
setEnabled
(boolean enabled) Set the enabled state of the cache
-
Field Details
-
textureMap
The cache map -
enabled
protected boolean enabledEnabled flag -
cache
The instance
-
-
Constructor Details
-
TextureCache
protected TextureCache()Construct a new instance of the empty cache.
-
-
Method Details
-
getInstance
Return the TextureCache instance- Returns:
- The TextureCache instance
-
release
Explicitly remove the Texture from the cache. If the object has already been freed, this request is silently ignored.- Parameters:
tag
- The texture id, typically it's URL stringtexture
- The Texture to release
-
release
Explicitly remove the Texture from the cache. If the object has already been freed, this request is silently ignored.- Parameters:
url
- The URL the texture was registered undertexture
- The Texture to release
-
clear
public void clear()Clear the cache. -
setEnabled
public void setEnabled(boolean enabled) Set the enabled state of the cache- Parameters:
enabled
- The enabled state of the cache
-
register
Register a Texture in the cache with the argument id. If the id is null, the argument Texture is not cached and is returned. If a Texture that matches the id and properties of the argument Texture is already in the cache, it will be returned and the argument Texture will not be stored. Otherwise, the argument Texture is stored and is returned.- Parameters:
url
- The texture idtexture
- The candidate texture to cache- Returns:
- The cached Texture
-
register
Register a Texture in the cache with the argument id. If the id is null, the argument Texture is not cached and is returned. If a Texture that matches the id and properties of the argument Texture is already in the cache, it will be returned and the argument Texture will not be stored. Otherwise, the argument Texture is stored and is returned.- Parameters:
tag
- The texture id, typically it's URL stringtexture
- The candidate texture to cache- Returns:
- The cached Texture
-