Package org.web3d.net.content
Class ImageContentHandler
java.lang.Object
java.net.ContentHandler
org.ietf.uri.ContentHandler
org.web3d.net.content.ImageContentHandler
public abstract class ImageContentHandler
extends org.ietf.uri.ContentHandler
Base abstract ContentHandler implementation for loading images
from a URI resource connection.
- Version:
- $Revision: 1.4 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Class
<?> The -preferred- image Classprotected static final boolean
How should we rescale the image, up to nearest power of two, lowerprotected static final int
The value read from the system property for MAX_TEXTURE_SIZE_PROPprotected static final int
The value read from the system property for RESCALEprotected static boolean
The value read from the system property for MIPMAPSFields inherited from class org.ietf.uri.ContentHandler
requiresStream
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a new instance of the content handler. -
Method Summary
Modifier and TypeMethodDescriptionprotected NIOBufferImage
consolidate
(NIOBufferImage[] imageArray) Extract the individual image byte buffers from the array of NIOBufferImages and consolidate them into a single byte buffer array in the returned NIOBufferImage.protected static NIOBufferImage
Convert and return the argument content Object of the argument Class into an NIOBufferImage.abstract Object
getContent
(org.ietf.uri.ResourceConnection resc) Given a fresh stream from a ResourceConnection, read and create an object instance.protected static Class
<?> Check for the existence of our preferred image class.protected NIOBufferImage[]
preprocess
(NIOBufferImage image) Scale and create mipmaps of the argument image.Methods inherited from class org.ietf.uri.ContentHandler
getContent, getContent, getContent, getContent, getSupportedClasses, notifyDownloadError, notifyDownloadFinished, notifyDownloadProgress, notifyDownloadStarted, requiresStreamAfterClose
-
Field Details
-
rescale
protected static final int rescaleThe value read from the system property for RESCALE -
imageScaleUp
protected static final boolean imageScaleUpHow should we rescale the image, up to nearest power of two, lower -
maxTextureSize
protected static final int maxTextureSizeThe value read from the system property for MAX_TEXTURE_SIZE_PROP -
useMipMaps
protected static boolean useMipMapsThe value read from the system property for MIPMAPS -
image_class
The -preferred- image Class
-
-
Constructor Details
-
ImageContentHandler
protected ImageContentHandler()Construct a new instance of the content handler.
-
-
Method Details
-
getContent
Given a fresh stream from a ResourceConnection, read and create an object instance.- Specified by:
getContent
in classorg.ietf.uri.ContentHandler
- Parameters:
resc
- The resource connection to read the data from- Returns:
- The object read in by the content handler
- Throws:
IOException
- The connection stuffed up.
-
convert
Convert and return the argument content Object of the argument Class into an NIOBufferImage. If the conversion fails for any reason, null will be returned.- Parameters:
image_class
- The Class of the content Objectcontent
- The Object containing the image data- Returns:
- An NIOBufferImage
-
getPreferedImageClass
Check for the existence of our preferred image class. If found, return it's Class object. Otherwise, return null.- Returns:
- The preferred Class object, or null if it does not exist.
-
preprocess
Scale and create mipmaps of the argument image. The initial image will be resized as necessary to dimensions that are a power of 2 and less than or equal to the maximum size (if defined). Mipmaps will be generated as specified from the resized initial image and the array of images returned.- Parameters:
image
- The initial image- Returns:
- The array containing the scaled image and it's mipmaps
-
consolidate
Extract the individual image byte buffers from the array of NIOBufferImages and consolidate them into a single byte buffer array in the returned NIOBufferImage. This is used to place the rescaled image and it's mipmaps into a single container.- Parameters:
imageArray
- The primary image and set of mipmaps- Returns:
- The consolidated NIOBufferImage
-