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


001:        /*
002:         * @(#) $Header: /cvs/jai-operators/src/main/ca/forklabs/media/jai/CollectionDescriptor.java,v 1.4 2007/08/08 19:19:28 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;
022:
023:        import java.awt.image.renderable.ParameterBlock;
024:        import java.util.Collection;
025:        import javax.media.jai.EnumeratedParameter;
026:        import javax.media.jai.OperationDescriptorImpl;
027:        import javax.media.jai.ParameterListDescriptor;
028:        import javax.media.jai.util.Range;
029:        import ca.forklabs.media.jai.DescriptorUtil;
030:
031:        /**
032:         * Class {@code CollectionDescriptor} helps in creating {OperationDescriptor}
033:         * that have collections has input source.
034:         *
035:         * @author   <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.CollectionDescriptor">Daniel Léonard</a>
036:         * @version $Revision: 1.4 $
037:         */
038:        public abstract class CollectionDescriptor extends
039:                OperationDescriptorImpl {
040:
041:            //---------------------------
042:            // Inner classes
043:            //---------------------------
044:
045:            /**
046:             * Empty implementation of interface {@link ParameterListDescriptor}.
047:             */
048:            protected static class EmptyParameterListDescriptor implements 
049:                    ParameterListDescriptor {
050:
051:                /**
052:                 * Constructor.
053:                 */
054:                public EmptyParameterListDescriptor() {
055:                    // nothing
056:                }
057:
058:                /**
059:                 * The default is to have no parameters.
060:                 * @return   always <em>0</em>.
061:                 */
062:                @Override
063:                public int getNumParameters() {
064:                    int num_parameters = 0;
065:                    return num_parameters;
066:                }
067:
068:                /**
069:                 * The default is to have no parameters.
070:                 * @return   always {@code null}.
071:                 */
072:                @Override
073:                public Class<?>[] getParamClasses() {
074:                    Class<?>[] clazzes = null;
075:                    return clazzes;
076:                }
077:
078:                /**
079:                 * The default is to have no parameters.
080:                 * @return   never.
081:                 * @exception   IllegalArgumentException   always.
082:                 */
083:                @Override
084:                public Object getParamDefaultValue(String name) {
085:                    String message = CollectionDescriptor
086:                            .getUnknownParameterErrorMessage(name);
087:                    throw new IllegalArgumentException(message);
088:                }
089:
090:                /**
091:                 * The default is to have no parameters.
092:                 * @return   always {@code null}.
093:                 */
094:                @Override
095:                @SuppressWarnings("nls")
096:                public Object[] getParamDefaults() {
097:                    Object[] defaults = null;
098:                    return defaults;
099:                }
100:
101:                /**
102:                 * The default is to have no parameters.
103:                 * @return   always {@code null}.
104:                 */
105:                @Override
106:                public String[] getParamNames() {
107:                    String[] names = null;
108:                    return names;
109:                }
110:
111:                /**
112:                 * There are no enumerator parameters.
113:                 * @return   always {@code null}.
114:                 */
115:                @Override
116:                public String[] getEnumeratedParameterNames() {
117:                    // no enumerated parameters
118:                    String[] names = null;
119:                    return names;
120:                }
121:
122:                /**
123:                 * There are no enumerator parameters.
124:                 * @return   never.
125:                 * @exception   UnsupportedOperationException   always.
126:                 */
127:                @Override
128:                public EnumeratedParameter[] getEnumeratedParameterValues(
129:                        String name) {
130:                    // no enumerated parameters
131:                    String message = CollectionDescriptor
132:                            .getNoEnumeratedParametersErrorMessage();
133:                    throw new UnsupportedOperationException(message);
134:                }
135:
136:                /**
137:                 * There are no range parameters.
138:                 * @return   alway {@code null}.
139:                 */
140:                @Override
141:                public Range getParamValueRange(String name) {
142:                    // no parameter is a range
143:                    Range range = null;
144:                    return range;
145:                }
146:
147:                /**
148:                 * No value is ever valid.
149:                 * @param   name   the name of the parameter.
150:                 * @param   value   the value of the parameter.
151:                 * @return    always {@code false}.
152:                 */
153:                @Override
154:                public boolean isParameterValueValid(String name, Object value) {
155:                    boolean is_valid = false;
156:                    return is_valid;
157:                }
158:
159:            }
160:
161:            //---------------------------
162:            // Constructors
163:            //---------------------------
164:
165:            /**
166:             * Constructor.
167:             * @param   resources   the resource tags and their corresponding data.
168:             * @param   modes   the modes that this operator supports.
169:             * @param   source_names   the source names.
170:             * @param   source_classes   the source types required by this operation for
171:             *                           each of the above supported modes.
172:             * @param   parameter_list_descriptors   the parameter list descriptor for
173:             *                                       each mode.
174:             */
175:            protected CollectionDescriptor(String[][] resources,
176:                    String[] modes, String[] source_names,
177:                    Class<?>[][] source_classes,
178:                    ParameterListDescriptor[] parameter_list_descriptors) {
179:                super (resources, modes, source_names, source_classes,
180:                        parameter_list_descriptors);
181:            }
182:
183:            //---------------------------
184:            // Overriden methods from javax.media.jai.OperationDescriptorImpl
185:            //---------------------------
186:
187:            /**
188:             * Collates and validates sources in both collection modes, non-collection
189:             * modes are handled by the super-class.
190:             * @param   mode   the rendering mode.
191:             * @param   pb   the parameter block.
192:             * @param   sb   sink for error messages.
193:             */
194:            @Override
195:            @SuppressWarnings({"unused","unchecked"})
196:            protected boolean validateSources(String mode, ParameterBlock pb,
197:                    StringBuffer sb) {
198:                // The type of source is checked in the super-class method
199:                // (later that is). Here we collate sources into a single
200:                // collection
201:                boolean is_ok = true;
202:
203:                DescriptorUtil.collateSources(pb);
204:
205:                Collection sources = (Collection) pb.getSource(0);
206:
207:                boolean is_rendered_mode = DescriptorUtil.isRenderedMode(mode);
208:                boolean is_collection_mode = DescriptorUtil
209:                        .isCollectionMode(mode);
210:
211:                boolean is_renderable_mode = DescriptorUtil
212:                        .isRenderableMode(mode);
213:                boolean is_renderable_collection_mode = DescriptorUtil
214:                        .isRenderableCollectionMode(mode);
215:
216:                if (is_rendered_mode || is_collection_mode) {
217:                    is_ok = DescriptorUtil.areAllSourceRendered(sources);
218:                    if (false == is_ok) {
219:                        String message = this .getNotAllRenderedErrorMessage();
220:                        sb.append(message);
221:                    }
222:                } else if (is_renderable_mode || is_renderable_collection_mode) {
223:                    is_ok = DescriptorUtil.areAllSourceRenderable(sources);
224:                    if (false == is_ok) {
225:                        String message = this .getNotAllRenderableErrorMessage();
226:                        sb.append(message);
227:                    }
228:                } else {
229:                    is_ok = false;
230:                    String message = this 
231:                            .getNeitherCollectionNorRenderableCollectionModeErrorMessage(mode);
232:                    sb.append(message);
233:                }
234:
235:                // validations from the super-class
236:                is_ok = is_ok && super .validateSources(mode, pb, sb);
237:
238:                return is_ok;
239:            }
240:
241:            //---------------------------
242:            // External resources methods
243:            //---------------------------
244:
245:            /**
246:             * Gets the error message saying that this operator does not have any
247:             * enumerated parameters.
248:             * @return   the error message.
249:             */
250:            protected static String getNoEnumeratedParametersErrorMessage() {
251:                String key = Resources.NO_ENUMERATED_PARAMETERS;
252:                String message = Resources.getLocalizedString(key);
253:                return message;
254:            }
255:
256:            /**
257:             * Gets the error message saying that parameter is unknown.
258:             * @param   name   the name of the offending parameter.
259:             * @return   the error message.
260:             */
261:            protected static String getUnknownParameterErrorMessage(String name) {
262:                String key = Resources.UNKNOWN_PARAMETER;
263:                String message = Resources.getLocalizedString(key, name);
264:                return message;
265:            }
266:
267:            /**
268:             * Gets the error message saying that not all sources are rendered images.
269:             * @return   the error message.
270:             */
271:            protected String getNotAllRenderedErrorMessage() {
272:                String key = Resources.NOT_ALL_RENDERED_IMAGE;
273:                String message = Resources.getLocalizedString(key);
274:                return message;
275:            }
276:
277:            /**
278:             * Gets the error message saying that not all sources are renderable images.
279:             * @return   the error message.
280:             */
281:            protected String getNotAllRenderableErrorMessage() {
282:                String key = Resources.NOT_ALL_RENDERABLE_IMAGE;
283:                String message = Resources.getLocalizedString(key);
284:                return message;
285:            }
286:
287:            /**
288:             * Gets the error message saying that we are neither in collection nor
289:             * renderable collection mode.
290:             * @param   mode   the offending mode.
291:             * @return   the error message.
292:             */
293:            protected String getNeitherCollectionNorRenderableCollectionModeErrorMessage(
294:                    String mode) {
295:                String key = Resources.NEITHER_COLLECTION_NOR_RENDERABLE_COLLECTION_MODE;
296:                String message = Resources.getLocalizedString(key, mode);
297:                return message;
298:            }
299:
300:        }
301:
302:        /*
303:         * $Log: CollectionDescriptor.java,v $
304:         * Revision 1.4  2007/08/08 19:19:28  forklabs
305:         * Corrected javadoc documentation.
306:         *
307:         * Revision 1.3  2007/07/03 19:01:06  forklabs
308:         * * javadoc *
309:         *
310:         * Revision 1.2  2007/06/13 18:53:54  forklabs
311:         * Changed the mission from helping collection descriptor to helping descriptors using collection sources.
312:         *
313:         * Revision 1.1  2007/06/11 22:10:36  forklabs
314:         * A class to help descriptors in collection and renderable collection mode.
315:         *
316:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.