root / trunk / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / WMSParamsPanel.java @ 4606
History | View | Annotate | Download (40.5 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.Component; |
44 |
import java.awt.Dimension; |
45 |
import java.awt.event.FocusAdapter; |
46 |
import java.awt.event.FocusEvent; |
47 |
import java.awt.event.FocusListener; |
48 |
import java.awt.event.MouseAdapter; |
49 |
import java.awt.event.MouseEvent; |
50 |
import java.awt.geom.Rectangle2D; |
51 |
import java.util.AbstractCollection; |
52 |
import java.util.ArrayList; |
53 |
import java.util.Hashtable; |
54 |
import java.util.TreeSet; |
55 |
import java.util.Vector; |
56 |
import java.util.prefs.Preferences; |
57 |
|
58 |
import javax.swing.ImageIcon; |
59 |
import javax.swing.JButton; |
60 |
import javax.swing.JCheckBox; |
61 |
import javax.swing.JOptionPane; |
62 |
import javax.swing.JPanel; |
63 |
import javax.swing.JTabbedPane; |
64 |
import javax.swing.JTextField; |
65 |
import javax.swing.tree.TreePath; |
66 |
|
67 |
import org.cresques.cts.ICoordTrans; |
68 |
import org.cresques.cts.IProjection; |
69 |
import org.cresques.cts.ProjectionPool; |
70 |
import org.cresques.cts.gt2.CoordSys; |
71 |
import org.cresques.cts.gt2.CoordTrans; |
72 |
import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
73 |
import org.gvsig.gui.beans.listeners.BeanListener; |
74 |
|
75 |
import com.iver.andami.PluginServices; |
76 |
import com.iver.andami.messages.NotificationManager; |
77 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
78 |
import com.iver.cit.gvsig.fmap.exceptions.CannotReprojectException; |
79 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
80 |
import com.iver.cit.gvsig.fmap.layers.IFMapWMSDimension; |
81 |
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode; |
82 |
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode.FMapWMSStyle; |
83 |
import com.iver.cit.gvsig.gui.WizardPanel; |
84 |
import com.iver.cit.gvsig.gui.wizards.FormatListModel; |
85 |
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel; |
86 |
import com.iver.cit.gvsig.gui.wizards.SRSListModel; |
87 |
import com.iver.cit.gvsig.gui.wizards.WMSWizardData; |
88 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
89 |
/**
|
90 |
* This class implements the map option panel.
|
91 |
*
|
92 |
* It includes a set of Listeners that implement some control rules which
|
93 |
* refresh the component values that depends on those selected in the other
|
94 |
* components to avoid to choose an invalid set of options. It also includes a
|
95 |
* method (isCorrectlyConfigured()) that checks if the current set of values is
|
96 |
* enough to correctly launch a GetMap request.
|
97 |
*
|
98 |
* The information is obtained from a WMSWizardDataSource object.
|
99 |
*
|
100 |
*
|
101 |
* Esta clase implementa el panel de opciones disponibles sobre el mapa
|
102 |
*
|
103 |
* Incluye una serie de Listeners que implementan unas reglas de control que
|
104 |
* refrescan los valores de componentes cuyos valores dependen de aqu?llos
|
105 |
* seleccionados en otros componentes para evitar que se escoja una combinaci?n
|
106 |
* de opciones err?nea as? como una funci?n (isCorrectlyConfigured()) que
|
107 |
* comprueba si la combinaci?n escogida actualmente es suficiente para lanzar
|
108 |
* una operaci?n GetMap correctamente.
|
109 |
*
|
110 |
* La informaci?n obtiene a partir de un objeto WMSWizardDataSource.
|
111 |
*
|
112 |
* @author jaume - jaume dominguez faus
|
113 |
*
|
114 |
*/
|
115 |
public class WMSParamsPanel extends WizardPanel { |
116 |
|
117 |
private javax.swing.JScrollPane jScrollPane1 = null; |
118 |
private javax.swing.JScrollPane jScrollPane2 = null; |
119 |
private javax.swing.JScrollPane jScrollPane5 = null; |
120 |
private javax.swing.JButton btnAdd = null; |
121 |
private javax.swing.JButton btnDel = null; |
122 |
private javax.swing.JScrollPane jScrollPane6 = null; |
123 |
private javax.swing.JPanel jPanel2 = null; |
124 |
private javax.swing.JPanel tabFormats = null; |
125 |
private JPanel jPanel4 = null; |
126 |
private JTextField jTxtNomCapa = null; |
127 |
private LayerList lstSelectedLayers = null; |
128 |
private ArrayList selectedPaths = new ArrayList(); |
129 |
private javax.swing.JList lstSRSs = null; |
130 |
private LayerTree treeLayers = null; |
131 |
private javax.swing.JList lstFormats = null; |
132 |
private WizardListenerSupport listenerSupport;
|
133 |
public WMSWizardData dataSource;
|
134 |
private JTabbedPane jTabbedPane = null; |
135 |
private JPanel tabLayers = null; |
136 |
private JPanel jPanel1 = null; |
137 |
private JPanel jPanel5 = null; |
138 |
private StylesPanel tabStyle = null; |
139 |
private JCheckBox chkTransparency = null; |
140 |
private InfoPanel tabInfo = null; |
141 |
private DimensionPanel tabDimensions = null; |
142 |
private int dimensionTabIndex; |
143 |
private int stylesTabIndex; |
144 |
private String oldSRS = null; |
145 |
private AbstractCollection oldDimensions = null; |
146 |
private Dimension sizeFixed; |
147 |
private JCheckBox chkExtendedNames = null; |
148 |
private JButton btnUp = null; |
149 |
private JButton btnDown = null; |
150 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wms-wizard" ); |
151 |
private JCheckBox chkDisagregate = null; |
152 |
|
153 |
public WMSParamsPanel(){
|
154 |
super();
|
155 |
initialize(); |
156 |
} |
157 |
|
158 |
//TODO: crear nuevo constructor para a?adir los panels que quieras...
|
159 |
public WMSParamsPanel(WMSWizardData data)
|
160 |
{ |
161 |
super();
|
162 |
setWizardData(data); |
163 |
this.setLayout(null); |
164 |
this.setVisible(false); |
165 |
this.setBounds(10, 5, 481, 427); |
166 |
|
167 |
if (jTabbedPane == null) { |
168 |
jTabbedPane = new JTabbedPane(); |
169 |
jTabbedPane.setBounds(3, 3, 475, 415); |
170 |
|
171 |
StylesPanel sp = getTabStyle(); |
172 |
DimensionPanel dp = getTabDimensions(); |
173 |
|
174 |
jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, getTabLayers(), null); |
175 |
jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, sp, null); |
176 |
stylesTabIndex = jTabbedPane.getTabCount()-1;
|
177 |
jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"), null, dp, null); |
178 |
dimensionTabIndex = jTabbedPane.getTabCount()-1;
|
179 |
jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, getTabFormats(), null); |
180 |
jTabbedPane.setEnabledAt(dimensionTabIndex, false);
|
181 |
jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
182 |
} |
183 |
this.add(jTabbedPane, null); |
184 |
|
185 |
setListenerSupport(new WizardListenerSupport());
|
186 |
} |
187 |
|
188 |
|
189 |
/**
|
190 |
* This method initializes panelPage2
|
191 |
*
|
192 |
* @return javax.swing.JPanel
|
193 |
*/
|
194 |
private void initialize() { |
195 |
this.setLayout(null); |
196 |
this.setVisible(false); |
197 |
this.setBounds(10, 5, 481, 427); |
198 |
this.add(getJTabbedPane(), null); |
199 |
} |
200 |
/**
|
201 |
* This method initializes jPanel2
|
202 |
*
|
203 |
* @return javax.swing.JPanel
|
204 |
*/
|
205 |
private javax.swing.JPanel getJPanel2() {
|
206 |
if (jPanel2 == null) { |
207 |
jPanel2 = new javax.swing.JPanel();
|
208 |
jPanel2.setLayout(null);
|
209 |
jPanel2.setBounds(4, 59, 457, 328); |
210 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder( |
211 |
null, PluginServices.getText(this, "select_layers"), |
212 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
213 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
214 |
jPanel2.add(getChkExtendedNames(), null);
|
215 |
|
216 |
jPanel2.add(getJScrollPane1(), null);
|
217 |
jPanel2.add(getBtnDel(), null);
|
218 |
jPanel2.add(getBtnAdd(), null);
|
219 |
jPanel2.add(getJScrollPane5(), null);
|
220 |
jPanel2.add(getBtnUp(), null);
|
221 |
jPanel2.add(getBtnDown(), null);
|
222 |
jPanel2.add(getChkDisagregate(), null);
|
223 |
} |
224 |
|
225 |
return jPanel2;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* This method initializes jPanel4
|
230 |
*
|
231 |
* @return javax.swing.JPanel
|
232 |
*/
|
233 |
private JPanel getJPanel4() { |
234 |
if (jPanel4 == null) { |
235 |
jPanel4 = new JPanel(); |
236 |
jPanel4.setLayout(null);
|
237 |
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
238 |
null, PluginServices.getText(this, "layer_name"), |
239 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
240 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
241 |
jPanel4.setBounds(4, 8, 457, 49); |
242 |
jPanel4.add(getJTxtNomCapa(), null);
|
243 |
} |
244 |
|
245 |
return jPanel4;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* This method initializes jPanel3
|
250 |
*
|
251 |
* @return javax.swing.JPanel
|
252 |
*/
|
253 |
private javax.swing.JPanel getTabFormats() {
|
254 |
if (tabFormats == null) { |
255 |
tabFormats = new javax.swing.JPanel();
|
256 |
tabFormats.setLayout(null);
|
257 |
tabFormats.add(getJPanel1(), null);
|
258 |
tabFormats.add(getJPanel5(), null);
|
259 |
} |
260 |
|
261 |
return tabFormats;
|
262 |
} |
263 |
/**
|
264 |
* This method initializes jScrollPane1
|
265 |
*
|
266 |
* @return javax.swing.JScrollPane
|
267 |
*/
|
268 |
private javax.swing.JScrollPane getJScrollPane1() {
|
269 |
if (jScrollPane1 == null) { |
270 |
jScrollPane1 = new javax.swing.JScrollPane();
|
271 |
jScrollPane1.setBounds(11, 22, 430, 123); |
272 |
jScrollPane1.setViewportView(getTreeLayers()); |
273 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75)); |
274 |
} |
275 |
|
276 |
return jScrollPane1;
|
277 |
} |
278 |
|
279 |
/**
|
280 |
* This method initializes btnDel
|
281 |
*
|
282 |
* @return javax.swing.JButton
|
283 |
*/
|
284 |
private javax.swing.JButton getBtnDel() {
|
285 |
if (btnDel == null) { |
286 |
btnDel = new javax.swing.JButton();
|
287 |
//btnDel.setPreferredSize(new java.awt.Dimension(23, 23));
|
288 |
btnDel.setText(PluginServices.getText(this, "remove")); |
289 |
btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
290 |
btnDel.setBounds(339, 300, 101, 20); |
291 |
btnDel.setEnabled(false);
|
292 |
btnDel.addActionListener(new java.awt.event.ActionListener() {
|
293 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
294 |
delLayer(); |
295 |
} |
296 |
}); |
297 |
} |
298 |
return btnDel;
|
299 |
} |
300 |
|
301 |
/**
|
302 |
* This method initializes btnAdd
|
303 |
*
|
304 |
* @return javax.swing.JButton
|
305 |
*/
|
306 |
private javax.swing.JButton getBtnAdd() {
|
307 |
if (btnAdd == null) { |
308 |
btnAdd = new javax.swing.JButton();
|
309 |
//btnAdd.setPreferredSize(new java.awt.Dimension(23, 23));
|
310 |
btnAdd.setText(PluginServices.getText(this, "add")); |
311 |
btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
312 |
btnAdd.setBounds(236, 300, 101, 20); |
313 |
btnAdd.setEnabled(false);
|
314 |
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
315 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
316 |
addLayer(); |
317 |
} |
318 |
}); |
319 |
} |
320 |
return btnAdd;
|
321 |
} |
322 |
|
323 |
/**
|
324 |
* This method initializes jScrollPane5
|
325 |
*
|
326 |
* @return javax.swing.JScrollPane
|
327 |
*/
|
328 |
private javax.swing.JScrollPane getJScrollPane5() {
|
329 |
if (jScrollPane5 == null) { |
330 |
jScrollPane5 = new javax.swing.JScrollPane();
|
331 |
jScrollPane5.setBounds(47, 155, 394, 120); |
332 |
jScrollPane5.setViewportView(getLstSelectedLayers()); |
333 |
jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75)); |
334 |
} |
335 |
|
336 |
return jScrollPane5;
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* This method initializes jTextField
|
341 |
*
|
342 |
* @return javax.swing.JTextField
|
343 |
*/
|
344 |
private JTextField getJTxtNomCapa() { |
345 |
if (jTxtNomCapa == null) { |
346 |
jTxtNomCapa = new JTextField(); |
347 |
jTxtNomCapa.setBounds(10, 19, 437, 20); |
348 |
jTxtNomCapa.setText(PluginServices.getText(this, "WMSLayer")); |
349 |
jTxtNomCapa.addKeyListener(new java.awt.event.KeyAdapter() {
|
350 |
public void keyTyped(java.awt.event.KeyEvent e) { |
351 |
fireWizardComplete(isCorrectlyConfigured()); |
352 |
} |
353 |
}); |
354 |
} |
355 |
|
356 |
return jTxtNomCapa;
|
357 |
} |
358 |
|
359 |
|
360 |
/**
|
361 |
* This method initializes jScrollPane6
|
362 |
*
|
363 |
* @return javax.swing.JScrollPane
|
364 |
*/
|
365 |
private javax.swing.JScrollPane getJScrollPane6() {
|
366 |
if (jScrollPane6 == null) { |
367 |
jScrollPane6 = new javax.swing.JScrollPane();
|
368 |
jScrollPane6.setBounds(5, 23, 442, 140); |
369 |
jScrollPane6.setViewportView(getLstFormats()); |
370 |
jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 200)); |
371 |
} |
372 |
|
373 |
return jScrollPane6;
|
374 |
} |
375 |
|
376 |
/**
|
377 |
* This method initializes jScrollPane2
|
378 |
*
|
379 |
* @return javax.swing.JScrollPane
|
380 |
*/
|
381 |
private javax.swing.JScrollPane getJScrollPane2() {
|
382 |
if (jScrollPane2 == null) { |
383 |
jScrollPane2 = new javax.swing.JScrollPane();
|
384 |
jScrollPane2.setBounds(5, 23, 442, 141); |
385 |
jScrollPane2.setViewportView(getLstSRSs()); |
386 |
jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200)); |
387 |
} |
388 |
|
389 |
return jScrollPane2;
|
390 |
} |
391 |
|
392 |
/**
|
393 |
* Gets the available layers in WMS maintaining the tree structure
|
394 |
* @return
|
395 |
*/
|
396 |
public LayerTree getLayerStructure(){
|
397 |
return treeLayers;
|
398 |
} |
399 |
|
400 |
/**
|
401 |
* This method initializes treeLayers
|
402 |
*
|
403 |
* @return javax.swing.JTree
|
404 |
*/
|
405 |
private LayerTree getTreeLayers() {
|
406 |
if (treeLayers == null) { |
407 |
treeLayers = new LayerTree();
|
408 |
treeLayers.setRootVisible(true);
|
409 |
treeLayers.addMouseListener(new java.awt.event.MouseAdapter() {
|
410 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
411 |
if (e.getClickCount() == 2){ |
412 |
addLayer(); |
413 |
} |
414 |
} |
415 |
}); |
416 |
treeLayers.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
417 |
public void valueChanged( |
418 |
javax.swing.event.TreeSelectionEvent e) { |
419 |
|
420 |
boolean isGetMapable = false; // pffff, jajaja |
421 |
TreePath[] selecciones = getTreeLayers().getSelectionPaths(); |
422 |
if (selecciones!=null) // no entenc perqu? peta ac? i li arriba null a voltes... |
423 |
{ |
424 |
for (int i = 0; i < selecciones.length && !isGetMapable; i++) { |
425 |
WMSLayerNode layer = ((WMSLayerNode) selecciones[i].getLastPathComponent()); |
426 |
isGetMapable = layer.getChildren().size()==0 || layer.getName()!=null; |
427 |
} |
428 |
|
429 |
} |
430 |
getBtnAdd().setEnabled(isGetMapable); |
431 |
fireWizardComplete(isCorrectlyConfigured()); |
432 |
} |
433 |
}); |
434 |
} |
435 |
|
436 |
return treeLayers;
|
437 |
} |
438 |
|
439 |
|
440 |
/**
|
441 |
* This method checks for the options selected within the configuration dialog are
|
442 |
* correct and enough to perform a GetMap request.
|
443 |
* @return true if you're done, false if not.
|
444 |
*/
|
445 |
public boolean isCorrectlyConfigured() { |
446 |
|
447 |
boolean b;
|
448 |
this.repaint();
|
449 |
if ((getLstSRSs().getSelectedIndex() != -1) && |
450 |
(getLstFormats().getSelectedIndex() != -1) &&
|
451 |
(getLstSelectedLayers().getModel().getSize() > 0)) {
|
452 |
b = true;
|
453 |
} else {
|
454 |
b = false;
|
455 |
} |
456 |
|
457 |
// Enable or disable del button.
|
458 |
int[] selectedIndices = getLstSelectedLayers().getSelectedIndices(); |
459 |
|
460 |
getBtnDel().setEnabled( |
461 |
selectedIndices != null
|
462 |
&& selectedIndices.length>0
|
463 |
); |
464 |
|
465 |
return b;
|
466 |
} |
467 |
|
468 |
public WMSLayerNode[] selectedLayersToArray() { |
469 |
JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel()); |
470 |
ArrayList elements = modelo.getElements();
|
471 |
WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]); |
472 |
return layers;
|
473 |
} |
474 |
|
475 |
/**
|
476 |
* DOCUMENT ME!
|
477 |
*/
|
478 |
private void delLayer() { |
479 |
int[] indices = lstSelectedLayers.getSelectedIndices(); |
480 |
|
481 |
try {
|
482 |
ArrayList removeList = new ArrayList(); |
483 |
WMSLayerNode[] infos = selectedLayersToArray();
|
484 |
JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel()); |
485 |
for (int i = 0; i < indices.length; i++) { |
486 |
removeList.add(infos[indices[i]]); |
487 |
} |
488 |
modelo.delIndices(indices); |
489 |
lstSelectedLayers.clearSelection(); |
490 |
fireWizardComplete(isCorrectlyConfigured()); |
491 |
|
492 |
//delete from selectedPaths as well
|
493 |
WMSLayerNode elemento = null;
|
494 |
WMSLayerNode last = null;
|
495 |
TreePath path = null; |
496 |
for(int i = removeList.size()-1; i >= 0 ; i--){ |
497 |
elemento = (WMSLayerNode)removeList.get(i); |
498 |
for(int j = 0; j < selectedPaths.size(); j++){ |
499 |
path = (TreePath)selectedPaths.get( j );
|
500 |
last = (WMSLayerNode)path.getLastPathComponent(); |
501 |
if (last.getTitle().compareTo(elemento.getTitle()) == 0 ){ |
502 |
selectedPaths.remove(path); |
503 |
} |
504 |
} |
505 |
} |
506 |
|
507 |
refreshData(); |
508 |
refreshInfo(); |
509 |
} catch (ArrayIndexOutOfBoundsException ex) { |
510 |
// if you reach this, please, tell me how you did it.
|
511 |
ex.printStackTrace(); |
512 |
} |
513 |
} |
514 |
|
515 |
/**
|
516 |
* Fires a notification to this wizard listeners telling them if the
|
517 |
* configuration is fair enough to send a GetMap request.
|
518 |
* @param b
|
519 |
*/
|
520 |
private void fireWizardComplete(boolean b){ |
521 |
listenerSupport.callStateChanged(b); |
522 |
callStateChanged(b); |
523 |
} |
524 |
|
525 |
/**
|
526 |
* Refreshes the content shown by this.
|
527 |
*/
|
528 |
public void refreshData() { |
529 |
refreshSRS(); |
530 |
getLstSelectedLayers().repaint(); |
531 |
refreshStyleTree(); |
532 |
refreshDimensions(); |
533 |
|
534 |
} |
535 |
|
536 |
/**
|
537 |
* Refreshes the info tab
|
538 |
*
|
539 |
*/
|
540 |
public void refreshInfo() { |
541 |
getTabInfo().refresh(dataSource, |
542 |
selectedLayersVector(), |
543 |
getStyleTitles(), |
544 |
getFormat(), |
545 |
getSRS(), |
546 |
getDimensions()); |
547 |
} |
548 |
|
549 |
private void refreshDimensions() { |
550 |
int size = getLstSelectedLayers().getModel().getSize();
|
551 |
boolean enable = false; |
552 |
for (int i=0; i<size; i++) { |
553 |
WMSLayerNode node = (WMSLayerNode) getLstSelectedLayers().getModel().getElementAt(i); |
554 |
if (node.getDimensions()==null) |
555 |
continue;
|
556 |
|
557 |
for (int j = 0; j < node.getDimensions().size(); j++) { |
558 |
IFMapWMSDimension dim = (IFMapWMSDimension) node.getDimensions().get(j); |
559 |
|
560 |
try {
|
561 |
getTabDimensions().addDimension(dim); |
562 |
enable = true;
|
563 |
} catch (IllegalArgumentException e) { |
564 |
NotificationManager.addWarning("Unrecognized dimension expression: " + dim.getExpression()
|
565 |
+ " (for " + dim.getName() + " in layer '"+node.getName()+"')", null); |
566 |
} |
567 |
} |
568 |
} |
569 |
jTabbedPane.setEnabledAt(dimensionTabIndex, enable); |
570 |
|
571 |
} |
572 |
|
573 |
/**
|
574 |
*
|
575 |
*/
|
576 |
private void refreshStyleTree() { |
577 |
|
578 |
int size = getLstSelectedLayers().getModel().getSize();
|
579 |
WMSLayerNode styleRoot = new WMSLayerNode();
|
580 |
styleRoot.setTitle(PluginServices.getText(this, "selected_themes")); |
581 |
|
582 |
StyleTreeModel model = new StyleTreeModel(styleRoot);
|
583 |
jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
584 |
for (int i=0; i<size; i++){ |
585 |
WMSLayerNode node = (WMSLayerNode) getLstSelectedLayers().getModel().getElementAt(i); |
586 |
// If any of the layers defines styles, the tab will be enabled.
|
587 |
if (model.addLayerBranch(node)) {
|
588 |
jTabbedPane.setEnabledAt(stylesTabIndex, true);
|
589 |
} |
590 |
} |
591 |
|
592 |
getStyleTree().setModel(model); |
593 |
getStyleTree().expandAll(); |
594 |
getStyleTree().repaint(); |
595 |
} |
596 |
|
597 |
/**
|
598 |
* Takes the array of selected layers and a vector containing the style names
|
599 |
* and set them as selected in the styles panel
|
600 |
* @param selectedLayers
|
601 |
* @param styles
|
602 |
*/
|
603 |
public void setStyleSelections(Vector styles) { |
604 |
|
605 |
WMSLayerNode[] layers = selectedLayersToArray();
|
606 |
int length = layers.length;
|
607 |
for (int i = 0; i < length; i++) { |
608 |
String styleName = (String) styles.get(i); |
609 |
layers[length - i - 1].setSelectedStyleByName(styleName);
|
610 |
} |
611 |
} |
612 |
|
613 |
/**
|
614 |
* Gets the currently shown style tree.
|
615 |
* @return
|
616 |
*/
|
617 |
private StyleTree getStyleTree() {
|
618 |
return getTabStyle().getStyleTree();
|
619 |
} |
620 |
|
621 |
|
622 |
|
623 |
/**
|
624 |
* Method called when pressing the Add layer button or when double-clicking on
|
625 |
* a layer from the server's layer tree.
|
626 |
*/
|
627 |
private void addLayer() { |
628 |
boolean alguno = false; |
629 |
|
630 |
TreePath[] selecciones = getTreeLayers().getSelectionPaths(); |
631 |
if (selecciones == null) |
632 |
return;
|
633 |
for (int i = 0; i < selecciones.length; i++) { |
634 |
selectedPaths.add(selecciones[i]); |
635 |
WMSLayerNode nodo = (WMSLayerNode) selecciones[i].getLastPathComponent(); |
636 |
if (nodo.getName() == null || nodo.getName().equals("")) |
637 |
// no es un node que es puga demanar
|
638 |
continue;
|
639 |
if (nodo.isSizeFixed()) {
|
640 |
if (sizeFixed == null) |
641 |
sizeFixed = nodo.getFixedSize(); |
642 |
else if ((sizeFixed.getHeight() != nodo.getFixedSize().getHeight()) || |
643 |
(sizeFixed.getWidth() != nodo.getFixedSize().getWidth())) { |
644 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame() |
645 |
,PluginServices.getText(this, "server_cant_render_layers")); |
646 |
continue;
|
647 |
} |
648 |
} |
649 |
// s'afegeix a la llista de capes seleccionades
|
650 |
JDnDListModel modelo = (JDnDListModel) lstSelectedLayers.getModel(); |
651 |
|
652 |
if (modelo.addElement(0, nodo.clone())) { |
653 |
alguno = true;
|
654 |
} |
655 |
} |
656 |
|
657 |
if (alguno) {
|
658 |
refreshData(); |
659 |
} |
660 |
refreshInfo(); |
661 |
} |
662 |
|
663 |
/**
|
664 |
* This method initializes lstSelectedLayers
|
665 |
*
|
666 |
* @return javax.swing.JList
|
667 |
*/
|
668 |
public LayerList getLstSelectedLayers() {
|
669 |
if (lstSelectedLayers == null) { |
670 |
lstSelectedLayers = new LayerList();
|
671 |
lstSelectedLayers.setModel(new JDnDListModel());
|
672 |
lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
673 |
lstSelectedLayers.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
674 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
675 |
fireWizardComplete(isCorrectlyConfigured()); |
676 |
} |
677 |
}); |
678 |
lstSelectedLayers.addMouseListener(new MouseAdapter(){ |
679 |
public void mouseReleased(MouseEvent e) { |
680 |
refreshData(); |
681 |
} |
682 |
}); |
683 |
} |
684 |
|
685 |
return lstSelectedLayers;
|
686 |
} |
687 |
|
688 |
/**
|
689 |
* This method initializes lstSRSs
|
690 |
*
|
691 |
* @return javax.swing.JList
|
692 |
*/
|
693 |
public javax.swing.JList getLstSRSs() {
|
694 |
if (lstSRSs == null) { |
695 |
lstSRSs = new javax.swing.JList();
|
696 |
lstSRSs.setModel(new SRSListModel());
|
697 |
lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
698 |
lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
699 |
public void valueChanged( |
700 |
javax.swing.event.ListSelectionEvent e) { |
701 |
int i = lstSRSs.getSelectedIndex();
|
702 |
if (i!=-1) |
703 |
oldSRS = (String) lstSRSs.getModel().getElementAt(i);
|
704 |
fireWizardComplete(isCorrectlyConfigured()); |
705 |
} |
706 |
}); |
707 |
} |
708 |
|
709 |
return lstSRSs;
|
710 |
} |
711 |
|
712 |
/**
|
713 |
* This method initializes lstFormats
|
714 |
*
|
715 |
* @return javax.swing.JList
|
716 |
*/
|
717 |
public javax.swing.JList getLstFormats() {
|
718 |
if (lstFormats == null) { |
719 |
lstFormats = new javax.swing.JList();
|
720 |
lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
721 |
lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
722 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
723 |
fireWizardComplete(isCorrectlyConfigured()); |
724 |
} |
725 |
}); |
726 |
} |
727 |
|
728 |
return lstFormats;
|
729 |
} |
730 |
|
731 |
/**
|
732 |
* Refreshes the SRS list
|
733 |
*/
|
734 |
private void refreshSRS() { |
735 |
ArrayList elements = ((JDnDListModel) lstSelectedLayers.getModel()).getElements();
|
736 |
WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]); |
737 |
|
738 |
SRSListModel model = new SRSListModel();
|
739 |
|
740 |
if (layers.length == 0) { |
741 |
lstSRSs.setModel(model);//new DefaultListModel());
|
742 |
sizeFixed = null;
|
743 |
} else {
|
744 |
TreeSet srsSet = new TreeSet(); |
745 |
srsSet.addAll(layers[0].getAllSrs());
|
746 |
model.setAll(srsSet); |
747 |
for (int i = 1; i < layers.length; i++) { |
748 |
model.setAll(model.intersect(layers[i].getAllSrs())); |
749 |
} |
750 |
lstSRSs.setModel(model); |
751 |
} |
752 |
int srsIndex = getSRSIndex( oldSRS );
|
753 |
if (srsIndex!=-1) |
754 |
getLstSRSs().setSelectedIndex(srsIndex); |
755 |
|
756 |
} |
757 |
|
758 |
public void setListenerSupport(WizardListenerSupport support) { |
759 |
listenerSupport = support; |
760 |
} |
761 |
|
762 |
public void setWizardData(WMSWizardData data) { |
763 |
this.dataSource = data;
|
764 |
((JDnDListModel) getLstSelectedLayers().getModel()).clear(); |
765 |
getLstSelectedLayers().repaint(); |
766 |
|
767 |
getLstFormats().setModel(new FormatListModel(this.dataSource.getFormats())); |
768 |
getTreeLayers().setModel(new LayerTreeModel(this.dataSource.getLayer())); |
769 |
|
770 |
refreshInfo(); |
771 |
} |
772 |
|
773 |
private Vector getStyleTitles() { |
774 |
return getTabStyle().getStyleTree().getStyleSelectionTitles();
|
775 |
} |
776 |
|
777 |
/**
|
778 |
* @return
|
779 |
*/
|
780 |
private Vector selectedLayersVector() { |
781 |
JDnDListModel mod = (JDnDListModel) getLstSelectedLayers().getModel(); |
782 |
Vector lyrs = new Vector(); |
783 |
for (int i = 0; i < mod.getSize(); i++) { |
784 |
lyrs.add(mod.getElementAt(i)); |
785 |
} |
786 |
return lyrs;
|
787 |
} |
788 |
|
789 |
public String getFormat() { |
790 |
return (String) getLstFormats().getSelectedValue(); |
791 |
} |
792 |
|
793 |
public String getLayersQuery() { |
794 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
795 |
WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]); |
796 |
|
797 |
//Nombre separado por comas de las capas
|
798 |
String layersQuery = layers[layers.length-1].getName(); |
799 |
|
800 |
for (int i = layers.length-2; i >= 0; i--) { |
801 |
layersQuery += ("," + layers[i].getName());
|
802 |
} |
803 |
|
804 |
return layersQuery;
|
805 |
|
806 |
} |
807 |
|
808 |
/**
|
809 |
* Returns the current selected SRS.
|
810 |
* @return
|
811 |
*/
|
812 |
public String getSRS() { |
813 |
return (String) getLstSRSs().getSelectedValue(); |
814 |
} |
815 |
|
816 |
/**
|
817 |
* Returns the name of the layer that the user has typed-in
|
818 |
* @return
|
819 |
*/
|
820 |
public String getLayerName() { |
821 |
return getJTxtNomCapa().getText();
|
822 |
} |
823 |
|
824 |
public void setLayerName(String name) { |
825 |
getJTxtNomCapa().setText(name); |
826 |
} |
827 |
|
828 |
public Rectangle2D getLayersRectangle() throws CannotReprojectException{ |
829 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
830 |
WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]); |
831 |
String[] layerNames = new String[layers.length]; |
832 |
for (int i = 0; i < layerNames.length; i++) { |
833 |
layerNames[i] = layers[i].getName(); |
834 |
} |
835 |
//Boundingbox de todas las capas
|
836 |
//ArrayList rectangulos = new ArrayList();
|
837 |
|
838 |
Rectangle2D rect;
|
839 |
String latLonID;
|
840 |
|
841 |
rect = dataSource.getBoundingBox(layerNames, getSRS()); |
842 |
if(rect == null) { |
843 |
latLonID = "EPSG:4326";
|
844 |
rect = dataSource.getBoundingBox(layerNames, latLonID); |
845 |
if (rect == null) { |
846 |
rect = dataSource.getBoundingBox(layerNames, "CRS:84");
|
847 |
} |
848 |
|
849 |
IProjection reqProj = ProjectionPool.get(getSRS()); |
850 |
IProjection latLonProj = ProjectionPool.get(latLonID); |
851 |
if ((reqProj != null) && (latLonProj != null)) { |
852 |
ICoordTrans ct = new CoordTrans((CoordSys) latLonProj, (CoordSys) reqProj);
|
853 |
Rectangle2D reprojectedRect;
|
854 |
reprojectedRect = ct.convert(rect); |
855 |
rect = reprojectedRect; |
856 |
} else {
|
857 |
throw new CannotReprojectException(PluginServices.getText(this, "cannotReproject") + " " + getSRS() + " -> " + latLonID); |
858 |
} |
859 |
} |
860 |
|
861 |
return rect;
|
862 |
} |
863 |
|
864 |
public TreePath[] getSelectedLayers() { |
865 |
return getTreeLayers().getSelectionPaths();
|
866 |
} |
867 |
|
868 |
public Hashtable getOnlineResources() { |
869 |
return dataSource.getOnlineResources();
|
870 |
} |
871 |
|
872 |
/**
|
873 |
* The piece of the GetMap request that has the layer names.
|
874 |
* @return
|
875 |
*/
|
876 |
public String getQueryableLayerQuery() { |
877 |
ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
|
878 |
WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]); |
879 |
//Nombre separado por comas de las capas
|
880 |
String layersQuery = ""; |
881 |
int i;
|
882 |
|
883 |
for (i = 0; i < layers.length; i++) { |
884 |
if (layers[i].isQueryable()) {
|
885 |
layersQuery = layers[i].getName(); |
886 |
|
887 |
break;
|
888 |
} |
889 |
} |
890 |
|
891 |
for (int j = i + 1; j < layers.length; j++) { |
892 |
if (layers[j].isQueryable()) {
|
893 |
layersQuery += ("," + layers[j].getName());
|
894 |
} |
895 |
} |
896 |
|
897 |
return layersQuery;
|
898 |
} |
899 |
|
900 |
/**
|
901 |
* Returns the index of the CRS within the CRS list.
|
902 |
*
|
903 |
* Devuelve la posicion que ocupa el CRS en la lista de CRS
|
904 |
*
|
905 |
* @param crs
|
906 |
* @return The CRS's index if it exists, -1 if it not exists.
|
907 |
*/
|
908 |
public int getSRSIndex(String crs) { |
909 |
for (int i=0; i<getLstSRSs().getModel().getSize(); i++){ |
910 |
if (crs!=null && crs.equals(getLstSRSs().getModel().getElementAt(i))) |
911 |
return i;
|
912 |
} |
913 |
return -1; |
914 |
} |
915 |
|
916 |
/**
|
917 |
* Returns the index of the format within the formats list.
|
918 |
*
|
919 |
* Devuelve la posicion que ocupa el formato en la lista de formatos
|
920 |
* @param format
|
921 |
*
|
922 |
* @return The format's index if it exists, -1 if it not exists.
|
923 |
*/
|
924 |
public int getFormatIndex(String format) { |
925 |
for (int i=0; i<getLstFormats().getModel().getSize(); i++){ |
926 |
if (format!=null && format.equals(getLstFormats().getModel().getElementAt(i))) |
927 |
return i;
|
928 |
} |
929 |
return -1; |
930 |
} |
931 |
|
932 |
/**
|
933 |
* This method initializes jTabbedPane
|
934 |
*
|
935 |
* @return javax.swing.JTabbedPane
|
936 |
*/
|
937 |
public JTabbedPane getJTabbedPane() { |
938 |
if (jTabbedPane == null) { |
939 |
jTabbedPane = new JTabbedPane(); |
940 |
jTabbedPane.setBounds(3, 3, 475, 415); |
941 |
InfoPanel ip = getTabInfo(); |
942 |
ip.addFocusListener(new FocusListener(){ |
943 |
public void focusGained(FocusEvent e) { |
944 |
refreshInfo(); |
945 |
} |
946 |
public void focusLost(FocusEvent e) { |
947 |
} |
948 |
}); |
949 |
|
950 |
StylesPanel sp = getTabStyle(); |
951 |
DimensionPanel dp = getTabDimensions(); |
952 |
|
953 |
|
954 |
jTabbedPane.addTab(PluginServices.getText(this, "info"), null, ip, null); |
955 |
jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, getTabLayers(), null); |
956 |
jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, sp, null); |
957 |
stylesTabIndex = jTabbedPane.getTabCount()-1;
|
958 |
jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"), null, dp, null); |
959 |
dimensionTabIndex = jTabbedPane.getTabCount()-1;
|
960 |
jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, getTabFormats(), null); |
961 |
jTabbedPane.setEnabledAt(dimensionTabIndex, false);
|
962 |
jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
963 |
} |
964 |
return jTabbedPane;
|
965 |
} |
966 |
|
967 |
/**
|
968 |
* This method initializes jPanel
|
969 |
*
|
970 |
* @return javax.swing.JPanel
|
971 |
*/
|
972 |
private JPanel getTabLayers() { |
973 |
if (tabLayers == null) { |
974 |
tabLayers = new JPanel(); |
975 |
tabLayers.setLayout(null);
|
976 |
tabLayers.add(getJPanel4(), null);
|
977 |
tabLayers.add(getJPanel2(), null);
|
978 |
} |
979 |
return tabLayers;
|
980 |
} |
981 |
|
982 |
/**
|
983 |
* This method initializes jPanel1
|
984 |
*
|
985 |
* @return javax.swing.JPanel
|
986 |
*/
|
987 |
private JPanel getJPanel1() { |
988 |
if (jPanel1 == null) { |
989 |
jPanel1 = new JPanel(); |
990 |
jPanel1.setLayout(null);
|
991 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
992 |
null, PluginServices.getText(this, "select_formats"), |
993 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
994 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
995 |
jPanel1.setBounds(7, 10, 453, 194); |
996 |
jPanel1.add(getJScrollPane6(), null);
|
997 |
jPanel1.add(getChkTransparency(), null);
|
998 |
} |
999 |
return jPanel1;
|
1000 |
} |
1001 |
|
1002 |
/**
|
1003 |
* This method initializes jPanel5
|
1004 |
*
|
1005 |
* @return javax.swing.JPanel
|
1006 |
*/
|
1007 |
private JPanel getJPanel5() { |
1008 |
if (jPanel5 == null) { |
1009 |
jPanel5 = new JPanel(); |
1010 |
jPanel5.setLayout(null);
|
1011 |
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder( |
1012 |
null, PluginServices.getText(this, "seleccionar_srs"), |
1013 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
1014 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
1015 |
jPanel5.setBounds(7, 210, 453, 168); |
1016 |
jPanel5.add(getJScrollPane2(), null);
|
1017 |
} |
1018 |
return jPanel5;
|
1019 |
} |
1020 |
|
1021 |
/**
|
1022 |
* This method initializes jPanel6
|
1023 |
*
|
1024 |
* @return javax.swing.JPanel
|
1025 |
*/
|
1026 |
private StylesPanel getTabStyle() {
|
1027 |
if (tabStyle == null) { |
1028 |
tabStyle = new StylesPanel(this); |
1029 |
tabStyle.setEnabled(false);
|
1030 |
tabStyle.addListener(new BeanListener(){
|
1031 |
public void beanValueChanged(Object value) { |
1032 |
fireWizardComplete(isCorrectlyConfigured()); |
1033 |
}; |
1034 |
}); |
1035 |
tabStyle.addFocusListener(new FocusAdapter() { |
1036 |
public void focusGained(FocusEvent e) { |
1037 |
refreshStyleTree(); |
1038 |
} |
1039 |
}); |
1040 |
} |
1041 |
return tabStyle;
|
1042 |
} |
1043 |
|
1044 |
/**
|
1045 |
* Sets the focus to the tab next to the current one.
|
1046 |
*
|
1047 |
* Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
1048 |
*
|
1049 |
*/
|
1050 |
public void avanzaTab(){ |
1051 |
int currentPage = currentPage();
|
1052 |
int nPages = getNumTabs();
|
1053 |
if (nPages -1 > currentPage){ |
1054 |
getJTabbedPane().setSelectedIndex(nextEnabledPage()); |
1055 |
} |
1056 |
} |
1057 |
|
1058 |
/**
|
1059 |
* Sets the focus to the tab previous to the current one.
|
1060 |
*
|
1061 |
* Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
1062 |
*
|
1063 |
*/
|
1064 |
public void retrocedeTab(){ |
1065 |
this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
1066 |
|
1067 |
} |
1068 |
/**
|
1069 |
* Returns the index of the current tab.
|
1070 |
*
|
1071 |
* Devuelve el ?ndice de la p?gina actual del wizard.
|
1072 |
*
|
1073 |
* @return
|
1074 |
*/
|
1075 |
public int currentPage(){ |
1076 |
return getJTabbedPane().getSelectedIndex();
|
1077 |
} |
1078 |
|
1079 |
/**
|
1080 |
* Returns the tab amount that the WMSParamsPanel currently have
|
1081 |
*
|
1082 |
* Devuelve el n?mero de solapas que tiene actualmente el WMSParamsPanel
|
1083 |
*
|
1084 |
* @return int
|
1085 |
*/
|
1086 |
public int getNumTabs(){ |
1087 |
return getJTabbedPane().getTabCount();
|
1088 |
} |
1089 |
|
1090 |
/**
|
1091 |
* <p>
|
1092 |
* Returns the index of the previous enabled tab.
|
1093 |
* </p>
|
1094 |
* <p>
|
1095 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
|
1096 |
* ninguna.
|
1097 |
* </p>
|
1098 |
* @return The index, or -1 if there is no one.
|
1099 |
*/
|
1100 |
public int previousEnabledPage(){ |
1101 |
int currentPage = currentPage();
|
1102 |
int j=0; |
1103 |
if (currentPage == 0) |
1104 |
j= -1;
|
1105 |
for (int i = currentPage-1; i>-1; i--){ |
1106 |
if (getJTabbedPane().isEnabledAt(i)){
|
1107 |
j= i; |
1108 |
break;
|
1109 |
} |
1110 |
} |
1111 |
return j;
|
1112 |
} |
1113 |
|
1114 |
/**
|
1115 |
* <p>
|
1116 |
* Returns the previous of the previous enabled tab.
|
1117 |
* </p>
|
1118 |
* <p>
|
1119 |
* Devuelve el ?ndice de la siguiente p?gina habilitada del wizard o -1 si no hay
|
1120 |
* ninguna.
|
1121 |
* </p>
|
1122 |
* @return The index, or -1 if there is no one.
|
1123 |
*/
|
1124 |
public int nextEnabledPage() { |
1125 |
int currentPage = currentPage();
|
1126 |
int nPages = getNumTabs();
|
1127 |
if (currentPage == nPages)
|
1128 |
return -1; |
1129 |
for (int i=currentPage+1; i<nPages; i++){ |
1130 |
if (getJTabbedPane().isEnabledAt(i)){
|
1131 |
return i;
|
1132 |
} |
1133 |
} |
1134 |
return -1; |
1135 |
} |
1136 |
|
1137 |
/**
|
1138 |
* Selects/deselects the transparency checkbox.
|
1139 |
* @param b
|
1140 |
*/
|
1141 |
public void setTransparent(boolean b) { |
1142 |
getChkTransparency().setSelected(b); |
1143 |
} |
1144 |
/**
|
1145 |
* This method initializes chkTrasparency
|
1146 |
*
|
1147 |
* @return javax.swing.JCheckBox
|
1148 |
*/
|
1149 |
private JCheckBox getChkTransparency() { |
1150 |
if (chkTransparency == null) { |
1151 |
chkTransparency = new JCheckBox(); |
1152 |
chkTransparency.setText(PluginServices.getText(this, "wms_transparency")); |
1153 |
chkTransparency.setSelected(true);
|
1154 |
chkTransparency.addItemListener(new java.awt.event.ItemListener() {
|
1155 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
1156 |
fireWizardComplete(isCorrectlyConfigured()); |
1157 |
} |
1158 |
}); |
1159 |
chkTransparency.setBounds(5, 168, 441, 21); |
1160 |
|
1161 |
} |
1162 |
return chkTransparency;
|
1163 |
} |
1164 |
|
1165 |
/**
|
1166 |
* Returns a vector of strings containing the styles selected for the
|
1167 |
* layers. A blank style is correct and means that default style will
|
1168 |
* be used.
|
1169 |
*
|
1170 |
* @return Vector
|
1171 |
*/
|
1172 |
public Vector getStyles() { |
1173 |
Vector v = new Vector(); |
1174 |
WMSLayerNode[] layers = selectedLayersToArray();
|
1175 |
for (int i = 0; i < layers.length; i++) { |
1176 |
FMapWMSStyle sty = layers[i].getSelectedStyle(); |
1177 |
String s = (sty!=null)? sty.name : ""; |
1178 |
v.add(s); |
1179 |
} |
1180 |
return v;
|
1181 |
} |
1182 |
|
1183 |
/**
|
1184 |
* This method initializes tabInfo
|
1185 |
*
|
1186 |
* @return javax.swing.JPanel
|
1187 |
*/
|
1188 |
private InfoPanel getTabInfo() {
|
1189 |
if (tabInfo == null) { |
1190 |
tabInfo = new InfoPanel();
|
1191 |
|
1192 |
} |
1193 |
return tabInfo;
|
1194 |
} |
1195 |
|
1196 |
public void setDimensions(Vector dimensions) { |
1197 |
for (int i = 0; i < dimensions.size(); i++) { |
1198 |
String st = (String) dimensions.get(i); |
1199 |
if (st.split("=").length == 2) { |
1200 |
String[] s = st.split("="); |
1201 |
getTabDimensions().setDimensionValue(s[0], s[1]); |
1202 |
} |
1203 |
} |
1204 |
|
1205 |
} |
1206 |
|
1207 |
/**
|
1208 |
* This method initializes tabDimension
|
1209 |
*
|
1210 |
* @return javax.swing.JPanel
|
1211 |
*/
|
1212 |
private DimensionPanel getTabDimensions() {
|
1213 |
if (tabDimensions == null) { |
1214 |
tabDimensions = new DimensionPanel();
|
1215 |
tabDimensions.setEnabled(false);
|
1216 |
tabDimensions.addListener(new BeanListener(){
|
1217 |
public void beanValueChanged(Object value) { |
1218 |
Vector myDimensions = (Vector) value; |
1219 |
if (value!=null && ( oldDimensions == null || |
1220 |
!(oldDimensions.size() == myDimensions.size() |
1221 |
&& oldDimensions.containsAll(myDimensions))) |
1222 |
){ |
1223 |
oldDimensions = myDimensions; |
1224 |
} |
1225 |
fireWizardComplete(isCorrectlyConfigured()); |
1226 |
} |
1227 |
}); |
1228 |
|
1229 |
} |
1230 |
return tabDimensions;
|
1231 |
} |
1232 |
|
1233 |
/**
|
1234 |
* @return
|
1235 |
*/
|
1236 |
public boolean getTransparency() { |
1237 |
return getChkTransparency().isSelected();
|
1238 |
} |
1239 |
|
1240 |
/**
|
1241 |
* @return
|
1242 |
*/
|
1243 |
public Vector getDimensions() { |
1244 |
return getTabDimensions().getDimensions();
|
1245 |
} |
1246 |
|
1247 |
public void initWizard() {} |
1248 |
public void execute() { } |
1249 |
public FLayer getLayer() { return null; } |
1250 |
|
1251 |
public FMapWMSDriver getDriver() {
|
1252 |
return dataSource.getDriver();
|
1253 |
} |
1254 |
|
1255 |
public Dimension getFixedSize() { |
1256 |
return sizeFixed;
|
1257 |
} |
1258 |
|
1259 |
/**
|
1260 |
* This method initializes chkExtendedNames
|
1261 |
*
|
1262 |
* @return javax.swing.JCheckBox
|
1263 |
*/
|
1264 |
private JCheckBox getChkExtendedNames() { |
1265 |
if (chkExtendedNames == null) { |
1266 |
chkExtendedNames = new JCheckBox(); |
1267 |
chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names")); |
1268 |
chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
1269 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
1270 |
boolean b = chkExtendedNames.isSelected();
|
1271 |
getTreeLayers().showLayerNames = b; |
1272 |
getTreeLayers().repaint(); |
1273 |
getLstSelectedLayers().showLayerNames = b; |
1274 |
getLstSelectedLayers().repaint(); |
1275 |
getStyleTree().showLayerNames = b; |
1276 |
} |
1277 |
}); |
1278 |
chkExtendedNames.addActionListener(new java.awt.event.ActionListener() {
|
1279 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
1280 |
fPrefs.putBoolean("show_layer_names", chkExtendedNames.isSelected());
|
1281 |
} |
1282 |
}); |
1283 |
chkExtendedNames.setBounds(46, 300, 150, 20); |
1284 |
chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names", false)); |
1285 |
|
1286 |
} |
1287 |
return chkExtendedNames;
|
1288 |
} |
1289 |
|
1290 |
/**
|
1291 |
* This method initializes btnUp
|
1292 |
*
|
1293 |
* @return javax.swing.JButton
|
1294 |
*/
|
1295 |
private JButton getBtnUp() { |
1296 |
if (btnUp == null) { |
1297 |
btnUp = new JButton(); |
1298 |
btnUp.setBounds(11, 184, 30, 30); |
1299 |
btnUp.setToolTipText(PluginServices.getText(this, "move_layer_up")); |
1300 |
btnUp.addActionListener(new java.awt.event.ActionListener() {
|
1301 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
1302 |
LayerList list = getLstSelectedLayers(); |
1303 |
int[] selectedIndices = list.getSelectedIndices(); |
1304 |
int index = list.getSelectedIndex();
|
1305 |
if (selectedIndices != null && selectedIndices.length==1 && index > 0 ) { |
1306 |
JDnDListModel m = (JDnDListModel) list.getModel(); |
1307 |
m.itemsMoved(index - 1, new int[] {index}); |
1308 |
list.setSelectedIndex(index - 1);
|
1309 |
} |
1310 |
} |
1311 |
}); |
1312 |
btnUp.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/up-arrow.png"))); |
1313 |
} |
1314 |
return btnUp;
|
1315 |
} |
1316 |
|
1317 |
/**
|
1318 |
* This method initializes btnDown
|
1319 |
*
|
1320 |
* @return javax.swing.JButton
|
1321 |
*/
|
1322 |
private JButton getBtnDown() { |
1323 |
if (btnDown == null) { |
1324 |
btnDown = new JButton(); |
1325 |
btnDown.setBounds(11, 215, 30, 30); |
1326 |
btnDown.setToolTipText(PluginServices.getText(this, "move_layer_down")); |
1327 |
btnDown.addActionListener(new java.awt.event.ActionListener() {
|
1328 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
1329 |
LayerList list = getLstSelectedLayers(); |
1330 |
int[] selectedIndices = list.getSelectedIndices(); |
1331 |
int index = list.getSelectedIndex();
|
1332 |
if (selectedIndices != null && selectedIndices.length == 1 && index < getLstSelectedLayers().getModel().getSize()-1) { |
1333 |
JDnDListModel m = (JDnDListModel) list.getModel(); |
1334 |
m.itemsMoved(index + 1, new int[] {index}); |
1335 |
list.setSelectedIndex( index + 1);
|
1336 |
} |
1337 |
} |
1338 |
}); |
1339 |
btnDown.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/down-arrow.png"))); |
1340 |
} |
1341 |
return btnDown;
|
1342 |
} |
1343 |
|
1344 |
public void setFixedSize(Dimension sz) { |
1345 |
sizeFixed = sz; |
1346 |
} |
1347 |
|
1348 |
public ArrayList getSelectedPaths(){ |
1349 |
return selectedPaths;
|
1350 |
} |
1351 |
/**
|
1352 |
* This method initializes chkDisagregate
|
1353 |
*
|
1354 |
* @return javax.swing.JCheckBox
|
1355 |
*/
|
1356 |
private JCheckBox getChkDisagregate() { |
1357 |
if (chkDisagregate == null) { |
1358 |
chkDisagregate = new JCheckBox(); |
1359 |
chkDisagregate.setBounds(new java.awt.Rectangle(46,276,247,20)); |
1360 |
chkDisagregate.setText(PluginServices.getText(this, "disagregate_layers")); |
1361 |
} |
1362 |
return chkDisagregate;
|
1363 |
} |
1364 |
|
1365 |
public boolean getDisagregatedLayers(){ |
1366 |
return chkDisagregate.isSelected();
|
1367 |
} |
1368 |
} // @jve:decl-index=0:visual-constraint="10,10"
|