Source Code Cross Referenced for SourcelessOpImage.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: SourcelessOpImage.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:21 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.awt.Point;
015:        import java.awt.Rectangle;
016:        import java.awt.image.Raster;
017:        import java.awt.image.SampleModel;
018:        import java.awt.image.WritableRaster;
019:        import java.util.Map;
020:        import javax.media.jai.util.CaselessStringKey;
021:
022:        /**
023:         * An abstract base class for image operators that have no image
024:         * sources.
025:         *
026:         * <p> <code>SourcelessOpImage</code> is intended as a convenient superclass
027:         * for <code>OpImage</code>s that have no source image.  Some examples are
028:         * constant color images, file readers, protocol-based network readers,
029:         * and mathematically-defined imagery such as fractals.
030:         *
031:         * <p> The <code>computeTile</code> method of this class will call the
032:         * <code>computeRect(PlanarImage[], WritableRaster, Rectangle)</code>
033:         * method of the subclass to perform the computation.  The first
034:         * argument will be <code>null</code> as there are no source images.
035:         *
036:         * @see OpImage
037:         */
038:        public abstract class SourcelessOpImage extends OpImage {
039:
040:            private static ImageLayout layoutHelper(int minX, int minY,
041:                    int width, int height, SampleModel sampleModel,
042:                    ImageLayout il) {
043:                ImageLayout layout = (il == null) ? new ImageLayout()
044:                        : (ImageLayout) il.clone();
045:
046:                layout.setMinX(minX);
047:                layout.setMinY(minY);
048:                layout.setWidth(width);
049:                layout.setHeight(height);
050:                layout.setSampleModel(sampleModel);
051:
052:                if (!layout.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) {
053:                    layout.setTileGridXOffset(layout.getMinX(null));
054:                }
055:                if (!layout.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) {
056:                    layout.setTileGridYOffset(layout.getMinY(null));
057:                }
058:
059:                return layout;
060:            }
061:
062:            /**
063:             * Constructs a <code>SourcelessOpImage</code>.  The image bounds
064:             * and <code>SampleModel</code> are set explicitly; other layout
065:             * parameters may be set using the <code>layout</code> parameter.
066:             * The min X, min Y, width, height, and <code>SampleModel</code>
067:             * fields of the <code>layout</code> parameter are ignored.
068:             *
069:             * <p> If <code>sampleModel</code> is <code>null</code>, no
070:             * exceptions will be thrown.  However, the caller must be sure to
071:             * set the <code>sampleModel</code> instance variable before
072:             * construction terminates.  This feature allows subclasses that
073:             * require external computation such as file loading to defer the
074:             * determination of their <code>SampleModel</code> until after the
075:             * call to <code>super</code>.
076:             *
077:             * <p> Similarly, <code>minX</code>, <code>minY</code>,
078:             * <code>width</code>, and <code>height</code> may be dummy values
079:             * if care is taken to manually set all values that depend on
080:             * them, namely the tile grid offset, tile size, and
081:             * <code>SampleModel</code> width and height.
082:             *
083:             * <p> The tile dimensions, tile grid X and Y offsets, and
084:             * <code>ColorModel</code> of the output will be set in the standard
085:             * way by the <code>OpImage</code> constructor.
086:             *
087:             * @param configuration Configurable attributes of the image including
088:             *        configuration variables indexed by
089:             *        <code>RenderingHints.Key</code>s and image properties indexed
090:             *        by <code>String</code>s or <code>CaselessStringKey</code>s.
091:             *        This is simply forwarded to the superclass constructor.
092:             * @param layout an <code>ImageLayout</code> describing the layout.
093:             *
094:             * @since JAI 1.1
095:             */
096:            public SourcelessOpImage(ImageLayout layout, Map configuration,
097:                    SampleModel sampleModel, int minX, int minY, int width,
098:                    int height) {
099:                super (null, layoutHelper(minX, minY, width, height,
100:                        sampleModel, layout), configuration, false);
101:            }
102:
103:            /**
104:             * Returns false as SourcelessOpImages often return Rasters
105:             * via computeTile() tile that are internally cached.  Some
106:             * subclasses may want to override this method and return true.
107:             */
108:            public boolean computesUniqueTiles() {
109:                return false;
110:            }
111:
112:            /**
113:             * Computes a tile.  Since the operation has no sources,
114:             * there is no need to worry about cobbling.
115:             *
116:             * <p> Subclasses should implement the
117:             * <code>computeRect(PlanarImage[], WritableRaster, Rectangle)</code>
118:             * method to perform the actual computation.
119:             *
120:             * @param tileX The X index of the tile.
121:             * @param tileY The Y index of the tile.
122:             */
123:            public Raster computeTile(int tileX, int tileY) {
124:                /* Create a new WritableRaster to represent this tile. */
125:                Point org = new Point(tileXToX(tileX), tileYToY(tileY));
126:                WritableRaster dest = createWritableRaster(sampleModel, org);
127:
128:                /* Clip output rectangle to image bounds. */
129:                Rectangle rect = new Rectangle(org.x, org.y, sampleModel
130:                        .getWidth(), sampleModel.getHeight());
131:                Rectangle destRect = rect.intersection(getBounds());
132:                computeRect((PlanarImage[]) null, dest, destRect);
133:                return dest;
134:            }
135:
136:            /**
137:             * Throws an IllegalArgumentException since the image has no image
138:             * sources.
139:             *
140:             * @param sourceRect ignored.
141:             * @param sourceIndex ignored.
142:             *
143:             * @throws IllegalArgumentException since the image has no sources.
144:             */
145:            public Rectangle mapSourceRect(Rectangle sourceRect, int sourceIndex) {
146:                throw new IllegalArgumentException(JaiI18N
147:                        .getString("SourcelessOpImage0"));
148:            }
149:
150:            /**
151:             * Throws an IllegalArgumentException since the image has no image
152:             * sources.
153:             *
154:             * @param destRect ignored.
155:             * @param sourceIndex ignored.
156:             *
157:             * @throws IllegalArgumentException since the image has no sources.
158:             */
159:            public Rectangle mapDestRect(Rectangle destRect, int sourceIndex) {
160:                throw new IllegalArgumentException(JaiI18N
161:                        .getString("SourcelessOpImage0"));
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.