1 /*
2  * $RCSfile: ExpDescriptor.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 java.awt.RenderingHints;
14 import java.awt.image.RenderedImage;
15 import java.awt.image.renderable.RenderableImage;
16 import com.lightcrafts.mediax.jai.JAI;
17 import com.lightcrafts.mediax.jai.OperationDescriptorImpl;
18 import com.lightcrafts.mediax.jai.ParameterBlockJAI;
19 import com.lightcrafts.mediax.jai.RenderableOp;
20 import com.lightcrafts.mediax.jai.RenderedOp;
21 import com.lightcrafts.mediax.jai.registry.RenderableRegistryMode;
22 import com.lightcrafts.mediax.jai.registry.RenderedRegistryMode;
23 
24 /**
25  * An <code>OperationDescriptor</code> describing the "Exp" operation.
26  *
27  * <p> The "Exp" operation takes the exponential of the pixel values
28  * of an image. The pixel values of the destination image are defined
29  * by the pseudocode:
30  *
31  * <pre>dst[x][y][b] = java.lang.Math.exp(src[x][y][b])</pre>
32  *
33  * <p> For integral image datatypes, the result will be rounded and clamped
34  * as needed.
35  *
36  * <p><table border=1>
37  * <caption>Resource List</caption>
38  * <tr><th>Name</th>        <th>Value</th></tr>
39  * <tr><td>GlobalName</td>  <td>Exp</td></tr>
40  * <tr><td>LocalName</td>   <td>Exp</td></tr>
41  * <tr><td>Vendor</td>      <td>com.lightcrafts.media.jai</td></tr>
42  * <tr><td>Description</td> <td>Computes the exponential of the pixel values
43  *                              of an image.</td></tr>
44  * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ExpDescriptor.html</td></tr>
45  * <tr><td>Version</td>     <td>1.0</td></tr>
46  * </table></p>
47  *
48  * <p> No parameters are needed for the "Exp" operation.
49  *
50  * @see com.lightcrafts.mediax.jai.OperationDescriptor
51  */
52 public class ExpDescriptor extends OperationDescriptorImpl {
53 
54     /**
55      * The resource strings that provide the general documentation
56      * and specify the parameter list for this operation.
57      */
58     private static final String[][] resources = {
59         {"GlobalName",  "Exp"},
60         {"LocalName",   "Exp"},
61         {"Vendor",      "com.lightcrafts.media.jai"},
62         {"Description", JaiI18N.getString("ExpDescriptor0")},
63         {"DocURL",      "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ExpDescriptor.html"},
64         {"Version",     JaiI18N.getString("DescriptorVersion")}
65     };
66 
67     /** Constructor. */
ExpDescriptor()68     public ExpDescriptor() {
69         super(resources, 1, null, null, null);
70     }
71 
72     /** Returns <code>true</code> since renderable operation is supported. */
isRenderableSupported()73     public boolean isRenderableSupported() {
74         return true;
75     }
76 
77 
78     /**
79      * Computes the exponential of the pixel values of an image.
80      *
81      * <p>Creates a <code>ParameterBlockJAI</code> from all
82      * supplied arguments except <code>hints</code> and invokes
83      * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
84      *
85      * @see JAI
86      * @see ParameterBlockJAI
87      * @see RenderedOp
88      *
89      * @param source0 <code>RenderedImage</code> source 0.
90      * @param hints The <code>RenderingHints</code> to use.
91      * May be <code>null</code>.
92      * @return The <code>RenderedOp</code> destination.
93      * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
94      */
create(RenderedImage source0, RenderingHints hints)95     public static RenderedOp create(RenderedImage source0,
96                                     RenderingHints hints)  {
97         ParameterBlockJAI pb =
98             new ParameterBlockJAI("Exp",
99                                   RenderedRegistryMode.MODE_NAME);
100 
101         pb.setSource("source0", source0);
102 
103         return JAI.create("Exp", pb, hints);
104     }
105 
106     /**
107      * Computes the exponential of the pixel values of an image.
108      *
109      * <p>Creates a <code>ParameterBlockJAI</code> from all
110      * supplied arguments except <code>hints</code> and invokes
111      * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
112      *
113      * @see JAI
114      * @see ParameterBlockJAI
115      * @see RenderableOp
116      *
117      * @param source0 <code>RenderableImage</code> source 0.
118      * @param hints The <code>RenderingHints</code> to use.
119      * May be <code>null</code>.
120      * @return The <code>RenderableOp</code> destination.
121      * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
122      */
createRenderable(RenderableImage source0, RenderingHints hints)123     public static RenderableOp createRenderable(RenderableImage source0,
124                                                 RenderingHints hints)  {
125         ParameterBlockJAI pb =
126             new ParameterBlockJAI("Exp",
127                                   RenderableRegistryMode.MODE_NAME);
128 
129         pb.setSource("source0", source0);
130 
131         return JAI.createRenderable("Exp", pb, hints);
132     }
133 }
134