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