Source Code Cross Referenced for Point.java in  » GIS » jts » com » vividsolutions » jts » geom » 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 » jts » com.vividsolutions.jts.geom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:
002:        /*
003:         * The JTS Topology Suite is a collection of Java classes that
004:         * implement the fundamental operations required to validate a given
005:         * geo-spatial data set to a known topological specification.
006:         *
007:         * Copyright (C) 2001 Vivid Solutions
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         *
023:         * For more information, contact:
024:         *
025:         *     Vivid Solutions
026:         *     Suite #1A
027:         *     2328 Government Street
028:         *     Victoria BC  V8T 5G5
029:         *     Canada
030:         *
031:         *     (250)385-6040
032:         *     www.vividsolutions.com
033:         */
034:        package com.vividsolutions.jts.geom;
035:
036:        import com.vividsolutions.jts.util.Assert;
037:
038:        /**
039:         *  Basic implementation of <code>Point</code>.
040:         *
041:         *@version 1.7
042:         */
043:        public class Point extends Geometry {
044:            private static final long serialVersionUID = 4902022702746614570L;
045:            /**
046:             *  The <code>Coordinate</code> wrapped by this <code>Point</code>.
047:             */
048:            private CoordinateSequence coordinates;
049:
050:            /**
051:             *  Constructs a <code>Point</code> with the given coordinate.
052:             *
053:             *@param  coordinate      the coordinate on which to base this <code>Point</code>
054:             *      , or <code>null</code> to create the empty geometry.
055:             *@param  precisionModel  the specification of the grid of allowable points
056:             *      for this <code>Point</code>
057:             *@param  SRID            the ID of the Spatial Reference System used by this
058:             *      <code>Point</code>
059:             * @deprecated Use GeometryFactory instead
060:             */
061:            public Point(Coordinate coordinate, PrecisionModel precisionModel,
062:                    int SRID) {
063:                super (new GeometryFactory(precisionModel, SRID));
064:                init(getFactory().getCoordinateSequenceFactory().create(
065:                        coordinate != null ? new Coordinate[] { coordinate }
066:                                : new Coordinate[] {}));
067:            }
068:
069:            /**
070:             *@param  coordinates      contains the single coordinate on which to base this <code>Point</code>
071:             *      , or <code>null</code> to create the empty geometry.
072:             */
073:            public Point(CoordinateSequence coordinates, GeometryFactory factory) {
074:                super (factory);
075:                init(coordinates);
076:            }
077:
078:            private void init(CoordinateSequence coordinates) {
079:                if (coordinates == null) {
080:                    coordinates = getFactory().getCoordinateSequenceFactory()
081:                            .create(new Coordinate[] {});
082:                }
083:                Assert.isTrue(coordinates.size() <= 1);
084:                this .coordinates = coordinates;
085:            }
086:
087:            public Coordinate[] getCoordinates() {
088:                return isEmpty() ? new Coordinate[] {}
089:                        : new Coordinate[] { getCoordinate() };
090:            }
091:
092:            public int getNumPoints() {
093:                return isEmpty() ? 0 : 1;
094:            }
095:
096:            public boolean isEmpty() {
097:                return getCoordinate() == null;
098:            }
099:
100:            public boolean isSimple() {
101:                return true;
102:            }
103:
104:            public boolean isValid() {
105:                return true;
106:            }
107:
108:            public int getDimension() {
109:                return 0;
110:            }
111:
112:            public int getBoundaryDimension() {
113:                return Dimension.FALSE;
114:            }
115:
116:            public double getX() {
117:                if (getCoordinate() == null) {
118:                    throw new IllegalStateException(
119:                            "getX called on empty Point");
120:                }
121:                return getCoordinate().x;
122:            }
123:
124:            public double getY() {
125:                if (getCoordinate() == null) {
126:                    throw new IllegalStateException(
127:                            "getY called on empty Point");
128:                }
129:                return getCoordinate().y;
130:            }
131:
132:            public Coordinate getCoordinate() {
133:                return coordinates.size() != 0 ? coordinates.getCoordinate(0)
134:                        : null;
135:            }
136:
137:            public String getGeometryType() {
138:                return "Point";
139:            }
140:
141:            /**
142:             * Gets the boundary of this geometry.
143:             * Zero-dimensional geometries have no boundary by definition,
144:             * so an empty GeometryCollection is returned.
145:             *
146:             * @return an empty GeometryCollection
147:             * @see Geometry#getBoundary
148:             */
149:            public Geometry getBoundary() {
150:                return getFactory().createGeometryCollection(null);
151:            }
152:
153:            protected Envelope computeEnvelopeInternal() {
154:                if (isEmpty()) {
155:                    return new Envelope();
156:                }
157:                Envelope env = new Envelope();
158:                env.expandToInclude(coordinates.getX(0), coordinates.getY(0));
159:                return env;
160:            }
161:
162:            public boolean equalsExact(Geometry other, double tolerance) {
163:                if (!isEquivalentClass(other)) {
164:                    return false;
165:                }
166:                if (isEmpty() && other.isEmpty()) {
167:                    return true;
168:                }
169:                return equal(((Point) other).getCoordinate(), this 
170:                        .getCoordinate(), tolerance);
171:            }
172:
173:            public void apply(CoordinateFilter filter) {
174:                if (isEmpty()) {
175:                    return;
176:                }
177:                filter.filter(getCoordinate());
178:            }
179:
180:            public void apply(CoordinateSequenceFilter filter) {
181:                if (isEmpty())
182:                    return;
183:                filter.filter(coordinates, 0);
184:                if (filter.isGeometryChanged())
185:                    geometryChanged();
186:            }
187:
188:            public void apply(GeometryFilter filter) {
189:                filter.filter(this );
190:            }
191:
192:            public void apply(GeometryComponentFilter filter) {
193:                filter.filter(this );
194:            }
195:
196:            /**
197:             * Creates and returns a full copy of this {@link Point} object.
198:             * (including all coordinates contained by it).
199:             *
200:             * @return a clone of this instance
201:             */
202:            public Object clone() {
203:                Point p = (Point) super .clone();
204:                p.coordinates = (CoordinateSequence) coordinates.clone();
205:                return p;// return the clone
206:            }
207:
208:            public void normalize() {
209:            }
210:
211:            protected int compareToSameClass(Object other) {
212:                Point point = (Point) other;
213:                return getCoordinate().compareTo(point.getCoordinate());
214:            }
215:
216:            protected int compareToSameClass(Object other,
217:                    CoordinateSequenceComparator comp) {
218:                Point point = (Point) other;
219:                return comp.compare(this .coordinates, point.coordinates);
220:            }
221:
222:            public CoordinateSequence getCoordinateSequence() {
223:                return coordinates;
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.