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