svn-gvsig-desktop / tags / v1_1_Build_1012 / extensions / extWMS / src / com / iver / cit / gvsig / gui / wizards / SRSListModel.java @ 12987
History | View | Annotate | Download (3.99 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui.wizards; |
42 |
|
43 |
import java.util.ArrayList; |
44 |
import java.util.Collection; |
45 |
import java.util.TreeSet; |
46 |
|
47 |
import javax.swing.AbstractListModel; |
48 |
|
49 |
|
50 |
/**
|
51 |
* DOCUMENT ME!
|
52 |
*
|
53 |
* @author Fernando Gonz?lez Cort?s
|
54 |
*/
|
55 |
public class SRSListModel extends AbstractListModel { |
56 |
ArrayList srs = new ArrayList(); |
57 |
|
58 |
public int getSize() { |
59 |
return srs.size();
|
60 |
} |
61 |
|
62 |
public Object getElementAt(int index) { |
63 |
return srs.get(index);
|
64 |
} |
65 |
|
66 |
public void setAll(Collection c) { |
67 |
|
68 |
srs.clear(); |
69 |
srs.addAll(c); |
70 |
} |
71 |
|
72 |
public Collection intersect(Collection c) { |
73 |
TreeSet resul = new TreeSet(); |
74 |
for (int i = 0; i < srs.size(); i++) { |
75 |
if (c.contains(srs.get(i)))
|
76 |
resul.add(srs.get(i)); |
77 |
} |
78 |
return resul;
|
79 |
} |
80 |
/*ArrayList comunes = new ArrayList();
|
81 |
|
82 |
private HashSet srsSet = new HashSet();
|
83 |
private HashMap cuenta = new HashMap();
|
84 |
private ArrayList nombresSRS = new ArrayList();
|
85 |
|
86 |
/**
|
87 |
* DOCUMENT ME!
|
88 |
*
|
89 |
* @param srs DOCUMENT ME!
|
90 |
* /
|
91 |
public void add(String srs) {
|
92 |
System.out.println("A?adiendo " + srs);
|
93 |
if (!srsSet.add(srs)) {
|
94 |
Integer i = (Integer) cuenta.get(srs);
|
95 |
cuenta.put(srs, new Integer(i.intValue() + 1));
|
96 |
System.out.println("Ya hab?a, llevamos " + i.intValue() + 1);
|
97 |
} else {
|
98 |
nombresSRS.add(srs);
|
99 |
cuenta.put(srs, new Integer(1));
|
100 |
fireContentsChanged(this, nombresSRS.size()-1,nombresSRS.size()-1);
|
101 |
}
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
* DOCUMENT ME!
|
106 |
*
|
107 |
* @param srs DOCUMENT ME!
|
108 |
* /
|
109 |
public void del(String srs) {
|
110 |
System.out.println("Eliminando SRS: "+ srs);
|
111 |
Integer i = (Integer) cuenta.get(srs);
|
112 |
|
113 |
if (i == null) {
|
114 |
System.out.println("Eliminando un elemento que no estaba");
|
115 |
return;
|
116 |
}
|
117 |
|
118 |
int nuevo = i.intValue() - 1;
|
119 |
|
120 |
System.out.println("quedan " + nuevo);
|
121 |
|
122 |
if (nuevo == 0) {
|
123 |
cuenta.remove(srs);
|
124 |
srsSet.remove(srs);
|
125 |
nombresSRS.remove(srs);
|
126 |
fireContentsChanged(this, 0,nombresSRS.size()-1);
|
127 |
} else {
|
128 |
cuenta.put(srs, new Integer(nuevo));
|
129 |
}
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
* DOCUMENT ME!
|
134 |
*
|
135 |
* @return
|
136 |
* /
|
137 |
public Iterator iterator() {
|
138 |
return srsSet.iterator();
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
* DOCUMENT ME!
|
143 |
*
|
144 |
* @return
|
145 |
* /
|
146 |
public int size() {
|
147 |
return srsSet.size();
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
* @see javax.swing.ListModel#getSize()
|
152 |
* /
|
153 |
public int getSize() {
|
154 |
return nombresSRS.size();
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
* @see javax.swing.ListModel#getElementAt(int)
|
159 |
* /
|
160 |
public Object getElementAt(int index) {
|
161 |
return nombresSRS.get(index);
|
162 |
}
|
163 |
|
164 |
public ArrayList intersect(Collection col) {
|
165 |
ArrayList resul = new ArrayList();
|
166 |
for (int i = 0; i < nombresSRS.size(); i++) {
|
167 |
if (col.contains(nombresSRS.get(i)))
|
168 |
resul.add(nombresSRS.get(i));
|
169 |
}
|
170 |
return resul;
|
171 |
}
|
172 |
*/
|
173 |
} |