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


001:        /*
002:         * $RCSfile: DataBufferState.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:56:50 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.rmi;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.DataBufferByte;
017:        import java.awt.image.DataBufferInt;
018:        import java.awt.image.DataBufferShort;
019:        import java.awt.image.DataBufferUShort;
020:        import java.io.IOException;
021:        import java.io.ObjectInputStream;
022:        import java.io.ObjectOutputStream;
023:        import java.io.Serializable;
024:        import com.sun.media.jai.util.DataBufferUtils;
025:
026:        /**
027:         * This class is a serializable proxy for a DataBuffer from which the
028:         * DataBuffer may be reconstituted.
029:         *
030:         *
031:         * @since 1.1
032:         */
033:        public class DataBufferState extends SerializableStateImpl {
034:
035:            /** DataBufferFloat and DataBufferDouble core classes or null. */
036:            private static Class[] J2DDataBufferClasses = null;
037:
038:            /** The DataBuffer. */
039:            private transient DataBuffer dataBuffer;
040:
041:            // Initialize J2DDataBufferClasses.
042:            static {
043:                try {
044:                    Class dbfClass = Class
045:                            .forName("java.awt.image.DataBufferFloat");
046:                    Class dbdClass = Class
047:                            .forName("java.awt.image.DataBufferDouble");
048:                    J2DDataBufferClasses = new Class[] { dbfClass, dbdClass };
049:                } catch (ClassNotFoundException e) {
050:                    // Ignore the exception.
051:                }
052:            }
053:
054:            public static Class[] getSupportedClasses() {
055:                Class[] supportedClasses = null;
056:                if (J2DDataBufferClasses != null) {
057:                    // Java 2 1.4.0 and higher.
058:                    supportedClasses = new Class[] {
059:                            DataBufferByte.class,
060:                            DataBufferShort.class,
061:                            DataBufferUShort.class,
062:                            DataBufferInt.class,
063:                            J2DDataBufferClasses[0],
064:                            J2DDataBufferClasses[1],
065:                            javax.media.jai.DataBufferFloat.class,
066:                            javax.media.jai.DataBufferDouble.class,
067:                            com.sun.media.jai.codecimpl.util.DataBufferFloat.class,
068:                            com.sun.media.jai.codecimpl.util.DataBufferDouble.class };
069:                } else {
070:                    // Java 2 pre-1.4.0.
071:                    supportedClasses = new Class[] {
072:                            DataBufferByte.class,
073:                            DataBufferShort.class,
074:                            DataBufferUShort.class,
075:                            DataBufferInt.class,
076:                            javax.media.jai.DataBufferFloat.class,
077:                            javax.media.jai.DataBufferDouble.class,
078:                            com.sun.media.jai.codecimpl.util.DataBufferFloat.class,
079:                            com.sun.media.jai.codecimpl.util.DataBufferDouble.class };
080:                }
081:
082:                return supportedClasses;
083:            }
084:
085:            /**
086:             * Constructs a <code>DataBufferState</code> from a
087:             * <code>DataBuffer</code>.
088:             *
089:             * @param source The <code>DataBuffer</code> to be serialized.
090:             * @param o The <code>SampleModel</code> to be serialized.
091:             * @param h The <code>RenderingHints</code> (ignored).
092:             */
093:            public DataBufferState(Class c, Object o, RenderingHints h) {
094:                super (c, o, h);
095:            }
096:
097:            // XXX Note that there is potential for some form of data compression in
098:            // the readObject() and writeObject() methods.
099:
100:            /**
101:             * Serialize the <code>DataBufferState</code>.
102:             *
103:             * @param out The <code>ObjectOutputStream</code>.
104:             */
105:            private void writeObject(ObjectOutputStream out) throws IOException {
106:                DataBuffer dataBuffer = (DataBuffer) theObject;
107:
108:                // Write serialized form to the stream.
109:                int dataType = dataBuffer.getDataType();
110:                out.writeInt(dataType);
111:                out.writeObject(dataBuffer.getOffsets());
112:                out.writeInt(dataBuffer.getSize());
113:                Object dataArray = null;
114:                switch (dataType) {
115:                case DataBuffer.TYPE_BYTE:
116:                    dataArray = ((DataBufferByte) dataBuffer).getBankData();
117:                    break;
118:                case DataBuffer.TYPE_SHORT:
119:                    dataArray = ((DataBufferShort) dataBuffer).getBankData();
120:                    break;
121:                case DataBuffer.TYPE_USHORT:
122:                    dataArray = ((DataBufferUShort) dataBuffer).getBankData();
123:                    break;
124:                case DataBuffer.TYPE_INT:
125:                    dataArray = ((DataBufferInt) dataBuffer).getBankData();
126:                    break;
127:                case DataBuffer.TYPE_FLOAT:
128:                    dataArray = DataBufferUtils.getBankDataFloat(dataBuffer);
129:                    break;
130:                case DataBuffer.TYPE_DOUBLE:
131:                    dataArray = DataBufferUtils.getBankDataDouble(dataBuffer);
132:                    break;
133:                default:
134:                    throw new RuntimeException(JaiI18N
135:                            .getString("DataBufferState0"));
136:                }
137:                out.writeObject(dataArray);
138:            }
139:
140:            /**
141:             * Deserialize the <code>DataBufferState</code>.
142:             *
143:             * @param out The <code>ObjectInputStream</code>.
144:             */
145:            private void readObject(ObjectInputStream in) throws IOException,
146:                    ClassNotFoundException {
147:                DataBuffer dataBuffer = null;
148:
149:                // Read serialized form from the stream.
150:                int dataType = -1;
151:                int[] offsets = null;
152:                int size = -1;
153:                Object dataArray = null;
154:                dataType = in.readInt();
155:                offsets = (int[]) in.readObject();
156:                size = in.readInt();
157:                dataArray = in.readObject();
158:
159:                // Restore the transient DataBuffer.
160:                switch (dataType) {
161:                case DataBuffer.TYPE_BYTE:
162:                    dataBuffer = new DataBufferByte((byte[][]) dataArray, size,
163:                            offsets);
164:                    break;
165:                case DataBuffer.TYPE_SHORT:
166:                    dataBuffer = new DataBufferShort((short[][]) dataArray,
167:                            size, offsets);
168:                    break;
169:                case DataBuffer.TYPE_USHORT:
170:                    dataBuffer = new DataBufferUShort((short[][]) dataArray,
171:                            size, offsets);
172:                    break;
173:                case DataBuffer.TYPE_INT:
174:                    dataBuffer = new DataBufferInt((int[][]) dataArray, size,
175:                            offsets);
176:                    break;
177:                case DataBuffer.TYPE_FLOAT:
178:                    dataBuffer = DataBufferUtils.createDataBufferFloat(
179:                            (float[][]) dataArray, size, offsets);
180:                    break;
181:                case DataBuffer.TYPE_DOUBLE:
182:                    dataBuffer = DataBufferUtils.createDataBufferDouble(
183:                            (double[][]) dataArray, size, offsets);
184:                    break;
185:                default:
186:                    throw new RuntimeException(JaiI18N
187:                            .getString("DataBufferState0"));
188:                }
189:
190:                theObject = dataBuffer;
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.