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


001:        /*
002:         * $RCSfile: RectIterFactory.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:27 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.iterator;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.image.ComponentSampleModel;
016:        import java.awt.image.DataBuffer;
017:        import java.awt.image.Raster;
018:        import java.awt.image.WritableRaster;
019:        import java.awt.image.RenderedImage;
020:        import java.awt.image.SampleModel;
021:        import java.awt.image.WritableRenderedImage;
022:        import com.sun.media.jai.iterator.RectIterCSMByte; // import com.sun.media.jai.iterator.RectIterCSMShort;
023:        // import com.sun.media.jai.iterator.RectIterCSMUShort;
024:        // import com.sun.media.jai.iterator.RectIterCSMInt;
025:        import com.sun.media.jai.iterator.RectIterCSMFloat; // import com.sun.media.jai.iterator.RectIterCSMDouble;
026:        import com.sun.media.jai.iterator.RectIterFallback;
027:        import com.sun.media.jai.iterator.WrapperRI;
028:        import com.sun.media.jai.iterator.WrapperWRI;
029:        import com.sun.media.jai.iterator.WritableRectIterCSMByte; // import com.sun.media.jai.iterator.WritableRectIterCSMShort;
030:        // import com.sun.media.jai.iterator.WritableRectIterCSMUShort;
031:        // import com.sun.media.jai.iterator.WritableRectIterCSMInt;
032:        import com.sun.media.jai.iterator.WritableRectIterCSMFloat; // import com.sun.media.jai.iterator.WritableRectIterCSMDouble;
033:        import com.sun.media.jai.iterator.WritableRectIterFallback;
034:
035:        /**
036:         * A factory class to instantiate instances of the RectIter and
037:         * WritableRectIter interfaces on sources of type Raster,
038:         * RenderedImage, and WritableRenderedImage.
039:         *
040:         * @see RectIter
041:         * @see WritableRectIter
042:         */
043:        public class RectIterFactory {
044:
045:            /** Prevent this class from ever being instantiated. */
046:            private RectIterFactory() {
047:            }
048:
049:            /**
050:             * Constructs and returns an instance of RectIter suitable
051:             * for iterating over the given bounding rectangle within the
052:             * given RenderedImage source.  If the bounds parameter is null,
053:             * the entire image will be used.
054:             *
055:             * @param im a read-only RenderedImage source.
056:             * @param bounds the bounding Rectangle for the iterator, or null.
057:             * @return a RectIter allowing read-only access to the source.
058:             */
059:            public static RectIter create(RenderedImage im, Rectangle bounds) {
060:                if (bounds == null) {
061:                    bounds = new Rectangle(im.getMinX(), im.getMinY(), im
062:                            .getWidth(), im.getHeight());
063:                }
064:
065:                SampleModel sm = im.getSampleModel();
066:                if (sm instanceof  ComponentSampleModel) {
067:                    switch (sm.getDataType()) {
068:                    case DataBuffer.TYPE_BYTE:
069:                        return new RectIterCSMByte(im, bounds);
070:                    case DataBuffer.TYPE_SHORT:
071:                        // return new RectIterCSMShort(im, bounds);
072:                        break;
073:                    case DataBuffer.TYPE_USHORT:
074:                        // return new RectIterCSMUShort(im, bounds);
075:                        break;
076:                    case DataBuffer.TYPE_INT:
077:                        // return new RectIterCSMInt(im, bounds);
078:                        break;
079:                    case DataBuffer.TYPE_FLOAT:
080:                        return new RectIterCSMFloat(im, bounds);
081:                    case DataBuffer.TYPE_DOUBLE:
082:                        // return new RectIterCSMDouble(im, bounds);
083:                        break;
084:                    }
085:                }
086:
087:                return new RectIterFallback(im, bounds);
088:            }
089:
090:            /**
091:             * Constructs and returns an instance of RectIter suitable
092:             * for iterating over the given bounding rectangle within the
093:             * given Raster source.  If the bounds parameter is null,
094:             * the entire Raster will be used.
095:             *
096:             * @param ras a read-only Raster source.
097:             * @param bounds the bounding Rectangle for the iterator, or null.
098:             * @return a RectIter allowing read-only access to the source.
099:             */
100:            public static RectIter create(Raster ras, Rectangle bounds) {
101:                RenderedImage im = new WrapperRI(ras);
102:                return create(im, bounds);
103:            }
104:
105:            /**
106:             * Constructs and returns an instance of WritableRectIter suitable for
107:             * iterating over the given bounding rectangle within the given
108:             * WritableRenderedImage source.  If the bounds parameter is null,
109:             * the entire image will be used.
110:             *
111:             * @param im a WritableRenderedImage source.
112:             * @param bounds the bounding Rectangle for the iterator, or null.
113:             * @return a WritableRectIter allowing read/write access to the source.
114:             */
115:            public static WritableRectIter createWritable(
116:                    WritableRenderedImage im, Rectangle bounds) {
117:                if (bounds == null) {
118:                    bounds = new Rectangle(im.getMinX(), im.getMinY(), im
119:                            .getWidth(), im.getHeight());
120:                }
121:
122:                SampleModel sm = im.getSampleModel();
123:                if (sm instanceof  ComponentSampleModel) {
124:                    switch (sm.getDataType()) {
125:                    case DataBuffer.TYPE_BYTE:
126:                        return new WritableRectIterCSMByte(im, bounds);
127:                    case DataBuffer.TYPE_SHORT:
128:                        // return new WritableRectIterCSMShort(im, bounds);
129:                        break;
130:                    case DataBuffer.TYPE_USHORT:
131:                        // return new WritableRectIterCSMUShort(im, bounds);
132:                        break;
133:                    case DataBuffer.TYPE_INT:
134:                        // return new WritableRectIterCSMInt(im, bounds);
135:                        break;
136:                    case DataBuffer.TYPE_FLOAT:
137:                        return new WritableRectIterCSMFloat(im, bounds);
138:                    case DataBuffer.TYPE_DOUBLE:
139:                        // return new WritableRectIterCSMDouble(im, bounds);
140:                        break;
141:                    }
142:                }
143:
144:                return new WritableRectIterFallback(im, bounds);
145:            }
146:
147:            /**
148:             * Constructs and returns an instance of WritableRectIter suitable for
149:             * iterating over the given bounding rectangle within the given
150:             * WritableRaster source.  If the bounds parameter is null,
151:             * the entire Raster will be used.
152:             *
153:             * @param ras a WritableRaster source.
154:             * @param bounds the bounding Rectangle for the iterator, or null.
155:             * @return a WritableRectIter allowing read/write access to the source.
156:             */
157:            public static WritableRectIter createWritable(WritableRaster ras,
158:                    Rectangle bounds) {
159:                WritableRenderedImage im = new WrapperWRI(ras);
160:                return createWritable(im, bounds);
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.