Source Code Cross Referenced for Rotate.java in  » Build » ANT » org » apache » tools » ant » types » optional » image » 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 » Build » ANT » org.apache.tools.ant.types.optional.image 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.types.optional.image;
019:
020:        import javax.media.jai.PlanarImage;
021:        import javax.media.jai.InterpolationNearest;
022:        import javax.media.jai.JAI;
023:        import java.awt.image.renderable.ParameterBlock;
024:        import java.awt.image.BufferedImage;
025:        import java.awt.Graphics2D;
026:
027:        /**
028:         * ImageOperation to rotate an image by a certain degree
029:         *
030:         * @see org.apache.tools.ant.taskdefs.optional.image.Image
031:         */
032:        public class Rotate extends TransformOperation implements  DrawOperation {
033:            private static final float HALF_CIRCLE = 180.0F;
034:
035:            // CheckStyle:VisibilityModifier OFF - bc
036:            protected float angle = 0.0F;
037:
038:            // CheckStyle:VisibilityModifier ON
039:
040:            /**
041:             * Sets the angle of rotation in degrees.
042:             * @param ang The angle at which to rotate the image
043:             */
044:            public void setAngle(String ang) {
045:                angle = Float.parseFloat(ang);
046:            }
047:
048:            /**
049:             * Rotate an image.
050:             * @param image the image to rotate.
051:             * @return the rotated image.
052:             */
053:            public PlanarImage performRotate(PlanarImage image) {
054:                float tAngle = (float) (angle * (Math.PI / HALF_CIRCLE));
055:                ParameterBlock pb = new ParameterBlock();
056:                pb.addSource(image);
057:                pb.add(0.0F);
058:                pb.add(0.0F);
059:                pb.add(tAngle);
060:                pb.add(new InterpolationNearest());
061:                return JAI.create("Rotate", pb, null);
062:            }
063:
064:            /**
065:             * Performs the image rotation when being handled as a TransformOperation.
066:             * @param image The image to perform the transformation on.
067:             * @return the transformed image.
068:             */
069:            public PlanarImage executeTransformOperation(PlanarImage image) {
070:                BufferedImage bi = null;
071:                Graphics2D graphics = null;
072:                for (int i = 0; i < instructions.size(); i++) {
073:                    ImageOperation instr = ((ImageOperation) instructions
074:                            .elementAt(i));
075:                    if (instr instanceof  DrawOperation) {
076:                        // If this TransformOperation has DrawOperation children
077:                        // then Rotate the first child and return.
078:                        System.out.println("Execing Draws");
079:                        PlanarImage op = ((DrawOperation) instr)
080:                                .executeDrawOperation();
081:                        image = performRotate(op);
082:                        return image;
083:                    } else if (instr instanceof  TransformOperation) {
084:                        bi = image.getAsBufferedImage();
085:                        graphics = (Graphics2D) bi.getGraphics();
086:                        System.out.println("Execing Transforms");
087:                        image = ((TransformOperation) instr)
088:                                .executeTransformOperation(PlanarImage
089:                                        .wrapRenderedImage(bi));
090:                        bi = image.getAsBufferedImage();
091:                    }
092:                }
093:                System.out.println("Execing as TransformOperation");
094:                image = performRotate(image);
095:                System.out.println(image);
096:                return image;
097:            }
098:
099:            /**
100:             *  Performs the image rotation when being handled as a DrawOperation.
101:             *  It absolutely requires that there be a DrawOperation nested beneath it,
102:             *  but only the FIRST DrawOperation will be handled since it can only return
103:             *  ONE image.
104:             * @return the image.
105:             */
106:            public PlanarImage executeDrawOperation() {
107:                for (int i = 0; i < instructions.size(); i++) {
108:                    ImageOperation instr = ((ImageOperation) instructions
109:                            .elementAt(i));
110:                    if (instr instanceof  DrawOperation) {
111:                        // If this TransformOperation has DrawOperation children
112:                        // then Rotate the first child and return.
113:                        PlanarImage op = ((DrawOperation) instr)
114:                                .executeDrawOperation();
115:                        op = performRotate(op);
116:                        return op;
117:                    }
118:                }
119:                return null;
120:            }
121:
122:        }
w_ww._j__a_v__a_2___s_._c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.