Source Code Cross Referenced for RescaleDescriptor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » operator » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai.operator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: RescaleDescriptor.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:43 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.operator;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.RenderedImage;
016:        import java.awt.image.renderable.ParameterBlock;
017:        import java.awt.image.renderable.RenderableImage;
018:        import javax.media.jai.JAI;
019:        import javax.media.jai.OperationDescriptorImpl;
020:        import javax.media.jai.ParameterBlockJAI;
021:        import javax.media.jai.RenderableOp;
022:        import javax.media.jai.RenderedOp;
023:        import javax.media.jai.registry.RenderableRegistryMode;
024:        import javax.media.jai.registry.RenderedRegistryMode;
025:
026:        /**
027:         * An <code>OperationDescriptor</code> describing the "Rescale" operation.
028:         *
029:         * <p> The "Rescale" operation takes a rendered or renderable source
030:         * image and maps the pixel values of an image from one range to
031:         * another range by multiplying each pixel value by one of a set of
032:         * constants and then adding another constant to the result of the
033:         * multiplication.  If the number of constants supplied is less than
034:         * the number of bands of the destination, then the constant from
035:         * entry 0 is applied to all the bands. Otherwise, a constant from a
036:         * different entry is applied to each band. There must be at least one
037:         * entry in each of the contants and offsets arrays.
038:         *
039:         * <p> The destination pixel values are defined by the pseudocode:
040:         * <pre>
041:         * constant = (constants.length < dstNumBands) ?
042:         *            constants[0] : constants[b];
043:         * offset = (offsets.length < dstNumBands) ?
044:         *          offsets[0] : offsets[b];
045:         *
046:         * dst[x][y][b] = src[x][y][b]*constant + offset;
047:         * </pre>
048:         *
049:         * <p> The pixel arithmetic is performed using the data type of the
050:         * destination image.  By default, the destination will have the same
051:         * data type as the source image unless an <code>ImageLayout</code>
052:         * containing a <code>SampleModel</code> with a different data type
053:         * is supplied as a rendering hint.
054:         *
055:         * <p><table border=1>
056:         * <caption>Resource List</caption>
057:         * <tr><th>Name</th>        <th>Value</th></tr>
058:         * <tr><td>GlobalName</td>  <td>Rescale</td></tr>
059:         * <tr><td>LocalName</td>   <td>Rescale</td></tr>
060:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
061:         * <tr><td>Description</td> <td>Maps the pixels values of an image from
062:         *                              one range to another range.</td></tr>
063:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/RescaleDescriptor.html</td></tr>
064:         * <tr><td>Version</td>     <td>1.0</td></tr>
065:         * <tr><td>arg0Desc</td>    <td>The per-band constants to multiply by.</td></tr>
066:         * <tr><td>arg1Desc</td>    <td>The per-band offsets to be added.</td></tr>
067:         * </table></p>
068:         *
069:         * <p><table border=1>
070:         * <caption>Parameter List</caption>
071:         * <tr><th>Name</th>   <th>Class Type</th>
072:         *                     <th>Default Value</th></tr>
073:         * <tr><td>constants</td> <td>double[]</td>
074:         *                     <td>{1.0}</td>
075:         * <tr><td>offsets</td> <td>double[]</td>
076:         *                     <td>{0.0}</td>
077:         * </table></p>
078:         *
079:         * @see javax.media.jai.OperationDescriptor
080:         */
081:        public class RescaleDescriptor extends OperationDescriptorImpl {
082:
083:            /**
084:             * The resource strings that provide the general documentation
085:             * and specify the parameter list for this operation.
086:             */
087:            private static final String[][] resources = {
088:                    { "GlobalName", "Rescale" },
089:                    { "LocalName", "Rescale" },
090:                    { "Vendor", "com.sun.media.jai" },
091:                    { "Description", JaiI18N.getString("RescaleDescriptor0") },
092:                    {
093:                            "DocURL",
094:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/RescaleDescriptor.html" },
095:                    { "Version", JaiI18N.getString("DescriptorVersion") },
096:                    { "arg0Desc", JaiI18N.getString("RescaleDescriptor1") },
097:                    { "arg1Desc", JaiI18N.getString("RescaleDescriptor2") } };
098:
099:            /** The parameter class list for this operation. */
100:            private static final Class[] paramClasses = { double[].class,
101:                    double[].class };
102:
103:            /** The parameter name list for this operation. */
104:            private static final String[] paramNames = { "constants", "offsets" };
105:
106:            /** The parameter default value list for this operation. */
107:            private static final Object[] paramDefaults = {
108:                    new double[] { 1.0 }, new double[] { 0.0 } };
109:
110:            /** Constructor. */
111:            public RescaleDescriptor() {
112:                super (resources, 1, paramClasses, paramNames, paramDefaults);
113:            }
114:
115:            /** Returns <code>true</code> since renderable operation is supported. */
116:            public boolean isRenderableSupported() {
117:                return true;
118:            }
119:
120:            /**
121:             * Validates the input parameters.
122:             *
123:             * <p> In addition to the standard checks performed by the
124:             * superclass method, this method checks that the length of the
125:             * "constants" and "offsets" arrays are each at least 1.
126:             */
127:            protected boolean validateParameters(ParameterBlock args,
128:                    StringBuffer msg) {
129:                if (!super .validateParameters(args, msg)) {
130:                    return false;
131:                }
132:
133:                int constantsLength = ((double[]) args.getObjectParameter(0)).length;
134:                int offsetsLength = ((double[]) args.getObjectParameter(1)).length;
135:
136:                if (constantsLength < 1) {
137:                    msg.append(getName() + " "
138:                            + JaiI18N.getString("RescaleDescriptor3"));
139:                    return false;
140:                }
141:
142:                if (offsetsLength < 1) {
143:                    msg.append(getName() + ": "
144:                            + JaiI18N.getString("RescaleDescriptor4"));
145:                    return false;
146:                }
147:
148:                return true;
149:            }
150:
151:            /**
152:             * Maps the pixels values of an image from one range to another range.
153:             *
154:             * <p>Creates a <code>ParameterBlockJAI</code> from all
155:             * supplied arguments except <code>hints</code> and invokes
156:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
157:             *
158:             * @see JAI
159:             * @see ParameterBlockJAI
160:             * @see RenderedOp
161:             *
162:             * @param source0 <code>RenderedImage</code> source 0.
163:             * @param constants The per-band constants to multiply by.
164:             * May be <code>null</code>.
165:             * @param offsets The per-band offsets to be added.
166:             * May be <code>null</code>.
167:             * @param hints The <code>RenderingHints</code> to use.
168:             * May be <code>null</code>.
169:             * @return The <code>RenderedOp</code> destination.
170:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
171:             */
172:            public static RenderedOp create(RenderedImage source0,
173:                    double[] constants, double[] offsets, RenderingHints hints) {
174:                ParameterBlockJAI pb = new ParameterBlockJAI("Rescale",
175:                        RenderedRegistryMode.MODE_NAME);
176:
177:                pb.setSource("source0", source0);
178:
179:                pb.setParameter("constants", constants);
180:                pb.setParameter("offsets", offsets);
181:
182:                return JAI.create("Rescale", pb, hints);
183:            }
184:
185:            /**
186:             * Maps the pixels values of an image from one range to another range.
187:             *
188:             * <p>Creates a <code>ParameterBlockJAI</code> from all
189:             * supplied arguments except <code>hints</code> and invokes
190:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
191:             *
192:             * @see JAI
193:             * @see ParameterBlockJAI
194:             * @see RenderableOp
195:             *
196:             * @param source0 <code>RenderableImage</code> source 0.
197:             * @param constants The per-band constants to multiply by.
198:             * May be <code>null</code>.
199:             * @param offsets The per-band offsets to be added.
200:             * May be <code>null</code>.
201:             * @param hints The <code>RenderingHints</code> to use.
202:             * May be <code>null</code>.
203:             * @return The <code>RenderableOp</code> destination.
204:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
205:             */
206:            public static RenderableOp createRenderable(
207:                    RenderableImage source0, double[] constants,
208:                    double[] offsets, RenderingHints hints) {
209:                ParameterBlockJAI pb = new ParameterBlockJAI("Rescale",
210:                        RenderableRegistryMode.MODE_NAME);
211:
212:                pb.setSource("source0", source0);
213:
214:                pb.setParameter("constants", constants);
215:                pb.setParameter("offsets", offsets);
216:
217:                return JAI.createRenderable("Rescale", pb, hints);
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.