Source Code Cross Referenced for ConstantDescriptor.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: ConstantDescriptor.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:32 $
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:        import javax.media.jai.util.Range;
026:
027:        /**
028:         * An <code>OperationDescriptor</code> describing the "Constant"
029:         * operation.
030:         * 
031:         * <p> The Constant operation creates a multi-banded, tiled rendered
032:         * image, where all the pixels from the same band have a constant
033:         * value.  The width and height of the image must be specified and
034:         * greater than 0. At least one constant must be supplied. The number
035:         * of bands of the image is determined by the number of constant pixel
036:         * values supplied in the "bandValues" parameter. The data type is
037:         * determined by the type of the constants; this means all elements of
038:         * the <code>bandValues</code> array must be of the same type.
039:         *
040:         * <p> If the <code>bandValues</code> array is a <code>Short</code>
041:         * array, then <code>TYPE_USHORT</code> is used if all values are
042:         * non-negative; otherwise <code>TYPE_SHORT</code> is used.
043:         *
044:         * <p><table border=1>
045:         * <caption>Resource List</caption>
046:         * <tr><th>Name</th>        <th>Value</th></tr>
047:         * <tr><td>GlobalName</td>  <td>Constant</td></tr>
048:         * <tr><td>LocalName</td>   <td>Constant</td></tr>
049:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
050:         * <tr><td>Description</td> <td>Creates an image with
051:         *                              constant pixel values.</td></tr>
052:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ConstantDescriptor.html</td></tr>
053:         * <tr><td>Version</td>     <td>1.0</td></tr>
054:         * <tr><td>arg0Desc</td>    <td>Image width in pixels.</td></tr>
055:         * <tr><td>arg1Desc</td>    <td>Image height in pixels.</td></tr>
056:         * <tr><td>arg2Desc</td>    <td>The constant pixel band values.</td></tr>
057:         * </table></p>
058:         *
059:         * <p><table border=1>
060:         * <caption>Parameter List</caption>
061:         * <tr><th>Name</th>       <th>Class Type</th>
062:         *                         <th>Default Value</th></tr>
063:         * <tr><td>width</td>      <td>java.lang.Float</td>
064:         *                         <td>NO_PARAMETER_DEFAULT</td>
065:         * <tr><td>height</td>     <td>java.lang.Float</td>
066:         *                         <td>NO_PARAMETER_DEFAULT</td>
067:         * <tr><td>bandValues</td> <td>java.lang.Number[]</td>
068:         *                         <td>NO_PARAMETER_DEFAULT</td>
069:         * </table></p>
070:         *
071:         * @see javax.media.jai.OperationDescriptor
072:         */
073:        public class ConstantDescriptor extends OperationDescriptorImpl {
074:
075:            /**
076:             * The resource strings that provide the general documentation
077:             * and specify the parameter list for this operation.
078:             */
079:            private static final String[][] resources = {
080:                    { "GlobalName", "Constant" },
081:                    { "LocalName", "Constant" },
082:                    { "Vendor", "com.sun.media.jai" },
083:                    { "Description", JaiI18N.getString("ConstantDescriptor0") },
084:                    {
085:                            "DocURL",
086:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/ConstantDescriptor.html" },
087:                    { "Version", JaiI18N.getString("DescriptorVersion") },
088:                    { "arg0Desc", JaiI18N.getString("ConstantDescriptor1") },
089:                    { "arg1Desc", JaiI18N.getString("ConstantDescriptor2") },
090:                    { "arg2Desc", JaiI18N.getString("ConstantDescriptor3") } };
091:
092:            /** The parameter class list for this operation. */
093:            private static final Class[] paramClasses = {
094:                    java.lang.Float.class, java.lang.Float.class,
095:                    java.lang.Number[].class };
096:
097:            /** The parameter name list for this operation. */
098:            private static final String[] paramNames = { "width", "height",
099:                    "bandValues" };
100:
101:            /** The parameter default value list for this operation. */
102:            private static final Object[] paramDefaults = {
103:                    NO_PARAMETER_DEFAULT, NO_PARAMETER_DEFAULT,
104:                    NO_PARAMETER_DEFAULT };
105:
106:            private static final String[] supportedModes = { "rendered",
107:                    "renderable" };
108:
109:            private static final Object[] validParamValues = {
110:                    new Range(Float.class, new Float(0.0F), false, null, false),
111:                    new Range(Float.class, new Float(0.0F), false, null, false),
112:                    null };
113:
114:            /** Constructor. */
115:            public ConstantDescriptor() {
116:                super (resources, supportedModes, 0, paramNames, paramClasses,
117:                        paramDefaults, validParamValues);
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 "width" and "height"
125:             * are greater than 0 (for rendered mode) and that "bandValues" has
126:             * length at least 1.
127:             */
128:            protected boolean validateParameters(String modeName,
129:                    ParameterBlock args, StringBuffer message) {
130:                if (!super .validateParameters(modeName, args, message)) {
131:                    return false;
132:                }
133:
134:                int length = ((Number[]) args.getObjectParameter(2)).length;
135:                if (length < 1) {
136:                    message.append(getName() + " "
137:                            + JaiI18N.getString("ConstantDescriptor4"));
138:                    return false;
139:                }
140:
141:                if (modeName.equalsIgnoreCase("rendered")) {
142:                    int width = Math.round(args.getFloatParameter(0));
143:                    int height = Math.round(args.getFloatParameter(1));
144:
145:                    if ((width < 1) || (height < 1)) {
146:                        message.append(getName() + " "
147:                                + JaiI18N.getString("ConstantDescriptor5"));
148:                        return false;
149:                    }
150:                } else if (modeName.equalsIgnoreCase("renderable")) {
151:                    float width = args.getFloatParameter(0);
152:                    float height = args.getFloatParameter(1);
153:
154:                    if ((width <= 0.0F) || (height <= 0.0F)) {
155:                        message.append(getName() + " "
156:                                + JaiI18N.getString("ConstantDescriptor6"));
157:                        return false;
158:                    }
159:                }
160:
161:                return true;
162:            }
163:
164:            /**
165:             * Creates an image with constant pixel values.
166:             *
167:             * <p>Creates a <code>ParameterBlockJAI</code> from all
168:             * supplied arguments except <code>hints</code> and invokes
169:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
170:             *
171:             * @see JAI
172:             * @see ParameterBlockJAI
173:             * @see RenderedOp
174:             *
175:             * @param width Image width in pixels.
176:             * @param height Image height in pixels.
177:             * @param bandValues The constant pixel band values.
178:             * @param hints The <code>RenderingHints</code> to use.
179:             * May be <code>null</code>.
180:             * @return The <code>RenderedOp</code> destination.
181:             * @throws IllegalArgumentException if <code>width</code> is <code>null</code>.
182:             * @throws IllegalArgumentException if <code>height</code> is <code>null</code>.
183:             * @throws IllegalArgumentException if <code>bandValues</code> is <code>null</code>.
184:             */
185:            public static RenderedOp create(Float width, Float height,
186:                    Number[] bandValues, RenderingHints hints) {
187:                ParameterBlockJAI pb = new ParameterBlockJAI("Constant",
188:                        RenderedRegistryMode.MODE_NAME);
189:
190:                pb.setParameter("width", width);
191:                pb.setParameter("height", height);
192:                pb.setParameter("bandValues", bandValues);
193:
194:                return JAI.create("Constant", pb, hints);
195:            }
196:
197:            /**
198:             * Creates an image with constant pixel values.
199:             *
200:             * <p>Creates a <code>ParameterBlockJAI</code> from all
201:             * supplied arguments except <code>hints</code> and invokes
202:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
203:             *
204:             * @see JAI
205:             * @see ParameterBlockJAI
206:             * @see RenderableOp
207:             *
208:             * @param width Image width in pixels.
209:             * @param height Image height in pixels.
210:             * @param bandValues The constant pixel band values.
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>width</code> is <code>null</code>.
215:             * @throws IllegalArgumentException if <code>height</code> is <code>null</code>.
216:             * @throws IllegalArgumentException if <code>bandValues</code> is <code>null</code>.
217:             */
218:            public static RenderableOp createRenderable(Float width,
219:                    Float height, Number[] bandValues, RenderingHints hints) {
220:                ParameterBlockJAI pb = new ParameterBlockJAI("Constant",
221:                        RenderableRegistryMode.MODE_NAME);
222:
223:                pb.setParameter("width", width);
224:                pb.setParameter("height", height);
225:                pb.setParameter("bandValues", bandValues);
226:
227:                return JAI.createRenderable("Constant", 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.