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