Source Code Cross Referenced for Range.java in  » GIS » openjump » com » vividsolutions » jump » util » 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 » com.vividsolutions.jump.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         * 
012:         * This program 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
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         * 
021:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:        package com.vividsolutions.jump.util;
033:
034:        import java.util.Comparator;
035:        import java.util.TreeMap;
036:
037:        import com.vividsolutions.jts.util.Assert;
038:
039:        public class Range {
040:            private boolean includingMin;
041:            private boolean includingMax;
042:            private Object max;
043:            private Object min;
044:
045:            public String toString() {
046:                return min + " - " + max;
047:            }
048:
049:            public Range() {
050:                this (new NegativeInfinity(), false, new PositiveInfinity(),
051:                        false);
052:            }
053:
054:            //NegativeInfinity and PositiveInfinity are classes so they can be
055:            //serialized via Java2XML. [Jon Aquino]
056:            public static final class NegativeInfinity {
057:                public String toString() {
058:                    // Empty string, for range display in TreeLayerNamePanel. [Jon Aquino 2005-07-25]
059:                    return "";
060:                }
061:            }
062:
063:            public static final class PositiveInfinity {
064:                public String toString() {
065:                    return "";
066:                }
067:            }
068:
069:            public Range(Object min, boolean includingMin, Object max,
070:                    boolean includingMax) {
071:                Assert
072:                        .isTrue(!(min.equals(max) && (!includingMin || !includingMax)));
073:                this .min = min;
074:                this .max = max;
075:                this .includingMin = includingMin;
076:                this .includingMax = includingMax;
077:            }
078:
079:            public boolean equals(Object obj) {
080:                return Range.RANGE_COMPARATOR.compare(this , obj) == 0;
081:            }
082:
083:            public boolean isIncludingMax() {
084:                return includingMax;
085:            }
086:
087:            public boolean isIncludingMin() {
088:                return includingMin;
089:            }
090:
091:            public Object getMax() {
092:                return max;
093:            }
094:
095:            public Object getMin() {
096:                return min;
097:            }
098:
099:            public void setIncludingMax(boolean b) {
100:                includingMax = b;
101:            }
102:
103:            public void setIncludingMin(boolean b) {
104:                includingMin = b;
105:            }
106:
107:            public void setMax(Object object) {
108:                max = object;
109:            }
110:
111:            public void setMin(Object object) {
112:                min = object;
113:            }
114:
115:            private static final Comparator INFINITY_COMPARATOR = new Comparator() {
116:                public int compare(Object o1, Object o2) {
117:                    if (o1 instanceof  PositiveInfinity
118:                            || o2 instanceof  NegativeInfinity) {
119:                        return +1;
120:                    }
121:                    if (o1 instanceof  NegativeInfinity
122:                            || o2 instanceof  PositiveInfinity) {
123:                        return -1;
124:                    }
125:                    return ((Comparable) o1).compareTo(o2);
126:                }
127:            };
128:
129:            public static final Comparator RANGE_COMPARATOR = new Comparator() {
130:                public int compare(Object o1, Object o2) {
131:                    Range range1 = o1 instanceof  Range ? (Range) o1
132:                            : new Range(o1, true, o1, true);
133:                    Range range2 = o2 instanceof  Range ? (Range) o2
134:                            : new Range(o2, true, o2, true);
135:                    int max1ComparedToMin2 = INFINITY_COMPARATOR.compare(range1
136:                            .getMax(), range2.getMin());
137:                    if (max1ComparedToMin2 < 0
138:                            || (max1ComparedToMin2 == 0 && (!range1
139:                                    .isIncludingMax() || !range2
140:                                    .isIncludingMin()))) {
141:                        return -1;
142:                    }
143:                    int min1ComparedToMax2 = INFINITY_COMPARATOR.compare(range1
144:                            .getMin(), range2.getMax());
145:                    if (min1ComparedToMax2 > 0
146:                            || (min1ComparedToMax2 == 0 && (!range1
147:                                    .isIncludingMin() || !range2
148:                                    .isIncludingMax()))) {
149:                        return +1;
150:                    }
151:                    return 0;
152:                }
153:            };
154:
155:            //Trivial, but necessary for Java2XML serialization. [Jon Aquino]
156:            public static class RangeTreeMap extends TreeMap {
157:                public RangeTreeMap() {
158:                    super(RANGE_COMPARATOR);
159:                }
160:            }
161:
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.