001: /*
002: * $RCSfile: StreamDescriptor.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:57:44 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import com.sun.media.jai.codec.ImageDecodeParam;
015: import com.sun.media.jai.codec.SeekableStream;
016: import java.awt.RenderingHints;
017: import java.awt.image.RenderedImage;
018: import java.awt.image.renderable.ParameterBlock;
019: import javax.media.jai.JAI;
020: import javax.media.jai.OperationDescriptorImpl;
021: import javax.media.jai.ParameterBlockJAI;
022: import javax.media.jai.RenderedOp;
023: import javax.media.jai.registry.RenderedRegistryMode;
024:
025: /**
026: * An <code>OperationDescriptor</code> describing the "Stream" operation.
027: *
028: * <p> The Stream operation produces an image by decoding data from a
029: * <code>SeekableStream</code>. The allowable formats are those
030: * registered with the <code>com.sun.media.jai.codec.ImageCodec</code>
031: * class.
032: *
033: * <p> The allowable formats are those registered with the
034: * <code>com.sun.media.jai.codec.ImageCodec</code> class.
035: *
036: * <p> The second parameter contains an instance of
037: * <code>ImageDecodeParam</code> to be used during the decoding.
038: * It may be set to <code>null</code> in order to perform default
039: * decoding, or equivalently may be omitted.
040: *
041: * <p><b> The classes in the <code>com.sun.media.jai.codec</code>
042: * package are not a committed part of the JAI API. Future releases
043: * of JAI will make use of new classes in their place. This
044: * class will change accordingly.</b>
045: *
046: * <p><table border=1>
047: * <caption>Resource List</caption>
048: * <tr><th>Name</th> <th>Value</th></tr>
049: * <tr><td>GlobalName</td> <td>stream</td></tr>
050: * <tr><td>LocalName</td> <td>stream</td></tr>
051: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
052: * <tr><td>Description</td> <td>Reads an image from a SeekableStream.</td></tr>
053: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/StreamDescriptor.html</td></tr>
054: * <tr><td>Version</td> <td>1.0</td></tr>
055: * <tr><td>arg0Desc</td> <td>The SeekableStream to read from.</td></tr>
056: * <tr><td>arg1Desc</td> <td>The ImageDecodeParam to use.</td></tr>
057: * </table></p>
058: *
059: * <p><table border=1>
060: * <caption>Parameter List</caption>
061: * <tr><th>Name</th> <th>Class Type</th>
062: * <th>Default Value</th></tr>
063: * <tr><td>stream</td> <td>com.sun.media.jai.codec.SeekableStream</td>
064: * <td>NO_PARAMETER_DEFAULT</td>
065: * <tr><td>param</td> <td>com.sun.media.jai.codec.ImageDecodeParam</td>
066: * <td>null</td>
067: * </table></p>
068: *
069: * @see javax.media.jai.OperationDescriptor
070: */
071: public class StreamDescriptor extends OperationDescriptorImpl {
072:
073: /**
074: * The resource strings that provide the general documentation and
075: * specify the parameter list for the "Stream" operation.
076: */
077: private static final String[][] resources = {
078: { "GlobalName", "Stream" },
079: { "LocalName", "Stream" },
080: { "Vendor", "com.sun.media.jai" },
081: { "Description", JaiI18N.getString("StreamDescriptor0") },
082: {
083: "DocURL",
084: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/StreamDescriptor.html" },
085: { "Version", JaiI18N.getString("DescriptorVersion") },
086: { "arg0Desc", JaiI18N.getString("StreamDescriptor1") },
087: { "arg1Desc", JaiI18N.getString("StreamDescriptor2") } };
088:
089: /** The parameter names for the "Stream" operation. */
090: private static final String[] paramNames = { "stream", "param" };
091:
092: /** The parameter class types for the "Stream" operation. */
093: private static final Class[] paramClasses = {
094: com.sun.media.jai.codec.SeekableStream.class,
095: com.sun.media.jai.codec.ImageDecodeParam.class };
096:
097: /** The parameter default values for the "Stream" operation. */
098: private static final Object[] paramDefaults = {
099: NO_PARAMETER_DEFAULT, null };
100:
101: /** Constructor. */
102: public StreamDescriptor() {
103: super (resources, 0, paramClasses, paramNames, paramDefaults);
104: }
105:
106: /**
107: * Reads an image from a SeekableStream.
108: *
109: * <p>Creates a <code>ParameterBlockJAI</code> from all
110: * supplied arguments except <code>hints</code> and invokes
111: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
112: *
113: * @see JAI
114: * @see ParameterBlockJAI
115: * @see RenderedOp
116: *
117: * @param stream The SeekableStream to read from.
118: * @param param The ImageDecodeParam to use.
119: * May be <code>null</code>.
120: * @param hints The <code>RenderingHints</code> to use.
121: * May be <code>null</code>.
122: * @return The <code>RenderedOp</code> destination.
123: * @throws IllegalArgumentException if <code>stream</code> is <code>null</code>.
124: */
125: public static RenderedOp create(SeekableStream stream,
126: ImageDecodeParam param, RenderingHints hints) {
127: ParameterBlockJAI pb = new ParameterBlockJAI("Stream",
128: RenderedRegistryMode.MODE_NAME);
129:
130: pb.setParameter("stream", stream);
131: pb.setParameter("param", param);
132:
133: return JAI.create("Stream", pb, hints);
134: }
135: }
|