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


001:        /*
002:         * $RCSfile: ConstantCRIF.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:19 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.opimage;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.geom.AffineTransform;
016:        import java.awt.geom.Rectangle2D;
017:        import java.awt.image.DataBuffer;
018:        import java.awt.image.RenderedImage;
019:        import java.awt.image.renderable.ParameterBlock;
020:        import java.awt.image.renderable.RenderContext;
021:        import java.awt.image.renderable.RenderableImage;
022:        import javax.media.jai.CRIFImpl;
023:        import javax.media.jai.ImageLayout;
024:        import java.util.Map;
025:
026:        /**
027:         * This image factory supports image operator <code>ConstantOpImage</code>
028:         * in the rendered and renderable image layers.
029:         *
030:         * @see ConstantOpImage
031:         */
032:        public class ConstantCRIF extends CRIFImpl {
033:
034:            private static final int DEFAULT_TILE_SIZE = 128;
035:
036:            /** Constructor. */
037:            public ConstantCRIF() {
038:                super ("constant");
039:            }
040:
041:            /**
042:             * Creates a new instance of <code>ConstantOpImage</code>
043:             * in the rendered layer. This method satisfies the
044:             * implementation of RIF.
045:             */
046:            public RenderedImage create(ParameterBlock paramBlock,
047:                    RenderingHints renderHints) {
048:                // Get ImageLayout from renderHints if any.
049:                ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
050:
051:                // Get width, height, bandValues from the parameter block
052:                int width = Math.round(paramBlock.getFloatParameter(0));
053:                int height = Math.round(paramBlock.getFloatParameter(1));
054:                Number[] bandValues = (Number[]) paramBlock
055:                        .getObjectParameter(2);
056:
057:                int minX = 0;
058:                int minY = 0;
059:                int tileWidth = Math.min(width, DEFAULT_TILE_SIZE);
060:                int tileHeight = Math.min(height, DEFAULT_TILE_SIZE);
061:
062:                // Attempt to get minX, minY, tileWidth, tileHeight
063:                // from the ImageLayout hint
064:                if (layout != null) {
065:                    if (layout.isValid(ImageLayout.MIN_X_MASK)) {
066:                        minX = layout.getMinX(null);
067:                    }
068:                    if (layout.isValid(ImageLayout.MIN_Y_MASK)) {
069:                        minY = layout.getMinY(null);
070:                    }
071:                    if (layout.isValid(ImageLayout.TILE_WIDTH_MASK)) {
072:                        tileWidth = layout.getTileWidth(null);
073:                    }
074:                    if (layout.isValid(ImageLayout.TILE_HEIGHT_MASK)) {
075:                        tileHeight = layout.getTileHeight(null);
076:                    }
077:                }
078:
079:                return new ConstantOpImage(minX, minY, width, height,
080:                        tileWidth, tileHeight, bandValues);
081:            }
082:
083:            /**
084:             * Creates a new instance of <code>ConstantOpImage</code>
085:             * in the renderable layer. This method satisfies the
086:             * implementation of CRIF.
087:             *
088:             * @pram renderContext  Rendering information.
089:             * @param paramBlock    The image layout for the output of
090:             *                      <code>ConstantOpImage</code>
091:             *                      and the constant pixel value.
092:             */
093:            public RenderedImage create(RenderContext renderContext,
094:                    ParameterBlock paramBlock) {
095:                float minX = 0;
096:                float minY = 0;
097:                float width = paramBlock.getFloatParameter(0);
098:                float height = paramBlock.getFloatParameter(1);
099:                Number[] bandValues = (Number[]) paramBlock
100:                        .getObjectParameter(2);
101:
102:                AffineTransform trans = renderContext.getTransform();
103:                float maxX, maxY;
104:                float[] ptSrc = new float[8];
105:                float[] ptDst = new float[8];
106:
107:                ptSrc[0] = minX;
108:                ptSrc[1] = minY;
109:                ptSrc[2] = minX + width;
110:                ptSrc[3] = minY;
111:                ptSrc[4] = minX + width;
112:                ptSrc[5] = minY + height;
113:                ptSrc[6] = minX;
114:                ptSrc[7] = minY + height;
115:                trans.transform(ptSrc, 0, ptDst, 0, 4);
116:
117:                minX = Math.min(ptDst[0], ptDst[2]);
118:                minX = Math.min(minX, ptDst[4]);
119:                minX = Math.min(minX, ptDst[6]);
120:
121:                maxX = Math.max(ptDst[0], ptDst[2]);
122:                maxX = Math.max(maxX, ptDst[4]);
123:                maxX = Math.max(maxX, ptDst[6]);
124:
125:                minY = Math.min(ptDst[1], ptDst[3]);
126:                minY = Math.min(minY, ptDst[5]);
127:                minY = Math.min(minY, ptDst[7]);
128:
129:                maxY = Math.max(ptDst[1], ptDst[3]);
130:                maxY = Math.max(maxY, ptDst[5]);
131:                maxY = Math.max(maxY, ptDst[7]);
132:
133:                int iMinX = (int) minX;
134:                int iMinY = (int) minY;
135:                int iWidth = (int) maxX - iMinX;
136:                int iHeight = (int) maxY - iMinY;
137:
138:                return new ConstantOpImage(iMinX, iMinY, iWidth, iHeight, Math
139:                        .min(iWidth, DEFAULT_TILE_SIZE), Math.min(iHeight,
140:                        DEFAULT_TILE_SIZE), bandValues);
141:            }
142:
143:            /**
144:             * Gets the bounding box for the output of <code>ConstantOpImage</code>.
145:             * This method satisfies the implementation of CRIF.
146:             *
147:             * @param paramBlock  Image's width, height, and constant pixel values.
148:             */
149:            public Rectangle2D getBounds2D(ParameterBlock paramBlock) {
150:                return new Rectangle2D.Float(0, 0, paramBlock
151:                        .getFloatParameter(0), paramBlock.getFloatParameter(1));
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.