root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / selectionByTheme / SelectionByTheme.java @ 2970
History | View | Annotate | Download (10.1 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.selectionByTheme; |
42 |
|
43 |
import java.util.ArrayList; |
44 |
|
45 |
import javax.swing.DefaultComboBoxModel; |
46 |
import javax.swing.JPanel; |
47 |
|
48 |
import com.iver.andami.PluginServices; |
49 |
import com.iver.andami.ui.mdiManager.View; |
50 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
52 |
|
53 |
|
54 |
public class SelectionByTheme extends JPanel implements View { |
55 |
public static final int EQUALS = 0; |
56 |
public static final int DISJOINT = 1; |
57 |
public static final int INTERSECTS = 2; |
58 |
public static final int TOUCHES = 3; |
59 |
public static final int CROSSES = 4; |
60 |
public static final int WITHIN = 5; |
61 |
public static final int CONTAINS = 6; |
62 |
public static final int OVERLAPS = 7; |
63 |
public static final String[] textosAcciones = new String[] { |
64 |
"sean iguales a",
|
65 |
"sean disjuntos a",
|
66 |
"intersecten con",
|
67 |
"toquen",
|
68 |
"crucen con",
|
69 |
"contengan",
|
70 |
"est?n contenidos en",
|
71 |
"se superponen a"
|
72 |
}; |
73 |
|
74 |
private SelectionByThemeModel dataSource = null; |
75 |
|
76 |
private ArrayList listeners = new ArrayList(); |
77 |
|
78 |
private javax.swing.JPanel jPanel = null; |
79 |
private javax.swing.JPanel jPanel1 = null; |
80 |
private javax.swing.JLabel jLabel = null; |
81 |
private javax.swing.JComboBox cmbAction = null; |
82 |
private javax.swing.JLabel jLabel1 = null; |
83 |
private javax.swing.JComboBox cmbCapas = null; |
84 |
private javax.swing.JButton btnNew = null; |
85 |
private javax.swing.JButton btnAdd = null; |
86 |
private javax.swing.JButton btnFrom = null; |
87 |
private javax.swing.JButton btnCancel = null; |
88 |
/**
|
89 |
* This is the default constructor
|
90 |
*/
|
91 |
public SelectionByTheme() {
|
92 |
super();
|
93 |
initialize(); |
94 |
} |
95 |
/**
|
96 |
* This method initializes this
|
97 |
*
|
98 |
* @return void
|
99 |
*/
|
100 |
private void initialize() { |
101 |
java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
|
102 |
layFlowLayout2.setHgap(0);
|
103 |
layFlowLayout2.setVgap(0);
|
104 |
this.setLayout(layFlowLayout2);
|
105 |
this.add(getJPanel(), null); |
106 |
this.add(getJPanel1(), null); |
107 |
this.setSize(440, 220); |
108 |
} |
109 |
/**
|
110 |
* This method initializes jPanel
|
111 |
*
|
112 |
* @return javax.swing.JPanel
|
113 |
*/
|
114 |
private javax.swing.JPanel getJPanel() {
|
115 |
if(jPanel == null) { |
116 |
jPanel = new javax.swing.JPanel();
|
117 |
java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
|
118 |
layFlowLayout1.setVgap(30);
|
119 |
jPanel.setLayout(layFlowLayout1); |
120 |
jPanel.add(getJLabel(), null);
|
121 |
jPanel.add(getCmbAction(), null);
|
122 |
jPanel.add(getJLabel1(), null);
|
123 |
jPanel.add(getCmbCapas(), null);
|
124 |
jPanel.setPreferredSize(new java.awt.Dimension(290,220)); |
125 |
} |
126 |
return jPanel;
|
127 |
} |
128 |
/**
|
129 |
* This method initializes jPanel1
|
130 |
*
|
131 |
* @return javax.swing.JPanel
|
132 |
*/
|
133 |
private javax.swing.JPanel getJPanel1() {
|
134 |
if(jPanel1 == null) { |
135 |
jPanel1 = new javax.swing.JPanel();
|
136 |
java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
|
137 |
layFlowLayout3.setVgap(25);
|
138 |
jPanel1.setLayout(layFlowLayout3); |
139 |
jPanel1.add(getBtnNew(), null);
|
140 |
jPanel1.add(getBtnAdd(), null);
|
141 |
jPanel1.add(getBtnFrom(), null);
|
142 |
jPanel1.add(getBtnCancel(), null);
|
143 |
jPanel1.setPreferredSize(new java.awt.Dimension(140,220)); |
144 |
} |
145 |
return jPanel1;
|
146 |
} |
147 |
/**
|
148 |
* This method initializes jLabel
|
149 |
*
|
150 |
* @return javax.swing.JLabel
|
151 |
*/
|
152 |
private javax.swing.JLabel getJLabel() {
|
153 |
if(jLabel == null) { |
154 |
jLabel = new javax.swing.JLabel();
|
155 |
jLabel.setText("Seleccionar de las capas activas los elementos que... ");
|
156 |
jLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
157 |
} |
158 |
return jLabel;
|
159 |
} |
160 |
/**
|
161 |
* This method initializes cmbAction
|
162 |
*
|
163 |
* @return javax.swing.JComboBox
|
164 |
*/
|
165 |
private javax.swing.JComboBox getCmbAction() {
|
166 |
if(cmbAction == null) { |
167 |
cmbAction = new javax.swing.JComboBox();
|
168 |
cmbAction.setPreferredSize(new java.awt.Dimension(200,20)); |
169 |
DefaultComboBoxModel model = new DefaultComboBoxModel(textosAcciones); |
170 |
cmbAction.setModel(model); |
171 |
cmbAction.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
172 |
} |
173 |
return cmbAction;
|
174 |
} |
175 |
/**
|
176 |
* This method initializes jLabel1
|
177 |
*
|
178 |
* @return javax.swing.JLabel
|
179 |
*/
|
180 |
private javax.swing.JLabel getJLabel1() {
|
181 |
if(jLabel1 == null) { |
182 |
jLabel1 = new javax.swing.JLabel();
|
183 |
jLabel1.setText("elementos seleccionados de la capa");
|
184 |
jLabel1.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
185 |
} |
186 |
return jLabel1;
|
187 |
} |
188 |
/**
|
189 |
* This method initializes cmbCapas
|
190 |
*
|
191 |
* @return javax.swing.JComboBox
|
192 |
*/
|
193 |
private javax.swing.JComboBox getCmbCapas() {
|
194 |
if(cmbCapas == null) { |
195 |
cmbCapas = new javax.swing.JComboBox();
|
196 |
cmbCapas.setPreferredSize(new java.awt.Dimension(200,20)); |
197 |
cmbCapas.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
198 |
} |
199 |
return cmbCapas;
|
200 |
} |
201 |
/**
|
202 |
* This method initializes btnNew
|
203 |
*
|
204 |
* @return javax.swing.JButton
|
205 |
*/
|
206 |
private javax.swing.JButton getBtnNew() {
|
207 |
if(btnNew == null) { |
208 |
btnNew = new javax.swing.JButton();
|
209 |
btnNew.setText("Nuevo Conjunto");
|
210 |
btnNew.setMargin(new java.awt.Insets(2,2,2,2)); |
211 |
btnNew.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
212 |
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
213 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
214 |
callNewListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
215 |
} |
216 |
}); |
217 |
} |
218 |
return btnNew;
|
219 |
} |
220 |
/**
|
221 |
* This method initializes btnAdd
|
222 |
*
|
223 |
* @return javax.swing.JButton
|
224 |
*/
|
225 |
private javax.swing.JButton getBtnAdd() {
|
226 |
if(btnAdd == null) { |
227 |
btnAdd = new javax.swing.JButton();
|
228 |
btnAdd.setText("A?adir al conjunto");
|
229 |
btnAdd.setMargin(new java.awt.Insets(2,2,2,2)); |
230 |
btnAdd.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
231 |
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
232 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
233 |
callAddToListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
234 |
} |
235 |
}); |
236 |
} |
237 |
return btnAdd;
|
238 |
} |
239 |
/**
|
240 |
* This method initializes btnFrom
|
241 |
*
|
242 |
* @return javax.swing.JButton
|
243 |
*/
|
244 |
private javax.swing.JButton getBtnFrom() {
|
245 |
if(btnFrom == null) { |
246 |
btnFrom = new javax.swing.JButton();
|
247 |
btnFrom.setText("Seleccionar del conjunto");
|
248 |
btnFrom.setMargin(new java.awt.Insets(2,2,2,2)); |
249 |
btnFrom.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
250 |
btnFrom.addActionListener(new java.awt.event.ActionListener() {
|
251 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
252 |
callFromListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
253 |
} |
254 |
}); |
255 |
} |
256 |
return btnFrom;
|
257 |
} |
258 |
/**
|
259 |
* This method initializes btnCancel
|
260 |
*
|
261 |
* @return javax.swing.JButton
|
262 |
*/
|
263 |
private javax.swing.JButton getBtnCancel() {
|
264 |
if(btnCancel == null) { |
265 |
btnCancel = new javax.swing.JButton();
|
266 |
btnCancel.setText("Cancel");
|
267 |
btnCancel.setMargin(new java.awt.Insets(2,2,2,2)); |
268 |
btnCancel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10)); |
269 |
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
270 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
271 |
PluginServices.getMDIManager().closeView(SelectionByTheme.this); |
272 |
} |
273 |
}); |
274 |
} |
275 |
return btnCancel;
|
276 |
} |
277 |
|
278 |
/**
|
279 |
* @return
|
280 |
*/
|
281 |
public SelectionByThemeModel getModel() {
|
282 |
return dataSource;
|
283 |
} |
284 |
|
285 |
/**
|
286 |
* @param source
|
287 |
*/
|
288 |
public void setModel(SelectionByThemeModel source) { |
289 |
dataSource = source; |
290 |
String[] nameLayers = new String[dataSource.getLayers().getLayersCount()]; |
291 |
for (int i=0; i < nameLayers.length; i++) |
292 |
nameLayers[i] = dataSource.getLayers().getLayer(i).getName(); |
293 |
DefaultComboBoxModel model =
|
294 |
new DefaultComboBoxModel(nameLayers); |
295 |
cmbCapas.setModel(model); |
296 |
} |
297 |
/**
|
298 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
299 |
*/
|
300 |
public ViewInfo getViewInfo() {
|
301 |
ViewInfo vi = new ViewInfo(ViewInfo.MODALDIALOG);
|
302 |
return vi;
|
303 |
} |
304 |
|
305 |
private void callNewListeners(int selection, int actionCode){ |
306 |
for (int i = 0; i < listeners.size(); |
307 |
i++) { |
308 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
309 |
l.newSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
310 |
} |
311 |
|
312 |
} |
313 |
|
314 |
private void callAddToListeners(int selection, int actionCode){ |
315 |
for (int i = 0; i < listeners.size(); |
316 |
i++) { |
317 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
318 |
l.addToSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
319 |
} |
320 |
|
321 |
} |
322 |
|
323 |
private void callFromListeners(int selection, int actionCode){ |
324 |
for (int i = 0; i < listeners.size(); |
325 |
i++) { |
326 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
327 |
l.fromSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
328 |
} |
329 |
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* DOCUMENT ME!
|
334 |
*
|
335 |
* @param arg0
|
336 |
*
|
337 |
* @return
|
338 |
*/
|
339 |
public boolean addSelectionListener(SelectionByThemeListener arg0) { |
340 |
return listeners.add(arg0);
|
341 |
} |
342 |
|
343 |
/**
|
344 |
* DOCUMENT ME!
|
345 |
*
|
346 |
* @param arg0
|
347 |
*
|
348 |
* @return
|
349 |
*/
|
350 |
public boolean removeSelectionListener(SelectionByThemeListener arg0) { |
351 |
return listeners.remove(arg0);
|
352 |
} |
353 |
/**
|
354 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
355 |
*/
|
356 |
public void viewActivated() { |
357 |
} |
358 |
|
359 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|