Source Code Cross Referenced for IDFT3DDescriptor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » ca » forklabs » 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 » ca.forklabs.media.jai.operator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#) $Header: /cvs/jai-operators/src/main/ca/forklabs/media/jai/operator/IDFT3DDescriptor.java,v 1.5 2007/07/17 16:27:27 forklabs Exp $
003:         *
004:         * Copyright (C) 2007  Forklabs Daniel Léonard
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         */
020:
021:        package ca.forklabs.media.jai.operator;
022:
023:        import java.awt.RenderingHints;
024:        import java.awt.image.RenderedImage;
025:        import java.util.Arrays;
026:        import java.util.Collection;
027:        import javax.media.jai.EnumeratedParameter;
028:        import javax.media.jai.JAI;
029:        import javax.media.jai.OperationDescriptor;
030:        import javax.media.jai.ParameterBlockJAI;
031:        import javax.media.jai.ParameterListDescriptor;
032:        import javax.media.jai.operator.DFTDataNature;
033:        import javax.media.jai.operator.DFTScalingType;
034:        import javax.media.jai.registry.CollectionRegistryMode;
035:        import ca.forklabs.media.jai.CollectionDescriptor;
036:
037:        /**
038:         * Class {@code IDFT3DDescriptor} is an {@link OperationDescriptor} describing
039:         * the <em>idft</em> operation for the collection mode. This operation performs
040:         * an inverse 3D Fourier transform on the collection as if it were a cubic data.
041:         * <p>
042:         * The <em>idft</em> operation takes two parameter: - the scaling type and -
043:         * the data nature.
044:         * <p>
045:         * Finally, all the images in the collection must be {@link RenderedImage}.
046:         *
047:         * <table border=1>
048:         * <caption>Resource List</caption>
049:         * <tr><th>Name</th>        <th>Value</th></tr>
050:         * <tr><td>GlobalName</td>  <td>idft</td></tr>
051:         * <tr><td>LocalName</td>   <td>idft</td></tr>
052:         * <tr><td>Vendor</td>      <td>ca.forklabs.media.jai.opimage</td></tr>
053:         * <tr><td>Description</td> <td>3D inverse Fourier transform</td></tr>
054:         * <tr><td>DocURL</td>      <td>n/a</td></tr>
055:         * <tr><td>Version</td>     <td>$Version$</td></tr>
056:         * <tr><td>Arg0Desct</td>   <td>The data scaling type</td></tr>
057:         * <tr><td>Arg1Desct</td>   <td>The data nature</td></tr>
058:         * </table>
059:         *
060:         * <table border=1>
061:         * <caption>Parameter List</caption>
062:         * <tr><th>Name</th>          <th>Class Type</th>               <th>Default Value</th></tr>
063:         * <tr><td>scalingType</td>   <td>{@link DFTScalingType}</td>   <td>{@link #SCALING_DIMENSIONS}</td>
064:         * <tr><td>dataNature</td>    <td>{@link DFTDataNature}</td>    <td>{@link #COMPLEX_TO_REAL}</td>
065:         * </table>
066:         *
067:         * @author   <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.operator.IDFT3DDescriptor">Daniel Léonard</a>
068:         * @version $Revision: 1.5 $
069:         */
070:        public class IDFT3DDescriptor extends CollectionDescriptor {
071:
072:            //---------------------------
073:            // Class variables
074:            //---------------------------
075:
076:            /** <em>serialVersionUID</em>. */
077:            private static final long serialVersionUID = -7533738120094575186L;
078:
079:            /**
080:             * No scaling of the spectral data is made.
081:             */
082:            public static final DFTScalingType SCALING_NONE = DFT3DDescriptor.SCALING_NONE;
083:
084:            /**
085:             * The spectral data is divided by the square root of the product of the
086:             * <em>cubic image</em> dimension.
087:             */
088:            public static final DFTScalingType SCALING_UNITARY = DFT3DDescriptor.SCALING_UNITARY;
089:
090:            /**
091:             * The spectral data is divided by the product of the <em>cubic image</em>
092:             * dimension.
093:             */
094:            public static final DFTScalingType SCALING_DIMENSIONS = DFT3DDescriptor.SCALING_DIMENSIONS;
095:
096:            /**
097:             * Indicates that the source data is in the real domain and that the sink
098:             * data is expected to be in the complex domain.
099:             */
100:            public static final DFTDataNature REAL_TO_COMPLEX = DFT3DDescriptor.REAL_TO_COMPLEX;
101:
102:            /**
103:             * Indicates that the source data is in the complex domain and that the sink
104:             * data is expected to be in the complex domain.
105:             */
106:            public static final DFTDataNature COMPLEX_TO_COMPLEX = DFT3DDescriptor.COMPLEX_TO_COMPLEX;
107:
108:            /**
109:             * Indicates that the source data is in the complex domain and that the sink
110:             * data is expected to be in the real domain.
111:             */
112:            public static final DFTDataNature COMPLEX_TO_REAL = DFT3DDescriptor.COMPLEX_TO_REAL;
113:
114:            /** The name of this operator. */
115:            @SuppressWarnings("nls")
116:            public static final String NAME = "idft";
117:
118:            /** The name of the scaling parameter. */
119:            @SuppressWarnings("nls")
120:            public static final String SCALING_PARAMETER_NAME = DFT3DDescriptor.SCALING_PARAMETER_NAME;
121:            /** The name of the nature parameter. */
122:            @SuppressWarnings("nls")
123:            public static final String NATURE_PARAMETER_NAME = DFT3DDescriptor.NATURE_PARAMETER_NAME;
124:
125:            /** The index in the parameter block of the scaling parameter. */
126:            public static final int SCALING_PARAMETER_INDEX = DFT3DDescriptor.SCALING_PARAMETER_INDEX;
127:            /** The index in the parameter block of the nature parameter. */
128:            public static final int NATURE_PARAMETER_INDEX = DFT3DDescriptor.NATURE_PARAMETER_INDEX;
129:
130:            /** The default value for the scaling type. */
131:            public static final DFTScalingType SCALING_DEFAULT_VALUE = IDFT3DDescriptor.SCALING_DIMENSIONS;
132:            /** The default value for the data nature. */
133:            public static final DFTDataNature NATURE_DEFAULT_VALUE = IDFT3DDescriptor.COMPLEX_TO_REAL;
134:
135:            /**
136:             * The resource strings that provide the general documentation and specify
137:             * the parameter list for this operation.
138:             */
139:            @SuppressWarnings("nls")
140:            private static final String[][] RESOURCES = {
141:                    { "GlobalName", IDFT3DDescriptor.NAME, },
142:                    { "LocalName", IDFT3DDescriptor.NAME, },
143:                    { "Vendor", "ca.forklabs.media.jai.opimage", },
144:                    { "Description", IDFT3DDescriptor.getDescription(), },
145:                    { "DocURL", "n/a", }, { "Version", "$Version$", },
146:                    { "arg0Desc", IDFT3DDescriptor.getArg0Description(), },
147:                    { "arg1Desc", IDFT3DDescriptor.getArg1Description(), }, };
148:
149:            /** The supported modes. */
150:            private static final String[] SUPPORTED_MODES = { CollectionRegistryMode.MODE_NAME, };
151:
152:            /** The name of the source, use default. */
153:            private static final String[] SOURCE_NAMES = null;
154:
155:            /** The type of source for each mode. */
156:            private static final Class<?>[][] SOURCE_CLASSES = new Class<?>[][] { { Collection.class, }, };
157:
158:            /** The parameter list descriptor for all modes. */
159:            private static final ParameterListDescriptor PARAMETER_LIST_DESCRIPTOR = new CollectionDescriptor.EmptyParameterListDescriptor() {
160:
161:                @Override
162:                public String[] getEnumeratedParameterNames() {
163:                    String[] names = new String[] {
164:                            IDFT3DDescriptor.SCALING_PARAMETER_NAME,
165:                            IDFT3DDescriptor.NATURE_PARAMETER_NAME, };
166:                    return names;
167:                }
168:
169:                @Override
170:                @SuppressWarnings({"static-access","synthetic-access"})
171:                public EnumeratedParameter[] getEnumeratedParameterValues(
172:                        String name) {
173:                    EnumeratedParameter[] values;
174:                    if (DFT3DDescriptor.SCALING_PARAMETER_NAME
175:                            .equalsIgnoreCase(name)) {
176:                        values = new EnumeratedParameter[] {
177:                                IDFT3DDescriptor.SCALING_NONE,
178:                                IDFT3DDescriptor.SCALING_UNITARY,
179:                                IDFT3DDescriptor.SCALING_DIMENSIONS, };
180:                    } else if (DFT3DDescriptor.NATURE_PARAMETER_NAME
181:                            .equalsIgnoreCase(name)) {
182:                        values = new EnumeratedParameter[] {
183:                                IDFT3DDescriptor.REAL_TO_COMPLEX,
184:                                IDFT3DDescriptor.COMPLEX_TO_COMPLEX,
185:                                IDFT3DDescriptor.COMPLEX_TO_REAL, };
186:                    } else {
187:                        // this call throws an exception
188:                        values = super .getEnumeratedParameterValues(name);
189:                    }
190:                    return values;
191:                }
192:
193:                @Override
194:                public int getNumParameters() {
195:                    int num_parameters = 2;
196:                    return num_parameters;
197:                }
198:
199:                @Override
200:                public Class<?>[] getParamClasses() {
201:                    Class<?>[] clazzes = new Class<?>[] { DFTScalingType.class,
202:                            DFTDataNature.class, };
203:                    return clazzes;
204:                }
205:
206:                @Override
207:                @SuppressWarnings({"static-access","synthetic-access"})
208:                public Object getParamDefaultValue(String name) {
209:                    int index;
210:                    if (IDFT3DDescriptor.SCALING_PARAMETER_NAME.equals(name)) {
211:                        index = IDFT3DDescriptor.SCALING_PARAMETER_INDEX;
212:                    } else if (IDFT3DDescriptor.NATURE_PARAMETER_NAME
213:                            .equals(name)) {
214:                        index = IDFT3DDescriptor.NATURE_PARAMETER_INDEX;
215:                    } else {
216:                        // this call throws an exception
217:                        return super .getParamDefaultValue(name);
218:                    }
219:
220:                    Object[] values = this .getParamDefaults();
221:                    Object value = values[index];
222:                    return value;
223:                }
224:
225:                @Override
226:                @SuppressWarnings("nls")
227:                public Object[] getParamDefaults() {
228:                    Object[] defaults = new Object[] {
229:                            IDFT3DDescriptor.SCALING_DEFAULT_VALUE,
230:                            IDFT3DDescriptor.NATURE_DEFAULT_VALUE, };
231:                    return defaults;
232:                }
233:
234:                @Override
235:                public String[] getParamNames() {
236:                    String[] names = new String[] {
237:                            IDFT3DDescriptor.SCALING_PARAMETER_NAME,
238:                            IDFT3DDescriptor.NATURE_PARAMETER_NAME, };
239:                    return names;
240:                }
241:
242:                @Override
243:                public boolean isParameterValueValid(String name, Object value) {
244:                    EnumeratedParameter[] values = this 
245:                            .getEnumeratedParameterValues(name);
246:                    Collection<EnumeratedParameter> set = Arrays.asList(values);
247:                    boolean is_valid = set.contains(value);
248:                    return is_valid;
249:                }
250:
251:            };
252:
253:            /** Description of the parameters. */
254:            private static final ParameterListDescriptor[] PARAMETER_LIST_DESCRIPTORS = new ParameterListDescriptor[] { IDFT3DDescriptor.PARAMETER_LIST_DESCRIPTOR, };
255:
256:            //---------------------------
257:            // Constructor
258:            //---------------------------
259:
260:            /**
261:             * Constructor.
262:             */
263:            public IDFT3DDescriptor() {
264:                super (RESOURCES, SUPPORTED_MODES, SOURCE_NAMES, SOURCE_CLASSES,
265:                        PARAMETER_LIST_DESCRIPTORS);
266:            }
267:
268:            //---------------------------
269:            // Class methods
270:            //---------------------------
271:
272:            /**
273:             * Creates and fills a new parameter block.
274:             * @param   mode   the rendering mode.
275:             * @param   source   the source image.
276:             * @param   scaling   the scaling strategy.
277:             * @param   nature   the nature of the data.
278:             * @return   a new parameter block.
279:             */
280:            protected static ParameterBlockJAI createParameterBlock(
281:                    String mode, Object source, DFTScalingType scaling,
282:                    DFTDataNature nature) {
283:                String name = IDFT3DDescriptor.NAME;
284:                ParameterBlockJAI pb = new ParameterBlockJAI(name, mode);
285:                if (null != source) {
286:                    pb.addSource(source);
287:                }
288:                pb.setParameter(IDFT3DDescriptor.SCALING_PARAMETER_NAME,
289:                        scaling);
290:                pb.setParameter(IDFT3DDescriptor.NATURE_PARAMETER_NAME, nature);
291:                return pb;
292:            }
293:
294:            /**
295:             * Creates and fills a new parameter block for the rendered mode.
296:             * @param   sources   the source images.
297:             * @param   scaling   the scaling strategy.
298:             * @param   nature   the nature of the data.
299:             * @return   a new parameter block.
300:             */
301:            public static ParameterBlockJAI createParameterBlock(
302:                    Collection<RenderedImage> sources, DFTScalingType scaling,
303:                    DFTDataNature nature) {
304:                String mode = CollectionRegistryMode.MODE_NAME;
305:                ParameterBlockJAI pb_jai = IDFT3DDescriptor
306:                        .createParameterBlock(mode, sources, scaling, nature);
307:                return pb_jai;
308:            }
309:
310:            /**
311:             * Performs the operation on a collection of image.
312:             * @param   sources   the source images.
313:             * @param   scaling   the scaling strategy.
314:             * @param   nature   the nature of the data.
315:             * @param   hints    the rendering hints, may be {@code null}.
316:             * @return   the rendered result image.
317:             */
318:            @SuppressWarnings("unchecked")
319:            public static Collection<RenderedImage> createCollection(
320:                    Collection<RenderedImage> sources, DFTScalingType scaling,
321:                    DFTDataNature nature, RenderingHints hints) {
322:                String name = IDFT3DDescriptor.NAME;
323:                ParameterBlockJAI parameter_block = IDFT3DDescriptor
324:                        .createParameterBlock(sources, scaling, nature);
325:                Collection<RenderedImage> sinks = JAI.createCollection(name,
326:                        parameter_block, hints);
327:                return sinks;
328:            }
329:
330:            //---------------------------
331:            // External resources methods
332:            //---------------------------
333:
334:            /**
335:             * Gets the description of this operation.
336:             * @return   the description message.
337:             */
338:            protected static String getDescription() {
339:                String key = Resources.IDFT3D_DESCRIPTION;
340:                String message = Resources.getLocalizedString(key);
341:                return message;
342:            }
343:
344:            /**
345:             * Gets the description for the first argument, the scaling type.
346:             * @return   the description message.
347:             */
348:            protected static String getArg0Description() {
349:                String message = DFT3DDescriptor.getArg0Description();
350:                return message;
351:            }
352:
353:            /**
354:             * Gets the description for the second argument, the data nature.
355:             * @return   the description message.
356:             */
357:            protected static String getArg1Description() {
358:                String message = DFT3DDescriptor.getArg1Description();
359:                return message;
360:            }
361:
362:        }
363:
364:        /*
365:         * $Log: IDFT3DDescriptor.java,v $
366:         * Revision 1.5  2007/07/17 16:27:27  forklabs
367:         * Operation renamed from idft3d to idft.
368:         *
369:         * Revision 1.4  2007/06/13 18:57:21  forklabs
370:         * Changed parent to use CollectionDescriptor.
371:         *
372:         * Revision 1.3  2007/06/05 22:03:20  forklabs
373:         * Condensed the code.
374:         *
375:         * Revision 1.2  2007/06/05 20:50:06  forklabs
376:         * Changed signatures and error message.
377:         *
378:         * Revision 1.1  2007/06/05 02:42:19  forklabs
379:         * Operators dft3d and idft3d
380:         *
381:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.