1 /* 2 * $RCSfile: StreamDescriptor.java,v $ 3 * 4 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 5 * 6 * Use is subject to license terms. 7 * 8 * $Revision: 1.1 $ 9 * $Date: 2005/02/11 04:57:44 $ 10 * $State: Exp $ 11 */ 12 package com.lightcrafts.mediax.jai.operator; 13 import com.lightcrafts.media.jai.codec.ImageDecodeParam; 14 import com.lightcrafts.media.jai.codec.SeekableStream; 15 import java.awt.RenderingHints; 16 import java.awt.image.renderable.ParameterBlock; 17 import com.lightcrafts.mediax.jai.JAI; 18 import com.lightcrafts.mediax.jai.OperationDescriptorImpl; 19 import com.lightcrafts.mediax.jai.ParameterBlockJAI; 20 import com.lightcrafts.mediax.jai.RenderedOp; 21 import com.lightcrafts.mediax.jai.registry.RenderedRegistryMode; 22 23 /** 24 * An <code>OperationDescriptor</code> describing the "Stream" operation. 25 * 26 * <p> The Stream operation produces an image by decoding data from a 27 * <code>SeekableStream</code>. The allowable formats are those 28 * registered with the <code>com.lightcrafts.media.jai.codec.ImageCodec</code> 29 * class. 30 * 31 * <p> The allowable formats are those registered with the 32 * <code>com.lightcrafts.media.jai.codec.ImageCodec</code> class. 33 * 34 * <p> The second parameter contains an instance of 35 * <code>ImageDecodeParam</code> to be used during the decoding. 36 * It may be set to <code>null</code> in order to perform default 37 * decoding, or equivalently may be omitted. 38 * 39 * <p><b> The classes in the <code>com.lightcrafts.media.jai.codec</code> 40 * package are not a committed part of the JAI API. Future releases 41 * of JAI will make use of new classes in their place. This 42 * class will change accordingly.</b> 43 * 44 * <p><table border=1> 45 * <caption>Resource List</caption> 46 * <tr><th>Name</th> <th>Value</th></tr> 47 * <tr><td>GlobalName</td> <td>stream</td></tr> 48 * <tr><td>LocalName</td> <td>stream</td></tr> 49 * <tr><td>Vendor</td> <td>com.lightcrafts.media.jai</td></tr> 50 * <tr><td>Description</td> <td>Reads an image from a SeekableStream.</td></tr> 51 * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/StreamDescriptor.html</td></tr> 52 * <tr><td>Version</td> <td>1.0</td></tr> 53 * <tr><td>arg0Desc</td> <td>The SeekableStream to read from.</td></tr> 54 * <tr><td>arg1Desc</td> <td>The ImageDecodeParam to use.</td></tr> 55 * </table></p> 56 * 57 * <p><table border=1> 58 * <caption>Parameter List</caption> 59 * <tr><th>Name</th> <th>Class Type</th> 60 * <th>Default Value</th></tr> 61 * <tr><td>stream</td> <td>com.lightcrafts.media.jai.codec.SeekableStream</td> 62 * <td>NO_PARAMETER_DEFAULT</td> 63 * <tr><td>param</td> <td>com.lightcrafts.media.jai.codec.ImageDecodeParam</td> 64 * <td>null</td> 65 * </table></p> 66 * 67 * @see com.lightcrafts.mediax.jai.OperationDescriptor 68 */ 69 public class StreamDescriptor extends OperationDescriptorImpl { 70 71 /** 72 * The resource strings that provide the general documentation and 73 * specify the parameter list for the "Stream" operation. 74 */ 75 private static final String[][] resources = { 76 {"GlobalName", "Stream"}, 77 {"LocalName", "Stream"}, 78 {"Vendor", "com.lightcrafts.media.jai"}, 79 {"Description", JaiI18N.getString("StreamDescriptor0")}, 80 {"DocURL", "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/StreamDescriptor.html"}, 81 {"Version", JaiI18N.getString("DescriptorVersion")}, 82 {"arg0Desc", JaiI18N.getString("StreamDescriptor1")}, 83 {"arg1Desc", JaiI18N.getString("StreamDescriptor2")} 84 }; 85 86 /** The parameter names for the "Stream" operation. */ 87 private static final String[] paramNames = { 88 "stream", "param" 89 }; 90 91 /** The parameter class types for the "Stream" operation. */ 92 private static final Class[] paramClasses = { 93 com.lightcrafts.media.jai.codec.SeekableStream.class, 94 com.lightcrafts.media.jai.codec.ImageDecodeParam.class 95 }; 96 97 /** The parameter default values for the "Stream" operation. */ 98 private static final Object[] paramDefaults = { 99 NO_PARAMETER_DEFAULT, null 100 }; 101 102 /** Constructor. */ StreamDescriptor()103 public StreamDescriptor() { 104 super(resources, 0, paramClasses, paramNames, paramDefaults); 105 } 106 107 108 /** 109 * Reads an image from a SeekableStream. 110 * 111 * <p>Creates a <code>ParameterBlockJAI</code> from all 112 * supplied arguments except <code>hints</code> and invokes 113 * {@link JAI#create(String,ParameterBlock,RenderingHints)}. 114 * 115 * @see JAI 116 * @see ParameterBlockJAI 117 * @see RenderedOp 118 * 119 * @param stream The SeekableStream to read from. 120 * @param param The ImageDecodeParam to use. 121 * May be <code>null</code>. 122 * @param hints The <code>RenderingHints</code> to use. 123 * May be <code>null</code>. 124 * @return The <code>RenderedOp</code> destination. 125 * @throws IllegalArgumentException if <code>stream</code> is <code>null</code>. 126 */ create(SeekableStream stream, ImageDecodeParam param, RenderingHints hints)127 public static RenderedOp create(SeekableStream stream, 128 ImageDecodeParam param, 129 RenderingHints hints) { 130 ParameterBlockJAI pb = 131 new ParameterBlockJAI("Stream", 132 RenderedRegistryMode.MODE_NAME); 133 134 pb.setParameter("stream", stream); 135 pb.setParameter("param", param); 136 137 return JAI.create("Stream", pb, hints); 138 } 139 } 140