Source Code Cross Referenced for BandSelectDescriptor.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: BandSelectDescriptor.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.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 "BandSelect" operation.
028:         *
029:         * <p> The BandSelect operation chooses <code>N</code> bands from a
030:         * rendered or renderable source image and copies the pixel data of
031:         * these bands to the destination image in the order specified.  The
032:         * <code>bandIndices</code> parameter specifies the source band
033:         * indices, and its size (<code>bandIndices.length</code>) determines
034:         * the number of bands of the destination image.  The destination
035:         * image may have ay number of bands, and a particular band of the
036:         * source image may be repeated in the destination image by specifying
037:         * it multiple times in the <code>bandIndices</code> parameter.
038:         *
039:         * <p> Each of the <code>bandIndices</code> value should be a valid
040:         * band index number of the source image. For example, if the source
041:         * only has two bands, then 1 is a valid band index, but 3 is not. The
042:         * first band is numbered 0.
043:         *
044:         * <p> The destination pixel values are defined by the pseudocode:
045:         * <pre>
046:         * dst[x][y][b] = src[x][y][bandIndices[b]];
047:         * </pre>
048:         *
049:         * <p><table border=1>
050:         * <caption>Resource List</caption>
051:         * <tr><th>Name</th>        <th>Value</th></tr>
052:         * <tr><td>GlobalName</td>  <td>BandSelect</td></tr>
053:         * <tr><td>LocalName</td>   <td>BandSelect</td></tr>
054:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
055:         * <tr><td>Description</td> <td>Selects n number of bands from
056:         *                              an image.</td></tr>
057:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BandSelectDescriptor.html</td></tr>
058:         * <tr><td>Version</td>     <td>1.0</td></tr>
059:         * <tr><td>arg0Desc</td>    <td>The indices of the selected bands.</td></tr>
060:         * </table></p>
061:         *
062:         * <p><table border=1>
063:         * <caption>Parameter List</caption>
064:         * <tr><th>Name</th>        <th>Class Type</th>
065:         *                          <th>Default Value</th></tr>
066:         * <tr><td>bandIndices</td> <td>int[]</td>
067:         *                          <td>NO_PARAMETER_DEFAULT</td>
068:         * </table></p>
069:         *
070:         * @see javax.media.jai.OperationDescriptor
071:         */
072:        public class BandSelectDescriptor extends OperationDescriptorImpl {
073:
074:            /**
075:             * The resource strings that provide the general documentation
076:             * and specify the parameter list for this operation.
077:             */
078:            private static final String[][] resources = {
079:                    { "GlobalName", "BandSelect" },
080:                    { "LocalName", "BandSelect" },
081:                    { "Vendor", "com.sun.media.jai" },
082:                    { "Description", JaiI18N.getString("BandSelectDescriptor0") },
083:                    {
084:                            "DocURL",
085:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BandSelectDescriptor.html" },
086:                    { "Version", JaiI18N.getString("DescriptorVersion") },
087:                    { "arg0Desc", JaiI18N.getString("BandSelectDescriptor1") } };
088:
089:            /** The parameter class list for this operation. */
090:            private static final Class[] paramClasses = { int[].class };
091:
092:            /** The parameter name list for this operation. */
093:            private static final String[] paramNames = { "bandIndices" };
094:
095:            /** The parameter default value list for this operation. */
096:            private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
097:
098:            private static final String[] supportedModes = { "rendered",
099:                    "renderable" };
100:
101:            /** Constructor. */
102:            public BandSelectDescriptor() {
103:                super (resources, supportedModes, 1, paramNames, paramClasses,
104:                        paramDefaults, null);
105:            }
106:
107:            /**
108:             * Validates the input source and parameters.
109:             *
110:             * <p> In addition to the standard checks performed by the
111:             * superclass method, this method checks that "bandIndices" has a
112:             * length of at least 1 and does not contain any values less than
113:             * 0 or greater than the number of source bands minus 1.
114:             */
115:            public boolean validateArguments(String modeName,
116:                    ParameterBlock args, StringBuffer message) {
117:                if (!super .validateArguments(modeName, args, message)) {
118:                    return false;
119:                }
120:
121:                if (!modeName.equalsIgnoreCase("rendered"))
122:                    return true;
123:
124:                int[] indices = (int[]) args.getObjectParameter(0);
125:                if (indices.length < 1) {
126:                    message.append(getName() + " "
127:                            + JaiI18N.getString("BandSelectDescriptor2"));
128:                    return false;
129:                }
130:
131:                RenderedImage src = args.getRenderedSource(0);
132:
133:                int bands = src.getSampleModel().getNumBands();
134:                for (int i = 0; i < indices.length; i++) {
135:                    if (indices[i] < 0 || indices[i] >= bands) {
136:                        message.append(getName() + " "
137:                                + JaiI18N.getString("BandSelectDescriptor3"));
138:                        return false;
139:                    }
140:                }
141:
142:                return true;
143:            }
144:
145:            /**
146:             * Selects n number of bands from an image.
147:             *
148:             * <p>Creates a <code>ParameterBlockJAI</code> from all
149:             * supplied arguments except <code>hints</code> and invokes
150:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
151:             *
152:             * @see JAI
153:             * @see ParameterBlockJAI
154:             * @see RenderedOp
155:             *
156:             * @param source0 <code>RenderedImage</code> source 0.
157:             * @param bandIndices The indices of the selected bands.
158:             * @param hints The <code>RenderingHints</code> to use.
159:             * May be <code>null</code>.
160:             * @return The <code>RenderedOp</code> destination.
161:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
162:             * @throws IllegalArgumentException if <code>bandIndices</code> is <code>null</code>.
163:             */
164:            public static RenderedOp create(RenderedImage source0,
165:                    int[] bandIndices, RenderingHints hints) {
166:                ParameterBlockJAI pb = new ParameterBlockJAI("BandSelect",
167:                        RenderedRegistryMode.MODE_NAME);
168:
169:                pb.setSource("source0", source0);
170:
171:                pb.setParameter("bandIndices", bandIndices);
172:
173:                return JAI.create("BandSelect", pb, hints);
174:            }
175:
176:            /**
177:             * Selects n number of bands from an image.
178:             *
179:             * <p>Creates a <code>ParameterBlockJAI</code> from all
180:             * supplied arguments except <code>hints</code> and invokes
181:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
182:             *
183:             * @see JAI
184:             * @see ParameterBlockJAI
185:             * @see RenderableOp
186:             *
187:             * @param source0 <code>RenderableImage</code> source 0.
188:             * @param bandIndices The indices of the selected bands.
189:             * @param hints The <code>RenderingHints</code> to use.
190:             * May be <code>null</code>.
191:             * @return The <code>RenderableOp</code> destination.
192:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
193:             * @throws IllegalArgumentException if <code>bandIndices</code> is <code>null</code>.
194:             */
195:            public static RenderableOp createRenderable(
196:                    RenderableImage source0, int[] bandIndices,
197:                    RenderingHints hints) {
198:                ParameterBlockJAI pb = new ParameterBlockJAI("BandSelect",
199:                        RenderableRegistryMode.MODE_NAME);
200:
201:                pb.setSource("source0", source0);
202:
203:                pb.setParameter("bandIndices", bandIndices);
204:
205:                return JAI.createRenderable("BandSelect", pb, hints);
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.