|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jagatoo.loaders.textures.AbstractTextureLoader
public abstract class AbstractTextureLoader
Loads Textures from various image resources.
Loading (by name) works in the following order:
If the texture was already loaded and is still in the cache then the
existing texture is returned. So don't modify loaded nad cached textures!
All TextureStreamLocators are tried in the order, in which they are
registered.
If a stream was found then the following is tried on the stream:
All TextureImageFormatLoaders are tried in the order, in which they are
registered. A texture can then be created from this AbstractTextureImage.
All TextureFormatLoaders are tried in the order, in which they are
registered.
At last the fallback TextureImageFormatLoader is used to load the
Texture. It will most probably use ImageIO.
The loading stops as soon as a Texture is created.
| Field Summary | |
|---|---|
protected boolean |
autoDotAddedOnce
|
protected TextureImageFormatLoader |
fallbackTextureImageFormatLoader
|
protected java.util.ArrayList<TextureFormatLoader> |
textureFormatLoaders
|
protected java.util.ArrayList<TextureImageFormatLoader> |
textureImageFormatLoaders
|
protected java.util.ArrayList<TextureStreamLocator> |
textureStreamLocators
|
| Constructor Summary | |
|---|---|
protected |
AbstractTextureLoader()
|
protected |
AbstractTextureLoader(TextureCache textureCache,
TextureImageFormatLoader fallbackTextureImageFormatLoader)
|
| Method Summary | |
|---|---|
void |
addTextureFormatLoader(TextureFormatLoader tsl)
Registers a TextureStreamLoader. |
void |
addTextureImageFormatLoader(TextureImageFormatLoader l)
Registers a TextureImageFormatLoader. |
TextureStreamLocatorFile |
addTextureStreamLocator(java.io.File file)
Registers a TextureStreamLocatorFile. |
TextureStreamLocatorFile |
addTextureStreamLocator(java.lang.String filename)
Registers a TextureStreamLocatorFile. |
void |
addTextureStreamLocator(TextureStreamLocator tsl)
Registers a TextureStreamLocator. |
TextureStreamLocatorURL |
addTextureStreamLocator(java.net.URL url)
Registers a TextureStreamLocatorURL. |
TextureStreamLocatorURL |
addTextureStreamLocator(java.net.URL baseURL,
java.lang.String resName)
Registers a TextureStreamLocatorURL. |
protected AbstractTexture |
checkCache(java.lang.String name,
java.lang.String key)
|
protected AbstractTexture |
createTextureFromTextureImage(AbstractTextureImage ti,
boolean loadMipmaps,
TextureFactory texFactory)
|
protected java.lang.String |
generateCacheKey(java.lang.String name,
boolean acceptAlpha,
boolean loadMipmaps,
boolean flipVertically,
boolean allowStreching)
|
TextureCache |
getCache()
|
TextureImageFormatLoader |
getFallbackTextureImageFormatLoader()
|
protected java.io.BufferedInputStream |
getInputStream(java.lang.String name)
|
protected void |
initStandardFormatLoaders()
Adds all known standard TextureImageFormatLoaders. |
protected AbstractTexture |
loadOrGetTexture(java.lang.String name,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory,
boolean useCache,
boolean writeToCache)
Retrives the texture with the given name. |
protected AbstractTexture |
loadTextureFromStream(java.io.BufferedInputStream in,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory)
Tries to load the texture from an InputStream. |
protected AbstractTexture |
loadTextureFromURL(java.net.URL imageURL,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory)
Retrives the texture with the given name. |
protected AbstractTextureImage |
loadTextureImage(java.lang.String name,
boolean flipVertically,
boolean acceptAlpha,
boolean allowStreching,
TextureFactory texFactory)
Retrives the texture-image with the given name. |
protected AbstractTextureImage |
loadTextureImageFromStream(java.io.BufferedInputStream in,
boolean flipVertically,
boolean acceptAlpha,
boolean allowStreching,
TextureFactory texFactory)
Tries to load the texture-image from an InputStream. |
protected abstract void |
onTextureLoaded(AbstractTexture texture,
java.lang.String resourceName)
This method is called by the loaded after a texture haa actually been loaded, but not taken from teh cache. |
boolean |
removeTextureFormatLoader(TextureFormatLoader tsl)
Removes a registered TextureStreamLoader. |
boolean |
removeTextureImageFormatLoader(TextureImageFormatLoader l)
Removes a registered TextureImageFormatLoader |
boolean |
removeTextureStreamLocator(TextureStreamLocator tsl)
Removes a registered TextureStreamLocator. |
TextureCache |
setCache(TextureCache textureCache,
boolean copyCachedTextures)
Sets the new TextureCache to be used to cache loaded Textures. |
void |
setFallbackTextureImageFormatLoader(TextureImageFormatLoader ftifl)
Sets the TextureImageFormatLoader, that is used as the
fallback-loader, if no other format-loader was capable of loading
the requested texture resource. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.util.ArrayList<TextureStreamLocator> textureStreamLocators
protected boolean autoDotAddedOnce
protected final java.util.ArrayList<TextureImageFormatLoader> textureImageFormatLoaders
protected final java.util.ArrayList<TextureFormatLoader> textureFormatLoaders
protected TextureImageFormatLoader fallbackTextureImageFormatLoader
| Constructor Detail |
|---|
protected AbstractTextureLoader(TextureCache textureCache,
TextureImageFormatLoader fallbackTextureImageFormatLoader)
protected AbstractTextureLoader()
| Method Detail |
|---|
public TextureCache setCache(TextureCache textureCache,
boolean copyCachedTextures)
TextureCache to be used to cache loaded Textures.
textureCache - the new TextureCachecopyCachedTextures - if true, the currently cached Textures are copied to the new cache
TextureCache.public final TextureCache getCache()
TextureCache used to cache loaded Textures (never null).public void addTextureStreamLocator(TextureStreamLocator tsl)
TextureStreamLocator. A TextureStreamLocator returns an
InputStream that holds the data for a Texture or an Image. Note: No check
is performed to prevent duplicate registrations!
tsl - the TextureStreamLocator to addpublic TextureStreamLocatorURL addTextureStreamLocator(java.net.URL url)
TextureStreamLocatorURL. A TextureStreamLocator returns an
InputStream that holds the data for a Texture or a Image. Note: No check
is performed to prevent duplicate registrations!
url - the URL to create and add a TextureStreamLocatorURL from
TextureStreamLocatorURL.
public TextureStreamLocatorURL addTextureStreamLocator(java.net.URL baseURL,
java.lang.String resName)
throws java.net.MalformedURLException
TextureStreamLocatorURL. A TextureStreamLocator returns an
InputStream that holds the data for a Texture or a Image. Note: No check
is performed to prevent duplicate registrations!
baseURL - the base-URL to create and add a TextureStreamLocatorURL fromresName - the resource-name to compose a new URL from (together with baseURL)
TextureStreamLocatorURL.
java.net.MalformedURLExceptionpublic TextureStreamLocatorFile addTextureStreamLocator(java.io.File file)
TextureStreamLocatorFile. A TextureStreamLocator returns an
InputStream that holds the data for a Texture or a Image. Note: No check
is performed to prevent duplicate registrations!
file - the File to create and add a TextureStreamLocatorFile from
TextureStreamLocatorFile.public TextureStreamLocatorFile addTextureStreamLocator(java.lang.String filename)
TextureStreamLocatorFile. A TextureStreamLocator returns an
InputStream that holds the data for a Texture or a Image. Note: No check
is performed to prevent duplicate registrations!
filename - the filename to create and add a TextureStreamLocatorFile from
TextureStreamLocatorFile.public boolean removeTextureStreamLocator(TextureStreamLocator tsl)
tsl - the TextureStreamLocator to add
public void addTextureImageFormatLoader(TextureImageFormatLoader l)
l - The TextureImageLoader.public boolean removeTextureImageFormatLoader(TextureImageFormatLoader l)
l - the TextureImageLoader to be removed
public void addTextureFormatLoader(TextureFormatLoader tsl)
tsl - the TextureStreamLoader to addpublic boolean removeTextureFormatLoader(TextureFormatLoader tsl)
tsl - the TextureStreamLoader to be removed
public void setFallbackTextureImageFormatLoader(TextureImageFormatLoader ftifl)
TextureImageFormatLoader, that is used as the
fallback-loader, if no other format-loader was capable of loading
the requested texture resource.
ftifl - public final TextureImageFormatLoader getFallbackTextureImageFormatLoader()
TextureImageFormatLoader, that is used as the
fallback-loader, if no other format-loader was capable of loading
the requested texture resource.
protected AbstractTexture createTextureFromTextureImage(AbstractTextureImage ti,
boolean loadMipmaps,
TextureFactory texFactory)
protected AbstractTextureImage loadTextureImageFromStream(java.io.BufferedInputStream in,
boolean flipVertically,
boolean acceptAlpha,
boolean allowStreching,
TextureFactory texFactory)
in - the InputStream to load the Texture fromflipVertically - flip the image vertically or notacceptAlpha - try to load with alpha channel or notloadMipmaps - create mipmaps?allowStreching - If true, the image is streched to power-of-two width and height, if necessary.texFactory -
protected AbstractTexture loadTextureFromStream(java.io.BufferedInputStream in,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory)
in - the InputStream to load the Texture fromflipVertically - flip the image vertically or notacceptAlpha - try to load with alpha channel or notloadMipmaps - create mipmaps?allowStreching - If true, the image is streched to power-of-two width and height, if necessary.texFactory -
protected java.lang.String generateCacheKey(java.lang.String name,
boolean acceptAlpha,
boolean loadMipmaps,
boolean flipVertically,
boolean allowStreching)
protected final AbstractTexture checkCache(java.lang.String name,
java.lang.String key)
protected java.io.BufferedInputStream getInputStream(java.lang.String name)
protected AbstractTextureImage loadTextureImage(java.lang.String name,
boolean flipVertically,
boolean acceptAlpha,
boolean allowStreching,
TextureFactory texFactory)
TextureStreamLocators are tried in the order in which they are
registered.TextureImageFormatLoaders are tried in the order in which they are
registered. A texture is then created with this AbstractTextureImage
(mipmaps currently not implemented).TextureFormatLoaders are tried in the order in which they are
registered.TextureImageFormatLoader is used to load the
Texture. It will most probably use ImageIO.
name - The name of the texture.flipVertically - flip the image vertically or notacceptAlpha - try to load with alpha channel or notallowStreching - If true, the image is streched to power-of-two width and height, if necessary.texFactory -
AbstractTextureImage object or a null, if it was not found.
protected abstract void onTextureLoaded(AbstractTexture texture,
java.lang.String resourceName)
texture - resourceName -
protected AbstractTexture loadOrGetTexture(java.lang.String name,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory,
boolean useCache,
boolean writeToCache)
TextureStreamLocators are tried in the order in which they are
registered.TextureImageFormatLoaders are tried in the order in which they are
registered. A texture is then created with this AbstractTextureImage
(mipmaps currently not implemented).TextureFormatLoaders are tried in the order in which they are
registered.TextureImageFormatLoader is used to load the
Texture. It will most probably use ImageIO.
name - The name of the texture.flipVertically - flip the image vertically or notacceptAlpha - try to load with alpha channel or notloadMipmaps - create mipmaps?allowStreching - If true, the image is streched to power-of-two width and height, if necessary.texFactory - useCache - writeToCache - ignored, if useCache is false
AbstractTexture object or a null, if it was not found.
protected AbstractTexture loadTextureFromURL(java.net.URL imageURL,
boolean flipVertically,
boolean acceptAlpha,
boolean loadMipmaps,
boolean allowStreching,
TextureFactory texFactory)
TextureImageFormatLoaders are tried in the order in which they are
registered. A texture is then created with this AbstractTextureImage
(mipmaps currently not implemented).TextureFormatLoaders are tried in the order in which they are
registered.TextureImageFormatLoader is used to load the
Texture. It will most probably use ImageIO.
imageURL - The name of the texture.flipVertically - flip the image vertically or notacceptAlpha - try to load with alpha channel or notloadMipmaps - create mipmaps?allowStreching - If true, the image is streched to power-of-two width and height, if necessary.texFactory -
AbstractTexture object or a null, if it was not found.protected void initStandardFormatLoaders()
TextureImageFormatLoaders.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||