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


001:        /*
002:         * $RCSfile: RookIterFallback.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:55:43 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.iterator;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.SampleModel;
018:        import javax.media.jai.PlanarImage;
019:        import javax.media.jai.iterator.RookIter;
020:
021:        /**
022:         * @since EA2
023:         */
024:        public class RookIterFallback implements  RookIter {
025:
026:            /** The source image. */
027:            protected RenderedImage im;
028:
029:            /** The iterator bounding rectangle. */
030:            protected Rectangle bounds;
031:
032:            /** The SampleModel for the tiles of the source image. */
033:            protected SampleModel sampleModel;
034:
035:            /** The number of bands of the source image. */
036:            protected int numBands;
037:
038:            /** The width of tiles in the source image. */
039:            protected int tileWidth;
040:
041:            /** The height of tiles in the source image. */
042:            protected int tileHeight;
043:
044:            /** The X offset of the source image tile grid. */
045:            protected int tileGridXOffset;
046:
047:            /** The Y offset of the source image tile grid. */
048:            protected int tileGridYOffset;
049:
050:            /** The tile index of the leftmost column in the iterator's bounds. */
051:            protected int startTileX;
052:
053:            /** The tile index of the rightmost column in the iterator's bounds. */
054:            protected int endTileX;
055:
056:            /** The tile index of the topmost row in the iterator's bounds. */
057:            protected int startTileY;
058:
059:            /** The tile index of the bottommost row in the iterator's bounds. */
060:            protected int endTileY;
061:
062:            /** The (inclusive) smallest X coordinate of the current tile. */
063:            protected int tileXStart;
064:
065:            /** The (inclusive) largest X coordinate of the current tile. */
066:            protected int tileXEnd;
067:
068:            /** The (inclusive) smallest Y coordinate of the current tile. */
069:            protected int tileYStart;
070:
071:            /** The (inclusive) largest Y coordinate of the current tile. */
072:            protected int tileYEnd;
073:
074:            /** The next leftwards tile or image boundary. */
075:            protected int prevXBoundary;
076:
077:            /** The next rightwards tile or image boundary. */
078:            protected int nextXBoundary;
079:
080:            /** The next upwards tile or image boundary. */
081:            protected int prevYBoundary;
082:
083:            /** The next downwards tile or image boundary. */
084:            protected int nextYBoundary;
085:
086:            /** The X index of the current tile. */
087:            protected int tileX;
088:
089:            /** The Y index of the current tile. */
090:            protected int tileY;
091:
092:            /** The (inclusive) smallest X coordinate of the bounding rectangle. */
093:            protected int firstX;
094:
095:            /** The (inclusive) smallest Y coordinate of the bounding rectangle. */
096:            protected int firstY;
097:
098:            /** The (inclusive) largest X coordinate of the bounding rectangle. */
099:            protected int lastX;
100:
101:            /** The (inclusive) largest Y coordinate of the bounding rectangle. */
102:            protected int lastY;
103:
104:            /** The current X pixel position. */
105:            protected int x;
106:
107:            /** The current Y pixel position. */
108:            protected int y;
109:
110:            /** The current X pixel position relative to the tile start. */
111:            protected int localX;
112:
113:            /** The current Y pixel position relative to the tile start. */
114:            protected int localY;
115:
116:            /** The current band offset. */
117:            protected int b;
118:
119:            /** The DataBuffer of the current tile. */
120:            protected DataBuffer dataBuffer = null;
121:
122:            public RookIterFallback(RenderedImage im, Rectangle bounds) {
123:                this .im = im;
124:                this .bounds = bounds;
125:
126:                this .sampleModel = im.getSampleModel();
127:                this .numBands = sampleModel.getNumBands();
128:
129:                this .tileGridXOffset = im.getTileGridXOffset();
130:                this .tileGridYOffset = im.getTileGridYOffset();
131:                this .tileWidth = im.getTileWidth();
132:                this .tileHeight = im.getTileHeight();
133:
134:                this .startTileX = PlanarImage.XToTileX(bounds.x,
135:                        tileGridXOffset, tileWidth);
136:                this .endTileX = PlanarImage.XToTileX(bounds.x + bounds.width
137:                        - 1, tileGridXOffset, tileWidth);
138:                this .startTileY = PlanarImage.YToTileY(bounds.y,
139:                        tileGridYOffset, tileHeight);
140:                this .endTileY = PlanarImage.YToTileY(bounds.y + bounds.height
141:                        - 1, tileGridYOffset, tileHeight);
142:
143:                this .tileX = startTileX;
144:                this .tileY = startTileY;
145:
146:                this .firstX = bounds.x;
147:                this .firstY = bounds.y;
148:                this .lastX = bounds.x + bounds.width - 1;
149:                this .lastY = bounds.y + bounds.height - 1;
150:
151:                x = bounds.x;
152:                y = bounds.y;
153:                b = 0;
154:
155:                setTileXBounds();
156:                setTileYBounds();
157:                setDataBuffer();
158:            }
159:
160:            private final void setTileXBounds() {
161:                tileXStart = tileX * tileWidth + tileGridXOffset;
162:                tileXEnd = tileXStart + tileWidth - 1;
163:                localX = x - tileXStart;
164:
165:                prevXBoundary = Math.max(tileXStart, firstX);
166:                nextXBoundary = Math.min(tileXEnd, lastX);
167:            }
168:
169:            private final void setTileYBounds() {
170:                tileYStart = tileY * tileHeight + tileGridYOffset;
171:                tileYEnd = tileYStart + tileHeight - 1;
172:                localY = y - tileYStart;
173:
174:                prevYBoundary = Math.max(tileYStart, firstY);
175:                nextYBoundary = Math.min(tileYEnd, lastY);
176:            }
177:
178:            private final void setDataBuffer() {
179:                this .dataBuffer = im.getTile(tileX, tileY).getDataBuffer();
180:            }
181:
182:            public void startLines() {
183:                y = firstY;
184:                localY = y - tileYStart;
185:                tileY = startTileY;
186:                setTileYBounds();
187:                setDataBuffer();
188:            }
189:
190:            public void endLines() {
191:                y = lastY;
192:                localY = y - tileYStart;
193:                tileY = endTileY;
194:                setTileYBounds();
195:                setDataBuffer();
196:            }
197:
198:            public void nextLine() {
199:                ++y;
200:                ++localY;
201:            }
202:
203:            public void prevLine() {
204:                --y;
205:                --localY;
206:            }
207:
208:            public void jumpLines(int num) {
209:                y += num;
210:                localY += num;
211:
212:                if (y < tileYStart || y > tileYEnd) {
213:                    this .tileY = PlanarImage.YToTileY(y, tileGridYOffset,
214:                            tileHeight);
215:                    setTileYBounds();
216:                    setDataBuffer();
217:                }
218:            }
219:
220:            public boolean finishedLines() {
221:                if (y > nextYBoundary) {
222:                    if (y > lastY) {
223:                        return true;
224:                    } else {
225:                        ++tileY;
226:                        tileYStart += tileHeight;
227:                        tileYEnd += tileHeight;
228:                        localY -= tileHeight;
229:                        prevYBoundary = Math.max(tileYStart, firstY);
230:                        nextYBoundary = Math.min(tileYEnd, lastY);
231:
232:                        setDataBuffer();
233:                        return false;
234:                    }
235:                } else {
236:                    return false;
237:                }
238:            }
239:
240:            public boolean finishedLinesTop() {
241:                if (y < prevYBoundary) {
242:                    if (y < firstY) {
243:                        return true;
244:                    } else {
245:                        --tileY;
246:                        tileYStart -= tileHeight;
247:                        tileYEnd -= tileHeight;
248:                        localY += tileHeight;
249:                        prevYBoundary = Math.max(tileYStart, firstY);
250:                        nextYBoundary = Math.min(tileYEnd, lastY);
251:
252:                        setDataBuffer();
253:                        return false;
254:                    }
255:                } else {
256:                    return false;
257:                }
258:            }
259:
260:            public boolean nextLineDone() {
261:                nextLine();
262:                return finishedLines();
263:            }
264:
265:            public boolean prevLineDone() {
266:                prevLine();
267:                return finishedLinesTop();
268:            }
269:
270:            public void startPixels() {
271:                x = firstX;
272:                localX = x - tileXStart;
273:                tileX = startTileX;
274:                setTileXBounds();
275:                setDataBuffer();
276:            }
277:
278:            public void endPixels() {
279:                x = lastX;
280:                tileX = endTileX;
281:                setTileXBounds();
282:                setDataBuffer();
283:            }
284:
285:            public void nextPixel() {
286:                ++x;
287:                ++localX;
288:            }
289:
290:            public void prevPixel() {
291:                --x;
292:                --localX;
293:            }
294:
295:            public void jumpPixels(int num) {
296:                x += num;
297:                localX += num;
298:
299:                if (x < tileXStart || x > tileXEnd) {
300:                    this .tileX = PlanarImage.XToTileX(x, tileGridXOffset,
301:                            tileWidth);
302:                    setTileXBounds();
303:                    setDataBuffer();
304:                }
305:            }
306:
307:            public boolean finishedPixels() {
308:                if (x > nextXBoundary) {
309:                    if (x > lastX) {
310:                        return true;
311:                    } else {
312:                        ++tileX;
313:                        tileXStart += tileWidth;
314:                        tileXEnd += tileWidth;
315:                        localX -= tileWidth;
316:                        prevXBoundary = Math.max(tileXStart, firstX);
317:                        nextXBoundary = Math.min(tileXEnd, lastX);
318:
319:                        setDataBuffer();
320:                        return false;
321:                    }
322:                } else {
323:                    return false;
324:                }
325:            }
326:
327:            public boolean finishedPixelsLeft() {
328:                if (x < prevXBoundary) {
329:                    if (x < firstX) {
330:                        return true;
331:                    } else {
332:                        --tileX;
333:                        tileXStart -= tileWidth;
334:                        tileXEnd -= tileWidth;
335:                        localX += tileWidth;
336:                        prevXBoundary = Math.max(tileXStart, firstX);
337:                        nextXBoundary = Math.min(tileXEnd, lastX);
338:
339:                        setDataBuffer();
340:                        return false;
341:                    }
342:                } else {
343:                    return false;
344:                }
345:            }
346:
347:            public boolean nextPixelDone() {
348:                nextPixel();
349:                return finishedPixels();
350:            }
351:
352:            public boolean prevPixelDone() {
353:                prevPixel();
354:                return finishedPixelsLeft();
355:            }
356:
357:            public void startBands() {
358:                b = 0;
359:            }
360:
361:            public void endBands() {
362:                b = numBands - 1;
363:            }
364:
365:            public void prevBand() {
366:                --b;
367:            }
368:
369:            public void nextBand() {
370:                ++b;
371:            }
372:
373:            public boolean prevBandDone() {
374:                return (--b) < 0;
375:            }
376:
377:            public boolean nextBandDone() {
378:                return (++b) >= numBands;
379:            }
380:
381:            public boolean finishedBands() {
382:                return b >= numBands;
383:            }
384:
385:            public int getSample() {
386:                return sampleModel.getSample(localX, localY, b, dataBuffer);
387:            }
388:
389:            public int getSample(int b) {
390:                return sampleModel.getSample(localX, localY, b, dataBuffer);
391:            }
392:
393:            public float getSampleFloat() {
394:                return sampleModel
395:                        .getSampleFloat(localX, localY, b, dataBuffer);
396:            }
397:
398:            public float getSampleFloat(int b) {
399:                return sampleModel
400:                        .getSampleFloat(localX, localY, b, dataBuffer);
401:            }
402:
403:            public double getSampleDouble() {
404:                return sampleModel.getSampleDouble(localX, localY, b,
405:                        dataBuffer);
406:            }
407:
408:            public double getSampleDouble(int b) {
409:                return sampleModel.getSampleDouble(localX, localY, b,
410:                        dataBuffer);
411:            }
412:
413:            public int[] getPixel(int[] iArray) {
414:                return sampleModel.getPixel(localX, localY, iArray, dataBuffer);
415:            }
416:
417:            public float[] getPixel(float[] fArray) {
418:                return sampleModel.getPixel(localX, localY, fArray, dataBuffer);
419:            }
420:
421:            public double[] getPixel(double[] dArray) {
422:                return sampleModel.getPixel(localX, localY, dArray, dataBuffer);
423:            }
424:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.