001: /*
002: * $RCSfile: PNMDescriptor.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:42 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import com.sun.media.jai.codec.SeekableStream;
015: import java.awt.RenderingHints;
016: import java.awt.image.RenderedImage;
017: import java.awt.image.renderable.ParameterBlock;
018: import javax.media.jai.JAI;
019: import javax.media.jai.OperationDescriptorImpl;
020: import javax.media.jai.ParameterBlockJAI;
021: import javax.media.jai.RenderedOp;
022: import javax.media.jai.registry.RenderedRegistryMode;
023:
024: /**
025: * An <code>OperationDescriptor</code> describing the "PNM" operation.
026: *
027: * <p>The "PNM" operation reads a standard PNM file, including PBM,
028: * PGM, and PPM images of both ASCII and raw formats. It stores the
029: * image data into an appropriate <code>SampleModel</code>,
030: *
031: * <p><b> The classes in the <code>com.sun.media.jai.codec</code>
032: * package are not a committed part of the JAI API. Future releases
033: * of JAI will make use of new classes in their place. This
034: * class will change accordingly.</b>
035: *
036: * <p><table border=1>
037: * <caption>Resource List</caption>
038: * <tr><th>Name</th> <th>Value</th></tr>
039: * <tr><td>GlobalName</td> <td>PNM</td></tr>
040: * <tr><td>LocalName</td> <td>PNM</td></tr>
041: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
042: * <tr><td>Description</td> <td>Reads a standard PNM file.</td></tr>
043: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/PNMDescriptor.html</td></tr>
044: * <tr><td>Version</td> <td>1.0</td></tr>
045: * <tr><td>arg0Desc</td> <td>A SeekableStream representing the PNM file.</td></tr>
046: * </table></p>
047: *
048: * <p><table border=1>
049: * <caption>Parameter List</caption>
050: * <tr><th>Name</th> <th>Class Type</th>
051: * <th>Default Value</th></tr>
052: * <tr><td>stream</td> <td>com.sun.media.jai.codec.SeekableStream</td>
053: * <td>NO_PARAMETER_DEFAULT</td>
054: * </table></p>
055: *
056: * @see com.sun.media.jai.codec.SeekableStream
057: * @see javax.media.jai.OperationDescriptor
058: */
059: public class PNMDescriptor extends OperationDescriptorImpl {
060:
061: /**
062: * The resource strings that provide the general documentation and
063: * specify the parameter list for the "PNM" operation.
064: */
065: private static final String[][] resources = {
066: { "GlobalName", "PNM" },
067: { "LocalName", "PNM" },
068: { "Vendor", "com.sun.media.jai" },
069: { "Description", JaiI18N.getString("PNMDescriptor0") },
070: {
071: "DocURL",
072: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/PNMDescriptor.html" },
073: { "Version", JaiI18N.getString("DescriptorVersion") },
074: { "arg0Desc", JaiI18N.getString("PNMDescriptor1") } };
075:
076: /** The parameter names for the "PNM" operation. */
077: private static final String[] paramNames = { "stream" };
078:
079: /** The parameter class types for the "PNM" operation. */
080: private static final Class[] paramClasses = { com.sun.media.jai.codec.SeekableStream.class };
081:
082: /** The parameter default values for the "PNM" operation. */
083: private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
084:
085: /** Constructor. */
086: public PNMDescriptor() {
087: super (resources, 0, paramClasses, paramNames, paramDefaults);
088: }
089:
090: /**
091: * Reads a standard PNM file.
092: *
093: * <p>Creates a <code>ParameterBlockJAI</code> from all
094: * supplied arguments except <code>hints</code> and invokes
095: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
096: *
097: * @see JAI
098: * @see ParameterBlockJAI
099: * @see RenderedOp
100: *
101: * @param stream A SeekableStream representing the PNM file.
102: * @param hints The <code>RenderingHints</code> to use.
103: * May be <code>null</code>.
104: * @return The <code>RenderedOp</code> destination.
105: * @throws IllegalArgumentException if <code>stream</code> is <code>null</code>.
106: */
107: public static RenderedOp create(SeekableStream stream,
108: RenderingHints hints) {
109: ParameterBlockJAI pb = new ParameterBlockJAI("PNM",
110: RenderedRegistryMode.MODE_NAME);
111:
112: pb.setParameter("stream", stream);
113:
114: return JAI.create("PNM", pb, hints);
115: }
116: }
|