Source Code Cross Referenced for TurbulenceRable8Bit.java in  » Graphic-Library » batik » org » apache » batik » ext » 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 » Graphic Library » batik » org.apache.batik.ext.awt.image.renderable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:
020:        package org.apache.batik.ext.awt.image.renderable;
021:
022:        import java.awt.Rectangle;
023:        import java.awt.Shape;
024:        import java.awt.color.ColorSpace;
025:        import java.awt.geom.AffineTransform;
026:        import java.awt.geom.NoninvertibleTransformException;
027:        import java.awt.geom.Rectangle2D;
028:        import java.awt.image.RenderedImage;
029:        import java.awt.image.renderable.RenderContext;
030:
031:        import org.apache.batik.ext.awt.image.rendered.TurbulencePatternRed;
032:
033:        /**
034:         * Creates a sourceless image from a turbulence function.
035:         *
036:         * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
037:         * @version $Id: TurbulenceRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
038:         */
039:        public class TurbulenceRable8Bit extends
040:                AbstractColorInterpolationRable implements  TurbulenceRable {
041:
042:            int seed = 0; // Seed value to pseudo rand num gen.
043:            int numOctaves = 1; // number of octaves in turbulence function
044:            double baseFreqX = 0; // Frequency in X/Y directions
045:            double baseFreqY = 0;
046:            boolean stitched = false; // True if tiles are stitched
047:            boolean fractalNoise = false; // True if fractal noise should be used.
048:
049:            Rectangle2D region;
050:
051:            public TurbulenceRable8Bit(Rectangle2D region) {
052:                super ();
053:                this .region = region;
054:            }
055:
056:            public TurbulenceRable8Bit(Rectangle2D region, int seed,
057:                    int numOctaves, double baseFreqX, double baseFreqY,
058:                    boolean stitched, boolean fractalNoise) {
059:                super ();
060:                this .seed = seed;
061:                this .numOctaves = numOctaves;
062:                this .baseFreqX = baseFreqX;
063:                this .baseFreqY = baseFreqY;
064:                this .stitched = stitched;
065:                this .fractalNoise = fractalNoise;
066:                this .region = region;
067:            }
068:
069:            /**
070:             * Get the turbulence region
071:             */
072:            public Rectangle2D getTurbulenceRegion() {
073:                return (Rectangle2D) region.clone();
074:            }
075:
076:            /**
077:             * Get the turbulence region
078:             */
079:            public Rectangle2D getBounds2D() {
080:                return (Rectangle2D) region.clone();
081:            }
082:
083:            /**
084:             * Get the current seed value for the pseudo random number generator.
085:             * @return The current seed value for the pseudo random number generator.
086:             */
087:            public int getSeed() {
088:                return seed;
089:            }
090:
091:            /**
092:             * Get the current number of octaves for the noise function .
093:             * @return The current number of octaves for the noise function .
094:             */
095:            public int getNumOctaves() {
096:                return numOctaves;
097:            }
098:
099:            /**
100:             * Get the current base fequency in x direction.
101:             * @return The current base fequency in x direction.
102:             */
103:            public double getBaseFrequencyX() {
104:                return baseFreqX;
105:            }
106:
107:            /**
108:             * Get the current base fequency in y direction.
109:             * @return The current base fequency in y direction.
110:             */
111:            public double getBaseFrequencyY() {
112:                return baseFreqY;
113:            }
114:
115:            /**
116:             * Returns true if the turbulence function is currently stitching tiles.
117:             * @return true if the turbulence function is currently stitching tiles.
118:             */
119:            public boolean isStitched() {
120:                return stitched;
121:            }
122:
123:            /**
124:             * Returns true if the turbulence function is using fractal noise,
125:             * instead of turbulence noise.
126:             * @return true if the turbulence function is using fractal noise,
127:             * instead of turbulence noise.
128:             */
129:            public boolean isFractalNoise() {
130:                return fractalNoise;
131:            }
132:
133:            /**
134:             * Sets the turbulence region
135:             * @param turbulenceRegion region to fill with turbulence function.
136:             */
137:            public void setTurbulenceRegion(Rectangle2D turbulenceRegion) {
138:                touch();
139:                this .region = turbulenceRegion;
140:            }
141:
142:            /**
143:             * Set the seed value for the pseudo random number generator.
144:             * @param seed The new seed value for the pseudo random number generator.
145:             */
146:            public void setSeed(int seed) {
147:                touch();
148:                this .seed = seed;
149:            }
150:
151:            /**
152:             * Set the number of octaves for the noise function .
153:             * @param numOctaves The new number of octaves for the noise function .
154:             */
155:            public void setNumOctaves(int numOctaves) {
156:                touch();
157:                this .numOctaves = numOctaves;
158:            }
159:
160:            /**
161:             * Set the base fequency in x direction.
162:             * @param baseFreqX The new base fequency in x direction.
163:             */
164:            public void setBaseFrequencyX(double baseFreqX) {
165:                touch();
166:                this .baseFreqX = baseFreqX;
167:            }
168:
169:            /**
170:             * Set the base fequency in y direction.
171:             * @param baseFreqY The new base fequency in y direction.
172:             */
173:            public void setBaseFrequencyY(double baseFreqY) {
174:                touch();
175:                this .baseFreqY = baseFreqY;
176:            }
177:
178:            /**
179:             * Set stitching state for tiles.
180:             * @param stitched true if the turbulence operator should stitch tiles.
181:             */
182:            public void setStitched(boolean stitched) {
183:                touch();
184:                this .stitched = stitched;
185:            }
186:
187:            /**
188:             * Turns on/off fractal noise.
189:             * @param fractalNoise true if fractal noise should be used.
190:             */
191:            public void setFractalNoise(boolean fractalNoise) {
192:                touch();
193:                this .fractalNoise = fractalNoise;
194:            }
195:
196:            public RenderedImage createRendering(RenderContext rc) {
197:
198:                Rectangle2D aoiRect;
199:                Shape aoi = rc.getAreaOfInterest();
200:                if (aoi == null) {
201:                    aoiRect = getBounds2D();
202:                } else {
203:                    Rectangle2D rect = getBounds2D();
204:                    aoiRect = aoi.getBounds2D();
205:                    if (!aoiRect.intersects(rect))
206:                        return null;
207:                    Rectangle2D.intersect(aoiRect, rect, aoiRect);
208:                }
209:
210:                AffineTransform usr2dev = rc.getTransform();
211:
212:                // Compute size of raster image in device space.
213:                // System.out.println("Turbulence aoi : " + aoi);
214:                // System.out.println("Scale X : " + usr2dev.getScaleX() + " scaleY : " + usr2dev.getScaleY());
215:                // System.out.println("Turbulence aoi dev : " + usr2dev.createTransformedShape(aoi).getBounds());
216:                final Rectangle devRect = usr2dev.createTransformedShape(
217:                        aoiRect).getBounds();
218:
219:                if ((devRect.width <= 0) || (devRect.height <= 0))
220:                    return null;
221:
222:                ColorSpace cs = getOperationColorSpace();
223:
224:                Rectangle2D tile = null;
225:                if (stitched)
226:                    tile = (Rectangle2D) region.clone();
227:
228:                AffineTransform patternTxf = new AffineTransform();
229:                try {
230:                    patternTxf = usr2dev.createInverse();
231:                } catch (NoninvertibleTransformException e) {
232:                }
233:
234:                return new TurbulencePatternRed(baseFreqX, baseFreqY,
235:                        numOctaves, seed, fractalNoise, tile, patternTxf,
236:                        devRect, cs, true);
237:            }
238:        }
w_w___w___.j__a__v__a___2___s_.co___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.