javax.media.ding3d
Class ImageComponent3D

java.lang.Object
  extended by javax.media.ding3d.SceneGraphObject
      extended by javax.media.ding3d.NodeComponent
          extended by javax.media.ding3d.ImageComponent
              extended by javax.media.ding3d.ImageComponent3D

public class ImageComponent3D
extends ImageComponent

This class defines a 3D image component. This is used for texture images. Prior to Java 3D 1.2, only BufferedImage objects could be used as the input to an ImageComponent3D object. As of Java 3D 1.2, an ImageComponent3D accepts an array of arbitrary RenderedImage objects (BufferedImage is an implementation of the RenderedImage interface). The methods that set/get a BufferedImage object are left in for compatibility. The new methods that set/get a RenderedImage are a superset of the old methods. In particular, the two set methods in the following example are equivalent:


Nested Class Summary
static interface ImageComponent3D.Updater
          The ImageComponent3D.Updater interface is used in updating image data that is accessed by reference from a live or compiled ImageComponent object.
 
Nested classes/interfaces inherited from class javax.media.ding3d.ImageComponent
ImageComponent.ImageClass
 
Field Summary
 
Fields inherited from class javax.media.ding3d.ImageComponent
ALLOW_FORMAT_READ, ALLOW_IMAGE_READ, ALLOW_IMAGE_WRITE, ALLOW_SIZE_READ, FORMAT_CHANNEL8, FORMAT_LUM4_ALPHA4, FORMAT_LUM8_ALPHA8, FORMAT_R3_G3_B2, FORMAT_RGB, FORMAT_RGB4, FORMAT_RGB5, FORMAT_RGB5_A1, FORMAT_RGB8, FORMAT_RGBA, FORMAT_RGBA4, FORMAT_RGBA8
 
Constructor Summary
ImageComponent3D(int format, java.awt.image.BufferedImage[] images)
          Constructs a 3D image component object using the specified format, and the BufferedImage array.
ImageComponent3D(int format, java.awt.image.BufferedImage[] images, boolean byReference, boolean yUp)
          Constructs a 3D image component object using the specified format, BufferedImage array, byReference flag, and yUp flag.
ImageComponent3D(int format, int width, int height, int depth)
          Constructs a 3D image component object using the specified format, width, height, and depth.
ImageComponent3D(int format, int width, int height, int depth, boolean byReference, boolean yUp)
          Constructs a 3D image component object using the specified format, width, height, depth, byReference flag, and yUp flag.
ImageComponent3D(int format, NioImageBuffer[] images, boolean byReference, boolean yUp)
          Constructs a 3D image component object using the specified format, NioImageBuffer array, byReference flag, and yUp flag.
ImageComponent3D(int format, java.awt.image.RenderedImage[] images)
          Constructs a 3D image component object using the specified format, and the RenderedImage array.
ImageComponent3D(int format, java.awt.image.RenderedImage[] images, boolean byReference, boolean yUp)
          Constructs a 3D image component object using the specified format, RenderedImage array, byReference flag, and yUp flag.
 
Method Summary
 NodeComponent cloneNodeComponent()
          Deprecated. replaced with cloneNodeComponent(boolean forceDuplicate)
 int getDepth()
          Retrieves the depth of this 3D image component object.
 java.awt.image.BufferedImage[] getImage()
          Retrieves the images from this ImageComponent3D object.
 java.awt.image.BufferedImage getImage(int index)
          Retrieves one of the images from this ImageComponent3D object.
 NioImageBuffer[] getNioImage()
          Retrieves the images from this ImageComponent3D object.
 NioImageBuffer getNioImage(int index)
          Retrieves one of the images from this ImageComponent3D object.
 java.awt.image.RenderedImage[] getRenderedImage()
          Retrieves the images from this ImageComponent3D object.
 java.awt.image.RenderedImage getRenderedImage(int index)
          Retrieves one of the images from this ImageComponent3D object.
 void set(java.awt.image.BufferedImage[] images)
          Sets the array of images in this image component to the specified array of BufferedImage objects.
 void set(int index, java.awt.image.BufferedImage image)
          Sets this image component at the specified index to the specified BufferedImage object.
 void set(int index, NioImageBuffer image)
          Sets this image component at the specified index to the specified NioImageBuffer object.
 void set(int index, java.awt.image.RenderedImage image)
          Sets this image component at the specified index to the specified RenderedImage object.
 void set(NioImageBuffer[] images)
          Sets the array of images in this image component to the specified array of NioImageBuffer objects.
 void set(java.awt.image.RenderedImage[] images)
          Sets the array of images in this image component to the specified array of RenderedImage objects.
 void setSubImage(int index, java.awt.image.RenderedImage image, int width, int height, int srcX, int srcY, int dstX, int dstY)
          Modifies a contiguous subregion of a particular slice of image of this ImageComponent3D object.
 void updateData(ImageComponent3D.Updater updater, int index, int x, int y, int width, int height)
          Updates a particular slice of image data that is accessed by reference.
 
Methods inherited from class javax.media.ding3d.ImageComponent
getFormat, getHeight, getImageClass, getWidth, isByReference, isYUp, setYUp
 
Methods inherited from class javax.media.ding3d.NodeComponent
cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree
 
Methods inherited from class javax.media.ding3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageComponent3D

public ImageComponent3D(int format,
                        int width,
                        int height,
                        int depth)
Constructs a 3D image component object using the specified format, width, height, and depth. Default values are used for all other parameters. The default values are as follows:

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
width - the number of columns of pixels in this image component object
height - the number of rows of pixels in this image component object
depth - the number of 2D slices in this image component object
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if any of width, height, or depth are not positive.

ImageComponent3D

public ImageComponent3D(int format,
                        java.awt.image.BufferedImage[] images)
Constructs a 3D image component object using the specified format, and the BufferedImage array. The image class is set to ImageClass.BUFFERED_IMAGE. Default values are used for all other parameters.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA etc.
images - an array of BufferedImage objects. The first image in the array determines the width and height of this ImageComponent3D.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the first image are not positive.

ImageComponent3D

public ImageComponent3D(int format,
                        java.awt.image.RenderedImage[] images)
Constructs a 3D image component object using the specified format, and the RenderedImage array. The image class is set to ImageClass.BUFFERED_IMAGE. Default values are used for all other parameters.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA etc.
images - an array of RenderedImage objects. The first image in the array determines the width and height of this ImageComponent3D.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the first image are not positive.
Since:
Java 3D 1.2

ImageComponent3D

public ImageComponent3D(int format,
                        int width,
                        int height,
                        int depth,
                        boolean byReference,
                        boolean yUp)
Constructs a 3D image component object using the specified format, width, height, depth, byReference flag, and yUp flag. Default values are used for all other parameters.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
width - the number of columns of pixels in this image component object
height - the number of rows of pixels in this image component object
depth - the number of 2D slices in this image component object
byReference - a flag that indicates whether the data is copied into this image component object or is accessed by reference.
yUp - a flag that indicates the y-orientation of this image component. If yUp is set to true, the origin of the image is the lower left; otherwise, the origin of the image is the upper left.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if any of width, height, or depth are not positive.
Since:
Java 3D 1.2

ImageComponent3D

public ImageComponent3D(int format,
                        java.awt.image.BufferedImage[] images,
                        boolean byReference,
                        boolean yUp)
Constructs a 3D image component object using the specified format, BufferedImage array, byReference flag, and yUp flag. The image class is set to ImageClass.BUFFERED_IMAGE.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA etc.
images - an array of BufferedImage objects. The first image in the array determines the width and height of this ImageComponent3D.
byReference - a flag that indicates whether the data is copied into this image component object or is accessed by reference.
yUp - a flag that indicates the y-orientation of this image component. If yUp is set to true, the origin of the image is the lower left; otherwise, the origin of the image is the upper left.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the first image are not positive.
Since:
Java 3D 1.2

ImageComponent3D

public ImageComponent3D(int format,
                        java.awt.image.RenderedImage[] images,
                        boolean byReference,
                        boolean yUp)
Constructs a 3D image component object using the specified format, RenderedImage array, byReference flag, and yUp flag. The image class is set to ImageClass.RENDERED_IMAGE if the byReference flag is true and any of the specified RenderedImages is not an instance of BufferedImage. In all other cases, the image class is set to ImageClass.BUFFERED_IMAGE.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA etc.
images - an array of RenderedImage objects. The first image in the array determines the width and height of this ImageComponent3D.
byReference - a flag that indicates whether the data is copied into this image component object or is accessed by reference.
yUp - a flag that indicates the y-orientation of this image component. If yUp is set to true, the origin of the image is the lower left; otherwise, the origin of the image is the upper left.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the first image are not positive.
Since:
Java 3D 1.2

ImageComponent3D

public ImageComponent3D(int format,
                        NioImageBuffer[] images,
                        boolean byReference,
                        boolean yUp)
Constructs a 3D image component object using the specified format, NioImageBuffer array, byReference flag, and yUp flag. The image class is set to ImageClass.NIO_IMAGE_BUFFER.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA etc.
images - an array of NioImageBuffer objects. The first image in the array determines the width and height of this ImageComponent3D.
byReference - a flag that indicates whether the data is copied into this image component object or is accessed by reference.
yUp - a flag that indicates the y-orientation of this image component. If yUp is set to true, the origin of the image is the lower left; otherwise, the origin of the image is the upper left.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the first image are not positive.
java.lang.IllegalArgumentException - if the byReference flag is false.
java.lang.IllegalArgumentException - if the yUp flag is false.
java.lang.UnsupportedOperationException - this method is not supported for Java 3D 1.5.
Since:
Java 3D 1.5
Method Detail

getDepth

public int getDepth()
Retrieves the depth of this 3D image component object.

Returns:
the depth of this 3D image component object
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

set

public void set(java.awt.image.BufferedImage[] images)
Sets the array of images in this image component to the specified array of BufferedImage objects. If the data access mode is not by-reference, then the BufferedImage data is copied into this object. If the data access mode is by-reference, then a shallow copy of the array of references to the BufferedImage objects is made, but the BufferedImage data is not necessarily copied.

The image class is set to ImageClass.BUFFERED_IMAGE.

Parameters:
images - array of BufferedImage objects containing the image. The size (width and height) of each image must be the same as the size of the image component, and the length of the images array must equal the depth of the image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalArgumentException - if the length of the images array is not equal to the depth of this ImageComponent object.
java.lang.IllegalArgumentException - if the width and height of each image in the images array is not equal to the width and height of this ImageComponent object.

set

public void set(java.awt.image.RenderedImage[] images)
Sets the array of images in this image component to the specified array of RenderedImage objects. If the data access mode is not by-reference, then the RenderedImage data is copied into this object. If the data access mode is by-reference, then a shallow copy of the array of references to the RenderedImage objects is made, but the RenderedImage data is not necessarily copied.

The image class is set to ImageClass.RENDERED_IMAGE if the data access mode is by-reference and any of the specified RenderedImages is not an instance of BufferedImage. In all other cases, the image class is set to ImageClass.BUFFERED_IMAGE.

Parameters:
images - array of RenderedImage objects containing the image. The size (width and height) of each image must be the same as the size of the image component, and the length of the images array must equal the depth of the image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalArgumentException - if the length of the images array is not equal to the depth of this ImageComponent object.
java.lang.IllegalArgumentException - if the width and height of each image in the images array is not equal to the width and height of this ImageComponent object.
Since:
Java 3D 1.2

set

public void set(NioImageBuffer[] images)
Sets the array of images in this image component to the specified array of NioImageBuffer objects. If the data access mode is not by-reference, then the NioImageBuffer data is copied into this object. If the data access mode is by-reference, then a shallow copy of the array of references to the NioImageBuffer objects is made, but the NioImageBuffer data is not necessarily copied.

The image class is set to ImageClass.NIO_IMAGE_BUFFER.

Parameters:
images - array of NioImageBuffer objects containing the image. The size (width and height) of each image must be the same as the size of the image component, and the length of the images array must equal the depth of the image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if this ImageComponent object is not yUp.
java.lang.IllegalArgumentException - if the length of the images array is not equal to the depth of this ImageComponent object.
java.lang.IllegalArgumentException - if the width and height of each image in the images array is not equal to the width and height of this ImageComponent object.
java.lang.UnsupportedOperationException - this method is not supported for Java 3D 1.5.
Since:
Java 3D 1.5

set

public void set(int index,
                java.awt.image.BufferedImage image)
Sets this image component at the specified index to the specified BufferedImage object. If the data access mode is not by-reference, then the BufferedImage data is copied into this object. If the data access mode is by-reference, then a reference to the BufferedImage is saved, but the data is not necessarily copied.

Parameters:
index - the image index. The index must be less than the depth of this ImageComponent3D object.
image - BufferedImage object containing the image. The size (width and height) must be the same as the current size of this ImageComponent3D object.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.BUFFERED_IMAGE.
java.lang.IllegalArgumentException - if the width and height the image is not equal to the width and height of this ImageComponent object.

set

public void set(int index,
                java.awt.image.RenderedImage image)
Sets this image component at the specified index to the specified RenderedImage object. If the data access mode is not by-reference, then the RenderedImage data is copied into this object. If the data access mode is by-reference, then a reference to the RenderedImage is saved, but the data is not necessarily copied.

Parameters:
index - the image index. The index must be less than the depth of this ImageComponent3D object.
image - RenderedImage object containing the image. The size (width and height) must be the same as the current size of this ImageComponent3D object.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not one of: ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.
java.lang.IllegalArgumentException - if the width and height the image is not equal to the width and height of this ImageComponent object.
Since:
Java 3D 1.2

set

public void set(int index,
                NioImageBuffer image)
Sets this image component at the specified index to the specified NioImageBuffer object. If the data access mode is not by-reference, then the NioImageBuffer data is copied into this object. If the data access mode is by-reference, then a reference to the NioImageBuffer is saved, but the data is not necessarily copied.

Parameters:
index - the image index. The index must be less than the depth of this ImageComponent3D object.
image - NioImageBuffer object containing the image. The size (width and height) must be the same as the current size of this ImageComponent3D object.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.NIO_IMAGE_BUFFER.
java.lang.IllegalArgumentException - if the width and height the image is not equal to the width and height of this ImageComponent object.
java.lang.UnsupportedOperationException - this method is not supported for Java 3D 1.5.
Since:
Java 3D 1.5

getImage

public java.awt.image.BufferedImage[] getImage()
Retrieves the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the images is made. If the data access mode is by-reference, then the references are returned.

Returns:
either a new array of new BufferedImage objects created from the data in this image component, or a new array of references to the BufferedImages that this image component refers to.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.BUFFERED_IMAGE.

getRenderedImage

public java.awt.image.RenderedImage[] getRenderedImage()
Retrieves the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the images is made. If the data access mode is by-reference, then the references are returned.

Returns:
either a new array of new RenderedImage objects created from the data in this image component, or a new array of references to the RenderedImages that this image component refers to.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not one of: ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.
Since:
Java 3D 1.2

getNioImage

public NioImageBuffer[] getNioImage()
Retrieves the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the images is made. If the data access mode is by-reference, then the references are returned.

Returns:
either a new array of new RenderedImage objects created from the data in this image component, or a new array of references to the RenderedImages that this image component refers to.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.NIO_IMAGE_BUFFER.
java.lang.UnsupportedOperationException - this method is not supported for Java 3D 1.5.
Since:
Java 3D 1.5

getImage

public java.awt.image.BufferedImage getImage(int index)
Retrieves one of the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the image is made. If the data access mode is by-reference, then the reference is returned.

Parameters:
index - the index of the image to retrieve. The index must be less than the depth of this ImageComponent3D object.
Returns:
either a new BufferedImage object created from the data in this image component, or the BufferedImage object referenced by this image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.BUFFERED_IMAGE.

getRenderedImage

public java.awt.image.RenderedImage getRenderedImage(int index)
Retrieves one of the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the image is made. If the data access mode is by-reference, then the reference is returned.

Parameters:
index - the index of the image to retrieve. The index must be less than the depth of this ImageComponent3D object.
Returns:
either a new RenderedImage object created from the data in this image component, or the RenderedImage object referenced by this image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not one of: ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.
Since:
Java 3D 1.2

getNioImage

public NioImageBuffer getNioImage(int index)
Retrieves one of the images from this ImageComponent3D object. If the data access mode is not by-reference, then a copy of the image is made. If the data access mode is by-reference, then the reference is returned.

Parameters:
index - the index of the image to retrieve. The index must be less than the depth of this ImageComponent3D object.
Returns:
either a new NioImageBuffer object created from the data in this image component, or the NioImageBuffer object referenced by this image component.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the image class is not ImageClass.NIO_IMAGE_BUFFER.
java.lang.UnsupportedOperationException - this method is not supported for Java 3D 1.5.
Since:
Java 3D 1.5

setSubImage

public void setSubImage(int index,
                        java.awt.image.RenderedImage image,
                        int width,
                        int height,
                        int srcX,
                        int srcY,
                        int dstX,
                        int dstY)
Modifies a contiguous subregion of a particular slice of image of this ImageComponent3D object. Block of data of dimension (width * height) starting at the offset (srcX, srcY) of the specified RenderedImage object will be copied into the particular slice of image component starting at the offset (dstX, dstY) of this ImageComponent3D object. The specified RenderedImage object must be of the same format as the current format of this object. This method can only be used if the data access mode is by-copy. If it is by-reference, see updateData().

Parameters:
index - index of the image to be modified. The index must be less than the depth of this ImageComponent3D object.
image - RenderedImage object containing the subimage.
width - width of the subregion.
height - height of the subregion.
srcX - starting X offset of the subregion in the specified image.
srcY - starting Y offset of the subregion in the specified image.
dstX - startin X offset of the subregion in the image component of this object.
dstY - starting Y offset of the subregion in the image component of this object.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the data access mode is BY_REFERENCE.
java.lang.IllegalArgumentException - if width or height of the subregion exceeds the dimension of the image in this object.
java.lang.IllegalArgumentException - if dstX < 0, or (dstX + width) > width of this object, or dstY < 0, or (dstY + height) > height of this object.
java.lang.IllegalArgumentException - if srcX < 0, or (srcX + width) > width of the RenderedImage object containing the subimage, or srcY < 0, or (srcY + height) > height of the RenderedImage object containing the subimage.
java.lang.IllegalArgumentException - if the specified RenderedImage is not compatible with the existing RenderedImage.
java.lang.IllegalStateException - if the image class is not one of: ImageClass.BUFFERED_IMAGE or ImageClass.RENDERED_IMAGE.
Since:
Java 3D 1.3

updateData

public void updateData(ImageComponent3D.Updater updater,
                       int index,
                       int x,
                       int y,
                       int width,
                       int height)
Updates a particular slice of image data that is accessed by reference. This method calls the updateData method of the specified ImageComponent3D.Updater object to synchronize updates to the image data that is referenced by this ImageComponent3D object. Applications that wish to modify such data must perform all updates via this method.

The data to be modified has to be within the boundary of the subregion specified by the offset (x, y) and the dimension (width*height). It is illegal to modify data outside this boundary. If any referenced data is modified outside the updateData method, or any data outside the specified boundary is modified, the results are undefined.

Parameters:
updater - object whose updateData callback method will be called to update the data referenced by this ImageComponent3D object.
index - index of the image to be modified. The index must be less than the depth of this ImageComponent3D object.
x - starting X offset of the subregion.
y - starting Y offset of the subregion.
width - width of the subregion.
height - height of the subregion.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalStateException - if the data access mode is BY_COPY.
java.lang.IllegalArgumentException - if width or height of the subregion exceeds the dimension of the image in this object.
java.lang.IllegalArgumentException - if x < 0, or (x + width) > width of this object, or y < 0, or (y + height) > height of this object.
java.lang.ArrayIndexOutOfBoundsException - if index > the depth of this object.
Since:
Java 3D 1.3

cloneNodeComponent

public NodeComponent cloneNodeComponent()
Deprecated. replaced with cloneNodeComponent(boolean forceDuplicate)

Overrides:
cloneNodeComponent in class NodeComponent