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


001:        /*
002:         * @(#) $Header: /cvs/jai-operators/src/main/ca/forklabs/media/jai/opimage/PeriodicShift3DRCIF.java,v 1.2 2007/07/05 18:24:45 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.opimage;
022:
023:        import java.awt.RenderingHints;
024:        import java.awt.image.RenderedImage;
025:        import java.awt.image.renderable.ParameterBlock;
026:        import java.awt.image.renderable.RenderableImage;
027:        import java.util.ArrayList;
028:        import java.util.Collections;
029:        import java.util.List;
030:        import javax.media.jai.CollectionImage;
031:        import javax.media.jai.CollectionImageFactory;
032:        import javax.media.jai.CollectionOp;
033:        import javax.media.jai.JAI;
034:        import javax.media.jai.RenderableCollectionImageFactory;
035:        import ca.forklabs.media.jai.ParameterBlockUtil;
036:        import ca.forklabs.media.jai.SimpleCollectionImage;
037:        import ca.forklabs.media.jai.operator.PeriodicShift3DDescriptor;
038:
039:        /**
040:         * Class {@code PeriodicShift3DRCIF} is a {@link CollectionImageFactory} and a
041:         * {@link RenderableCollectionImageFactory} supporting the
042:         * <em>periodicshift3d</em> operation.
043:         *
044:         * @author   <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.opimage.PeriodicShift3DRCIF">Daniel Léonard</a>
045:         * @version $Revision: 1.2 $
046:         */
047:        public class PeriodicShift3DRCIF implements  CollectionImageFactory,
048:                RenderableCollectionImageFactory {
049:
050:            //---------------------------
051:            // Constructor
052:            //---------------------------
053:
054:            /**
055:             * Constructor.
056:             */
057:            public PeriodicShift3DRCIF() {
058:                // nothing
059:            }
060:
061:            //---------------------------
062:            // Instance methods
063:            //---------------------------
064:
065:            /**
066:             * Gets the diplacement in <em>x</em> within the parameter block.
067:             * @param   pb   the parameter block.
068:             * @return   the displacement.
069:             */
070:            protected Integer getShiftX(ParameterBlock pb) {
071:                int index = PeriodicShift3DDescriptor.SHIFT_X_PARAMETER_INDEX;
072:                Integer shift_x = (Integer) pb.getObjectParameter(index);
073:                return shift_x;
074:            }
075:
076:            /**
077:             * Gets the diplacement in <em>y</em> within the parameter block.
078:             * @param   pb   the parameter block.
079:             * @return   the displacement.
080:             */
081:            protected Integer getShiftY(ParameterBlock pb) {
082:                int index = PeriodicShift3DDescriptor.SHIFT_Y_PARAMETER_INDEX;
083:                Integer shift_y = (Integer) pb.getObjectParameter(index);
084:                return shift_y;
085:            }
086:
087:            /**
088:             * Gets the diplacement in <em>z</em> within the parameter block.
089:             * @param   pb   the parameter block.
090:             * @return   the displacement.
091:             */
092:            @SuppressWarnings("boxing")
093:            protected Integer getShiftZ(ParameterBlock pb) {
094:                int index = PeriodicShift3DDescriptor.SHIFT_Z_PARAMETER_INDEX;
095:                Integer shift_z = (Integer) pb.getObjectParameter(index);
096:                return shift_z;
097:            }
098:
099:            /**
100:             * Shifts the cubic image.
101:             * @param   pb   the parameter block.
102:             * @param   hints   the rendering hints.
103:             * @return   the shifted cubic image.
104:             */
105:            @SuppressWarnings({"unchecked","nls","boxing"})
106:            protected CollectionImage shift(ParameterBlock pb,
107:                    RenderingHints hints) {
108:                CollectionImage sources = (CollectionImage) pb.getSource(0);
109:
110:                Integer shift_x = this .getShiftX(pb);
111:                Integer shift_y = this .getShiftY(pb);
112:                Integer shift_z = this .getShiftZ(pb);
113:
114:                int len = sources.size();
115:                List sinks = new ArrayList(len);
116:
117:                for (Object source : sources) {
118:                    Object sink;
119:                    if (source instanceof  RenderedImage) {
120:                        RenderedImage image = (RenderedImage) source;
121:                        ParameterBlock parameters = ParameterBlockUtil
122:                                .createPeriodicShiftParameterBlock(image,
123:                                        shift_x, shift_y);
124:                        sink = JAI.create("periodicshift", parameters, hints);
125:                    } else if (source instanceof  RenderableImage) {
126:                        RenderableImage image = (RenderableImage) source;
127:                        ParameterBlock parameters = ParameterBlockUtil
128:                                .createPeriodicShiftParameterBlock(image,
129:                                        shift_x, shift_y);
130:                        sink = JAI.createRenderable("periodicshift",
131:                                parameters, hints);
132:                    } else {
133:                        Class<?> clazz = source.getClass();
134:                        String messsage = this 
135:                                .getNeitherRenderedNorRenderableErrorMessage(clazz);
136:                        throw new IllegalStateException(messsage);
137:                    }
138:                    sinks.add(sink);
139:                }
140:
141:                Collections.rotate(sinks, shift_z);
142:
143:                CollectionImage collection_image = new SimpleCollectionImage(
144:                        sinks);
145:                return collection_image;
146:            }
147:
148:            /**
149:             * Gets the error message saying that a source image is neither a rendered
150:             * nor a renderable image.
151:             * @param   clazz   the class of the offending image.
152:             * @return   the error message.
153:             */
154:            protected String getNeitherRenderedNorRenderableErrorMessage(
155:                    Class<?> clazz) {
156:                String key = Resources.NEITHER_RENDERED_NOR_RENDERABLE;
157:                String message = Resources.getLocalizedString(key, clazz);
158:                return message;
159:            }
160:
161:            //---------------------------
162:            // Implemented methods from javax.media.jai.CollectionImageFactory
163:            //---------------------------
164:
165:            /**
166:             * Calls {@link #shift(ParameterBlock, RenderingHints)}.
167:             * @param   pb   the parameter block.
168:             * @param   hints   the rendering hints.
169:             * @return   the shifted cubic image.
170:             */
171:            @SuppressWarnings("unchecked")
172:            public CollectionImage create(ParameterBlock pb,
173:                    RenderingHints hints) {
174:                CollectionImage collection_image = this .shift(pb, hints);
175:                return collection_image;
176:            }
177:
178:            /**
179:             * It is impratical to perform the update.
180:             * @param old_pb   ignored
181:             * @param old_hints   ignored
182:             * @param new_pb   ignored
183:             * @param new_hints   ignored
184:             * @param old_image   ignored
185:             * @param op   ignored
186:             * @return always {@code null}.
187:             */
188:            public CollectionImage update(ParameterBlock old_pb,
189:                    RenderingHints old_hints, ParameterBlock new_pb,
190:                    RenderingHints new_hints, CollectionImage old_image,
191:                    CollectionOp op) {
192:                // it is impracticable to perform the update
193:                CollectionImage new_image = null;
194:                return new_image;
195:            }
196:
197:            //---------------------------
198:            // Implemented methods from javax.media.jai.RenderableCollectionImageFactory
199:            //---------------------------
200:
201:            /**
202:             * Calls {@link #shift(ParameterBlock, RenderingHints)}.
203:             * @param   pb   the parameter block.
204:             * @return   the shifted cubic image.
205:             */
206:            @Override
207:            public CollectionImage create(ParameterBlock pb) {
208:                RenderingHints hints = null;
209:                CollectionImage sinks = this .shift(pb, hints);
210:                return sinks;
211:            }
212:
213:        }
214:
215:        /*
216:         * $Log: PeriodicShift3DRCIF.java,v $
217:         * Revision 1.2  2007/07/05 18:24:45  forklabs
218:         * Now uses CollectionImage instead of lists.
219:         *
220:         * Revision 1.1  2007/06/05 20:29:59  forklabs
221:         * Operator periodicshift3d.
222:         *
223:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.