Source Code Cross Referenced for NullOpImage.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: NullOpImage.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:12 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.ColorModel;
016:        import java.awt.image.Raster;
017:        import java.awt.image.RenderedImage;
018:        import java.util.Hashtable;
019:        import java.util.Map;
020:        import javax.media.jai.util.CaselessStringKey;
021:        import com.sun.media.jai.util.JDKWorkarounds;
022:
023:        /**
024:         * A trivial <code>OpImage</code> subclass that simply transmits its
025:         * source unchanged.  This may be useful when an interface requires an
026:         * <code>OpImage</code> but another sort of <code>RenderedImage</code>
027:         * (such as a <code>BufferedImage</code> or <code>TiledImage</code>)
028:         * is available.  Additionally, <code>NullOpImage</code> is able to
029:         * make use of JAI's tile caching mechanisms.
030:         *
031:         * <p> Methods that get or set properties are implemented to forward
032:         * the requests to the source image; no independent property information
033:         * is stored in the <code>NullOpImage</code> itself.
034:         *
035:         * @see PointOpImage
036:         */
037:        public class NullOpImage extends PointOpImage {
038:
039:            protected int computeType;
040:
041:            /**
042:             * Create a new ImageLayout from the source image optionally
043:             * overriding a ColorModel supplied via the layout.
044:             */
045:            private static ImageLayout layoutHelper(RenderedImage source,
046:                    ImageLayout layout) {
047:                // Create basic layout from the source.
048:                ImageLayout il = new ImageLayout(source);
049:
050:                // If a layout containing a valid ColorModel field is supplied then
051:                // reset the ColorModel if it is compatible with the SampleModel.
052:                if (layout != null
053:                        && layout.isValid(ImageLayout.COLOR_MODEL_MASK)) {
054:                    ColorModel colorModel = layout.getColorModel(null);
055:                    if (JDKWorkarounds.areCompatibleDataModels(source
056:                            .getSampleModel(), colorModel)) {
057:                        il.setColorModel(colorModel);
058:                    }
059:                }
060:
061:                return il;
062:            }
063:
064:            /**
065:             * Constructs a <code>NullOpImage</code>.  The superclass
066:             * constructor will be passed a new <code>ImageLayout</code>
067:             * object with all of its fields filled in.  The <code>ColorModel</code>
068:             * may be overridden via the supplied <code>ImageLayout</code>; all
069:             * other layout fields are derived from the source image.  Any
070:             * specified <code>ColorModel</code> will be used if and only if it
071:             * is compatible with the source image <code>SampleModel</code>.
072:             *
073:             * @param layout An <code>ImageLayout</code> optionally specifying
074:             *        the image <code>ColorModel</code>; all other fields are
075:             *        ignored.  This parameter may be <code>null</code>.
076:             * @param source A <code>RenderedImage</code>; must not be
077:             *        <code>null</code> or a <code>IllegalArgumentException</code>
078:             *        will be thrown.
079:             * @param configuration Configurable attributes of the image including
080:             *        configuration variables indexed by
081:             *        <code>RenderingHints.Key</code>s and image properties indexed
082:             *        by <code>String</code>s or <code>CaselessStringKey</code>s.
083:             *        This is simply forwarded to the superclass constructor.
084:             * @param computeType A tag indicating whether the source
085:             *        is <code>OpImage.OP_COMPUTE_BOUND</code>,
086:             *        <code>OpImage.OP_IO_BOUND</code> or
087:             *        <code>OpImage.OP_NETWORK_BOUND</code>.  This information is
088:             *        used as a hint to optimize <code>OpImage</code> computation.
089:             *
090:             * @throws <code>IllegalArgumentException</code> if <code>source</code>
091:             *        is <code>null</code>.
092:             * @throws <code>IllegalArgumentException</code> if <code>computeType</code>
093:             *        is not one of the known <code>OP_*_BOUND</code> values.
094:             *
095:             * @since JAI 1.1
096:             */
097:            public NullOpImage(RenderedImage source, ImageLayout layout,
098:                    Map configuration, int computeType) {
099:                // cobbleSources is irrelevant since we override getTile().
100:                super (PlanarImage.wrapRenderedImage(source).createSnapshot(),
101:                        layoutHelper(source, layout), configuration, false);
102:
103:                if (computeType != OP_COMPUTE_BOUND
104:                        && computeType != OP_IO_BOUND
105:                        && computeType != OP_NETWORK_BOUND) {
106:                    throw new IllegalArgumentException(JaiI18N
107:                            .getString("NullOpImage0"));
108:                }
109:
110:                this .computeType = computeType;
111:            }
112:
113:            /**
114:             * Constructs a <code>NullOpImage</code>.  The superclass
115:             * constructor will be passed a new <code>ImageLayout</code>
116:             * object with all of its fields filled in.  The <code>ColorModel</code>
117:             * may be overridden via the supplied <code>ImageLayout</code>; all
118:             * other layout fields are derived from the source image.  Any
119:             * specified <code>ColorModel</code> will be used if and only if it
120:             * is compatible with the source image <code>SampleModel</code>.
121:             *
122:             * @param source A <code>RenderedImage</code>; must not be
123:             *        <code>null</code> or a <code>IllegalArgumentException</code>
124:             *        will be thrown.
125:             * @param cache a TileCache object to store tiles from this OpImage,
126:             *        or null.  If null, a default cache will be used.
127:             * @param computeType A tag indicating whether the source
128:             *        is <code>OpImage.OP_COMPUTE_BOUND</code>,
129:             *        <code>OpImage.OP_IO_BOUND</code> or
130:             *        <code>OpImage.OP_NETWORK_BOUND</code>.  This information is
131:             *        used as a hint to optimize <code>OpImage</code> computation.
132:             * @param layout An <code>ImageLayout</code> optionally specifying
133:             *        the image <code>ColorModel</code>; all other fields are
134:             *        ignored.  This parameter may be <code>null</code>.
135:             *
136:             * @throws IllegalArgumentException if <code>source</code>
137:             *        is <code>null</code>.
138:             * @throws IllegalArgumentException if <code>computeType</code>
139:             *        is not one of the known <code>OP_*_BOUND</code> values.
140:             *
141:             * @deprecated as of JAI 1.1.
142:             */
143:            public NullOpImage(RenderedImage source, TileCache cache,
144:                    int computeType, ImageLayout layout) {
145:                this (source, layout, cache != null ? new RenderingHints(
146:                        JAI.KEY_TILE_CACHE, cache) : null, computeType);
147:            }
148:
149:            /**
150:             * Returns a tile for reading.
151:             *
152:             * @param tileX The X index of the tile.
153:             * @param tileY The Y index of the tile.
154:             * @return The tile as a <code>Raster</code>.
155:             */
156:            public Raster computeTile(int tileX, int tileY) {
157:                return getSource(0).getTile(tileX, tileY);
158:            }
159:
160:            /**
161:             * Returns false as NullOpImage can return via computeTile()
162:             * tiles that are internally cached.
163:             */
164:            public boolean computesUniqueTiles() {
165:                return false;
166:            }
167:
168:            /**
169:             * Returns the properties from the source image.
170:             */
171:            protected synchronized Hashtable getProperties() {
172:                return getSource(0).getProperties();
173:            }
174:
175:            /**
176:             * Set the properties <code>Hashtable</code> of the source image
177:             * to the supplied <code>Hashtable</code>.
178:             */
179:            protected synchronized void setProperties(Hashtable properties) {
180:                getSource(0).setProperties(properties);
181:            }
182:
183:            /**
184:             * Returns the property names from the source image or <code>null</code>
185:             * if no property names are recognized.
186:             */
187:            public String[] getPropertyNames() {
188:                return getSource(0).getPropertyNames();
189:            }
190:
191:            /**
192:             * Returns the property names with the supplied prefix from
193:             * the source image or <code>null</code> if no property names
194:             * are recognized.
195:             */
196:            public String[] getPropertyNames(String prefix) {
197:                return getSource(0).getPropertyNames(prefix);
198:            }
199:
200:            /**
201:             * Returns the class of the specified property from the source image.
202:             *
203:             * @since JAI 1.1
204:             */
205:            public Class getPropertyClass(String name) {
206:                return getSource(0).getPropertyClass(name);
207:            }
208:
209:            /**
210:             * Retrieves a property from the source image by name or
211:             * <code>java.awt.Image.UndefinedProperty</code> if the property
212:             * with the specified name is not defined.
213:             */
214:            public Object getProperty(String name) {
215:                return getSource(0).getProperty(name);
216:            }
217:
218:            /**
219:             * Sets a property on the source image by name.
220:             */
221:            public void setProperty(String name, Object value) {
222:                getSource(0).setProperty(name, value);
223:            }
224:
225:            /**
226:             * Removes a property from the source image by name.
227:             *
228:             * @since JAI 1.1
229:             */
230:            public void removeProperty(String name) {
231:                getSource(0).removeProperty(name);
232:            }
233:
234:            /**
235:             * Returns one of OP_COMPUTE_BOUND, OP_IO_BOUND, or
236:             * OP_NETWORK_BOUND to indicate how the operation is likely to
237:             * spend its time.  The answer does not affect the output of the
238:             * operation, but may allow a scheduler to parallelize the
239:             * computation of multiple operations more effectively.  The
240:             * default implementation returns OP_COMPUTE_BOUND.
241:             */
242:            public int getOperationComputeType() {
243:                return computeType;
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.