Source Code Cross Referenced for Simplex.java in  » GIS » openjump » org » openjump » core » graph » delauneySimplexInsert » 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 » openjump » org.openjump.core.graph.delauneySimplexInsert 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005 by L. Paul Chew.
003:         * 
004:         * Permission is hereby granted, without written agreement and without
005:         * license or royalty fees, to use, copy, modify, and distribute this
006:         * software and its documentation for any purpose, subject to the following 
007:         * conditions:
008:         *
009:         * The above copyright notice and this permission notice shall be included 
010:         * in all copies or substantial portions of the Software.
011:         * 
012:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
013:         * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
014:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
015:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
016:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
017:         * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
018:         * DEALINGS IN THE SOFTWARE.
019:         */
020:
021:        package org.openjump.core.graph.delauneySimplexInsert;
022:
023:        import java.util.AbstractSet;
024:        import java.util.ArrayList;
025:        import java.util.Arrays;
026:        import java.util.Collection;
027:        import java.util.Collections;
028:        import java.util.HashSet;
029:        import java.util.Iterator;
030:        import java.util.LinkedList;
031:        import java.util.List;
032:        import java.util.Set;
033:
034:        /**
035:         * A Simplex is an immutable set of vertices (usually Pnts).
036:         * 
037:         * @author Paul Chew
038:         * 
039:         * Created July 2005. Derived from an earlier, messier version.
040:         */
041:        class Simplex extends AbstractSet implements  Set {
042:
043:            private List vertices; // The simplex's vertices
044:            private long idNumber; // The id number
045:            private static long idGenerator = 0; // Used to create id numbers
046:            public static boolean moreInfo = false; // True iff more info in toString
047:
048:            /**
049:             * Constructor.
050:             * @param collection a Collection holding the Simplex vertices
051:             * @throws IllegalArgumentException if there are duplicate vertices
052:             */
053:            public Simplex(Collection collection) {
054:                this .vertices = Collections.unmodifiableList(new ArrayList(
055:                        collection));
056:                this .idNumber = idGenerator++;
057:                Set noDups = new HashSet(this );
058:                if (noDups.size() != this .vertices.size())
059:                    throw new IllegalArgumentException(
060:                            "Duplicate vertices in Simplex");
061:            }
062:
063:            /**
064:             * Constructor.
065:             * @param vertices the vertices of the Simplex.
066:             * @throws IllegalArgumentException if there are duplicate vertices
067:             */
068:            public Simplex(Object[] vertices) {
069:                this (Arrays.asList(vertices));
070:            }
071:
072:            /**
073:             * String representation.
074:             * @return the String representation of this Simplex
075:             */
076:            public String toString() {
077:                if (!moreInfo)
078:                    return "Simplex" + idNumber;
079:                return "Simplex" + idNumber + super .toString();
080:            }
081:
082:            /**
083:             * Dimension of the Simplex.
084:             * @return dimension of Simplex (one less than number of vertices)
085:             */
086:            public int dimension() {
087:                return this .vertices.size() - 1;
088:            }
089:
090:            /**
091:             * True iff simplices are neighbors.
092:             * Two simplices are neighbors if they are the same dimension and they share
093:             * a facet.
094:             * @param simplex the other Simplex
095:             * @return true iff this Simplex is a neighbor of simplex
096:             */
097:            public boolean isNeighbor(Simplex simplex) {
098:                HashSet h = new HashSet(this );
099:                h.removeAll(simplex);
100:                return (this .size() == simplex.size()) && (h.size() == 1);
101:            }
102:
103:            /**
104:             * Report the facets of this Simplex.
105:             * Each facet is a set of vertices.
106:             * @return an Iterable for the facets of this Simplex
107:             */
108:            public List facets() {
109:                List theFacets = new LinkedList();
110:                for (Iterator it = this .iterator(); it.hasNext();) {
111:                    Object v = it.next();
112:                    Set facet = new HashSet(this );
113:                    facet.remove(v);
114:                    theFacets.add(facet);
115:                }
116:                return theFacets;
117:            }
118:
119:            /**
120:             * Report the boundary of a Set of Simplices.
121:             * The boundary is a Set of facets where each facet is a Set of vertices.
122:             * @return an Iterator for the facets that make up the boundary
123:             */
124:            public static Set boundary(Set simplexSet) {
125:                Set theBoundary = new HashSet();
126:                for (Iterator it = simplexSet.iterator(); it.hasNext();) {
127:                    Simplex simplex = (Simplex) it.next();
128:                    for (Iterator otherIt = simplex.facets().iterator(); otherIt
129:                            .hasNext();) {
130:                        Set facet = (Set) otherIt.next();
131:                        if (theBoundary.contains(facet))
132:                            theBoundary.remove(facet);
133:                        else
134:                            theBoundary.add(facet);
135:                    }
136:                }
137:                return theBoundary;
138:            }
139:
140:            /* Remaining methods are those required by AbstractSet */
141:
142:            /**
143:             * @return Iterator for Simplex's vertices.
144:             */
145:            public Iterator iterator() {
146:                return this .vertices.iterator();
147:            }
148:
149:            /**
150:             * @return the size (# of vertices) of this Simplex
151:             */
152:            public int size() {
153:                return this .vertices.size();
154:            }
155:
156:            /**
157:             * @return the hashCode of this Simplex
158:             */
159:            public int hashCode() {
160:                return (int) (idNumber ^ (idNumber >>> 32));
161:            }
162:
163:            /**
164:             * We want to allow for different simplices that share the same vertex set.
165:             * @return true for equal Simplices
166:             */
167:            public boolean equals(Object o) {
168:                return (this == o);
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.