Source Code Cross Referenced for SubsampleAverageCRIF.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: SubsampleAverageCRIF.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:43 $
010:         * $State: Exp $
011:         */package com.sun.media.jai.opimage;
012:
013:        import java.awt.RenderingHints;
014:        import java.awt.geom.AffineTransform;
015:        import java.awt.geom.Rectangle2D;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.renderable.RenderContext;
018:        import java.awt.image.renderable.ParameterBlock;
019:        import java.awt.image.renderable.RenderableImage;
020:        import javax.media.jai.ImageLayout;
021:        import javax.media.jai.CRIFImpl;
022:
023:        /**
024:         * @see SubsampleAverageOpImage
025:         */
026:        public class SubsampleAverageCRIF extends CRIFImpl {
027:
028:            /** Constructor. */
029:            public SubsampleAverageCRIF() {
030:                super ("SubsampleAverage");
031:            }
032:
033:            /**
034:             * Creates a new instance of SubsampleAverageOpImage in the rendered layer.
035:             * This method satisfies the implementation of RIF.
036:             *
037:             * @param paramBlock  The source image, the X and Y scale factor,
038:             *                    and the interpolation method for resampling.
039:             */
040:            public RenderedImage create(ParameterBlock paramBlock,
041:                    RenderingHints renderHints) {
042:
043:                // Get ImageLayout from renderHints if any.
044:                ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
045:
046:                RenderedImage source = paramBlock.getRenderedSource(0);
047:                double scaleX = paramBlock.getDoubleParameter(0);
048:                double scaleY = paramBlock.getDoubleParameter(1);
049:
050:                // Check and see if we are scaling by 1.0 in both x and y and no
051:                // translations. If so return the source directly.	
052:                if (scaleX == 1.0 && scaleY == 1.0) {
053:                    return source;
054:                }
055:
056:                return new SubsampleAverageOpImage(source, layout, renderHints,
057:                        scaleX, scaleY);
058:            }
059:
060:            /**
061:             * Creates a new instance of <code>SubsampleAverageOpImage</code>
062:             * in the renderable layer. This method satisfies the
063:             * implementation of CRIF.
064:             */
065:            public RenderedImage create(RenderContext renderContext,
066:                    ParameterBlock paramBlock) {
067:                return paramBlock.getRenderedSource(0);
068:            }
069:
070:            /**
071:             * Maps the output RenderContext into the RenderContext for the ith
072:             * source.
073:             * This method satisfies the implementation of CRIF.
074:             *
075:             * @param i               The index of the source image.
076:             * @param renderContext   The renderContext being applied to the operation.
077:             * @param paramBlock      The ParameterBlock containing the sources
078:             *                        and the translation factors.
079:             * @param image           The RenderableImageOp from which this method
080:             *                        was called.
081:             */
082:            public RenderContext mapRenderContext(int i,
083:                    RenderContext renderContext, ParameterBlock paramBlock,
084:                    RenderableImage image) {
085:
086:                double scaleX = paramBlock.getDoubleParameter(0);
087:                double scaleY = paramBlock.getDoubleParameter(1);
088:
089:                AffineTransform scale = new AffineTransform(scaleX, 0.0, 0.0,
090:                        scaleY, 0.0, 0.0);
091:
092:                RenderContext RC = (RenderContext) renderContext.clone();
093:                AffineTransform usr2dev = RC.getTransform();
094:                usr2dev.concatenate(scale);
095:                RC.setTransform(usr2dev);
096:                return RC;
097:            }
098:
099:            /**
100:             * Gets the bounding box for the output of <code>ScaleOpImage</code>.
101:             * This method satisfies the implementation of CRIF.
102:             */
103:            public Rectangle2D getBounds2D(ParameterBlock paramBlock) {
104:
105:                RenderableImage source = paramBlock.getRenderableSource(0);
106:
107:                double scaleX = paramBlock.getDoubleParameter(0);
108:                double scaleY = paramBlock.getDoubleParameter(1);
109:
110:                // Get the source dimensions
111:                float x0 = (float) source.getMinX();
112:                float y0 = (float) source.getMinY();
113:                float w = (float) source.getWidth();
114:                float h = (float) source.getHeight();
115:
116:                // Forward map the source using x0, y0, w and h
117:                float d_x0 = (float) (x0 * scaleX);
118:                float d_y0 = (float) (y0 * scaleY);
119:                float d_w = (float) (w * scaleX);
120:                float d_h = (float) (h * scaleY);
121:
122:                return new Rectangle2D.Float(d_x0, d_y0, d_w, d_h);
123:            }
124:
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.