1 /*
2  * $RCSfile: FPXDescriptor.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:35 $
10  * $State: Exp $
11  */
12 package com.lightcrafts.mediax.jai.operator;
13 import com.lightcrafts.media.jai.codec.FPXDecodeParam;
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 "FPX" operation.
25  *
26  * The "FPX" operation reads an image from a FlashPix stream.
27  *
28  * <p> The second parameter contains an instance of
29  * <code>FPXDecodeParam</code> to be used during the decoding.
30  * It may be set to <code>null</code> in order to perform default
31  * decoding, or equivalently may be omitted.
32  *
33  * <p><b> The classes in the <code>com.lightcrafts.media.jai.codec</code>
34  * package are not a committed part of the JAI API.  Future releases
35  * of JAI will make use of new classes in their place.  This
36  * class will change accordingly.</b>
37  *
38  * <p><table border=1>
39  * <caption>Resource List</caption>
40  * <tr><th>Name</th>        <th>Value</th></tr>
41  * <tr><td>GlobalName</td>  <td>FPX</td></tr>
42  * <tr><td>LocalName</td>   <td>FPX</td></tr>
43  * <tr><td>Vendor</td>      <td>com.lightcrafts.media.jai</td></tr>
44  * <tr><td>Description</td> <td>Reads an image from a FlashPix stream.</td></tr>
45  * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/FPXDescriptor.html</td></tr>
46  * <tr><td>Version</td>     <td>1.0</td></tr>
47  * <tr><td>arg0Desc</td>    <td>The SeekableStream to read from.</td></tr>
48  * <tr><td>arg1Desc</td>    <td>The FPXDecodeParam to use.</td></tr>
49  * </table></p>
50  *
51  * <p><table border=1>
52  * <caption>Parameter List</caption>
53  * <tr><th>Name</th>          <th>Class Type</th>
54  *                            <th>Default Value</th></tr>
55  * <tr><td>stream</td>        <td>com.lightcrafts.media.jai.codec.SeekableStream</td>
56  *                            <td>NO_PARAMETER_DEFAULT</td>
57  * <tr><td>param</td>         <td>com.lightcrafts.media.jai.codec.FPXDecodeParam</td>
58  *                            <td>null</td>
59  * </table></p>
60  *
61  * @see com.lightcrafts.media.jai.codec.SeekableStream
62  * @see com.lightcrafts.mediax.jai.OperationDescriptor
63  */
64 public class FPXDescriptor extends OperationDescriptorImpl {
65 
66     /** Convenience name for the Max Resolution of an FPX image */
67     public static final Integer MAX_RESOLUTION = new Integer(-1);
68 
69     /**
70      * The resource strings that provide the general documentation and
71      * specify the parameter list for the "FPX" operation.
72      */
73     private static final String[][] resources = {
74         {"GlobalName",  "FPX"},
75         {"LocalName",   "FPX"},
76         {"Vendor",      "com.lightcrafts.media.jai"},
77         {"Description", JaiI18N.getString("FPXDescriptor0")},
78         {"DocURL",      "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/FPXDescriptor.html"},
79         {"Version",     JaiI18N.getString("DescriptorVersion")},
80         {"arg0Desc",    JaiI18N.getString("FPXDescriptor1")},
81         {"arg1Desc",    JaiI18N.getString("FPXDescriptor2")}
82     };
83 
84     /** The parameter names for the "FPX" operation. */
85     private static final String[] paramNames = {
86         "stream", "param"
87     };
88 
89     /** The parameter class types for the "FPX" operation. */
90     private static final Class[] paramClasses = {
91         com.lightcrafts.media.jai.codec.SeekableStream.class,
92         com.lightcrafts.media.jai.codec.FPXDecodeParam.class
93     };
94 
95     /** The parameter default values for the "FPX" operation. */
96     private static final Object[] paramDefaults = {
97         NO_PARAMETER_DEFAULT, null
98     };
99 
100     /** Constructor. */
FPXDescriptor()101     public FPXDescriptor() {
102         super(resources, 0, paramClasses, paramNames, paramDefaults);
103     }
104 
105 
106     /**
107      * Reads an image from a FlashPix stream.
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 FPXDecodeParam 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      */
create(SeekableStream stream, FPXDecodeParam param, RenderingHints hints)125     public static RenderedOp create(SeekableStream stream,
126                                     FPXDecodeParam param,
127                                     RenderingHints hints)  {
128         ParameterBlockJAI pb =
129             new ParameterBlockJAI("FPX",
130                                   RenderedRegistryMode.MODE_NAME);
131 
132         pb.setParameter("stream", stream);
133         pb.setParameter("param", param);
134 
135         return JAI.create("FPX", pb, hints);
136     }
137 }
138