Sweet Home 3D 3.4

com.eteks.sweethome3d.j3d
Class TextureManager

java.lang.Object
  extended by com.eteks.sweethome3d.j3d.TextureManager

public class TextureManager
extends java.lang.Object

Singleton managing texture image cache.

Author:
Emmanuel Puybaret

Nested Class Summary
static interface TextureManager.TextureObserver
          An observer that receives texture loading notifications.
 
Method Summary
 void clear()
          Shutdowns the multithreaded service that load textures.
static TextureManager getInstance()
          Returns an instance of this singleton.
 boolean isTextureTransparent(Texture texture)
          Returns true if the texture is shared and its image contains at least one transparent pixel.
 Texture loadTexture(Content content)
          Returns a texture created from the image from content.
 void loadTexture(Content content, boolean synchronous, TextureManager.TextureObserver textureObserver)
          Reads a texture image from content notified to textureObserver.
 void loadTexture(Content content, TextureManager.TextureObserver textureObserver)
          Reads a texture image from content notified to textureObserver If the texture isn't loaded in cache yet, a one pixel white image texture will be notified immediately to the given textureObserver, then a second notification will be given in Event Dispatch Thread once the image texture is loaded.
 Texture shareTexture(Texture texture)
          Returns either the texture in parameter or a shared texture if the same texture as the one in parameter is already shared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TextureManager getInstance()
Returns an instance of this singleton.


clear

public void clear()
Shutdowns the multithreaded service that load textures.


loadTexture

public void loadTexture(Content content,
                        TextureManager.TextureObserver textureObserver)
Reads a texture image from content notified to textureObserver If the texture isn't loaded in cache yet, a one pixel white image texture will be notified immediately to the given textureObserver, then a second notification will be given in Event Dispatch Thread once the image texture is loaded. If the texture is in cache, it will be notified immediately to the given textureObserver.

Parameters:
content - an object containing an image
textureObserver - the observer that will be notified once the texture is available

loadTexture

public void loadTexture(Content content,
                        boolean synchronous,
                        TextureManager.TextureObserver textureObserver)
Reads a texture image from content notified to textureObserver. If the texture isn't loaded in cache yet and synchronous is false, a one pixel white image texture will be notified immediately to the given textureObserver, then a second notification will be given in Event Dispatch Thread once the image texture is loaded. If the texture is in cache, it will be notified immediately to the given textureObserver.

Parameters:
content - an object containing an image
synchronous - if true, this method will return only once image content is loaded.
textureObserver - the observer that will be notified once the texture is available
Throws:
java.lang.IllegalStateException - if synchronous is false and the current thread isn't the Event Dispatch Thread.

loadTexture

public Texture loadTexture(Content content)
Returns a texture created from the image from content.


shareTexture

public Texture shareTexture(Texture texture)
Returns either the texture in parameter or a shared texture if the same texture as the one in parameter is already shared.


isTextureTransparent

public boolean isTextureTransparent(Texture texture)
Returns true if the texture is shared and its image contains at least one transparent pixel.


Sweet Home 3D 3.4

? Copyrights 2006-2011 eTeks - All rights reserved
Distributed under GNU General Public License