Source Code Cross Referenced for BandCombineDescriptor.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: BandCombineDescriptor.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:30 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.operator;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.ColorModel;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.SampleModel;
018:        import java.awt.image.renderable.ParameterBlock;
019:        import java.awt.image.renderable.RenderableImage;
020:        import javax.media.jai.JAI;
021:        import javax.media.jai.OpImage;
022:        import javax.media.jai.OperationDescriptorImpl;
023:        import javax.media.jai.ParameterBlockJAI;
024:        import javax.media.jai.RenderableOp;
025:        import javax.media.jai.RenderedOp;
026:        import javax.media.jai.registry.RenderableRegistryMode;
027:        import javax.media.jai.registry.RenderedRegistryMode;
028:
029:        /**
030:         * An <code>OperationDescriptor</code> describing the "BandCombine" operation.
031:         *
032:         * <p> The BandCombing operation computes a set of arbitrary linear
033:         * combinations of the bands of a rendered or renderable source image,
034:         * using a specified matrix.  The matrix must a number of rows equal to 
035:         * the number of desired destination bands and a number of columns equal to the
036:         * number of source bands plus one.  In other words, the array may be
037:         * constructed using the syntax:
038:         *
039:         * <pre>
040:         * double[][] matrix = new double[destBands][sourceBands + 1];
041:         * </pre>
042:         *
043:         * <p> The number of source bands used to determine the matrix dimensions
044:         * is given by <code>source.getSampleModel().getNumBands()</code> regardless
045:         * of the type of <code>ColorModel</code> the source has.
046:         *
047:         * <p> The extra column in the matrix contains constant values each of which
048:         * is added to the respective band of the destination. The transformation is
049:         * therefore defined by the pseudocode:
050:         *
051:         * <pre>
052:         * // s = source pixel
053:         * // d = destination pixel
054:         * for(int i = 0; i < destBands; i++) {
055:         *     d[i] = matrix[i][sourceBands];
056:         *     for(int j = 0; j < sourceBands; j++) {
057:         *         d[i] += matrix[i][j]*s[j];
058:         *     }
059:         * }
060:         * </pre>
061:         *
062:         * <p> If the result of the computation underflows/overflows the
063:         * minimum/maximum value supported by the destination image, then it
064:         * will be clamped to the minimum/maximum value respectively.
065:         *
066:         * <p><table border=1>
067:         * <caption>Resource List</caption>
068:         * <tr><th>Name</th>        <th>Value</th></tr>
069:         * <tr><td>GlobalName</td>  <td>BandCombine</td></tr>
070:         * <tr><td>LocalName</td>   <td>BandCombine</td></tr>
071:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
072:         * <tr><td>Description</td> <td>Performs arbitrary interband linear combination
073:         *                              using a specified matrix.</td></tr>
074:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BandCombineDescriptor.html</td></tr>
075:         * <tr><td>Version</td>     <td>1.0</td></tr>
076:         * <tr><td>arg0Desc</td>    <td>The matrix specifying the band combination.</td></tr>
077:         * </table></p>
078:         *
079:         * <p><table border=1>
080:         * <caption>Parameter List</caption>
081:         * <tr><th>Name</th>   <th>Class Type</th>
082:         *                     <th>Default Value</th></tr>
083:         * <tr><td>matrix</td> <td>double[][]</td>
084:         *                     <td>NO_PARAMETER_DEFAULT</td>
085:         * </table></p>
086:         *
087:         * @see javax.media.jai.OperationDescriptor
088:         */
089:        public class BandCombineDescriptor extends OperationDescriptorImpl {
090:
091:            /**
092:             * The resource strings that provide the general documentation
093:             * and specify the parameter list for this operation.
094:             */
095:            private static final String[][] resources = {
096:                    { "GlobalName", "BandCombine" },
097:                    { "LocalName", "BandCombine" },
098:                    { "Vendor", "com.sun.media.jai" },
099:                    { "Description",
100:                            JaiI18N.getString("BandCombineDescriptor0") },
101:                    {
102:                            "DocURL",
103:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BandCombineDescriptor.html" },
104:                    { "Version", JaiI18N.getString("DescriptorVersion") },
105:                    { "arg0Desc", JaiI18N.getString("BandCombineDescriptor1") } };
106:
107:            /** The parameter class list for this operation. */
108:            private static final Class[] paramClasses = { double[][].class };
109:
110:            /** The parameter name list for this operation. */
111:            private static final String[] paramNames = { "matrix" };
112:
113:            /** The parameter default value list for this operation. */
114:            private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
115:
116:            private static final String[] supportedModes = { "rendered",
117:                    "renderable" };
118:
119:            /** Constructor. */
120:            public BandCombineDescriptor() {
121:                super (resources, supportedModes, 1, paramNames, paramClasses,
122:                        paramDefaults, null);
123:            }
124:
125:            /**
126:             * Validates the input source and parameters.
127:             *
128:             * <p> In addition to the standard checks performed by the
129:             * superclass method, this method checks that "matrix" has at
130:             * least 1 row and (source bands + 1) columns.
131:             * 
132:             * <p> The number of source bands is considered to be equal to
133:             * <code>source.getSampleModel().getNumBands()</code>.
134:             */
135:            public boolean validateArguments(String modeName,
136:                    ParameterBlock args, StringBuffer message) {
137:                if (!super .validateArguments(modeName, args, message)) {
138:                    return false;
139:                }
140:
141:                if (!modeName.equalsIgnoreCase("rendered"))
142:                    return true;
143:
144:                RenderedImage src = args.getRenderedSource(0);
145:
146:                double[][] matrix = (double[][]) args.getObjectParameter(0);
147:                SampleModel sm = src.getSampleModel();
148:                int rowLength = sm.getNumBands() + 1;
149:
150:                if (matrix.length < 1) {
151:                    message.append(getName() + ": "
152:                            + JaiI18N.getString("BandCombineDescriptor2"));
153:                    return false;
154:                }
155:
156:                for (int i = 0; i < matrix.length; i++) {
157:                    if (matrix[i].length != rowLength) {
158:                        message.append(getName() + ": "
159:                                + JaiI18N.getString("BandCombineDescriptor2"));
160:                        return false;
161:                    }
162:                }
163:
164:                return true;
165:            }
166:
167:            /**
168:             * Performs arbitrary interband linear combination using a specified matrix.
169:             *
170:             * <p>Creates a <code>ParameterBlockJAI</code> from all
171:             * supplied arguments except <code>hints</code> and invokes
172:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
173:             *
174:             * @see JAI
175:             * @see ParameterBlockJAI
176:             * @see RenderedOp
177:             *
178:             * @param source0 <code>RenderedImage</code> source 0.
179:             * @param matrix The matrix specifying the band combination.
180:             * @param hints The <code>RenderingHints</code> to use.
181:             * May be <code>null</code>.
182:             * @return The <code>RenderedOp</code> destination.
183:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
184:             * @throws IllegalArgumentException if <code>matrix</code> is <code>null</code>.
185:             */
186:            public static RenderedOp create(RenderedImage source0,
187:                    double[][] matrix, RenderingHints hints) {
188:                ParameterBlockJAI pb = new ParameterBlockJAI("BandCombine",
189:                        RenderedRegistryMode.MODE_NAME);
190:
191:                pb.setSource("source0", source0);
192:
193:                pb.setParameter("matrix", matrix);
194:
195:                return JAI.create("BandCombine", pb, hints);
196:            }
197:
198:            /**
199:             * Performs arbitrary interband linear combination using a specified matrix.
200:             *
201:             * <p>Creates a <code>ParameterBlockJAI</code> from all
202:             * supplied arguments except <code>hints</code> and invokes
203:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
204:             *
205:             * @see JAI
206:             * @see ParameterBlockJAI
207:             * @see RenderableOp
208:             *
209:             * @param source0 <code>RenderableImage</code> source 0.
210:             * @param matrix The matrix specifying the band combination.
211:             * @param hints The <code>RenderingHints</code> to use.
212:             * May be <code>null</code>.
213:             * @return The <code>RenderableOp</code> destination.
214:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
215:             * @throws IllegalArgumentException if <code>matrix</code> is <code>null</code>.
216:             */
217:            public static RenderableOp createRenderable(
218:                    RenderableImage source0, double[][] matrix,
219:                    RenderingHints hints) {
220:                ParameterBlockJAI pb = new ParameterBlockJAI("BandCombine",
221:                        RenderableRegistryMode.MODE_NAME);
222:
223:                pb.setSource("source0", source0);
224:
225:                pb.setParameter("matrix", matrix);
226:
227:                return JAI.createRenderable("BandCombine", pb, hints);
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.