svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.jts / src / main / java / org / gvsig / fmap / geom / jts / utils / ReadOnlyCoordinates.java @ 42260
History | View | Annotate | Download (4.2 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2015 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.geom.jts.utils; |
24 |
|
25 |
import java.util.Collection; |
26 |
import java.util.Iterator; |
27 |
|
28 |
import com.vividsolutions.jts.geom.Coordinate; |
29 |
|
30 |
|
31 |
/**
|
32 |
* @author fdiaz
|
33 |
*
|
34 |
*/
|
35 |
public class ReadOnlyCoordinates implements Collection<Coordinate> { |
36 |
|
37 |
Coordinate coordinates[];
|
38 |
|
39 |
/**
|
40 |
*
|
41 |
*/
|
42 |
public ReadOnlyCoordinates(Coordinate coordinates[]) { |
43 |
this.coordinates = coordinates;
|
44 |
} |
45 |
|
46 |
/* (non-Javadoc)
|
47 |
* @see java.util.Collection#size()
|
48 |
*/
|
49 |
public int size() { |
50 |
return this.coordinates.length; |
51 |
} |
52 |
|
53 |
/* (non-Javadoc)
|
54 |
* @see java.util.Collection#isEmpty()
|
55 |
*/
|
56 |
public boolean isEmpty() { |
57 |
return this.coordinates.length==0; |
58 |
} |
59 |
|
60 |
/* (non-Javadoc)
|
61 |
* @see java.util.Collection#contains(java.lang.Object)
|
62 |
*/
|
63 |
public boolean contains(Object o) { |
64 |
for (int i = 0; i < coordinates.length; i++) { |
65 |
if(coordinates[i].equals(o)){
|
66 |
return true; |
67 |
} |
68 |
} |
69 |
return false; |
70 |
} |
71 |
|
72 |
/* (non-Javadoc)
|
73 |
* @see java.util.Collection#iterator()
|
74 |
*/
|
75 |
public Iterator<Coordinate> iterator() { |
76 |
return new Iterator<Coordinate>() { |
77 |
|
78 |
int i=0; |
79 |
|
80 |
public boolean hasNext() { |
81 |
return i<coordinates.length;
|
82 |
} |
83 |
|
84 |
public Coordinate next() {
|
85 |
return coordinates[i++];
|
86 |
} |
87 |
|
88 |
public void remove() { |
89 |
throw new UnsupportedOperationException(); |
90 |
} |
91 |
}; |
92 |
} |
93 |
|
94 |
/* (non-Javadoc)
|
95 |
* @see java.util.Collection#toArray()
|
96 |
*/
|
97 |
public Object[] toArray() { |
98 |
return this.coordinates; |
99 |
} |
100 |
|
101 |
/* (non-Javadoc)
|
102 |
* @see java.util.Collection#toArray(java.lang.Object[])
|
103 |
*/
|
104 |
public <T> T[] toArray(T[] a) { |
105 |
return (T[]) this.coordinates; |
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see java.util.Collection#add(java.lang.Object)
|
110 |
*/
|
111 |
public boolean add(Coordinate e) { |
112 |
throw new UnsupportedOperationException(); |
113 |
} |
114 |
|
115 |
/* (non-Javadoc)
|
116 |
* @see java.util.Collection#remove(java.lang.Object)
|
117 |
*/
|
118 |
public boolean remove(Object o) { |
119 |
throw new UnsupportedOperationException(); |
120 |
} |
121 |
|
122 |
/* (non-Javadoc)
|
123 |
* @see java.util.Collection#containsAll(java.util.Collection)
|
124 |
*/
|
125 |
public boolean containsAll(Collection<?> c) { |
126 |
for (Iterator iterator = c.iterator(); iterator.hasNext();) { |
127 |
Object object = (Object) iterator.next(); |
128 |
if(contains(object)){
|
129 |
return true; |
130 |
} |
131 |
} |
132 |
return false; |
133 |
} |
134 |
|
135 |
/* (non-Javadoc)
|
136 |
* @see java.util.Collection#addAll(java.util.Collection)
|
137 |
*/
|
138 |
public boolean addAll(Collection<? extends Coordinate> c) { |
139 |
throw new UnsupportedOperationException(); |
140 |
} |
141 |
|
142 |
/* (non-Javadoc)
|
143 |
* @see java.util.Collection#removeAll(java.util.Collection)
|
144 |
*/
|
145 |
public boolean removeAll(Collection<?> c) { |
146 |
throw new UnsupportedOperationException(); |
147 |
} |
148 |
|
149 |
/* (non-Javadoc)
|
150 |
* @see java.util.Collection#retainAll(java.util.Collection)
|
151 |
*/
|
152 |
public boolean retainAll(Collection<?> c) { |
153 |
throw new UnsupportedOperationException(); |
154 |
} |
155 |
|
156 |
/* (non-Javadoc)
|
157 |
* @see java.util.Collection#clear()
|
158 |
*/
|
159 |
public void clear() { |
160 |
throw new UnsupportedOperationException(); |
161 |
} |
162 |
|
163 |
} |