Source Code Cross Referenced for SubsampledRectIter.java in  » GIS » GeoTools-2.4.1 » org » geotools » image » io » 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 » GIS » GeoTools 2.4.1 » org.geotools.image.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2007, Geotools Project Managment Committee (PMC)
005:         *    (C) 2007, Geomatys
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation; either
010:         *    version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.image.io;
018:
019:        import javax.media.jai.iterator.RectIter;
020:
021:        /**
022:         * A {@link RectIter} with subsampling.
023:         *
024:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/coverageio/src/main/java/org/geotools/image/io/SubsampledRectIter.java $
025:         * @version $Id: SubsampledRectIter.java 26775 2007-08-30 15:58:26Z desruisseaux $
026:         * @author Martin Desruisseaux
027:         */
028:        final class SubsampledRectIter implements  RectIter {
029:            /**
030:             * The wrapped iterator.
031:             */
032:            private final RectIter iterator;
033:
034:            /**
035:             * Index of current band in the {@link #sourceBands} array.
036:             */
037:            private int bandIndex;
038:
039:            /**
040:             * The source bands.
041:             */
042:            private final int[] sourceBands;
043:
044:            /**
045:             * The subsampling parameters.
046:             */
047:            private final int dx, dy;
048:
049:            /**
050:             * Wraps the specified iterator.
051:             */
052:            public SubsampledRectIter(final RectIter iterator,
053:                    final int sourceXSubsampling, final int sourceYSubsampling,
054:                    final int[] sourceBands) {
055:                this .iterator = iterator;
056:                dx = sourceXSubsampling - 1;
057:                dy = sourceYSubsampling - 1;
058:                this .sourceBands = sourceBands;
059:            }
060:
061:            /**
062:             * Sets the iterator to the first line of its bounding rectangle.
063:             */
064:            public void startLines() {
065:                iterator.startLines();
066:            }
067:
068:            /**
069:             * Sets the iterator to the next line of the image.
070:             */
071:            public void nextLine() {
072:                nextLineDone();
073:            }
074:
075:            /**
076:             * Sets the iterator to the next line in the image.
077:             */
078:            public boolean nextLineDone() {
079:                if (iterator.nextLineDone()) {
080:                    return true;
081:                }
082:                iterator.jumpLines(dy);
083:                return false;
084:            }
085:
086:            /**
087:             * Jumps downward num lines from the current position.
088:             */
089:            public void jumpLines(final int num) {
090:                iterator.jumpLines(num * (dy + 1));
091:            }
092:
093:            /**
094:             * Returns true if the bottom row of the bounding rectangle has been passed.
095:             */
096:            public boolean finishedLines() {
097:                return iterator.finishedLines();
098:            }
099:
100:            /**
101:             * Sets the iterator to the leftmost pixel of its bounding rectangle.
102:             */
103:            public void startPixels() {
104:                iterator.startPixels();
105:            }
106:
107:            /**
108:             * Sets the iterator to the next pixel in image.
109:             */
110:            public void nextPixel() {
111:                nextPixelDone();
112:            }
113:
114:            /**
115:             * Sets the iterator to the next pixel in the image.
116:             */
117:            public boolean nextPixelDone() {
118:                if (iterator.nextPixelDone()) {
119:                    return true;
120:                }
121:                iterator.jumpPixels(dx);
122:                return false;
123:            }
124:
125:            /**
126:             * Jumps rightward num pixels from the current position.
127:             */
128:            public void jumpPixels(final int num) {
129:                iterator.jumpPixels(num * (dx + 1));
130:            }
131:
132:            /**
133:             * Returns true if the right edge of the bounding rectangle has been passed.
134:             */
135:            public boolean finishedPixels() {
136:                return iterator.finishedPixels();
137:            }
138:
139:            /**
140:             * Sets the iterator to the first band of the image.
141:             */
142:            public void startBands() {
143:                bandIndex = 0;
144:                iterator.startBands();
145:                for (int skip = sourceBands[0]; --skip >= 0;) {
146:                    iterator.nextBand();
147:                }
148:            }
149:
150:            /**
151:             * Sets the iterator to the next band in the image.
152:             */
153:            public void nextBand() {
154:                nextBandDone();
155:            }
156:
157:            /**
158:             * Sets the iterator to the next band in the image, and returns
159:             * true if the max band has been exceeded.
160:             */
161:            public boolean nextBandDone() {
162:                int skip = sourceBands[bandIndex];
163:                if (++bandIndex >= sourceBands.length) {
164:                    return true;
165:                }
166:                skip = sourceBands[bandIndex] - skip;
167:                if (skip < 0) {
168:                    iterator.startBands();
169:                    skip = sourceBands[bandIndex];
170:                }
171:                while (--skip >= 0) {
172:                    if (iterator.nextBandDone()) {
173:                        return true;
174:                    }
175:                }
176:                return false;
177:            }
178:
179:            /**
180:             * Returns true if the max band in the image has been exceeded.
181:             */
182:            public boolean finishedBands() {
183:                return iterator.finishedBands();
184:            }
185:
186:            public int getSample() {
187:                return iterator.getSample();
188:            }
189:
190:            public int getSample(int b) {
191:                return iterator.getSample(sourceBands[b]);
192:            }
193:
194:            public float getSampleFloat() {
195:                return iterator.getSampleFloat();
196:            }
197:
198:            public float getSampleFloat(int b) {
199:                return iterator.getSampleFloat(sourceBands[b]);
200:            }
201:
202:            public double getSampleDouble() {
203:                return iterator.getSampleDouble();
204:            }
205:
206:            public double getSampleDouble(int b) {
207:                return iterator.getSampleDouble(sourceBands[b]);
208:            }
209:
210:            public int[] getPixel(int[] a) {
211:                final int length = sourceBands.length;
212:                if (a == null) {
213:                    a = new int[length];
214:                }
215:                for (int i = 0; i < length; i++) {
216:                    a[i] = getSample(i);
217:                }
218:                return a;
219:            }
220:
221:            public float[] getPixel(float[] a) {
222:                final int length = sourceBands.length;
223:                if (a == null) {
224:                    a = new float[length];
225:                }
226:                for (int i = 0; i < length; i++) {
227:                    a[i] = getSampleFloat(i);
228:                }
229:                return a;
230:            }
231:
232:            public double[] getPixel(double[] a) {
233:                final int length = sourceBands.length;
234:                if (a == null) {
235:                    a = new double[length];
236:                }
237:                for (int i = 0; i < length; i++) {
238:                    a[i] = getSampleDouble(i);
239:                }
240:                return a;
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.