Source Code Cross Referenced for RenderableImageOp.java in  » Apache-Harmony-Java-SE » java-package » java » awt » image » renderable » 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 » Apache Harmony Java SE » java package » java.awt.image.renderable 
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:         * @author Igor V. Stolyarov
019:         * @version $Revision$
020:         */package java.awt.image.renderable;
021:
022:        import java.awt.RenderingHints;
023:        import java.awt.geom.AffineTransform;
024:        import java.awt.geom.Rectangle2D;
025:        import java.awt.image.RenderedImage;
026:        import java.util.Vector;
027:
028:        import org.apache.harmony.awt.internal.nls.Messages;
029:
030:        public class RenderableImageOp implements  RenderableImage {
031:
032:            ContextualRenderedImageFactory CRIF;
033:            ParameterBlock paramBlock;
034:            float minX, minY, width, height;
035:
036:            public RenderableImageOp(ContextualRenderedImageFactory CRIF,
037:                    ParameterBlock paramBlock) {
038:                this .CRIF = CRIF;
039:                this .paramBlock = (ParameterBlock) paramBlock.clone();
040:                Rectangle2D r = CRIF.getBounds2D(paramBlock);
041:                minX = (float) r.getMinX();
042:                minY = (float) r.getMinY();
043:                width = (float) r.getWidth();
044:                height = (float) r.getHeight();
045:            }
046:
047:            public Object getProperty(String name) {
048:                return CRIF.getProperty(paramBlock, name);
049:            }
050:
051:            public ParameterBlock setParameterBlock(ParameterBlock paramBlock) {
052:                ParameterBlock oldParam = this .paramBlock;
053:                this .paramBlock = (ParameterBlock) paramBlock.clone();
054:                return oldParam;
055:            }
056:
057:            public RenderedImage createRendering(RenderContext renderContext) {
058:
059:                Vector<RenderableImage> sources = getSources();
060:                ParameterBlock rdParam = (ParameterBlock) paramBlock.clone();
061:
062:                if (sources != null) {
063:                    Vector<Object> rdSources = new Vector<Object>();
064:                    int i = 0;
065:                    while (i < sources.size()) {
066:                        RenderContext newContext = CRIF.mapRenderContext(i,
067:                                renderContext, paramBlock, this );
068:                        RenderedImage rdim = sources.elementAt(i)
069:                                .createRendering(newContext);
070:
071:                        if (rdim != null) {
072:                            rdSources.addElement(rdim);
073:                        }
074:                        i++;
075:                    }
076:                    if (rdSources.size() > 0) {
077:                        rdParam.setSources(rdSources);
078:                    }
079:                }
080:                return CRIF.create(renderContext, rdParam);
081:            }
082:
083:            public RenderedImage createScaledRendering(int w, int h,
084:                    RenderingHints hints) {
085:                if (w == 0 && h == 0) {
086:                    // awt.60=Width and Height mustn't be equal zero both
087:                    throw new IllegalArgumentException(Messages
088:                            .getString("awt.60")); //$NON-NLS-1$
089:                }
090:                if (w == 0) {
091:                    w = Math.round(h * (getWidth() / getHeight()));
092:                }
093:
094:                if (h == 0) {
095:                    h = Math.round(w * (getHeight() / getWidth()));
096:                }
097:
098:                double sx = (double) w / getWidth();
099:                double sy = (double) h / getHeight();
100:
101:                AffineTransform at = AffineTransform.getScaleInstance(sx, sy);
102:                RenderContext context = new RenderContext(at, hints);
103:                return createRendering(context);
104:            }
105:
106:            public Vector<RenderableImage> getSources() {
107:                if (paramBlock.getNumSources() == 0) {
108:                    return null;
109:                }
110:                Vector<RenderableImage> v = new Vector<RenderableImage>();
111:                int i = 0;
112:                while (i < paramBlock.getNumSources()) {
113:                    Object o = paramBlock.getSource(i);
114:                    if (o instanceof  RenderableImage) {
115:                        v.addElement((RenderableImage) o);
116:                    }
117:                    i++;
118:                }
119:                return v;
120:            }
121:
122:            public String[] getPropertyNames() {
123:                return CRIF.getPropertyNames();
124:            }
125:
126:            public ParameterBlock getParameterBlock() {
127:                return paramBlock;
128:            }
129:
130:            public RenderedImage createDefaultRendering() {
131:                AffineTransform at = new AffineTransform();
132:                RenderContext context = new RenderContext(at);
133:                return createRendering(context);
134:            }
135:
136:            public boolean isDynamic() {
137:                return CRIF.isDynamic();
138:            }
139:
140:            public float getWidth() {
141:                return width;
142:            }
143:
144:            public float getMinY() {
145:                return minY;
146:            }
147:
148:            public float getMinX() {
149:                return minX;
150:            }
151:
152:            public float getHeight() {
153:                return height;
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.