svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / wms / WMSWizard.java @ 1103
History | View | Annotate | Download (32.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 23-abr-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.gui.wms; |
48 |
|
49 |
import java.awt.geom.Rectangle2D; |
50 |
import java.net.MalformedURLException; |
51 |
import java.net.URL; |
52 |
import java.util.ArrayList; |
53 |
import java.util.HashSet; |
54 |
import java.util.Iterator; |
55 |
import java.util.TreeSet; |
56 |
|
57 |
import javax.swing.DefaultComboBoxModel; |
58 |
import javax.swing.DefaultListModel; |
59 |
import javax.swing.JPanel; |
60 |
import javax.swing.JTextField; |
61 |
import javax.swing.tree.TreePath; |
62 |
|
63 |
import org.apache.log4j.Logger; |
64 |
|
65 |
import com.iver.andami.PluginServices; |
66 |
import com.iver.andami.Utilities; |
67 |
import com.iver.cit.gvsig.gui.WizardPanel; |
68 |
import com.iver.utiles.swing.JComboBox; |
69 |
|
70 |
|
71 |
|
72 |
/**
|
73 |
* DOCUMENT ME!
|
74 |
*
|
75 |
* @author Fernando Gonz?lez Cort?s
|
76 |
*/
|
77 |
public class WMSWizard extends WizardPanel { |
78 |
private static Logger logger = Logger.getLogger(WMSWizard.class.getName()); |
79 |
private int page = 0; |
80 |
private boolean conectado = false; |
81 |
private javax.swing.JPanel jContentPane = null; |
82 |
private JComboBox cmbHost = null; |
83 |
private javax.swing.JButton btnDetalles = null; |
84 |
private javax.swing.JPanel jPanel = null; |
85 |
private javax.swing.JLabel jLabel1 = null; |
86 |
private javax.swing.JLabel lblTitle = null; |
87 |
private javax.swing.JScrollPane jScrollPane = null; |
88 |
private javax.swing.JTextArea txtAbstract = null; |
89 |
private javax.swing.JScrollPane jScrollPane1 = null; |
90 |
private javax.swing.JTree treeLayers1 = null; |
91 |
private javax.swing.JScrollPane jScrollPane2 = null; |
92 |
private javax.swing.JList lstFormats1 = null; |
93 |
private javax.swing.JPanel panelPage1 = null; |
94 |
private javax.swing.JPanel panelPage2 = null; |
95 |
private javax.swing.JScrollPane jScrollPane5 = null; |
96 |
private javax.swing.JList lstSelectedLayers = null; |
97 |
private javax.swing.JButton btnAdd = null; |
98 |
private javax.swing.JButton btnDel = null; |
99 |
private javax.swing.JScrollPane jScrollPane6 = null; |
100 |
private javax.swing.JList lstSRSs = null; |
101 |
private LayerListModel selectedLayersModel = new LayerListModel(); |
102 |
private javax.swing.JButton btnSiguiente = null; |
103 |
private javax.swing.JButton btnAnterior = null; |
104 |
private javax.swing.JPanel jPanel1 = null; |
105 |
private javax.swing.JPanel jPanel2 = null; |
106 |
private javax.swing.JPanel jPanel3 = null; |
107 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
108 |
private WizardDataSource dataSource;
|
109 |
private JPanel jPanel4 = null; |
110 |
private JTextField jTxtNomCapa = null; |
111 |
|
112 |
/**
|
113 |
* This is the default constructor
|
114 |
*
|
115 |
* @param v DOCUMENT ME!
|
116 |
*/
|
117 |
public WMSWizard() {
|
118 |
super();
|
119 |
initialize(); |
120 |
} |
121 |
|
122 |
/**
|
123 |
* This method initializes this
|
124 |
*/
|
125 |
private void initialize() { |
126 |
this.setSize(510, 311); |
127 |
this.setLayout(null); |
128 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
129 |
this.setVisible(true); |
130 |
this.add(getPanelPage1(), null); |
131 |
this.add(getPanelPage2(), null); |
132 |
this.add(getBtnAnterior(), null); |
133 |
this.add(getBtnSiguiente(), null); |
134 |
activarVisualizarBotones(); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* DOCUMENT ME!
|
139 |
*/
|
140 |
private void actualizarSRS() { |
141 |
LayerInfo[] layers = ((LayerListModel) lstSelectedLayers.getModel()).getElements();
|
142 |
|
143 |
if (layers.length == 0) { |
144 |
lstSRSs.setModel(new DefaultListModel()); |
145 |
} else {
|
146 |
TreeSet srsSet = new TreeSet(); |
147 |
srsSet.addAll(layers[0].getSRSs());
|
148 |
|
149 |
for (int i = 1; i < layers.length; i++) { |
150 |
HashSet nuevo = new HashSet(layers[i].getSRSs()); |
151 |
Iterator it = srsSet.iterator();
|
152 |
|
153 |
while (it.hasNext()) {
|
154 |
String srs = (String) it.next(); |
155 |
|
156 |
if (!nuevo.contains(srs)) {
|
157 |
srsSet.remove(srs); |
158 |
} |
159 |
} |
160 |
} |
161 |
|
162 |
DefaultListModel model = new DefaultListModel(); |
163 |
String[] array = (String[]) srsSet.toArray(new String[0]); |
164 |
|
165 |
for (int i = 0; i < array.length; i++) { |
166 |
model.addElement(array[i]); |
167 |
} |
168 |
|
169 |
lstSRSs.setModel(model); |
170 |
} |
171 |
} |
172 |
|
173 |
/**
|
174 |
* DOCUMENT ME!
|
175 |
*/
|
176 |
private void addLayer() { |
177 |
boolean alguno = false; |
178 |
|
179 |
TreePath[] selecciones = getTreeLayers1().getSelectionPaths(); |
180 |
|
181 |
for (int i = 0; i < selecciones.length; i++) { |
182 |
LayerInfo nodo = (LayerInfo) selecciones[i].getLastPathComponent(); |
183 |
|
184 |
String name = nodo.name;
|
185 |
String text = nodo.text;
|
186 |
ArrayList srs = nodo.getSRSs();
|
187 |
|
188 |
//Se a?ade a la lista de layers seleccionados
|
189 |
LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel(); |
190 |
|
191 |
if (modelo.addElement(nodo)) {
|
192 |
alguno = true;
|
193 |
} |
194 |
} |
195 |
|
196 |
if (alguno) {
|
197 |
activarVisualizarBotones(); |
198 |
actualizarSRS(); |
199 |
} |
200 |
} |
201 |
|
202 |
/**
|
203 |
* DOCUMENT ME!
|
204 |
*/
|
205 |
private void delLayer() { |
206 |
int[] index = lstSelectedLayers.getSelectedIndices(); |
207 |
|
208 |
ArrayList removeList = new ArrayList(); |
209 |
LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel(); |
210 |
LayerInfo[] infos = modelo.getElements();
|
211 |
|
212 |
for (int i = 0; i < index.length; i++) { |
213 |
removeList.add(infos[index[i]]); |
214 |
} |
215 |
|
216 |
modelo.delElements(removeList); |
217 |
lstSelectedLayers.clearSelection(); |
218 |
|
219 |
activarVisualizarBotones(); |
220 |
|
221 |
actualizarSRS(); |
222 |
} |
223 |
|
224 |
private void addHost(String host){ |
225 |
host = host.trim(); |
226 |
DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost().getModel(); |
227 |
if (model.getIndexOf(host) < 0){ |
228 |
model.addElement(host); |
229 |
} |
230 |
} |
231 |
|
232 |
/**
|
233 |
* DOCUMENT ME!
|
234 |
*/
|
235 |
private void rellenarControles() { |
236 |
try {
|
237 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
238 |
|
239 |
if (!host.endsWith("?")) { |
240 |
host += "?";
|
241 |
} |
242 |
|
243 |
WizardData data = dataSource.detalles(new URL(host)); |
244 |
|
245 |
addHost(host); |
246 |
|
247 |
((LayerListModel) lstSelectedLayers.getModel()).clear(); |
248 |
lstSelectedLayers.repaint(); |
249 |
lblTitle.setText(data.getTitle()); |
250 |
txtAbstract.setText(data.getAbstract()); |
251 |
lstFormats1.setModel(new FormatListModel(data.getFormats()));
|
252 |
treeLayers1.setModel(new LayerTreeModel(data.getLayer()));
|
253 |
conectado = true;
|
254 |
activarVisualizarBotones(); |
255 |
} catch (Exception e) { |
256 |
listenerSupport.callError(e); |
257 |
} |
258 |
} |
259 |
|
260 |
/**
|
261 |
* DOCUMENT ME!
|
262 |
*/
|
263 |
private void activarVisualizarBotones() { |
264 |
if (page == 0) { |
265 |
getBtnAnterior().setEnabled(false);
|
266 |
getBtnSiguiente().setVisible(true);
|
267 |
|
268 |
if (conectado) {
|
269 |
getBtnSiguiente().setEnabled(true);
|
270 |
} else {
|
271 |
getBtnSiguiente().setEnabled(false);
|
272 |
} |
273 |
|
274 |
} else if (page == 1) { |
275 |
getBtnAnterior().setEnabled(true);
|
276 |
getBtnSiguiente().setVisible(false);
|
277 |
listenerSupport.callStateChanged(true);
|
278 |
|
279 |
if ((getLstSRSs().getSelectedIndex() != -1) && |
280 |
(getLstFormats1().getSelectedIndex() != -1) &&
|
281 |
(getLstSelectedLayers().getModel().getSize() > 0)) {
|
282 |
listenerSupport.callStateChanged(true);
|
283 |
} else {
|
284 |
listenerSupport.callStateChanged(false);
|
285 |
} |
286 |
|
287 |
if (getTreeLayers1().getSelectionCount() > 0) { |
288 |
LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath() |
289 |
.getLastPathComponent(); |
290 |
String name = nodo.name;
|
291 |
|
292 |
if (name != null) { |
293 |
getBtnAdd().setEnabled(true);
|
294 |
} else {
|
295 |
getBtnAdd().setEnabled(false);
|
296 |
} |
297 |
} else {
|
298 |
getBtnAdd().setEnabled(false);
|
299 |
} |
300 |
|
301 |
if (getLstSelectedLayers().getSelectedIndex() != -1) { |
302 |
getBtnDel().setEnabled(true);
|
303 |
} else {
|
304 |
getBtnDel().setEnabled(false);
|
305 |
} |
306 |
} |
307 |
} |
308 |
|
309 |
/*
|
310 |
* DOCUMENT ME!
|
311 |
*
|
312 |
private void finalizar() {
|
313 |
LayerInfo[] layers = ((LayerListModel) lstSelectedLayers.getModel()).getElements();
|
314 |
String srs = (String) lstSRSs.getSelectedValue();
|
315 |
//Nombre separado por comas de las capas
|
316 |
String layersQuery = layers[0].name;
|
317 |
for (int i = 1; i < layers.length; i++) {
|
318 |
layersQuery += ("," + layers[i].name);
|
319 |
}
|
320 |
Rectangle2D rect;
|
321 |
rect = v.getMapControl().getExtent();
|
322 |
if (rect == null) {
|
323 |
//Boundingbox de todas las capas
|
324 |
ArrayList rectangulos = new ArrayList();
|
325 |
for (int i = 0; i < layers.length; i++) {
|
326 |
rect = wms.getBoundingBox(layers[i].name, srs);
|
327 |
if (rect != null) {
|
328 |
rectangulos.add(rect);
|
329 |
}
|
330 |
}
|
331 |
rect = Utilities.getRectangle((Rectangle2D.Double[]) rectangulos.toArray(
|
332 |
new Rectangle2D.Double[0]));
|
333 |
if (rect == null) {
|
334 |
App.instance.getNm().addInfo("Si no hay un bounding box en la especificaci?n, y tampoco en el FMap.",
|
335 |
null);
|
336 |
return; //Si no hay un bounding box en la especificaci?n, y tampoco en el FMap.
|
337 |
}
|
338 |
logger.debug("(" + rect.getMinX() + ", " + rect.getMinY() + ")-(" +
|
339 |
rect.getMaxX() + ", " + rect.getMaxY() + ")");
|
340 |
}
|
341 |
if (rect != null) {
|
342 |
IFLayer lyr = new FLyrWMS(rect,
|
343 |
(String) lstFormats1.getSelectedValue(), layersQuery, srs,
|
344 |
wms);
|
345 |
v.getMapControl().getLayers().addLayer(lyr);
|
346 |
v.getTOC().refresh();
|
347 |
v.getMapControl().drawMap();
|
348 |
} else {
|
349 |
}
|
350 |
/*MapQuery query = new MapQuery();
|
351 |
query.setBBOX(rect);
|
352 |
query.setFormat((String) lstFormats1.getSelectedValue());
|
353 |
query.setHeight(300);
|
354 |
query.setLayers(layersQuery);
|
355 |
query.setSRS(srs);
|
356 |
query.setStyles("");
|
357 |
query.setVersion("1.0.0");
|
358 |
query.setWidth(300);
|
359 |
byte[] bytes;
|
360 |
try {
|
361 |
bytes = wms.doMapQuery(query);
|
362 |
FileOutputStream out;
|
363 |
out = new FileOutputStream("res.png");
|
364 |
out.write(bytes);
|
365 |
out.close();
|
366 |
} catch (WMSException e1) {
|
367 |
e1.printStackTrace();
|
368 |
} catch (Exception e1) {
|
369 |
e1.printStackTrace();
|
370 |
}
|
371 |
}*/
|
372 |
|
373 |
/**
|
374 |
* This method initializes txtHost
|
375 |
*
|
376 |
* @return javax.swing.JTextField
|
377 |
*/
|
378 |
private javax.swing.JComboBox getTxtHost() {
|
379 |
if (cmbHost == null) { |
380 |
cmbHost = new JComboBox(); |
381 |
cmbHost.setModel(new DefaultComboBoxModel()); |
382 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
383 |
cmbHost.setEditable(true);
|
384 |
((DefaultComboBoxModel) cmbHost.getModel()).addElement(
|
385 |
"http://demo.deegree.org:8080/deegree/wms");
|
386 |
((DefaultComboBoxModel) cmbHost.getModel()).addElement(
|
387 |
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?");
|
388 |
} |
389 |
|
390 |
return cmbHost;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* This method initializes btnDetalles
|
395 |
*
|
396 |
* @return javax.swing.JButton
|
397 |
*/
|
398 |
private javax.swing.JButton getBtnDetalles() {
|
399 |
if (btnDetalles == null) { |
400 |
btnDetalles = new javax.swing.JButton();
|
401 |
btnDetalles.setPreferredSize(new java.awt.Dimension(100, 20)); |
402 |
btnDetalles.setText(PluginServices.getText(this,"detalles")); |
403 |
btnDetalles.addActionListener(new java.awt.event.ActionListener() {
|
404 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
405 |
rellenarControles(); |
406 |
} |
407 |
}); |
408 |
} |
409 |
|
410 |
return btnDetalles;
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* This method initializes jPanel
|
415 |
*
|
416 |
* @return javax.swing.JPanel
|
417 |
*/
|
418 |
private javax.swing.JPanel getJPanel() {
|
419 |
if (jPanel == null) { |
420 |
jPanel = new javax.swing.JPanel();
|
421 |
jPanel.setLayout(null);
|
422 |
jPanel.setPreferredSize(new java.awt.Dimension(470, 130)); |
423 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
424 |
null, PluginServices.getText(this,"descripcion"), |
425 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
426 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
427 |
jPanel.setBounds(2, 67, 477, 197); |
428 |
jPanel.add(getJLabel1(), null);
|
429 |
jPanel.add(getLblTitle(), null);
|
430 |
jPanel.add(getJScrollPane(), null);
|
431 |
} |
432 |
|
433 |
return jPanel;
|
434 |
} |
435 |
|
436 |
/**
|
437 |
* This method initializes jLabel1
|
438 |
*
|
439 |
* @return javax.swing.JLabel
|
440 |
*/
|
441 |
private javax.swing.JLabel getJLabel1() {
|
442 |
if (jLabel1 == null) { |
443 |
jLabel1 = new javax.swing.JLabel();
|
444 |
jLabel1.setText(PluginServices.getText(this,"nombre")+":"); |
445 |
jLabel1.setBounds(37, 26, 40, 15); |
446 |
} |
447 |
|
448 |
return jLabel1;
|
449 |
} |
450 |
|
451 |
/**
|
452 |
* This method initializes lblTitle
|
453 |
*
|
454 |
* @return javax.swing.JLabel
|
455 |
*/
|
456 |
private javax.swing.JLabel getLblTitle() {
|
457 |
if (lblTitle == null) { |
458 |
lblTitle = new javax.swing.JLabel();
|
459 |
lblTitle.setText("-");
|
460 |
lblTitle.setPreferredSize(new java.awt.Dimension(350, 16)); |
461 |
lblTitle.setBounds(82, 26, 350, 16); |
462 |
} |
463 |
|
464 |
return lblTitle;
|
465 |
} |
466 |
|
467 |
/**
|
468 |
* This method initializes jScrollPane
|
469 |
*
|
470 |
* @return javax.swing.JScrollPane
|
471 |
*/
|
472 |
private javax.swing.JScrollPane getJScrollPane() {
|
473 |
if (jScrollPane == null) { |
474 |
jScrollPane = new javax.swing.JScrollPane();
|
475 |
jScrollPane.setViewportView(getTxtAbstract()); |
476 |
jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60)); |
477 |
jScrollPane.setBounds(10, 47, 450, 137); |
478 |
} |
479 |
|
480 |
return jScrollPane;
|
481 |
} |
482 |
|
483 |
/**
|
484 |
* This method initializes txtAbstract
|
485 |
*
|
486 |
* @return javax.swing.JTextArea
|
487 |
*/
|
488 |
private javax.swing.JTextArea getTxtAbstract() {
|
489 |
if (txtAbstract == null) { |
490 |
txtAbstract = new javax.swing.JTextArea();
|
491 |
txtAbstract.setWrapStyleWord(true);
|
492 |
txtAbstract.setColumns(30);
|
493 |
txtAbstract.setLineWrap(true);
|
494 |
} |
495 |
|
496 |
return txtAbstract;
|
497 |
} |
498 |
|
499 |
/**
|
500 |
* This method initializes jScrollPane1
|
501 |
*
|
502 |
* @return javax.swing.JScrollPane
|
503 |
*/
|
504 |
private javax.swing.JScrollPane getJScrollPane1() {
|
505 |
if (jScrollPane1 == null) { |
506 |
jScrollPane1 = new javax.swing.JScrollPane();
|
507 |
jScrollPane1.setViewportView(getTreeLayers1()); |
508 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75)); |
509 |
} |
510 |
|
511 |
return jScrollPane1;
|
512 |
} |
513 |
|
514 |
/**
|
515 |
* This method initializes treeLayers1
|
516 |
*
|
517 |
* @return javax.swing.JTree
|
518 |
*/
|
519 |
private javax.swing.JTree getTreeLayers1() {
|
520 |
if (treeLayers1 == null) { |
521 |
treeLayers1 = new javax.swing.JTree();
|
522 |
treeLayers1.setRootVisible(true);
|
523 |
treeLayers1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
524 |
public void valueChanged( |
525 |
javax.swing.event.TreeSelectionEvent e) { |
526 |
activarVisualizarBotones(); |
527 |
} |
528 |
}); |
529 |
} |
530 |
|
531 |
return treeLayers1;
|
532 |
} |
533 |
|
534 |
/**
|
535 |
* This method initializes jScrollPane2
|
536 |
*
|
537 |
* @return javax.swing.JScrollPane
|
538 |
*/
|
539 |
private javax.swing.JScrollPane getJScrollPane2() {
|
540 |
if (jScrollPane2 == null) { |
541 |
jScrollPane2 = new javax.swing.JScrollPane();
|
542 |
jScrollPane2.setViewportView(getLstFormats1()); |
543 |
jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200)); |
544 |
jScrollPane2.setBounds(297, 26, 183, 66); |
545 |
} |
546 |
|
547 |
return jScrollPane2;
|
548 |
} |
549 |
|
550 |
/**
|
551 |
* This method initializes lstFormats1
|
552 |
*
|
553 |
* @return javax.swing.JList
|
554 |
*/
|
555 |
private javax.swing.JList getLstFormats1() {
|
556 |
if (lstFormats1 == null) { |
557 |
lstFormats1 = new javax.swing.JList();
|
558 |
lstFormats1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
559 |
lstFormats1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
560 |
public void valueChanged( |
561 |
javax.swing.event.ListSelectionEvent e) { |
562 |
activarVisualizarBotones(); |
563 |
} |
564 |
}); |
565 |
} |
566 |
|
567 |
return lstFormats1;
|
568 |
} |
569 |
|
570 |
/**
|
571 |
* This method initializes panelPage1
|
572 |
*
|
573 |
* @return javax.swing.JPanel
|
574 |
*/
|
575 |
private javax.swing.JPanel getPanelPage1() {
|
576 |
if (panelPage1 == null) { |
577 |
panelPage1 = new javax.swing.JPanel();
|
578 |
panelPage1.setLayout(null);
|
579 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
580 |
panelPage1.setVisible(true);
|
581 |
panelPage1.setBounds(15, 5, 480, 262); |
582 |
panelPage1.add(getJPanel1(), null);
|
583 |
panelPage1.add(getJPanel(), null);
|
584 |
} |
585 |
|
586 |
return panelPage1;
|
587 |
} |
588 |
|
589 |
/**
|
590 |
* This method initializes panelPage2
|
591 |
*
|
592 |
* @return javax.swing.JPanel
|
593 |
*/
|
594 |
private javax.swing.JPanel getPanelPage2() {
|
595 |
if (panelPage2 == null) { |
596 |
panelPage2 = new javax.swing.JPanel();
|
597 |
panelPage2.setLayout(null);
|
598 |
panelPage2.setPreferredSize(new java.awt.Dimension(490, 300)); |
599 |
panelPage2.setVisible(false);
|
600 |
panelPage2.setBounds(10, 5, 490, 276); |
601 |
panelPage2.add(getJPanel2(), null);
|
602 |
panelPage2.add(getJPanel3(), null);
|
603 |
panelPage2.add(getJPanel4(), null);
|
604 |
} |
605 |
|
606 |
return panelPage2;
|
607 |
} |
608 |
|
609 |
/**
|
610 |
* This method initializes jScrollPane5
|
611 |
*
|
612 |
* @return javax.swing.JScrollPane
|
613 |
*/
|
614 |
private javax.swing.JScrollPane getJScrollPane5() {
|
615 |
if (jScrollPane5 == null) { |
616 |
jScrollPane5 = new javax.swing.JScrollPane();
|
617 |
jScrollPane5.setViewportView(getLstSelectedLayers()); |
618 |
jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75)); |
619 |
} |
620 |
|
621 |
return jScrollPane5;
|
622 |
} |
623 |
|
624 |
/**
|
625 |
* This method initializes lstSelectedLayers
|
626 |
*
|
627 |
* @return javax.swing.JList
|
628 |
*/
|
629 |
private javax.swing.JList getLstSelectedLayers() {
|
630 |
if (lstSelectedLayers == null) { |
631 |
lstSelectedLayers = new javax.swing.JList();
|
632 |
lstSelectedLayers.setModel(selectedLayersModel); |
633 |
lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
634 |
lstSelectedLayers.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
635 |
public void valueChanged( |
636 |
javax.swing.event.ListSelectionEvent e) { |
637 |
activarVisualizarBotones(); |
638 |
} |
639 |
}); |
640 |
} |
641 |
|
642 |
return lstSelectedLayers;
|
643 |
} |
644 |
|
645 |
/**
|
646 |
* This method initializes btnAdd
|
647 |
*
|
648 |
* @return javax.swing.JButton
|
649 |
*/
|
650 |
private javax.swing.JButton getBtnAdd() {
|
651 |
if (btnAdd == null) { |
652 |
btnAdd = new javax.swing.JButton();
|
653 |
btnAdd.setPreferredSize(new java.awt.Dimension(23, 23)); |
654 |
btnAdd.setText(">");
|
655 |
btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
656 |
btnAdd.setEnabled(false);
|
657 |
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
658 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
659 |
addLayer(); |
660 |
} |
661 |
}); |
662 |
} |
663 |
|
664 |
return btnAdd;
|
665 |
} |
666 |
|
667 |
/**
|
668 |
* This method initializes btnDel
|
669 |
*
|
670 |
* @return javax.swing.JButton
|
671 |
*/
|
672 |
private javax.swing.JButton getBtnDel() {
|
673 |
if (btnDel == null) { |
674 |
btnDel = new javax.swing.JButton();
|
675 |
btnDel.setPreferredSize(new java.awt.Dimension(23, 23)); |
676 |
btnDel.setText("<");
|
677 |
btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
678 |
btnDel.setEnabled(false);
|
679 |
btnDel.addActionListener(new java.awt.event.ActionListener() {
|
680 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
681 |
delLayer(); |
682 |
} |
683 |
}); |
684 |
} |
685 |
|
686 |
return btnDel;
|
687 |
} |
688 |
|
689 |
/**
|
690 |
* This method initializes jScrollPane6
|
691 |
*
|
692 |
* @return javax.swing.JScrollPane
|
693 |
*/
|
694 |
private javax.swing.JScrollPane getJScrollPane6() {
|
695 |
if (jScrollPane6 == null) { |
696 |
jScrollPane6 = new javax.swing.JScrollPane();
|
697 |
jScrollPane6.setViewportView(getLstSRSs()); |
698 |
jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 200)); |
699 |
jScrollPane6.setBounds(10, 26, 272, 68); |
700 |
} |
701 |
|
702 |
return jScrollPane6;
|
703 |
} |
704 |
|
705 |
/**
|
706 |
* This method initializes lstSRSs
|
707 |
*
|
708 |
* @return javax.swing.JList
|
709 |
*/
|
710 |
private javax.swing.JList getLstSRSs() {
|
711 |
if (lstSRSs == null) { |
712 |
lstSRSs = new javax.swing.JList();
|
713 |
lstSRSs.setModel(new SRSListModel());
|
714 |
lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
715 |
lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
716 |
public void valueChanged( |
717 |
javax.swing.event.ListSelectionEvent e) { |
718 |
activarVisualizarBotones(); |
719 |
} |
720 |
}); |
721 |
} |
722 |
|
723 |
return lstSRSs;
|
724 |
} |
725 |
|
726 |
/**
|
727 |
* This method initializes btnSiguiente
|
728 |
*
|
729 |
* @return javax.swing.JButton
|
730 |
*/
|
731 |
private javax.swing.JButton getBtnSiguiente() {
|
732 |
if (btnSiguiente == null) { |
733 |
btnSiguiente = new javax.swing.JButton();
|
734 |
btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30)); |
735 |
btnSiguiente.setText(PluginServices.getText(this,"siguiente")); |
736 |
btnSiguiente.setBounds(205, 282, 100, 21); |
737 |
btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
|
738 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
739 |
page++; |
740 |
getPanelPage1().setVisible(false);
|
741 |
getPanelPage2().setVisible(true);
|
742 |
activarVisualizarBotones(); |
743 |
} |
744 |
}); |
745 |
} |
746 |
|
747 |
return btnSiguiente;
|
748 |
} |
749 |
|
750 |
/**
|
751 |
* This method initializes btnAnterior
|
752 |
*
|
753 |
* @return javax.swing.JButton
|
754 |
*/
|
755 |
private javax.swing.JButton getBtnAnterior() {
|
756 |
if (btnAnterior == null) { |
757 |
btnAnterior = new javax.swing.JButton();
|
758 |
btnAnterior.setText(PluginServices.getText(this,"anterior")); |
759 |
btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30)); |
760 |
btnAnterior.setBounds(100, 282, 100, 21); |
761 |
btnAnterior.addActionListener(new java.awt.event.ActionListener() {
|
762 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
763 |
page--; |
764 |
getPanelPage1().setVisible(true);
|
765 |
getPanelPage2().setVisible(false);
|
766 |
activarVisualizarBotones(); |
767 |
} |
768 |
}); |
769 |
} |
770 |
|
771 |
return btnAnterior;
|
772 |
} |
773 |
|
774 |
/**
|
775 |
* This method initializes jPanel1
|
776 |
*
|
777 |
* @return javax.swing.JPanel
|
778 |
*/
|
779 |
private javax.swing.JPanel getJPanel1() {
|
780 |
if (jPanel1 == null) { |
781 |
jPanel1 = new javax.swing.JPanel();
|
782 |
jPanel1.add(getTxtHost(), null);
|
783 |
jPanel1.add(getBtnDetalles(), null);
|
784 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
785 |
null, PluginServices.getText(this,"servidor"), |
786 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
787 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
788 |
jPanel1.setBounds(2, 5, 477, 57); |
789 |
} |
790 |
|
791 |
return jPanel1;
|
792 |
} |
793 |
|
794 |
/**
|
795 |
* This method initializes jPanel2
|
796 |
*
|
797 |
* @return javax.swing.JPanel
|
798 |
*/
|
799 |
private javax.swing.JPanel getJPanel2() {
|
800 |
if (jPanel2 == null) { |
801 |
jPanel2 = new javax.swing.JPanel();
|
802 |
jPanel2.add(getJScrollPane1(), null);
|
803 |
jPanel2.add(getBtnDel(), null);
|
804 |
jPanel2.add(getBtnAdd(), null);
|
805 |
jPanel2.add(getJScrollPane5(), null);
|
806 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder( |
807 |
null, PluginServices.getText(this,"seleccionar_capas"), |
808 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
809 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
810 |
jPanel2.setBounds(-1, 5, 493, 112); |
811 |
} |
812 |
|
813 |
return jPanel2;
|
814 |
} |
815 |
|
816 |
/**
|
817 |
* This method initializes jPanel3
|
818 |
*
|
819 |
* @return javax.swing.JPanel
|
820 |
*/
|
821 |
private javax.swing.JPanel getJPanel3() {
|
822 |
if (jPanel3 == null) { |
823 |
jPanel3 = new javax.swing.JPanel();
|
824 |
jPanel3.setLayout(null);
|
825 |
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder( |
826 |
null, PluginServices.getText(this,"seleccionar_formato"), |
827 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
828 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
829 |
jPanel3.setPreferredSize(new java.awt.Dimension(493, 300)); |
830 |
jPanel3.setLocation(-1, 122); |
831 |
jPanel3.setSize(493, 101); |
832 |
jPanel3.add(getJScrollPane6(), null);
|
833 |
jPanel3.add(getJScrollPane2(), null);
|
834 |
} |
835 |
|
836 |
return jPanel3;
|
837 |
} |
838 |
|
839 |
/**
|
840 |
* DOCUMENT ME!
|
841 |
*
|
842 |
* @param listener
|
843 |
*/
|
844 |
public void addWizardListener(WizardListener listener) { |
845 |
listenerSupport.addWizardListener(listener); |
846 |
} |
847 |
|
848 |
/**
|
849 |
* DOCUMENT ME!
|
850 |
*
|
851 |
* @param listener
|
852 |
*/
|
853 |
public void removeWizardListener(WizardListener listener) { |
854 |
listenerSupport.removeWizardListener(listener); |
855 |
} |
856 |
|
857 |
/**
|
858 |
* DOCUMENT ME!
|
859 |
*
|
860 |
* @return
|
861 |
*/
|
862 |
public WizardDataSource getDataSource() {
|
863 |
return dataSource;
|
864 |
} |
865 |
|
866 |
/**
|
867 |
* DOCUMENT ME!
|
868 |
*
|
869 |
* @param source
|
870 |
*/
|
871 |
public void setDataSource(WizardDataSource source) { |
872 |
dataSource = source; |
873 |
} |
874 |
|
875 |
/**
|
876 |
* DOCUMENT ME!
|
877 |
*
|
878 |
* @return DOCUMENT ME!
|
879 |
*/
|
880 |
public String getLayersQuery() { |
881 |
LayerInfo[] layers = ((LayerListModel) lstSelectedLayers.getModel()).getElements();
|
882 |
|
883 |
//Nombre separado por comas de las capas
|
884 |
String layersQuery = layers[0].name; |
885 |
|
886 |
for (int i = 1; i < layers.length; i++) { |
887 |
layersQuery += ("," + layers[i].name);
|
888 |
} |
889 |
|
890 |
return layersQuery;
|
891 |
} |
892 |
|
893 |
/**
|
894 |
* DOCUMENT ME!
|
895 |
*
|
896 |
* @return DOCUMENT ME!
|
897 |
*/
|
898 |
public String getQueryableLayerQuery() { |
899 |
LayerInfo[] layers = ((LayerListModel) lstSelectedLayers.getModel()).getElements();
|
900 |
|
901 |
//Nombre separado por comas de las capas
|
902 |
String layersQuery = ""; |
903 |
int i;
|
904 |
|
905 |
for (i = 0; i < layers.length; i++) { |
906 |
if (layers[i].queryable) {
|
907 |
layersQuery = layers[i].name; |
908 |
|
909 |
break;
|
910 |
} |
911 |
} |
912 |
|
913 |
for (int j = i + 1; j < layers.length; j++) { |
914 |
if (layers[j].queryable) {
|
915 |
layersQuery += ("," + layers[j].name);
|
916 |
} |
917 |
} |
918 |
|
919 |
return layersQuery;
|
920 |
} |
921 |
|
922 |
/**
|
923 |
* DOCUMENT ME!
|
924 |
*
|
925 |
* @return DOCUMENT ME!
|
926 |
*/
|
927 |
public String getSRS() { |
928 |
return (String) lstSRSs.getSelectedValue(); |
929 |
} |
930 |
|
931 |
/**
|
932 |
* DOCUMENT ME!
|
933 |
*
|
934 |
* @return DOCUMENT ME!
|
935 |
*/
|
936 |
public String getFormat() { |
937 |
return (String) lstFormats1.getSelectedValue(); |
938 |
} |
939 |
|
940 |
/**
|
941 |
* DOCUMENT ME!
|
942 |
*
|
943 |
* @return DOCUMENT ME!
|
944 |
*/
|
945 |
public TreePath[] getSelectedLayers() { |
946 |
return getTreeLayers1().getSelectionPaths();
|
947 |
} |
948 |
|
949 |
/**
|
950 |
* DOCUMENT ME!
|
951 |
*
|
952 |
* @return DOCUMENT ME!
|
953 |
*/
|
954 |
public Rectangle2D getLayersRectangle() { |
955 |
TreePath[] layers = getSelectedLayers(); |
956 |
|
957 |
//Boundingbox de todas las capas
|
958 |
ArrayList rectangulos = new ArrayList(); |
959 |
|
960 |
Rectangle2D rect;
|
961 |
|
962 |
for (int i = 0; i < layers.length; i++) { |
963 |
String[] rutaCapa = new String[layers[i].getPathCount()]; |
964 |
|
965 |
for (int j = 0; j < layers[i].getPathCount(); j++) { |
966 |
rutaCapa[j] = ((LayerInfo) layers[i].getPathComponent(j)).text; |
967 |
} |
968 |
|
969 |
rect = dataSource.getBoundingBox(rutaCapa, getSRS()); |
970 |
|
971 |
if (rect != null) { |
972 |
rectangulos.add(rect); |
973 |
} |
974 |
} |
975 |
|
976 |
rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray( |
977 |
new Rectangle2D.Double[0])); |
978 |
|
979 |
return rect;
|
980 |
} |
981 |
|
982 |
/**
|
983 |
* Obtiene el rect?ngulo que contiene a todos los
|
984 |
* otros
|
985 |
*
|
986 |
* @param rects rectangulos
|
987 |
*
|
988 |
* @return Rectangulo que contiene a todos los demas
|
989 |
*/
|
990 |
public static Rectangle2D getRectangle(Rectangle2D[] rects) { |
991 |
Rectangle2D ret = rects[0]; |
992 |
|
993 |
for (int i = 1; i < rects.length; i++) { |
994 |
ret.add(rects[i]); |
995 |
} |
996 |
|
997 |
return ret;
|
998 |
} |
999 |
|
1000 |
/**
|
1001 |
* Devuelve el host que est? escrito en el cuadro de texto del host o null
|
1002 |
* en caso de que no haya nada escrito o est? mal escrito
|
1003 |
*
|
1004 |
* @return URL del host
|
1005 |
*/
|
1006 |
public URL getHost() { |
1007 |
try {
|
1008 |
return new URL(cmbHost.getModel().getSelectedItem().toString()); |
1009 |
} catch (MalformedURLException e) { |
1010 |
return null; |
1011 |
} |
1012 |
} |
1013 |
|
1014 |
/**
|
1015 |
* DOCUMENT ME!
|
1016 |
*
|
1017 |
* @return Nombre de la capa que aparece en el TOC.
|
1018 |
*/
|
1019 |
public String getLayerName() { |
1020 |
return jTxtNomCapa.getText();
|
1021 |
} |
1022 |
|
1023 |
/**
|
1024 |
* This method initializes jPanel4
|
1025 |
*
|
1026 |
* @return javax.swing.JPanel
|
1027 |
*/
|
1028 |
private JPanel getJPanel4() { |
1029 |
if (jPanel4 == null) { |
1030 |
jPanel4 = new JPanel(); |
1031 |
jPanel4.setLayout(null);
|
1032 |
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
1033 |
null, PluginServices.getText(this,"nombre_capa"), |
1034 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
1035 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
1036 |
jPanel4.setBounds(-1, 223, 493, 48); |
1037 |
jPanel4.add(getJTxtNomCapa(), null);
|
1038 |
} |
1039 |
|
1040 |
return jPanel4;
|
1041 |
} |
1042 |
|
1043 |
/**
|
1044 |
* This method initializes jTextField
|
1045 |
*
|
1046 |
* @return javax.swing.JTextField
|
1047 |
*/
|
1048 |
private JTextField getJTxtNomCapa() { |
1049 |
if (jTxtNomCapa == null) { |
1050 |
jTxtNomCapa = new JTextField(); |
1051 |
jTxtNomCapa.setBounds(10, 19, 474, 20); |
1052 |
jTxtNomCapa.setText(PluginServices.getText(this,"capaWMS")); |
1053 |
} |
1054 |
|
1055 |
return jTxtNomCapa;
|
1056 |
} |
1057 |
} |
1058 |
// @jve:decl-index=0:visual-constraint="10,10"
|
1059 |
// @jve:visual-info decl-index=0 visual-constraint="16,10"
|
1060 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1061 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1062 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|