svn-gvsig-desktop / branches / gvSIG_WMSv2 / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / WMSParamsPanel.java @ 3483
History | View | Annotate | Download (31.1 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 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.panels; |
42 |
|
43 |
import java.awt.geom.Rectangle2D; |
44 |
import java.util.ArrayList; |
45 |
import java.util.HashSet; |
46 |
import java.util.Iterator; |
47 |
import java.util.TreeSet; |
48 |
|
49 |
import javax.swing.DefaultListModel; |
50 |
import javax.swing.ImageIcon; |
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JCheckBox; |
53 |
import javax.swing.JComboBox; |
54 |
import javax.swing.JList; |
55 |
import javax.swing.JPanel; |
56 |
import javax.swing.JScrollPane; |
57 |
import javax.swing.JTabbedPane; |
58 |
import javax.swing.JTextField; |
59 |
import javax.swing.tree.TreePath; |
60 |
|
61 |
import org.gvsig.remoteClient.wms.WMSLayer; |
62 |
|
63 |
import com.iver.andami.PluginServices; |
64 |
import com.iver.cit.gvsig.gui.beans.JDnDList; |
65 |
import com.iver.cit.gvsig.gui.beans.JDnDListModel; |
66 |
import com.iver.cit.gvsig.gui.wizards.FormatListModel; |
67 |
//import com.iver.cit.gvsig.gui.wizards.LayerListModel;
|
68 |
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel; |
69 |
import com.iver.cit.gvsig.gui.wizards.SRSListModel; |
70 |
import com.iver.cit.gvsig.gui.wizards.WMSWizardData; |
71 |
import com.iver.cit.gvsig.gui.wizards.WMSWizardDataSource; |
72 |
import com.iver.cit.gvsig.gui.wizards.WizardData; |
73 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
74 |
/**
|
75 |
* This class implements the map option panel.
|
76 |
*
|
77 |
* It includes a set of Listeners that implement some control rules which
|
78 |
* refresh the component values that depends on those selected in the other
|
79 |
* components to avoid to choose an invalid set of options. It also includes a
|
80 |
* method (isCorrectlyConfigured()) that checks if the current set of values is enough to
|
81 |
* correctly launch a GetMap request.
|
82 |
*
|
83 |
* The information is obtained from a WMSWizardDataSource object.
|
84 |
*
|
85 |
*
|
86 |
* Esta clase implementa el panel de opciones disponibles sobre la cobertura.
|
87 |
*
|
88 |
* Incluye una serie de Listeners que implementan unas reglas de control que
|
89 |
* refrescan los valores de componentes cuyos valores dependen de aqu?llos
|
90 |
* seleccionados en otros componentes para evitar que se escoja una combinaci?n
|
91 |
* de opciones err?nea as? como una funci?n (isCorrectlyConfigured()) que
|
92 |
* comprueba si la combinaci?n escogida actualmente es suficiente para lanzar
|
93 |
* una operaci?n GetMap correctamente.
|
94 |
*
|
95 |
* La informaci?n obtiene a partir de un objeto WMSWizardDataSource.
|
96 |
*
|
97 |
* @author jaume - jaume dominguez faus
|
98 |
*
|
99 |
*/
|
100 |
public class WMSParamsPanel extends JPanel { |
101 |
private javax.swing.JScrollPane jScrollPane1 = null; |
102 |
private javax.swing.JScrollPane jScrollPane2 = null; |
103 |
private javax.swing.JScrollPane jScrollPane5 = null; |
104 |
private javax.swing.JButton btnAdd = null; |
105 |
private javax.swing.JButton btnDel = null; |
106 |
private javax.swing.JScrollPane jScrollPane6 = null; |
107 |
private javax.swing.JPanel panelPage2 = null; |
108 |
private javax.swing.JPanel jPanel2 = null; |
109 |
private javax.swing.JPanel tabFormats = null; |
110 |
private JPanel jPanel4 = null; |
111 |
private JTextField jTxtNomCapa = null; |
112 |
private JDnDList lstSelectedLayers = null; |
113 |
private javax.swing.JList lstSRSs = null; |
114 |
private javax.swing.JTree treeLayers = null; |
115 |
private javax.swing.JList lstFormats = null; |
116 |
private JDnDListModel selectedLayersModel = new JDnDListModel(); |
117 |
private WizardListenerSupport listenerSupport;
|
118 |
private WMSWizardData data;
|
119 |
private WMSWizardDataSource dataSource;
|
120 |
private JTabbedPane jTabbedPane = null; |
121 |
private JPanel tabLayers = null; |
122 |
private JPanel jPanel1 = null; |
123 |
private JPanel jPanel5 = null; |
124 |
private JPanel tabStyles = null; |
125 |
private JPanel jPanel7 = null; |
126 |
private JScrollPane scrlLayerNamedStyles = null; |
127 |
private JScrollPane scrlSelectedNamedStyles = null; |
128 |
private JList lstLayerNamedStyles = null; |
129 |
private JList lstSelectedNamedStyles = null; |
130 |
private JButton setLayerNamedStyleBtn = null; |
131 |
private JButton deleteLayerNamedStyleBtn = null; |
132 |
private JComboBox cmbNamedStyleLayers = null; |
133 |
private JCheckBox chkTransparency = null; |
134 |
|
135 |
public WMSParamsPanel(){
|
136 |
super();
|
137 |
initialize(); |
138 |
} |
139 |
|
140 |
/**
|
141 |
* This method initializes panelPage2
|
142 |
*
|
143 |
* @return javax.swing.JPanel
|
144 |
*/
|
145 |
private void initialize() { |
146 |
this.setLayout(null); |
147 |
this.setVisible(false); |
148 |
this.setBounds(10, 5, 481, 427); |
149 |
this.add(getJTabbedPane(), null); |
150 |
} |
151 |
/**
|
152 |
* This method initializes jPanel2
|
153 |
*
|
154 |
* @return javax.swing.JPanel
|
155 |
*/
|
156 |
private javax.swing.JPanel getJPanel2() {
|
157 |
if (jPanel2 == null) { |
158 |
jPanel2 = new javax.swing.JPanel();
|
159 |
jPanel2.setLayout(null);
|
160 |
jPanel2.setBounds(4, 59, 454, 328); |
161 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder( |
162 |
null, PluginServices.getText(this, "seleccionar_capas"), |
163 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
164 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
165 |
jPanel2.add(getJScrollPane1(), null);
|
166 |
jPanel2.add(getBtnDel(), null);
|
167 |
jPanel2.add(getBtnAdd(), null);
|
168 |
jPanel2.add(getJScrollPane5(), null);
|
169 |
} |
170 |
|
171 |
return jPanel2;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* This method initializes jPanel4
|
176 |
*
|
177 |
* @return javax.swing.JPanel
|
178 |
*/
|
179 |
private JPanel getJPanel4() { |
180 |
if (jPanel4 == null) { |
181 |
jPanel4 = new JPanel(); |
182 |
jPanel4.setLayout(null);
|
183 |
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
184 |
null, PluginServices.getText(this, "nombre_capa"), |
185 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
186 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
187 |
jPanel4.setBounds(4, 8, 457, 49); |
188 |
jPanel4.add(getJTxtNomCapa(), null);
|
189 |
} |
190 |
|
191 |
return jPanel4;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* This method initializes jPanel3
|
196 |
*
|
197 |
* @return javax.swing.JPanel
|
198 |
*/
|
199 |
private javax.swing.JPanel getTabFormats() {
|
200 |
if (tabFormats == null) { |
201 |
tabFormats = new javax.swing.JPanel();
|
202 |
tabFormats.setLayout(null);
|
203 |
//tabFormats.
|
204 |
tabFormats.add(getJPanel1(), null);
|
205 |
tabFormats.add(getJPanel5(), null);
|
206 |
} |
207 |
|
208 |
return tabFormats;
|
209 |
} |
210 |
/**
|
211 |
* This method initializes jScrollPane1
|
212 |
*
|
213 |
* @return javax.swing.JScrollPane
|
214 |
*/
|
215 |
private javax.swing.JScrollPane getJScrollPane1() {
|
216 |
if (jScrollPane1 == null) { |
217 |
jScrollPane1 = new javax.swing.JScrollPane();
|
218 |
jScrollPane1.setBounds(11, 22, 430, 124); |
219 |
jScrollPane1.setViewportView(getTreeLayers()); |
220 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75)); |
221 |
} |
222 |
|
223 |
return jScrollPane1;
|
224 |
} |
225 |
|
226 |
/**
|
227 |
* This method initializes btnDel
|
228 |
*
|
229 |
* @return javax.swing.JButton
|
230 |
*/
|
231 |
public javax.swing.JButton getBtnDel() {
|
232 |
if (btnDel == null) { |
233 |
btnDel = new javax.swing.JButton();
|
234 |
btnDel.setPreferredSize(new java.awt.Dimension(23, 23)); |
235 |
btnDel.setText(PluginServices.getText(this, "quitar")); |
236 |
btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
237 |
btnDel.setBounds(246, 158, 101, 23); |
238 |
btnDel.setEnabled(false);
|
239 |
btnDel.addActionListener(new java.awt.event.ActionListener() {
|
240 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
241 |
delLayer(); |
242 |
} |
243 |
}); |
244 |
} |
245 |
return btnDel;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* This method initializes btnAdd
|
250 |
*
|
251 |
* @return javax.swing.JButton
|
252 |
*/
|
253 |
public javax.swing.JButton getBtnAdd() {
|
254 |
if (btnAdd == null) { |
255 |
btnAdd = new javax.swing.JButton();
|
256 |
btnAdd.setPreferredSize(new java.awt.Dimension(23, 23)); |
257 |
btnAdd.setText(PluginServices.getText(this, "anadir")); |
258 |
btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
259 |
btnAdd.setBounds(133, 158, 101, 23); |
260 |
btnAdd.setEnabled(false);
|
261 |
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
262 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
263 |
addLayer(); |
264 |
} |
265 |
}); |
266 |
} |
267 |
|
268 |
return btnAdd;
|
269 |
} |
270 |
|
271 |
/**
|
272 |
* This method initializes jScrollPane5
|
273 |
*
|
274 |
* @return javax.swing.JScrollPane
|
275 |
*/
|
276 |
private javax.swing.JScrollPane getJScrollPane5() {
|
277 |
if (jScrollPane5 == null) { |
278 |
jScrollPane5 = new javax.swing.JScrollPane();
|
279 |
jScrollPane5.setBounds(11, 190, 431, 130); |
280 |
jScrollPane5.setViewportView(getLstSelectedLayers()); |
281 |
jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75)); |
282 |
} |
283 |
|
284 |
return jScrollPane5;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* This method initializes jTextField
|
289 |
*
|
290 |
* @return javax.swing.JTextField
|
291 |
*/
|
292 |
public JTextField getJTxtNomCapa() { |
293 |
if (jTxtNomCapa == null) { |
294 |
jTxtNomCapa = new JTextField(); |
295 |
jTxtNomCapa.setBounds(10, 19, 437, 20); |
296 |
jTxtNomCapa.setText(PluginServices.getText(this, "capaWMS")); |
297 |
} |
298 |
|
299 |
return jTxtNomCapa;
|
300 |
} |
301 |
|
302 |
|
303 |
/**
|
304 |
* This method initializes jScrollPane6
|
305 |
*
|
306 |
* @return javax.swing.JScrollPane
|
307 |
*/
|
308 |
private javax.swing.JScrollPane getJScrollPane6() {
|
309 |
if (jScrollPane6 == null) { |
310 |
jScrollPane6 = new javax.swing.JScrollPane();
|
311 |
jScrollPane6.setBounds(5, 23, 442, 140); |
312 |
jScrollPane6.setViewportView(getLstFormats()); |
313 |
jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 200)); |
314 |
} |
315 |
|
316 |
return jScrollPane6;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* This method initializes jScrollPane2
|
321 |
*
|
322 |
* @return javax.swing.JScrollPane
|
323 |
*/
|
324 |
private javax.swing.JScrollPane getJScrollPane2() {
|
325 |
if (jScrollPane2 == null) { |
326 |
jScrollPane2 = new javax.swing.JScrollPane();
|
327 |
jScrollPane2.setBounds(5, 23, 442, 141); |
328 |
jScrollPane2.setViewportView(getLstSRSs()); |
329 |
jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200)); |
330 |
} |
331 |
|
332 |
return jScrollPane2;
|
333 |
} |
334 |
|
335 |
/**
|
336 |
* This method initializes treeLayers
|
337 |
*
|
338 |
* @return javax.swing.JTree
|
339 |
*/
|
340 |
public javax.swing.JTree getTreeLayers() {
|
341 |
if (treeLayers == null) { |
342 |
treeLayers = new javax.swing.JTree();
|
343 |
treeLayers.setRootVisible(true);
|
344 |
treeLayers.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
345 |
public void valueChanged( |
346 |
javax.swing.event.TreeSelectionEvent e) { |
347 |
|
348 |
boolean isGetMapable = false; // pffff, jajaja |
349 |
TreePath[] selecciones = getTreeLayers().getSelectionPaths(); |
350 |
|
351 |
for (int i = 0; i < selecciones.length && !isGetMapable; i++) { |
352 |
isGetMapable = ((WMSLayer) selecciones[i].getLastPathComponent()).getChildren().size()==0;
|
353 |
} |
354 |
getBtnAdd().setEnabled(isGetMapable); |
355 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
356 |
} |
357 |
}); |
358 |
} |
359 |
|
360 |
return treeLayers;
|
361 |
} |
362 |
|
363 |
|
364 |
/**
|
365 |
* This method checks for the options selected within the configuration dialog are
|
366 |
* correct and enough to perform a GetMap request.
|
367 |
* @return true if you're done, false if not.
|
368 |
*/
|
369 |
public boolean isCorretlyConfigured() { |
370 |
boolean b;
|
371 |
if ((getLstSRSs().getSelectedIndex() != -1) && |
372 |
(getLstFormats().getSelectedIndex() != -1) &&
|
373 |
(getLstSelectedLayers().getModel().getSize() > 0)) {
|
374 |
b = true;
|
375 |
} else {
|
376 |
b = false;
|
377 |
} |
378 |
|
379 |
// Enable or disable the delete layer button.
|
380 |
getBtnDel().setEnabled(getLstSelectedLayers().getSelectedIndices()!=null && getLstSelectedLayers().getSelectedIndices().length>0); |
381 |
|
382 |
/*if (getTreeLayers1().getSelectionCount() > 0) {
|
383 |
LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath()
|
384 |
.getLastPathComponent();
|
385 |
String name = nodo.name;
|
386 |
|
387 |
if (name != null) {
|
388 |
getBtnAdd().setEnabled(true);
|
389 |
} else {
|
390 |
getBtnAdd().setEnabled(false);
|
391 |
}
|
392 |
} else {
|
393 |
getBtnAdd().setEnabled(false);
|
394 |
}
|
395 |
|
396 |
if (getLstSelectedLayers().getSelectedIndex() != -1) {
|
397 |
getBtnDel().setEnabled(true);
|
398 |
} else {
|
399 |
getBtnDel().setEnabled(false);
|
400 |
}*/
|
401 |
return b;
|
402 |
} |
403 |
|
404 |
/**
|
405 |
* DOCUMENT ME!
|
406 |
*/
|
407 |
private void delLayer() { |
408 |
int[] indices = lstSelectedLayers.getSelectedIndices(); |
409 |
|
410 |
ArrayList removeList = new ArrayList(); |
411 |
JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel()); |
412 |
ArrayList elements = modelo.getElements();
|
413 |
WMSLayer[] infos = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
414 |
|
415 |
for (int i = 0; i < indices.length; i++) { |
416 |
removeList.add(infos[indices[i]]); |
417 |
} |
418 |
|
419 |
modelo.delIndices(indices); |
420 |
lstSelectedLayers.clearSelection(); |
421 |
listenerSupport.callStateChanged(true);
|
422 |
//activarVisualizarBotones();
|
423 |
|
424 |
actualizarSRS(); |
425 |
} |
426 |
|
427 |
/**
|
428 |
* DOCUMENT ME!
|
429 |
*/
|
430 |
private void addLayer() { |
431 |
boolean alguno = false; |
432 |
|
433 |
TreePath[] selecciones = getTreeLayers().getSelectionPaths(); |
434 |
|
435 |
for (int i = 0; i < selecciones.length; i++) { |
436 |
WMSLayer nodo = (WMSLayer) selecciones[i].getLastPathComponent(); |
437 |
|
438 |
//Se a?ade a la lista de layers seleccionados
|
439 |
JDnDListModel modelo = (JDnDListModel) lstSelectedLayers.getModel(); |
440 |
|
441 |
if (modelo.addElement(nodo)) {
|
442 |
alguno = true;
|
443 |
} |
444 |
modelo.getSize(); |
445 |
} |
446 |
|
447 |
if (alguno) {
|
448 |
actualizarSRS(); |
449 |
} |
450 |
|
451 |
} |
452 |
|
453 |
/**
|
454 |
* This method initializes lstSelectedLayers
|
455 |
*
|
456 |
* @return javax.swing.JList
|
457 |
*/
|
458 |
public javax.swing.JList getLstSelectedLayers() {
|
459 |
if (lstSelectedLayers == null) { |
460 |
lstSelectedLayers = new JDnDList();
|
461 |
lstSelectedLayers.setModel(selectedLayersModel); |
462 |
lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); |
463 |
lstSelectedLayers.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
464 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
465 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
466 |
refreshCmbStyleLayers(); |
467 |
} |
468 |
}); |
469 |
} |
470 |
|
471 |
return lstSelectedLayers;
|
472 |
} |
473 |
|
474 |
protected void refreshCmbStyleLayers() { |
475 |
getCmbNamedStyleLayers().removeAllItems(); |
476 |
int size = getLstSelectedLayers().getModel().getSize();
|
477 |
for (int i=0; i<size; i++){ |
478 |
getCmbNamedStyleLayers().addItem(getLstSelectedLayers().getModel().getElementAt(i)); |
479 |
} |
480 |
} |
481 |
|
482 |
/**
|
483 |
* This method initializes lstSRSs
|
484 |
*
|
485 |
* @return javax.swing.JList
|
486 |
*/
|
487 |
public javax.swing.JList getLstSRSs() {
|
488 |
if (lstSRSs == null) { |
489 |
lstSRSs = new javax.swing.JList();
|
490 |
lstSRSs.setModel(new SRSListModel());
|
491 |
lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
492 |
lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
493 |
public void valueChanged( |
494 |
javax.swing.event.ListSelectionEvent e) { |
495 |
//activarVisualizarBotones();
|
496 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
497 |
} |
498 |
}); |
499 |
} |
500 |
|
501 |
return lstSRSs;
|
502 |
} |
503 |
|
504 |
/**
|
505 |
* This method initializes lstFormats1
|
506 |
*
|
507 |
* @return javax.swing.JList
|
508 |
*/
|
509 |
public javax.swing.JList getLstFormats() {
|
510 |
if (lstFormats == null) { |
511 |
lstFormats = new javax.swing.JList();
|
512 |
lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
513 |
lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
514 |
public void valueChanged( |
515 |
javax.swing.event.ListSelectionEvent e) { |
516 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
517 |
} |
518 |
}); |
519 |
} |
520 |
|
521 |
return lstFormats;
|
522 |
} |
523 |
|
524 |
/**
|
525 |
* DOCUMENT ME!
|
526 |
*/
|
527 |
public void actualizarSRS() { |
528 |
ArrayList elements = ((JDnDListModel) lstSelectedLayers.getModel()).getElements();
|
529 |
WMSLayer[] layers = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
530 |
|
531 |
|
532 |
if (layers.length == 0) { |
533 |
lstSRSs.setModel(new DefaultListModel()); |
534 |
} else {
|
535 |
TreeSet srsSet = new TreeSet(); |
536 |
srsSet.addAll(layers[0].getAllSrs());
|
537 |
|
538 |
for (int i = 1; i < layers.length; i++) { |
539 |
HashSet nuevo = new HashSet(layers[i].getAllSrs()); |
540 |
Iterator it = srsSet.iterator();
|
541 |
|
542 |
while (it.hasNext()) {
|
543 |
String srs = (String) it.next(); |
544 |
|
545 |
if (!nuevo.contains(srs)) {
|
546 |
srsSet.remove(srs); |
547 |
} |
548 |
} |
549 |
} |
550 |
|
551 |
DefaultListModel model = new DefaultListModel(); |
552 |
String[] array = (String[]) srsSet.toArray(new String[0]); |
553 |
|
554 |
for (int i = 0; i < array.length; i++) { |
555 |
model.addElement(array[i]); |
556 |
} |
557 |
|
558 |
lstSRSs.setModel(model); |
559 |
} |
560 |
} |
561 |
|
562 |
public void setListenerSupport(WizardListenerSupport support) { |
563 |
listenerSupport = support; |
564 |
} |
565 |
|
566 |
public void setWizardData(WizardData data) { |
567 |
this.data = (WMSWizardData) data;
|
568 |
((JDnDListModel) getLstSelectedLayers().getModel()).clear(); |
569 |
getLstSelectedLayers().repaint(); |
570 |
|
571 |
getLstFormats().setModel(new FormatListModel(this.data.getFormats())); |
572 |
getTreeLayers().setModel(new LayerTreeModel(this.data.getLayer())); |
573 |
/*getLstLayerStyles().setModel(getLstSelectedLayers().getModel());
|
574 |
getLstLayerStyles().repaint();*/
|
575 |
} |
576 |
|
577 |
public void setDataSource(WMSWizardDataSource dataSource) { |
578 |
this.dataSource = dataSource;
|
579 |
} |
580 |
|
581 |
public String getFormat() { |
582 |
return (String) getLstFormats().getSelectedValue(); |
583 |
} |
584 |
|
585 |
public String getLayersQuery() { |
586 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
587 |
WMSLayer[] layers = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
588 |
|
589 |
//Nombre separado por comas de las capas
|
590 |
String layersQuery = layers[0].getName(); |
591 |
|
592 |
for (int i = 1; i < layers.length; i++) { |
593 |
layersQuery += ("," + layers[i].getName());
|
594 |
} |
595 |
|
596 |
return layersQuery;
|
597 |
|
598 |
} |
599 |
|
600 |
public String getSRS() { |
601 |
return (String) getLstSRSs().getSelectedValue(); |
602 |
} |
603 |
|
604 |
public String getLayerName() { |
605 |
return getJTxtNomCapa().getText();
|
606 |
} |
607 |
|
608 |
public Rectangle2D getLayersRectangle(){ |
609 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
610 |
WMSLayer[] layers = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
611 |
String[] layerNames = new String[layers.length]; |
612 |
for (int i = 0; i < layerNames.length; i++) { |
613 |
layerNames[i] = layers[i].getName(); |
614 |
} |
615 |
//Boundingbox de todas las capas
|
616 |
ArrayList rectangulos = new ArrayList(); |
617 |
|
618 |
Rectangle2D rect;
|
619 |
|
620 |
for (int i = 0; i < layers.length; i++) { |
621 |
// String[] rutaCapa = new String[layers[i].getPathCount()];
|
622 |
//
|
623 |
// for (int j = 0; j < layers[i].getPathCount(); j++) {
|
624 |
// rutaCapa[j] = ((WMSLayer) layers[i].getPathComponent(j)).getTitle();
|
625 |
// }
|
626 |
//
|
627 |
rect = dataSource.getBoundingBox(layerNames, getSRS()); |
628 |
|
629 |
if (rect != null) { |
630 |
rectangulos.add(rect); |
631 |
} |
632 |
} |
633 |
|
634 |
rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray( |
635 |
new Rectangle2D.Double[0])); |
636 |
|
637 |
return rect;
|
638 |
} |
639 |
|
640 |
public Rectangle2D _getLayersRectangle(){ |
641 |
TreePath[] layers = getSelectedLayers(); |
642 |
|
643 |
//Boundingbox de todas las capas
|
644 |
ArrayList rectangulos = new ArrayList(); |
645 |
|
646 |
Rectangle2D rect;
|
647 |
|
648 |
for (int i = 0; i < layers.length; i++) { |
649 |
String[] rutaCapa = new String[layers[i].getPathCount()]; |
650 |
|
651 |
for (int j = 0; j < layers[i].getPathCount(); j++) { |
652 |
rutaCapa[j] = ((WMSLayer) layers[i].getPathComponent(j)).getTitle(); |
653 |
} |
654 |
|
655 |
rect = dataSource.getBoundingBox(rutaCapa, getSRS()); |
656 |
|
657 |
if (rect != null) { |
658 |
rectangulos.add(rect); |
659 |
} |
660 |
} |
661 |
|
662 |
rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray( |
663 |
new Rectangle2D.Double[0])); |
664 |
|
665 |
return rect;
|
666 |
} |
667 |
|
668 |
public TreePath[] getSelectedLayers() { |
669 |
return getTreeLayers().getSelectionPaths();
|
670 |
} |
671 |
|
672 |
/**
|
673 |
* Obtiene el rect?ngulo que contiene a todos los otros
|
674 |
*
|
675 |
* @param rects rectangulos
|
676 |
*
|
677 |
* @return Rectangulo que contiene a todos los demas
|
678 |
*/
|
679 |
private Rectangle2D getRectangle(Rectangle2D[] rects) { |
680 |
Rectangle2D ret = rects[0]; |
681 |
|
682 |
for (int i = 1; i < rects.length; i++) { |
683 |
ret.add(rects[i]); |
684 |
} |
685 |
|
686 |
return ret;
|
687 |
} |
688 |
|
689 |
public String getQueryableLayerQuery() { |
690 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
691 |
WMSLayer[] layers = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
692 |
//Nombre separado por comas de las capas
|
693 |
String layersQuery = ""; |
694 |
int i;
|
695 |
|
696 |
for (i = 0; i < layers.length; i++) { |
697 |
if (layers[i].isQueryable()) {
|
698 |
layersQuery = layers[i].getName(); |
699 |
|
700 |
break;
|
701 |
} |
702 |
} |
703 |
|
704 |
for (int j = i + 1; j < layers.length; j++) { |
705 |
if (layers[j].isQueryable()) {
|
706 |
layersQuery += ("," + layers[j].getName());
|
707 |
} |
708 |
} |
709 |
|
710 |
return layersQuery;
|
711 |
} |
712 |
|
713 |
/**
|
714 |
* Returns the index of the CRS within the CRS list.
|
715 |
*
|
716 |
* Devuelve la posicion que ocupa el CRS en la lista de CRS
|
717 |
*
|
718 |
* @param crs
|
719 |
* @return The CRS's index if it exists, -1 if it not exists.
|
720 |
*/
|
721 |
public int getSRSIndex(String crs) { |
722 |
for (int i=0; i<getLstSRSs().getModel().getSize(); i++){ |
723 |
if (crs.equals(getLstSRSs().getModel().getElementAt(i)))
|
724 |
return i;
|
725 |
} |
726 |
return -1; |
727 |
} |
728 |
|
729 |
/**
|
730 |
* Returns the index of the format within the formats list.
|
731 |
*
|
732 |
* Devuelve la posicion que ocupa el formato en la lista de formatos
|
733 |
* @param format
|
734 |
*
|
735 |
* @return The format's index if it exists, -1 if it not exists.
|
736 |
*/
|
737 |
public int getFormatIndex(String format) { |
738 |
for (int i=0; i<getLstFormats().getModel().getSize(); i++){ |
739 |
if (format.equals(getLstFormats().getModel().getElementAt(i)))
|
740 |
return i;
|
741 |
} |
742 |
return -1; |
743 |
} |
744 |
|
745 |
/**
|
746 |
* This method initializes jTabbedPane
|
747 |
*
|
748 |
* @return javax.swing.JTabbedPane
|
749 |
*/
|
750 |
private JTabbedPane getJTabbedPane() { |
751 |
if (jTabbedPane == null) { |
752 |
jTabbedPane = new JTabbedPane(); |
753 |
jTabbedPane.setBounds(3, 3, 475, 415); |
754 |
jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, getTabLayers(), null); |
755 |
jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, getTabFormats(), null); |
756 |
jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, getTabStyle(), null); |
757 |
|
758 |
} |
759 |
return jTabbedPane;
|
760 |
} |
761 |
|
762 |
/**
|
763 |
* This method initializes jPanel
|
764 |
*
|
765 |
* @return javax.swing.JPanel
|
766 |
*/
|
767 |
private JPanel getTabLayers() { |
768 |
if (tabLayers == null) { |
769 |
tabLayers = new JPanel(); |
770 |
tabLayers.setLayout(null);
|
771 |
tabLayers.add(getJPanel4(), null);
|
772 |
tabLayers.add(getJPanel2(), null);
|
773 |
} |
774 |
return tabLayers;
|
775 |
} |
776 |
|
777 |
/**
|
778 |
* This method initializes jPanel1
|
779 |
*
|
780 |
* @return javax.swing.JPanel
|
781 |
*/
|
782 |
private JPanel getJPanel1() { |
783 |
if (jPanel1 == null) { |
784 |
jPanel1 = new JPanel(); |
785 |
jPanel1.setLayout(null);
|
786 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
787 |
null, PluginServices.getText(this, "seleccionar_formato"), |
788 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
789 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
790 |
jPanel1.setBounds(7, 10, 453, 194); |
791 |
jPanel1.add(getJScrollPane6(), null);
|
792 |
jPanel1.add(getChkTransparency(), null);
|
793 |
} |
794 |
return jPanel1;
|
795 |
} |
796 |
|
797 |
/**
|
798 |
* This method initializes jPanel5
|
799 |
*
|
800 |
* @return javax.swing.JPanel
|
801 |
*/
|
802 |
private JPanel getJPanel5() { |
803 |
if (jPanel5 == null) { |
804 |
jPanel5 = new JPanel(); |
805 |
jPanel5.setLayout(null);
|
806 |
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder( |
807 |
null, PluginServices.getText(this, "seleccionar_srs"), |
808 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
809 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
810 |
jPanel5.setBounds(7, 210, 453, 168); |
811 |
jPanel5.add(getJScrollPane2(), null);
|
812 |
} |
813 |
return jPanel5;
|
814 |
} |
815 |
|
816 |
/**
|
817 |
* This method initializes jPanel6
|
818 |
*
|
819 |
* @return javax.swing.JPanel
|
820 |
*/
|
821 |
private JPanel getTabStyle() { |
822 |
if (tabStyles == null) { |
823 |
tabStyles = new JPanel(); |
824 |
tabStyles.setLayout(null);
|
825 |
tabStyles.add(getJPanel7(), null);
|
826 |
} |
827 |
return tabStyles;
|
828 |
} |
829 |
|
830 |
/**
|
831 |
* This method initializes jPanel7
|
832 |
*
|
833 |
* @return javax.swing.JPanel
|
834 |
*/
|
835 |
private JPanel getJPanel7() { |
836 |
if (jPanel7 == null) { |
837 |
jPanel7 = new JPanel(); |
838 |
jPanel7.setLayout(null);
|
839 |
jPanel7.setBounds(5, 9, 456, 376); |
840 |
jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder( |
841 |
null, PluginServices.getText(this, "seleccionar_estilo_para_capa"), |
842 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
843 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
844 |
jPanel7.add(getScrlLayerNamedStyles(), null);
|
845 |
jPanel7.add(getScrlSelectedNamedStyles(), null);
|
846 |
jPanel7.add(getSetLayerNamedStyleBtn(), null);
|
847 |
jPanel7.add(getDeleteLayerNamedStyleBtn(), null);
|
848 |
jPanel7.add(getCmbNamedStyleLayers(), null);
|
849 |
setSetLayerStyleButtonEnabled(false);
|
850 |
setDeleteButtonEnabled(false);
|
851 |
} |
852 |
return jPanel7;
|
853 |
} |
854 |
|
855 |
/**
|
856 |
* This method initializes scrlLayerStyles
|
857 |
*
|
858 |
* @return javax.swing.JScrollPane
|
859 |
*/
|
860 |
private JScrollPane getScrlLayerNamedStyles() { |
861 |
if (scrlLayerNamedStyles == null) { |
862 |
scrlLayerNamedStyles = new JScrollPane(); |
863 |
scrlLayerNamedStyles.setBounds(14, 67, 430, 117); |
864 |
scrlLayerNamedStyles.setViewportView(getLstLayerNamedStyles()); |
865 |
} |
866 |
return scrlLayerNamedStyles;
|
867 |
} |
868 |
|
869 |
/**
|
870 |
* This method initializes scrlStyles
|
871 |
*
|
872 |
* @return javax.swing.JScrollPane
|
873 |
*/
|
874 |
private JScrollPane getScrlSelectedNamedStyles() { |
875 |
if (scrlSelectedNamedStyles == null) { |
876 |
scrlSelectedNamedStyles = new JScrollPane(); |
877 |
scrlSelectedNamedStyles.setBounds(14, 250, 430, 111); |
878 |
scrlSelectedNamedStyles.setViewportView(getLstSelectedNamedStyles()); |
879 |
|
880 |
} |
881 |
return scrlSelectedNamedStyles;
|
882 |
} |
883 |
|
884 |
/**
|
885 |
* This method initializes lstLayerStyles
|
886 |
*
|
887 |
* @return javax.swing.JList
|
888 |
*/
|
889 |
private JList getLstLayerNamedStyles() { |
890 |
if (lstLayerNamedStyles == null) { |
891 |
lstLayerNamedStyles = new JList(); |
892 |
} |
893 |
return lstLayerNamedStyles;
|
894 |
} |
895 |
|
896 |
/**
|
897 |
* This method initializes lstStyles
|
898 |
*
|
899 |
* @return javax.swing.JList
|
900 |
*/
|
901 |
private JList getLstSelectedNamedStyles() { |
902 |
if (lstSelectedNamedStyles == null) { |
903 |
lstSelectedNamedStyles = new JList(); |
904 |
} |
905 |
return lstSelectedNamedStyles;
|
906 |
} |
907 |
|
908 |
|
909 |
/**
|
910 |
* Sets the focus to the tab next to the current one.
|
911 |
*
|
912 |
* Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
913 |
*
|
914 |
*/
|
915 |
public void avanzaTab(){ |
916 |
int currentPage = currentPage();
|
917 |
int nPages = getNumTabs();
|
918 |
if (nPages -1 > currentPage){ |
919 |
getJTabbedPane().setSelectedIndex(nextPageEnabled()); |
920 |
} |
921 |
} |
922 |
|
923 |
/**
|
924 |
* Sets the focus to the tab previous to the current one.
|
925 |
*
|
926 |
* Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
927 |
*
|
928 |
*/
|
929 |
public void retrocedeTab(){ |
930 |
this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
931 |
|
932 |
} |
933 |
/**
|
934 |
* Returns the index of the current tab.
|
935 |
*
|
936 |
* Devuelve el ?ndice de la p?gina actual del wizard.
|
937 |
*
|
938 |
* @return
|
939 |
*/
|
940 |
public int currentPage(){ |
941 |
return getJTabbedPane().getSelectedIndex();
|
942 |
} |
943 |
|
944 |
/**
|
945 |
* Returns the tab amount that the WMSParamsPanel currently have
|
946 |
*
|
947 |
* Devuelve el n?mero de solapas que tiene actualmente el WMSParamsPanel
|
948 |
*
|
949 |
* @return int
|
950 |
*/
|
951 |
public int getNumTabs(){ |
952 |
return getJTabbedPane().getTabCount();
|
953 |
} |
954 |
|
955 |
|
956 |
/**
|
957 |
* <p>
|
958 |
* Returns the index of the previous enabled tab.
|
959 |
* </p>
|
960 |
* <p>
|
961 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
|
962 |
* ninguna.
|
963 |
* </p>
|
964 |
* @return The index, or -1 if there is no one.
|
965 |
*/
|
966 |
public int previousEnabledPage(){ |
967 |
int currentPage = currentPage();
|
968 |
int j=0; |
969 |
if (currentPage == 0) |
970 |
j= -1;
|
971 |
for (int i = currentPage-1; i>-1; i--){ |
972 |
if (getJTabbedPane().isEnabledAt(i)){
|
973 |
j= i; |
974 |
break;
|
975 |
} |
976 |
} |
977 |
return j;
|
978 |
} |
979 |
|
980 |
/**
|
981 |
* <p>
|
982 |
* Returns the previous of the previous enabled tab.
|
983 |
* </p>
|
984 |
* <p>
|
985 |
* Devuelve el ?ndice de la siguiente p?gina habilitada del wizard o -1 si no hay
|
986 |
* ninguna.
|
987 |
* </p>
|
988 |
* @return The index, or -1 if there is no one.
|
989 |
*/
|
990 |
public int nextPageEnabled() { |
991 |
int currentPage = currentPage();
|
992 |
int nPages = getNumTabs();
|
993 |
if (currentPage == nPages)
|
994 |
return -1; |
995 |
for (int i=currentPage+1; i<nPages; i++){ |
996 |
if (getJTabbedPane().isEnabledAt(i)){
|
997 |
return i;
|
998 |
} |
999 |
} |
1000 |
return -1; |
1001 |
} |
1002 |
|
1003 |
/**
|
1004 |
* This method initializes setLayerStyleBtn
|
1005 |
*
|
1006 |
* @return javax.swing.JButton
|
1007 |
*/
|
1008 |
private JButton getSetLayerNamedStyleBtn() { |
1009 |
if (setLayerNamedStyleBtn == null) { |
1010 |
setLayerNamedStyleBtn = new JButton(); |
1011 |
setLayerNamedStyleBtn.setBounds(183, 199, 33, 33); |
1012 |
} |
1013 |
return setLayerNamedStyleBtn;
|
1014 |
} |
1015 |
|
1016 |
/**
|
1017 |
* This method initializes deleteLayerStyleBtn
|
1018 |
*
|
1019 |
* @return javax.swing.JButton
|
1020 |
*/
|
1021 |
private JButton getDeleteLayerNamedStyleBtn() { |
1022 |
if (deleteLayerNamedStyleBtn == null) { |
1023 |
deleteLayerNamedStyleBtn = new JButton(); |
1024 |
deleteLayerNamedStyleBtn.setBounds(236, 199, 33, 33); |
1025 |
} |
1026 |
return deleteLayerNamedStyleBtn;
|
1027 |
} |
1028 |
|
1029 |
/**
|
1030 |
* Enables or disables the delete style button, and also shifts the
|
1031 |
* IconImage.
|
1032 |
* @param enabled
|
1033 |
*/
|
1034 |
private void setDeleteButtonEnabled(boolean enabled){ |
1035 |
JButton btn = getDeleteLayerNamedStyleBtn();
|
1036 |
btn.setEnabled(enabled); |
1037 |
if (enabled){
|
1038 |
btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/delete-on.png"))); |
1039 |
} else{
|
1040 |
btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/delete-off.png"))); |
1041 |
} |
1042 |
} |
1043 |
|
1044 |
/**
|
1045 |
* Enables or disables the add style button, and also shifts the
|
1046 |
* IconImage.
|
1047 |
* @param enabled
|
1048 |
*/
|
1049 |
private void setSetLayerStyleButtonEnabled(boolean enabled){ |
1050 |
JButton btn = getSetLayerNamedStyleBtn();
|
1051 |
btn.setEnabled(enabled); |
1052 |
if (enabled){
|
1053 |
btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/arrow-down-on.png"))); |
1054 |
} else{
|
1055 |
btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/arrow-down-off.png"))); |
1056 |
} |
1057 |
} |
1058 |
|
1059 |
/**
|
1060 |
* This method initializes cmbStyleLayers
|
1061 |
*
|
1062 |
* @return javax.swing.JComboBox
|
1063 |
*/
|
1064 |
private JComboBox getCmbNamedStyleLayers() { |
1065 |
if (cmbNamedStyleLayers == null) { |
1066 |
cmbNamedStyleLayers = new JComboBox(); |
1067 |
cmbNamedStyleLayers.setBounds(14, 25, 430, 20); |
1068 |
cmbNamedStyleLayers.addItemListener(new java.awt.event.ItemListener() {
|
1069 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
1070 |
setNamedStyleList((WMSLayer)getCmbNamedStyleLayers().getSelectedItem()); |
1071 |
} |
1072 |
}); |
1073 |
} |
1074 |
return cmbNamedStyleLayers;
|
1075 |
} |
1076 |
|
1077 |
/**
|
1078 |
* Sets the named styles of the layer passed as the layer's title
|
1079 |
*
|
1080 |
* @param layerTitle
|
1081 |
*/
|
1082 |
private void setNamedStyleList(WMSLayer layer){ |
1083 |
// FormatListModel model = (FormatListModel) getLstLayerNamedStyles().getModel();
|
1084 |
// ((FormatListModel) getLstLayerNamedStyles().getModel()).addElements(layer.getNamedStyles());
|
1085 |
if (layer == null) |
1086 |
return;
|
1087 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
1088 |
WMSLayer[] layers = (WMSLayer[]) elements.toArray(new WMSLayer[0]); |
1089 |
for (int i = 0; i < layers.length; i++) { |
1090 |
if (layers[i].getName().equals(layer.getTitle())){
|
1091 |
String[] namedStyles = (String[])layers[i].getNamedStyles().toArray(new String[0]); |
1092 |
getLstLayerNamedStyles().setModel(new FormatListModel(namedStyles));
|
1093 |
} |
1094 |
} |
1095 |
} |
1096 |
|
1097 |
/**
|
1098 |
* This method initializes chkTrasparency
|
1099 |
*
|
1100 |
* @return javax.swing.JCheckBox
|
1101 |
*/
|
1102 |
public JCheckBox getChkTransparency() { |
1103 |
if (chkTransparency == null) { |
1104 |
chkTransparency = new JCheckBox(); |
1105 |
chkTransparency.setText(PluginServices.getText(this, "wms_transparency")); |
1106 |
chkTransparency.setSelected(true);
|
1107 |
chkTransparency.setBounds(5, 168, 441, 21); |
1108 |
} |
1109 |
return chkTransparency;
|
1110 |
} |
1111 |
} // @jve:decl-index=0:visual-constraint="10,10"
|