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


001:        /*
002:         * $RCSfile: WritableRenderedImageAdapter.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:25 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.awt.Point;
015:        import java.awt.image.Raster;
016:        import java.awt.image.WritableRaster;
017:        import java.awt.image.WritableRenderedImage;
018:        import java.awt.image.TileObserver;
019:
020:        /**
021:         * A <code>PlanarImage</code> wrapper for a
022:         * <code>WritableRenderedImage</code>.  The tile layout, sample model,
023:         * and so forth are preserved.  Calls to <code>getTile()</code> and so
024:         * forth are forwarded.
025:         *
026:         * <p> From JAI's point of view, this image is a
027:         * <code>PlanarImage</code> of unknown type, with no sources, and
028:         * additionally an implementer of the
029:         * <code>WritableRenderedImage</code> interface.  The image's pixel
030:         * data appear to be variable.
031:         *
032:         * <p> The class and all its methods are marked <code>final</code> in
033:         * order to allow dynamic inlining to take place.  This should
034:         * eliminate any performance penalty associated with the use of an
035:         * adapter class.
036:         *
037:         * @see PlanarImage
038:         * @see RenderedImageAdapter
039:         * @see java.awt.image.RenderedImage
040:         * @see java.awt.image.WritableRenderedImage
041:         *
042:         */
043:        public final class WritableRenderedImageAdapter extends
044:                RenderedImageAdapter implements  WritableRenderedImage {
045:
046:            /** The WritableRenderedImage being adapted. */
047:            private WritableRenderedImage theWritableImage;
048:
049:            /**
050:             * Constructs a <code>WritableRenderedImageAdapter</code>.
051:             *
052:             * @param im A <code>WritableRenderedImage</code> to be `wrapped'
053:             * as a <code>PlanarImage</code>.
054:             * @throws <code>IllegalArgumentException</code> if <code>im</code> is
055:             *         <code>null</code>.
056:             */
057:            public WritableRenderedImageAdapter(WritableRenderedImage im) {
058:                super (im);
059:                theWritableImage = im;
060:            }
061:
062:            /**
063:             * Adds an observer.  If the observer is already present,
064:             * it will receive multiple notifications.
065:             *
066:             * @param tileObserver The <code>TileObserver</code> to be added.
067:             * @throws <code>IllegalArgumentException</code> if
068:             *         <code>tileObserver</code> is <code>null</code>.
069:             */
070:            public final void addTileObserver(TileObserver tileObserver) {
071:                if (tileObserver == null) {
072:                    throw new IllegalArgumentException(JaiI18N
073:                            .getString("WritableRenderedImageAdapter0"));
074:                }
075:                theWritableImage.addTileObserver(tileObserver);
076:            }
077:
078:            /**
079:             * Removes an observer.  If the observer was not registered,
080:             * nothing happens.  If the observer was registered for multiple
081:             * notifications, it will now be registered for one fewer.
082:             *
083:             * @param tileObserver The <code>TileObserver</code> to be removed.
084:             * @throws <code>IllegalArgumentException</code> if
085:             *         <code>tileObserver</code> is <code>null</code>.
086:             */
087:            public final void removeTileObserver(TileObserver tileObserver) {
088:                if (tileObserver == null) {
089:                    throw new IllegalArgumentException(JaiI18N
090:                            .getString("WritableRenderedImageAdapter0"));
091:                }
092:                theWritableImage.removeTileObserver(tileObserver);
093:            }
094:
095:            /**
096:             * Checks out a tile for writing.  
097:             * 
098:             * <p> The <code>WritableRenderedImage</code> is responsible for
099:             * notifying all of its <code>TileObservers</code> when a tile
100:             * goes from having no writers to having one writer.
101:             *
102:             * @param tileX The X index of the tile.
103:             * @param tileY The Y index of the tile.
104:             * @return The tile as a <code>WritableRaster</code>.
105:             */
106:            public final WritableRaster getWritableTile(int tileX, int tileY) {
107:                return theWritableImage.getWritableTile(tileX, tileY);
108:            }
109:
110:            /**
111:             * Relinquishes the right to write to a tile.  If the caller
112:             * continues to write to the tile, the results are undefined.
113:             * Calls to this method should only appear in matching pairs with
114:             * calls to <code>getWritableTile()</code>; any other use will
115:             * lead to undefined results.
116:             *
117:             * <p> The <code>WritableRenderedImage</code> is responsible for
118:             * notifying all of its <code>TileObserver</code>s when a tile
119:             * goes from having one writer to having no writers.
120:             *
121:             * @param tileX The X index of the tile.
122:             * @param tileY The Y index of the tile.
123:             */
124:            public final void releaseWritableTile(int tileX, int tileY) {
125:                theWritableImage.releaseWritableTile(tileX, tileY);
126:            }
127:
128:            /**
129:             * Returns whether a tile is currently checked out for writing.
130:             *
131:             * @param tileX The X index of the tile.
132:             * @param tileY The Y index of the tile.
133:             *
134:             * @return <code>true</code> if the tile currently has writers.
135:             */
136:            public final boolean isTileWritable(int tileX, int tileY) {
137:                return theWritableImage.isTileWritable(tileX, tileY);
138:            }
139:
140:            /**
141:             * Returns an array of <code>Point</code> objects indicating which tiles
142:             * are checked out for writing.
143:             *
144:             * @return an array of <code>Point</code>s or <code>null</code> if no
145:             * tiles are checked out for writing.
146:             */
147:            public final Point[] getWritableTileIndices() {
148:                return theWritableImage.getWritableTileIndices();
149:            }
150:
151:            /**
152:             * Returns whether any tile is checked out for writing.
153:             * Semantically equivalent to (getWritableTiles().size() != 0).
154:             *
155:             * @return <code>true</code> if any tile currently has writers.
156:             */
157:            public final boolean hasTileWriters() {
158:                return theWritableImage.hasTileWriters();
159:            }
160:
161:            /**
162:             * Sets a rectangular region of the image to the contents of
163:             * <code>raster</code>.
164:             *
165:             * @param raster A <code>Raster</code>.
166:             * @throws <code>IllegalArgumentException</code> if <code>raster</code> is
167:             *         <code>null</code>.
168:             */
169:            public final void setData(Raster raster) {
170:                if (raster == null) {
171:                    throw new IllegalArgumentException(JaiI18N
172:                            .getString("WritableRenderedImageAdapter1"));
173:                }
174:                theWritableImage.setData(raster);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.