javax.media.j3d
Class ImageComponent2D

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.NodeComponent
          extended by javax.media.j3d.ImageComponent
              extended by javax.media.j3d.ImageComponent2D

public class ImageComponent2D
extends ImageComponent

This class defines a 2D image component. This is used for texture images, background images and raster components of Shape3D nodes. Prior to Java 3D 1.2, only BufferedImage objects could be used as the input to an ImageComponent2D object. As of Java 3D 1.2, an ImageComponent2D accepts any RenderedImage object (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 ImageComponent2D.Updater
          The ImageComponent2D.Updater interface is used in updating image data that is accessed by reference from a live or compiled ImageComponent object.
 
Field Summary
 
Fields inherited from class javax.media.j3d.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
ImageComponent2D(int format, java.awt.image.BufferedImage image)
          Constructs a 2D image component object using the specified format and BufferedImage.
ImageComponent2D(int format, java.awt.image.BufferedImage image, boolean byReference, boolean yUp)
          Constructs a 2D image component object using the specified format, BufferedImage, byReference flag, and yUp flag.
ImageComponent2D(int format, int width, int height)
          Constructs a 2D image component object using the specified format, width, and height, and a null image.
ImageComponent2D(int format, int width, int height, boolean byReference, boolean yUp)
          Constructs a 2D image component object using the specified format, width, height, byReference flag, and yUp flag, and a null image.
ImageComponent2D(int format, java.awt.image.RenderedImage image)
          Constructs a 2D image component object using the specified format and RenderedImage.
ImageComponent2D(int format, java.awt.image.RenderedImage image, boolean byReference, boolean yUp)
          Constructs a 2D image component object using the specified format, RenderedImage, byReference flag, and yUp flag.
 
Method Summary
 NodeComponent cloneNodeComponent()
          Deprecated. replaced with cloneNodeComponent(boolean forceDuplicate)
 java.awt.image.BufferedImage getImage()
          Retrieves the image from this ImageComponent2D object.
 java.awt.image.RenderedImage getRenderedImage()
          Retrieves the image from this ImageComponent2D object.
 void set(java.awt.image.BufferedImage image)
          Sets this image component to the specified BufferedImage object.
 void set(java.awt.image.RenderedImage image)
          Sets this image component to the specified RenderedImage object.
 void setSubImage(java.awt.image.RenderedImage image, int width, int height, int srcX, int srcY, int dstX, int dstY)
          Modifies a contiguous subregion of the image component.
 void updateData(ImageComponent2D.Updater updater, int x, int y, int width, int height)
          Updates image data that is accessed by reference.
 
Methods inherited from class javax.media.j3d.ImageComponent
getFormat, getHeight, getWidth, isByReference, isYUp, setYUp
 
Methods inherited from class javax.media.j3d.NodeComponent
cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageComponent2D

public ImageComponent2D(int format,
                        int width,
                        int height)
Constructs a 2D image component object using the specified format, width, and height, and a null image.

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
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if width or height are not positive.

ImageComponent2D

public ImageComponent2D(int format,
                        java.awt.image.BufferedImage image)
Constructs a 2D image component object using the specified format and BufferedImage. A copy of the BufferedImage is made.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
image - the BufferedImage used to create this 2D image component.
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the image are not positive.

ImageComponent2D

public ImageComponent2D(int format,
                        java.awt.image.RenderedImage image)
Constructs a 2D image component object using the specified format and RenderedImage. A copy of the RenderedImage is made.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
image - the RenderedImage used to create this 2D image component
Throws:
java.lang.IllegalArgumentException - if format is invalid, or if the width or height of the image are not positive.
Since:
Java 3D 1.2

ImageComponent2D

public ImageComponent2D(int format,
                        int width,
                        int height,
                        boolean byReference,
                        boolean yUp)
Constructs a 2D image component object using the specified format, width, height, byReference flag, and yUp flag, and a null image.

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
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 width or height are not positive.
Since:
Java 3D 1.2

ImageComponent2D

public ImageComponent2D(int format,
                        java.awt.image.BufferedImage image,
                        boolean byReference,
                        boolean yUp)
Constructs a 2D image component object using the specified format, BufferedImage, byReference flag, and yUp flag.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
image - the BufferedImage used to create this 2D image component
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 image are not positive.
Since:
Java 3D 1.2

ImageComponent2D

public ImageComponent2D(int format,
                        java.awt.image.RenderedImage image,
                        boolean byReference,
                        boolean yUp)
Constructs a 2D image component object using the specified format, RenderedImage, byReference flag, and yUp flag.

Parameters:
format - the image component format, one of: FORMAT_RGB, FORMAT_RGBA, etc.
image - the RenderedImage used to create this 2D image component
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 image are not positive.
Since:
Java 3D 1.2
Method Detail

set

public void set(java.awt.image.BufferedImage image)
Sets this image component 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:
image - BufferedImage object containing the image. The format and size must be the same as the current format in this ImageComponent2D 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.RenderedImage image)
Sets this image component to the specified RenderedImage object. If the data access mode is not by-reference, the RenderedImage data is copied into this object. If the data access mode is by-reference, a reference to the RenderedImage is saved, but the data is not necessarily copied.

Parameters:
image - RenderedImage object containing the image. The format and size must be the same as the current format in this ImageComponent2D object.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
Java 3D 1.2

getImage

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

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 data access mode is by-reference and the image referenced by this ImageComponent2D object is not an instance of BufferedImage.

getRenderedImage

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

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
Since:
Java 3D 1.2

setSubImage

public void setSubImage(java.awt.image.RenderedImage image,
                        int width,
                        int height,
                        int srcX,
                        int srcY,
                        int dstX,
                        int dstY)
Modifies a contiguous subregion of the image component. Block of data of dimension (width * height) starting at the offset (srcX, srcY) of the specified RenderedImage object will be copied into the image component starting at the offset (dstX, dstY) of the ImageComponent2D object. The 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:
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 - starting 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 of 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.
Since:
Java 3D 1.3

updateData

public void updateData(ImageComponent2D.Updater updater,
                       int x,
                       int y,
                       int width,
                       int height)
Updates image data that is accessed by reference. This method calls the updateData method of the specified ImageComponent2D.Updater object to synchronize updates to the image data that is referenced by this ImageComponent2D 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 outisde 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 ImageComponent2D 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 the appropriate capability is not set, and this object is part of a 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 of 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.
Since:
Java 3D 1.3

cloneNodeComponent

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

Overrides:
cloneNodeComponent in class NodeComponent


Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.