Source Code Cross Referenced for Node.java in  » GIS » jts » com » vividsolutions » jts » geomgraph » 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.geomgraph 
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.geomgraph;
035:
036:        import java.io.PrintStream;
037:        import java.util.*;
038:        import com.vividsolutions.jts.geom.Coordinate;
039:        import com.vividsolutions.jts.geom.IntersectionMatrix;
040:        import com.vividsolutions.jts.geom.Location;
041:        import com.vividsolutions.jts.geomgraph.GraphComponent;
042:        import com.vividsolutions.jts.geomgraph.Label;
043:        import com.vividsolutions.jts.util.*;
044:
045:        /**
046:         * @version 1.7
047:         */
048:        public class Node extends GraphComponent {
049:            protected Coordinate coord; // only non-null if this node is precise
050:            protected EdgeEndStar edges;
051:
052:            public Node(Coordinate coord, EdgeEndStar edges) {
053:                this .coord = coord;
054:                this .edges = edges;
055:                label = new Label(0, Location.NONE);
056:            }
057:
058:            public Coordinate getCoordinate() {
059:                return coord;
060:            }
061:
062:            public EdgeEndStar getEdges() {
063:                return edges;
064:            }
065:
066:            /**
067:             * Tests whether any incident edge is flagged as
068:             * being in the result.
069:             * This test can be used to determine if the node is in the result,
070:             * since if any incident edge is in the result, the node must be in the result as well.
071:             *
072:             * @return <code>true</code> if any indicident edge in the in the result
073:             */
074:            public boolean isIncidentEdgeInResult() {
075:                for (Iterator it = getEdges().getEdges().iterator(); it
076:                        .hasNext();) {
077:                    DirectedEdge de = (DirectedEdge) it.next();
078:                    if (de.getEdge().isInResult())
079:                        return true;
080:                }
081:                return false;
082:            }
083:
084:            public boolean isIsolated() {
085:                return (label.getGeometryCount() == 1);
086:            }
087:
088:            /**
089:             * Basic nodes do not compute IMs
090:             */
091:            protected void computeIM(IntersectionMatrix im) {
092:            }
093:
094:            /**
095:             * Add the edge to the list of edges at this node
096:             */
097:            public void add(EdgeEnd e) {
098:                // Assert: start pt of e is equal to node point
099:                edges.insert(e);
100:                e.setNode(this );
101:            }
102:
103:            public void mergeLabel(Node n) {
104:                mergeLabel(n.label);
105:            }
106:
107:            /**
108:             * To merge labels for two nodes,
109:             * the merged location for each LabelElement is computed.
110:             * The location for the corresponding node LabelElement is set to the result,
111:             * as long as the location is non-null.
112:             */
113:
114:            public void mergeLabel(Label label2) {
115:                for (int i = 0; i < 2; i++) {
116:                    int loc = computeMergedLocation(label2, i);
117:                    int this Loc = label.getLocation(i);
118:                    if (this Loc == Location.NONE)
119:                        label.setLocation(i, loc);
120:                }
121:            }
122:
123:            public void setLabel(int argIndex, int onLocation) {
124:                if (label == null) {
125:                    label = new Label(argIndex, onLocation);
126:                } else
127:                    label.setLocation(argIndex, onLocation);
128:            }
129:
130:            /**
131:             * Updates the label of a node to BOUNDARY,
132:             * obeying the mod-2 boundaryDetermination rule.
133:             */
134:            public void setLabelBoundary(int argIndex) {
135:                // determine the current location for the point (if any)
136:                int loc = Location.NONE;
137:                if (label != null)
138:                    loc = label.getLocation(argIndex);
139:                // flip the loc
140:                int newLoc;
141:                switch (loc) {
142:                case Location.BOUNDARY:
143:                    newLoc = Location.INTERIOR;
144:                    break;
145:                case Location.INTERIOR:
146:                    newLoc = Location.BOUNDARY;
147:                    break;
148:                default:
149:                    newLoc = Location.BOUNDARY;
150:                    break;
151:                }
152:                label.setLocation(argIndex, newLoc);
153:            }
154:
155:            /**
156:             * The location for a given eltIndex for a node will be one
157:             * of { null, INTERIOR, BOUNDARY }.
158:             * A node may be on both the boundary and the interior of a geometry;
159:             * in this case, the rule is that the node is considered to be in the boundary.
160:             * The merged location is the maximum of the two input values.
161:             */
162:            int computeMergedLocation(Label label2, int eltIndex) {
163:                int loc = Location.NONE;
164:                loc = label.getLocation(eltIndex);
165:                if (!label2.isNull(eltIndex)) {
166:                    int nLoc = label2.getLocation(eltIndex);
167:                    if (loc != Location.BOUNDARY)
168:                        loc = nLoc;
169:                }
170:                return loc;
171:            }
172:
173:            public void print(PrintStream out) {
174:                out.println("node " + coord + " lbl: " + label);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.