ptolemy.actor.lib.jai
Class JAIImageToken

java.lang.Object
  extended by ptolemy.data.Token
      extended by ptolemy.data.ImageToken
          extended by ptolemy.actor.lib.jai.JAIImageToken
All Implemented Interfaces:
java.io.Serializable

public class JAIImageToken
extends ImageToken

A token that contains a javax.media.jai.RenderedOp. This token is used when dealing with images in the Java Advanced Imaging (JAI) library. Because it extends ImageToken, it can be used with the standard image processing tools by simply calling asAWTImage().

Since:
Ptolemy II 3.0
Version:
$Id: JAIImageToken.java 57040 2010-01-27 20:52:32Z cxh $
Author:
James Yeh
See Also:
Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
private  java.awt.image.BufferedImage _bufferedImage
           
private  javax.media.jai.RenderedOp _renderedOp
           
 
Fields inherited from class ptolemy.data.Token
NIL
 
Constructor Summary
JAIImageToken(javax.media.jai.RenderedOp value)
          Construct a token with a specified RenderedOp.
 
Method Summary
private  java.awt.image.renderable.ParameterBlock _parameterize(javax.media.jai.RenderedOp left, JAIImageToken right)
           
 Token add(Token rightArgument)
          Return a new token whose value is the sum of this token and the argument.
 java.awt.Image asAWTImage()
          Convert a javax.media.jai.RenderedOp to a BufferedImage, a subclass of awt.Image, and return it.
 Token divide(Token rightArgument)
          Return a new token whose value is the division of this token and the argument.
 Type getType()
          Return the type of this token.
 javax.media.jai.RenderedOp getValue()
          Return the value of the token, a renderedop.
 Token multiply(Token rightArgument)
          Return a new token whose value is the multiplication of this token and the argument.
 Token subtract(Token rightArgument)
          Return a new token whose value is the subtraction of this token from the argument.
 java.lang.String toString()
          Return a description of the token.
 
Methods inherited from class ptolemy.data.Token
addReverse, divideReverse, isCloseTo, isCloseTo, isEqualTo, isNil, modulo, moduloReverse, multiplyReverse, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, subtractReverse, zero, zeroReturnType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_bufferedImage

private java.awt.image.BufferedImage _bufferedImage

_renderedOp

private javax.media.jai.RenderedOp _renderedOp
Constructor Detail

JAIImageToken

public JAIImageToken(javax.media.jai.RenderedOp value)
Construct a token with a specified RenderedOp.

Parameters:
value - The RenderedOp with which to construct the JAIImageToken.
Method Detail

add

public Token add(Token rightArgument)
          throws IllegalActionException
Return a new token whose value is the sum of this token and the argument. The image size is the size of the intersection of the two images. The number of bands in the image is equal to the smallest number of bands of the two sources. The data type is the smallest data type to have sufficient range for both input data types.

Overrides:
add in class Token
Parameters:
rightArgument - The token to add to this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the data type is not supported.

asAWTImage

public java.awt.Image asAWTImage()
Convert a javax.media.jai.RenderedOp to a BufferedImage, a subclass of awt.Image, and return it.

Specified by:
asAWTImage in class ImageToken
Returns:
A bufferedImage that is a rendering of the internal image.

divide

public Token divide(Token rightArgument)
             throws IllegalActionException
Return a new token whose value is the division of this token and the argument. The image size is the size of the intersection of the two images. The number of bands in the image is equal to the smallest number of bands of the two sources. The data type is the bigger of the two input data types

Overrides:
divide in class Token
Parameters:
rightArgument - The token to divide this token by.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the data type is not supported.

getType

public Type getType()
Return the type of this token.

Overrides:
getType in class Token
Returns:
BaseType.OBJECT

getValue

public javax.media.jai.RenderedOp getValue()
Return the value of the token, a renderedop.

Returns:
The RenderedOp in this token.

multiply

public Token multiply(Token rightArgument)
               throws IllegalActionException
Return a new token whose value is the multiplication of this token and the argument. The image size is the size of the intersection of the two images. The number of bands in the image is equal to the smallest number of bands of the two sources. The data type is the bigger of the two input data types

Overrides:
multiply in class Token
Parameters:
rightArgument - The token to multiply this token by.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the data type is not supported.

subtract

public Token subtract(Token rightArgument)
               throws IllegalActionException
Return a new token whose value is the subtraction of this token from the argument. The image size is the size of the intersection of the two images. The number of bands in the image is equal to the smallest number of bands of the two sources. The data type is the smallest data type to have sufficient range for both input data types.

Overrides:
subtract in class Token
Parameters:
rightArgument - The token to subtract from this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the data type is not supported.

toString

public java.lang.String toString()
Return a description of the token. If possible, derived classes should override this method and return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. Unfortunately, in this base class, we can only return the a partial description of the token.

Overrides:
toString in class Token
Returns:
A string representation of a record that partially describes the token.

_parameterize

private java.awt.image.renderable.ParameterBlock _parameterize(javax.media.jai.RenderedOp left,
                                                               JAIImageToken right)