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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2006, 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:         *    This package contains documentation from OpenGIS specifications.
018:         *    OpenGIS consortium's work is fully acknowledged here.
019:         */
020:        package org.geotools.coverage.grid;
021:
022:        // J2SE dependencies
023:        import java.io.Serializable;
024:        import java.util.Arrays;
025:
026:        // OpenGIS dependencies
027:        import org.opengis.coverage.grid.Grid; // For javadoc
028:        import org.opengis.coverage.grid.GridPoint; // For javadoc
029:        import org.opengis.coverage.grid.GridCoordinates;
030:        import org.opengis.geometry.DirectPosition;
031:
032:        /**
033:         * Holds the set of grid coordinates that specifies the location of the
034:         * {@linkplain GridPoint grid point} within the {@linkplain Grid grid}.
035:         *
036:         * @since 2.4
037:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/grid/GeneralGridCoordinates.java $
038:         * @version $Id: GeneralGridCoordinates.java 24925 2007-03-27 20:12:08Z jgarnett $
039:         * @author Martin Desruisseaux
040:         */
041:        public class GeneralGridCoordinates implements  GridCoordinates,
042:                Serializable {
043:            /**
044:             * For cross-version compatibility.
045:             */
046:            private static final long serialVersionUID = 8146318677770695383L;
047:
048:            /**
049:             * The grid coordinates.
050:             */
051:            private final int[] coordinates;
052:
053:            /**
054:             * Creates a grid coordinates of the specified dimension.
055:             * All coordinates are initially set to 0.
056:             */
057:            public GeneralGridCoordinates(final int dimension) {
058:                coordinates = new int[dimension];
059:            }
060:
061:            /**
062:             * Creates a grid coordinates initialized to the specified values.
063:             */
064:            public GeneralGridCoordinates(final int[] coordinates) {
065:                this .coordinates = (int[]) coordinates.clone();
066:            }
067:
068:            /**
069:             * Creates a grid coordinates initialized to the specified values
070:             * in the specified range.
071:             */
072:            GeneralGridCoordinates(final int[] coordinates, final int lower,
073:                    final int upper) {
074:                final int length = upper - lower;
075:                this .coordinates = new int[length];
076:                System.arraycopy(coordinates, lower, this .coordinates, 0,
077:                        length);
078:            }
079:
080:            /**
081:             * Returns the number of dimensions. This method is equivalent to
082:             * <code>{@linkplain #getCoordinateValues()}.length</code>. It is
083:             * provided for efficienty.
084:             */
085:            public int getDimension() {
086:                return coordinates.length;
087:            }
088:
089:            /**
090:             * Returns one integer value for each dimension of the grid. The ordering of these coordinate
091:             * values shall be the same as that of the elements of {@link Grid#getAxisNames}. The value of
092:             * a single coordinate shall be the number of offsets from the origin of the grid in the
093:             * direction of a specific axis.
094:             *
095:             * @return A copy of the coordinates. Changes in the returned array will not be reflected
096:             *         back in this {@code GeneralGridCoordinates} object.
097:             */
098:            public int[] getCoordinateValues() {
099:                return (int[]) coordinates.clone();
100:            }
101:
102:            /**
103:             * Returns the coordinate value at the specified dimension. This method is equivalent to
104:             * <code>{@linkplain #getCoordinateValues()}[<var>i</var>]</code>. It is provided for
105:             * efficienty.
106:             */
107:            public int getCoordinateValue(final int i) {
108:                return coordinates[i];
109:            }
110:
111:            /**
112:             * Sets the coordinate value at the specified dimension (optional operation).
113:             *
114:             * @param  i The index of the value to set.
115:             * @param  value The new value.
116:             * @throws UnsupportedOperationException if this grid coordinates is not modifiable.
117:             */
118:            public void setCoordinateValue(final int i, final int value)
119:                    throws UnsupportedOperationException {
120:                coordinates[i] = value;
121:            }
122:
123:            /**
124:             * Returns a string representation of this grid coordinates.
125:             */
126:            public String toString() {
127:                final StringBuffer buffer = new StringBuffer("GridCoordinates");
128:                for (int i = 0; i < coordinates.length; i++) {
129:                    buffer.append(i == 0 ? '[' : ',');
130:                    buffer.append(coordinates[i]);
131:                }
132:                buffer.append(']');
133:                return buffer.toString();
134:            }
135:
136:            /**
137:             * Returns a hash code value for this object.
138:             *
139:             * @todo Use {@link Arrays#hashCode(int[])} when we will be allowed to compile for J2SE 1.5.
140:             */
141:            public int hashCode() {
142:                int code = (int) serialVersionUID;
143:                for (int i = 0; i < coordinates.length; i++) {
144:                    code = code * 37 + coordinates[i];
145:                }
146:                return code;
147:            }
148:
149:            /**
150:             * Compares this grid coordinates with the specified object for equality.
151:             */
152:            public boolean equals(final Object object) {
153:                if (object == this ) {
154:                    // Slight optimization.
155:                    return true;
156:                }
157:                if (object != null && object.getClass().equals(getClass())) {
158:                    final GeneralGridCoordinates that = (GeneralGridCoordinates) object;
159:                    return Arrays.equals(this .coordinates, that.coordinates);
160:                }
161:                return false;
162:            }
163:
164:            /**
165:             * Returns a clone of this coordinates.
166:             */
167:            public Object clone() {
168:                return new GeneralGridCoordinates(coordinates);
169:            }
170:
171:            /**
172:             * An immutable flavor of {@link GridCoordinates}.
173:             */
174:            static final class Immutable extends GeneralGridCoordinates {
175:                /**
176:                 * For cross-version compatibility.
177:                 */
178:                private static final long serialVersionUID = -7723383411061425866L;
179:
180:                /**
181:                 * Creates a grid coordinates initialized to the specified values
182:                 * in the specified range.
183:                 */
184:                Immutable(final int[] coordinates, final int lower,
185:                        final int upper) {
186:                    super (coordinates, lower, upper);
187:                }
188:
189:                /**
190:                 * Do not allows modification of this grid coordinates.
191:                 */
192:                public void setCoordinateValue(final int i, final int value)
193:                        throws UnsupportedOperationException {
194:                    throw new UnsupportedOperationException();
195:                }
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.