svn-gvsig-desktop / tags / v1_1_Build_1001 / extensions / extWCS / src / com / iver / cit / gvsig / gui / panels / WCSParamsPanel.java @ 11984
History | View | Annotate | Download (33.8 KB)
1 | 3166 | jaume | /* 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 | 6122 | jaume | import java.awt.Dimension; |
44 | import java.awt.FlowLayout; |
||
45 | 4614 | jaume | import java.awt.event.FocusEvent; |
46 | import java.awt.event.FocusListener; |
||
47 | 3166 | jaume | import java.awt.geom.Point2D; |
48 | import java.awt.geom.Rectangle2D; |
||
49 | import java.util.ArrayList; |
||
50 | 4414 | jaume | import java.util.prefs.Preferences; |
51 | 3166 | jaume | |
52 | 6122 | jaume | import org.gvsig.gui.beans.swing.JButton; |
53 | 4414 | jaume | import javax.swing.JCheckBox; |
54 | 3166 | jaume | import javax.swing.JComboBox; |
55 | import javax.swing.JLabel; |
||
56 | import javax.swing.JList; |
||
57 | import javax.swing.JPanel; |
||
58 | import javax.swing.JScrollPane; |
||
59 | import javax.swing.JTabbedPane; |
||
60 | import javax.swing.JTextField; |
||
61 | |||
62 | 4573 | jaume | import org.gvsig.gui.beans.controls.dnd.JDnDList; |
63 | import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
||
64 | |||
65 | 3166 | jaume | import com.iver.andami.PluginServices; |
66 | 4356 | jaume | import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver; |
67 | 4398 | jaume | import com.iver.cit.gvsig.fmap.layers.FLayer; |
68 | 4573 | jaume | import com.iver.cit.gvsig.fmap.layers.FMapWCSParameter; |
69 | 4356 | jaume | import com.iver.cit.gvsig.fmap.layers.WCSLayer; |
70 | 4398 | jaume | import com.iver.cit.gvsig.gui.WizardPanel; |
71 | 3166 | jaume | import com.iver.cit.gvsig.gui.wcs.WCSWizardData; |
72 | 4398 | jaume | import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
73 | 3166 | jaume | |
74 | /**
|
||
75 | * This class implements the coverage option panel.
|
||
76 | 6122 | jaume | *
|
77 | 3166 | jaume | * It includes a set of Listeners that implement some control rules which
|
78 | * refresh the component values that depends on those selected in the other
|
||
79 | * components to avoid to choose an invalid set of options. It also includes a
|
||
80 | * method (isCorrectlyConfigured()) that checks if the current set of values is enough to
|
||
81 | * correctly launch a GetCoverage request.
|
||
82 | 6122 | jaume | *
|
83 | 3166 | jaume | * The information is obtained from a WCSWizardDataSource object.
|
84 | 6122 | jaume | *
|
85 | *
|
||
86 | 3166 | jaume | * Esta clase implementa el panel de opciones disponibles sobre la cobertura.
|
87 | 6122 | jaume | *
|
88 | 3166 | jaume | * Incluye una serie de Listeners que implementan unas reglas de control que
|
89 | 6122 | jaume | * refrescan los valores de componentes cuyos valores dependen de aqu?llos
|
90 | 3166 | jaume | * seleccionados en otros componentes para evitar que se escoja una combinaci?n
|
91 | * de opciones err?nea as? como una funci?n (isCorrectlyConfigured()) que
|
||
92 | * comprueba si la combinaci?n escogida actualmente es suficiente para lanzar
|
||
93 | * una operaci?n GetCoverage correctamente.
|
||
94 | 6122 | jaume | *
|
95 | 3166 | jaume | * La informaci?n obtiene a partir de un objeto WCSWizardDataSource.
|
96 | 6122 | jaume | *
|
97 | 3166 | jaume | * @author jaume - jaume dominguez faus
|
98 | *
|
||
99 | */
|
||
100 | 4398 | jaume | public class WCSParamsPanel extends WizardPanel{ |
101 | 3166 | jaume | private final int SINGLE_VALUE = 0; |
102 | private final int INTERVAL = 1; |
||
103 | 6122 | jaume | |
104 | 3166 | jaume | private JTabbedPane jTabbedPane = null; // @jve:decl-index=0:visual-constraint="37,30" |
105 | 4505 | jaume | private JPanel formatsPanel = null; |
106 | private JPanel timesPanel = null; |
||
107 | 3166 | jaume | private JList lstCRSs = null; |
108 | 4573 | jaume | private JList lstTimes = null; |
109 | 3166 | jaume | private JComboBox cmbParam = null; |
110 | 4573 | jaume | private JDnDList lstParamValues = null; |
111 | private JButton btnDelTime = null; |
||
112 | 3166 | jaume | private JList lstSelectedTimes = null; |
113 | 4414 | jaume | private JCheckBox chkExtendedNames = null; |
114 | 3166 | jaume | private JList lstFormats = null; |
115 | 4573 | jaume | private JPanel parameterPanel = null; |
116 | 3166 | jaume | private JPanel jPanel2 = null; |
117 | private JPanel jPanel3 = null; |
||
118 | 4414 | jaume | private JPanel coveragePanel = null; |
119 | 3166 | jaume | private JPanel jPanel4 = null; |
120 | 4414 | jaume | private JTextField txtName = null; |
121 | 3166 | jaume | private JScrollPane jScrollPane = null; |
122 | 4573 | jaume | private JButton btnAddTime = null; |
123 | 4414 | jaume | private LayerList lstCoverages = null; |
124 | 3166 | jaume | private JScrollPane jScrollPane2 = null; |
125 | private JScrollPane jScrollPane3 = null; |
||
126 | private JScrollPane jScrollPane4 = null; |
||
127 | private JScrollPane jScrollPane5 = null; |
||
128 | private JScrollPane jScrollPane1 = null; |
||
129 | private WCSWizardData data;
|
||
130 | 4398 | jaume | private WizardListenerSupport listenerSupport;
|
131 | 3166 | jaume | private int parameterType; |
132 | 4414 | jaume | private int indCoverage; |
133 | private int indFormat; |
||
134 | private int indTime; |
||
135 | private int indParameter; |
||
136 | 4472 | jaume | public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
137 | 4417 | jaume | private JComboBox cmbInterpolationMethods = null; |
138 | private JCheckBox chkUseInterpolationMethod = null; |
||
139 | 4505 | jaume | private InfoPanel infoPanel;
|
140 | private int intInfo; |
||
141 | 6122 | jaume | private JPanel pnlName; |
142 | 4573 | jaume | /**
|
143 | 6122 | jaume | * This method initializes jTabbedPane
|
144 | *
|
||
145 | * @return javax.swing.JTabbedPane
|
||
146 | */
|
||
147 | |||
148 | 3166 | jaume | public WCSParamsPanel(){
|
149 | super();
|
||
150 | initialize(); |
||
151 | } |
||
152 | /**
|
||
153 | * Returns the tab amount that the WCSParamsPanel currently have
|
||
154 | 6122 | jaume | *
|
155 | 3166 | jaume | * Devuelve el n?mero de solapas que tiene actualmente el WCSParamsPanel
|
156 | 6122 | jaume | *
|
157 | 3166 | jaume | * @return int
|
158 | */
|
||
159 | public int getNumTabs(){ |
||
160 | return getJTabbedPane().getTabCount();
|
||
161 | } |
||
162 | 6122 | jaume | |
163 | 4414 | jaume | private void initialize() { |
164 | 3166 | jaume | this.setLayout(null); |
165 | 4414 | jaume | this.setVisible(false); |
166 | 6501 | jaume | this.setBounds(0, 0, 510, 427); |
167 | 3166 | jaume | this.add(getJTabbedPane(), null); |
168 | } |
||
169 | 6122 | jaume | |
170 | 3166 | jaume | /**
|
171 | * Sets the focus to the tab next to the current one.
|
||
172 | 6122 | jaume | *
|
173 | 3166 | jaume | * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
174 | *
|
||
175 | */
|
||
176 | public void avanzaTab(){ |
||
177 | int currentPage = currentPage();
|
||
178 | int nPages = getNumTabs();
|
||
179 | if (nPages -1 > currentPage){ |
||
180 | getJTabbedPane().setSelectedIndex(nextPageEnabled()); |
||
181 | } |
||
182 | } |
||
183 | 6122 | jaume | |
184 | 3166 | jaume | /**
|
185 | 6122 | jaume | * Sets the focus to the tab previous to the current one.
|
186 | *
|
||
187 | 3166 | jaume | * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
188 | 6122 | jaume | *
|
189 | 3166 | jaume | */
|
190 | public void retrocedeTab(){ |
||
191 | this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
||
192 | |||
193 | } |
||
194 | 6122 | jaume | |
195 | 3166 | jaume | /**
|
196 | * Returns the current tab index.
|
||
197 | 6122 | jaume | *
|
198 | 3166 | jaume | * Devuelve el n?mero de solapa en que se encuentra
|
199 | 6122 | jaume | *
|
200 | 3166 | jaume | * @return
|
201 | */
|
||
202 | public int getIndiceSolapaActual(){ |
||
203 | return this.getJTabbedPane().getSelectedIndex(); |
||
204 | } |
||
205 | 6122 | jaume | |
206 | 4573 | jaume | private JTabbedPane getJTabbedPane() { |
207 | 3166 | jaume | if (jTabbedPane == null) { |
208 | jTabbedPane = new JTabbedPane(); |
||
209 | 6501 | jaume | jTabbedPane.setBounds(4, 4, 502, 415); |
210 | 4505 | jaume | jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getInfoPanel()); |
211 | intInfo = jTabbedPane.getTabCount()-1;
|
||
212 | jTabbedPane.addTab(PluginServices.getText(this, "coverage"), null, getPanelCovertures(), null); |
||
213 | 4414 | jaume | indCoverage = jTabbedPane.getTabCount()-1;
|
214 | 4505 | jaume | jTabbedPane.addTab(PluginServices.getText(this, "format"), null, getFormatsPanel(), null); |
215 | 4414 | jaume | indFormat = jTabbedPane.getTabCount()-1;
|
216 | 4505 | jaume | jTabbedPane.addTab(PluginServices.getText(this, "time"), null, getTimePanel(), null); |
217 | 4414 | jaume | indTime = jTabbedPane.getTabCount()-1;
|
218 | jTabbedPane.setEnabledAt(indTime, false);
|
||
219 | 4573 | jaume | jTabbedPane.addTab(PluginServices.getText(this, "parameters"), null, getParameterPanel(), null); |
220 | 4414 | jaume | indParameter = jTabbedPane.getTabCount()-1;
|
221 | jTabbedPane.setEnabledAt(indParameter, false);
|
||
222 | 3166 | jaume | } |
223 | return jTabbedPane;
|
||
224 | } |
||
225 | 6122 | jaume | |
226 | /**
|
||
227 | * This method initializes pnlName
|
||
228 | *
|
||
229 | * @return javax.swing.JPanel
|
||
230 | */
|
||
231 | private JPanel getPnlName() { |
||
232 | if (pnlName == null) { |
||
233 | 6501 | jaume | pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
234 | 6122 | jaume | pnlName.setBorder(javax.swing.BorderFactory.createTitledBorder( |
235 | null, PluginServices.getText(this, "nombre_cobertura"), |
||
236 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
237 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
238 | 6501 | jaume | pnlName.setBounds(new java.awt.Rectangle(7,4,482,52)); |
239 | 6122 | jaume | pnlName.add(getTxtName(), null);
|
240 | } |
||
241 | return pnlName;
|
||
242 | } |
||
243 | 4505 | jaume | private InfoPanel getInfoPanel() {
|
244 | if (infoPanel==null) { |
||
245 | infoPanel = new InfoPanel();
|
||
246 | 4614 | jaume | infoPanel.addFocusListener(new FocusListener() { |
247 | public void focusGained(java.awt.event.FocusEvent e) { |
||
248 | refreshInfo(); |
||
249 | } |
||
250 | |||
251 | public void focusLost(FocusEvent e) { |
||
252 | 6122 | jaume | |
253 | 4614 | jaume | } |
254 | }); |
||
255 | 4505 | jaume | } |
256 | return infoPanel;
|
||
257 | } |
||
258 | 3166 | jaume | /**
|
259 | 6122 | jaume | * This method initializes panelFormato
|
260 | *
|
||
261 | * @return javax.swing.JPanel
|
||
262 | */
|
||
263 | 4505 | jaume | private JPanel getFormatsPanel() { |
264 | if (formatsPanel == null) { |
||
265 | formatsPanel = new JPanel(); |
||
266 | formatsPanel.setLayout(null);
|
||
267 | formatsPanel.add(getJPanel3(), null);
|
||
268 | formatsPanel.add(getJPanel2(), null);
|
||
269 | 3166 | jaume | } |
270 | 4505 | jaume | return formatsPanel;
|
271 | 3166 | jaume | } |
272 | /**
|
||
273 | 6122 | jaume | * This method initializes panelTemps
|
274 | *
|
||
275 | * @return javax.swing.JPanel
|
||
276 | */
|
||
277 | 4505 | jaume | private JPanel getTimePanel() { |
278 | if (timesPanel == null) { |
||
279 | timesPanel = new JPanel(); |
||
280 | timesPanel.setLayout(null);
|
||
281 | 4573 | jaume | timesPanel.setBounds(5, 17, 464, 374); |
282 | timesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
283 | null, PluginServices.getText(this, "seleccionar_tiempo"), |
||
284 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
285 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
286 | timesPanel.add(getBtnAddTime(), null);
|
||
287 | timesPanel.add(getBtnDelTime(), null);
|
||
288 | timesPanel.add(getJScrollPane3(), null);
|
||
289 | timesPanel.add(getJScrollPane4(), null);
|
||
290 | timesPanel.setLayout(null);
|
||
291 | timesPanel.setBounds(5, 17, 464, 374); |
||
292 | timesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
293 | null, PluginServices.getText(this, "seleccionar_tiempo"), |
||
294 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
295 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
296 | timesPanel.add(getBtnAddTime(), null);
|
||
297 | timesPanel.add(getBtnDelTime(), null);
|
||
298 | timesPanel.add(getJScrollPane3(), null);
|
||
299 | timesPanel.add(getJScrollPane4(), null);
|
||
300 | // timesPanel = new JPanel();
|
||
301 | // timesPanel.setLayout(null);
|
||
302 | // //timesPanel.add(getJPanel(), null);
|
||
303 | 3166 | jaume | } |
304 | 4505 | jaume | return timesPanel;
|
305 | 3166 | jaume | } |
306 | 6122 | jaume | |
307 | 3166 | jaume | /**
|
308 | 6122 | jaume | * This method initializes lstCRSs
|
309 | *
|
||
310 | * @return javax.swing.JList
|
||
311 | */
|
||
312 | 3166 | jaume | public JList getLstCRSs() { |
313 | if (lstCRSs == null) { |
||
314 | lstCRSs = new JList(); |
||
315 | lstCRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
316 | 6122 | jaume | lstCRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
317 | 4573 | jaume | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
318 | listenerSupport.callStateChanged(isCorretlyConfigured()); |
||
319 | } |
||
320 | }); |
||
321 | 3166 | jaume | } |
322 | return lstCRSs;
|
||
323 | } |
||
324 | /**
|
||
325 | 6122 | jaume | * This method initializes lstTemps
|
326 | *
|
||
327 | * @return javax.swing.JList
|
||
328 | */
|
||
329 | 4573 | jaume | public JList getLstTimes() { |
330 | if (lstTimes == null) { |
||
331 | lstTimes = new JList(); |
||
332 | 3166 | jaume | } |
333 | 4573 | jaume | return lstTimes;
|
334 | 3166 | jaume | } |
335 | /**
|
||
336 | 6122 | jaume | * This method initializes cmbParam
|
337 | *
|
||
338 | * @return javax.swing.JComboBox
|
||
339 | */
|
||
340 | 3166 | jaume | public JComboBox getCmbParam() { |
341 | if (cmbParam == null) { |
||
342 | cmbParam = new JComboBox(); |
||
343 | 4573 | jaume | cmbParam.setEditable(false);
|
344 | 6501 | jaume | cmbParam.setBounds(10, 26, 229, 24); |
345 | 4573 | jaume | cmbParam.addItemListener(new java.awt.event.ItemListener() {
|
346 | public void itemStateChanged(java.awt.event.ItemEvent e) { |
||
347 | FMapWCSParameter p = (FMapWCSParameter) cmbParam.getSelectedItem(); |
||
348 | if (p!=null) { |
||
349 | getSingleParamValuesList().setListData(p.getValueList().toArray()); |
||
350 | } |
||
351 | fireWizardComplete(isCorretlyConfigured()); |
||
352 | } |
||
353 | }); |
||
354 | 3166 | jaume | } |
355 | return cmbParam;
|
||
356 | } |
||
357 | 6122 | jaume | |
358 | 3166 | jaume | /**
|
359 | 6122 | jaume | * This method initializes lstParamValues
|
360 | *
|
||
361 | * @return javax.swing.JList
|
||
362 | */
|
||
363 | 4573 | jaume | public JDnDList getSingleParamValuesList() {
|
364 | 3166 | jaume | if (lstParamValues == null) { |
365 | 4573 | jaume | lstParamValues = new JDnDList();
|
366 | lstParamValues.setModel(new JDnDListModel());
|
||
367 | lstParamValues.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||
368 | 6122 | jaume | lstParamValues.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
369 | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
||
370 | 6286 | jaume | System.out.println("list state changed"); |
371 | 4573 | jaume | fireWizardComplete(isCorretlyConfigured()); |
372 | } |
||
373 | }); |
||
374 | 3166 | jaume | } |
375 | return lstParamValues;
|
||
376 | } |
||
377 | 6122 | jaume | |
378 | 4573 | jaume | /**
|
379 | * Fires a notification to this wizard listeners telling them if the
|
||
380 | * configuration is fair enough to send a GetCoverage request.
|
||
381 | * @param b
|
||
382 | */
|
||
383 | private void fireWizardComplete(boolean b){ |
||
384 | listenerSupport.callStateChanged(b); |
||
385 | callStateChanged(b); |
||
386 | } |
||
387 | 3166 | jaume | |
388 | /**
|
||
389 | 4614 | jaume | * Refreshes the info shown in the info tab.
|
390 | */
|
||
391 | public void refreshInfo() { |
||
392 | FMapWCSParameter p = (FMapWCSParameter) getCmbParam().getSelectedItem(); |
||
393 | 6122 | jaume | String pString = (p!=null && getParameterString()!=null) ? p.toString()+"="+getParameterString().split("=")[1] : null; |
394 | 4614 | jaume | infoPanel.refresh(data, |
395 | (WCSLayer) getLstCoverages().getSelectedValue(), |
||
396 | getTime(), |
||
397 | 6122 | jaume | getFormat(), |
398 | 4614 | jaume | getSRS(), |
399 | pString); |
||
400 | } |
||
401 | /**
|
||
402 | 6122 | jaume | * This method initializes btnDelTemps
|
403 | *
|
||
404 | * @return org.gvsig.gui.beans.swing.JButton
|
||
405 | */
|
||
406 | 4573 | jaume | public JButton getBtnDelTime() { |
407 | if (btnDelTime == null) { |
||
408 | btnDelTime = new JButton(); |
||
409 | 6501 | jaume | btnDelTime.setBounds(200, 127, 50, 20); |
410 | 4573 | jaume | btnDelTime.setText("<");
|
411 | btnDelTime.addActionListener( |
||
412 | new java.awt.event.ActionListener() {
|
||
413 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
414 | delTime(); |
||
415 | } |
||
416 | }); |
||
417 | 3166 | jaume | } |
418 | 4573 | jaume | return btnDelTime;
|
419 | 3166 | jaume | } |
420 | /**
|
||
421 | 6122 | jaume | * This method initializes lstSelectedTimes
|
422 | *
|
||
423 | * @return javax.swing.JList
|
||
424 | */
|
||
425 | 3166 | jaume | public JList getLstSelectedTimes() { |
426 | if (lstSelectedTimes == null) { |
||
427 | lstSelectedTimes = new JList(); |
||
428 | 6122 | jaume | lstSelectedTimes.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
429 | 4573 | jaume | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
430 | listenerSupport.callStateChanged(isCorretlyConfigured()); |
||
431 | } |
||
432 | }); |
||
433 | 3166 | jaume | } |
434 | return lstSelectedTimes;
|
||
435 | } |
||
436 | /**
|
||
437 | 6122 | jaume | * This method initializes lstFormats
|
438 | *
|
||
439 | * @return javax.swing.JList
|
||
440 | */
|
||
441 | 3166 | jaume | public JList getLstFormats() { |
442 | if (lstFormats == null) { |
||
443 | lstFormats = new JList(); |
||
444 | 4414 | jaume | lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
445 | 6122 | jaume | lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
446 | 4573 | jaume | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
447 | listenerSupport.callStateChanged(isCorretlyConfigured()); |
||
448 | } |
||
449 | }); |
||
450 | 3166 | jaume | } |
451 | return lstFormats;
|
||
452 | } |
||
453 | 4573 | jaume | |
454 | 3166 | jaume | /**
|
455 | 6122 | jaume | * This method initializes jPanel1
|
456 | *
|
||
457 | * @return javax.swing.JPanel
|
||
458 | */
|
||
459 | 4573 | jaume | private JPanel getParameterPanel() { |
460 | if (parameterPanel == null) { |
||
461 | parameterPanel = new JPanel(); |
||
462 | parameterPanel.setLayout(null);
|
||
463 | parameterPanel.setBounds(5, 17, 464, 374); |
||
464 | parameterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
465 | 3166 | jaume | null, PluginServices.getText(this, "seleccionar_parametros"), |
466 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
467 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
468 | 4573 | jaume | parameterPanel.add(getCmbParam(), null);
|
469 | parameterPanel.add(getJScrollPane5(), null);
|
||
470 | 3166 | jaume | } |
471 | 4573 | jaume | return parameterPanel;
|
472 | 3166 | jaume | } |
473 | /**
|
||
474 | 6122 | jaume | * This method initializes jPanel2
|
475 | *
|
||
476 | * @return javax.swing.JPanel
|
||
477 | */
|
||
478 | 3166 | jaume | private JPanel getJPanel2() { |
479 | if (jPanel2 == null) { |
||
480 | jPanel2 = new JPanel(); |
||
481 | jPanel2.setLayout(null);
|
||
482 | jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
483 | null, PluginServices.getText(this, "seleccionar_CRS"), |
||
484 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
485 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
486 | 6501 | jaume | jPanel2.setBounds(0, 210, 499, 181); |
487 | 3166 | jaume | jPanel2.add(getJScrollPane2(), null);
|
488 | } |
||
489 | return jPanel2;
|
||
490 | } |
||
491 | /**
|
||
492 | 6122 | jaume | * This method initializes jPanel3
|
493 | *
|
||
494 | * @return javax.swing.JPanel
|
||
495 | */
|
||
496 | 3166 | jaume | private JPanel getJPanel3() { |
497 | if (jPanel3 == null) { |
||
498 | 6122 | jaume | |
499 | 3166 | jaume | jPanel3 = new JPanel(); |
500 | jPanel3.setLayout(null);
|
||
501 | 6501 | jaume | jPanel3.setBounds(0, 0, 499, 200); |
502 | 3166 | jaume | jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder( |
503 | null, PluginServices.getText(this, "seleccionar_formato"), |
||
504 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
505 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
506 | jPanel3.add(getJScrollPane1(), null);
|
||
507 | 6122 | jaume | |
508 | 4417 | jaume | jPanel3.add(getCmbInterpolationMethods(), null);
|
509 | jPanel3.add(getChkUseInterpolationMethod(), null);
|
||
510 | 3166 | jaume | } |
511 | return jPanel3;
|
||
512 | } |
||
513 | /**
|
||
514 | 6122 | jaume | * This method initializes panelCovertures
|
515 | *
|
||
516 | * @return javax.swing.JPanel
|
||
517 | */
|
||
518 | 3166 | jaume | private JPanel getPanelCovertures() { |
519 | 4414 | jaume | if (coveragePanel == null) { |
520 | 6122 | jaume | |
521 | 4414 | jaume | coveragePanel = new JPanel(); |
522 | coveragePanel.setLayout(null);
|
||
523 | coveragePanel.add(getJPanel4(), null);
|
||
524 | 6122 | jaume | coveragePanel.add(getPnlName(), null);
|
525 | 4414 | jaume | coveragePanel.add(getChkExtendedNames(), null);
|
526 | 3166 | jaume | } |
527 | 4414 | jaume | return coveragePanel;
|
528 | 3166 | jaume | } |
529 | /**
|
||
530 | 6122 | jaume | * This method initializes jPanel4
|
531 | *
|
||
532 | * @return javax.swing.JPanel
|
||
533 | */
|
||
534 | 3166 | jaume | private JPanel getJPanel4() { |
535 | if (jPanel4 == null) { |
||
536 | jPanel4 = new JPanel(); |
||
537 | jPanel4.setLayout(null);
|
||
538 | 6501 | jaume | jPanel4.setBounds(7, 56, 482, 305); |
539 | 3166 | jaume | jPanel4.add(getJScrollPane(), null);
|
540 | jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
541 | null, PluginServices.getText(this, "seleccionar_coberturas"), |
||
542 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
543 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
544 | } |
||
545 | return jPanel4;
|
||
546 | } |
||
547 | /**
|
||
548 | 6122 | jaume | * This method initializes jTextField
|
549 | *
|
||
550 | * @return javax.swing.JTextField
|
||
551 | */
|
||
552 | 4414 | jaume | public JTextField getTxtName() { |
553 | if (txtName == null) { |
||
554 | txtName = new JTextField(); |
||
555 | 6501 | jaume | txtName.setPreferredSize(new Dimension(469, 23)); |
556 | 3166 | jaume | } |
557 | 4414 | jaume | return txtName;
|
558 | 3166 | jaume | } |
559 | /**
|
||
560 | 6122 | jaume | * This method initializes chkExtendedNames
|
561 | *
|
||
562 | * @return javax.swing.JCheckBox
|
||
563 | */
|
||
564 | 4414 | jaume | private JCheckBox getChkExtendedNames() { |
565 | if (chkExtendedNames == null) { |
||
566 | chkExtendedNames = new JCheckBox(); |
||
567 | chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names")); |
||
568 | 6122 | jaume | chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
569 | 4414 | jaume | public void itemStateChanged(java.awt.event.ItemEvent e) { |
570 | boolean b = chkExtendedNames.isSelected();
|
||
571 | getLstCoverages().showLayerNames = b; |
||
572 | getLstCoverages().repaint(); |
||
573 | } |
||
574 | }); |
||
575 | 6122 | jaume | chkExtendedNames.addActionListener(new java.awt.event.ActionListener() {
|
576 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
577 | 4414 | jaume | fPrefs.putBoolean("show_layer_names", chkExtendedNames.isSelected());
|
578 | } |
||
579 | }); |
||
580 | 8765 | jjdelcerro | chkExtendedNames.setBounds(10, 368, 438, 20); |
581 | 4414 | jaume | chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names", false)); |
582 | 6122 | jaume | |
583 | 4414 | jaume | } |
584 | return chkExtendedNames;
|
||
585 | } |
||
586 | 6122 | jaume | |
587 | 4414 | jaume | /**
|
588 | 6122 | jaume | * This method initializes jScrollPane
|
589 | *
|
||
590 | * @return javax.swing.JScrollPane
|
||
591 | */
|
||
592 | 3166 | jaume | private JScrollPane getJScrollPane() { |
593 | if (jScrollPane == null) { |
||
594 | jScrollPane = new JScrollPane(); |
||
595 | 6501 | jaume | jScrollPane.setBounds(7, 17, 467, 282); |
596 | 3166 | jaume | jScrollPane.setViewportView(getLstCoverages()); |
597 | } |
||
598 | return jScrollPane;
|
||
599 | } |
||
600 | /**
|
||
601 | 6122 | jaume | * This method initializes jButton2
|
602 | *
|
||
603 | * @return org.gvsig.gui.beans.swing.JButton
|
||
604 | */
|
||
605 | 4573 | jaume | public JButton getBtnAddTime() { |
606 | if (btnAddTime == null) { |
||
607 | btnAddTime = new JButton(); |
||
608 | 6501 | jaume | btnAddTime.setBounds(200, 151, 50, 20); |
609 | 4573 | jaume | btnAddTime.setText(">");
|
610 | btnAddTime.addActionListener( |
||
611 | new java.awt.event.ActionListener() {
|
||
612 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
613 | addTime(); |
||
614 | } |
||
615 | }); |
||
616 | 3166 | jaume | } |
617 | 4573 | jaume | return btnAddTime;
|
618 | 3166 | jaume | } |
619 | /**
|
||
620 | 6122 | jaume | * This method initializes jList1
|
621 | *
|
||
622 | * @return javax.swing.JList
|
||
623 | */
|
||
624 | 4414 | jaume | public LayerList getLstCoverages() {
|
625 | 3166 | jaume | if (lstCoverages == null) { |
626 | 4414 | jaume | lstCoverages = new LayerList();
|
627 | 3166 | jaume | lstCoverages.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
628 | 6122 | jaume | lstCoverages.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
629 | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
||
630 | 4414 | jaume | refreshData(); |
631 | } |
||
632 | }); |
||
633 | 3166 | jaume | } |
634 | return lstCoverages;
|
||
635 | } |
||
636 | /**
|
||
637 | 6122 | jaume | * This method initializes jScrollPane2
|
638 | *
|
||
639 | * @return javax.swing.JScrollPane
|
||
640 | */
|
||
641 | 3166 | jaume | private JScrollPane getJScrollPane2() { |
642 | if (jScrollPane2 == null) { |
||
643 | jScrollPane2 = new JScrollPane(); |
||
644 | 6501 | jaume | jScrollPane2.setBounds(6, 19, 483, 155); |
645 | 3166 | jaume | jScrollPane2.setViewportView(getLstCRSs()); |
646 | } |
||
647 | return jScrollPane2;
|
||
648 | } |
||
649 | |||
650 | /**
|
||
651 | 6122 | jaume | * This method initializes jScrollPane3
|
652 | *
|
||
653 | * @return javax.swing.JScrollPane
|
||
654 | */
|
||
655 | 3166 | jaume | private JScrollPane getJScrollPane3() { |
656 | if (jScrollPane3 == null) { |
||
657 | jScrollPane3 = new JScrollPane(); |
||
658 | 6501 | jaume | jScrollPane3.setBounds(10, 30, 178, 334); |
659 | 4573 | jaume | jScrollPane3.setViewportView(getLstTimes()); |
660 | 3166 | jaume | } |
661 | return jScrollPane3;
|
||
662 | } |
||
663 | /**
|
||
664 | 6122 | jaume | * This method initializes jScrollPane4
|
665 | *
|
||
666 | * @return javax.swing.JScrollPane
|
||
667 | */
|
||
668 | 3166 | jaume | private JScrollPane getJScrollPane4() { |
669 | if (jScrollPane4 == null) { |
||
670 | jScrollPane4 = new JScrollPane(); |
||
671 | 6501 | jaume | jScrollPane4.setBounds(304, 30, 178, 334); |
672 | 3166 | jaume | jScrollPane4.setViewportView(getLstSelectedTimes()); |
673 | } |
||
674 | return jScrollPane4;
|
||
675 | } |
||
676 | /**
|
||
677 | 6122 | jaume | * This method initializes jScrollPane5
|
678 | *
|
||
679 | * @return javax.swing.JScrollPane
|
||
680 | */
|
||
681 | 3166 | jaume | public JScrollPane getJScrollPane5() { |
682 | if (jScrollPane5 == null) { |
||
683 | jScrollPane5 = new JScrollPane(); |
||
684 | 6501 | jaume | jScrollPane5.setBounds(254, 26, 236, 357); |
685 | 3166 | jaume | jScrollPane5.setViewportView(getSingleParamValuesList()); |
686 | } |
||
687 | return jScrollPane5;
|
||
688 | } |
||
689 | /**
|
||
690 | 6122 | jaume | * This method initializes jScrollPane1
|
691 | *
|
||
692 | * @return javax.swing.JScrollPane
|
||
693 | */
|
||
694 | 3166 | jaume | private JScrollPane getJScrollPane1() { |
695 | if (jScrollPane1 == null) { |
||
696 | jScrollPane1 = new JScrollPane(); |
||
697 | 6501 | jaume | jScrollPane1.setBounds(6, 19, 257, 174); |
698 | 3166 | jaume | jScrollPane1.setViewportView(getLstFormats()); |
699 | } |
||
700 | return jScrollPane1;
|
||
701 | } |
||
702 | |||
703 | 6122 | jaume | |
704 | 3166 | jaume | /**
|
705 | * Verifies that the selected parameters are enough to request the coverage
|
||
706 | * to the server.
|
||
707 | 6122 | jaume | *
|
708 | 3166 | jaume | * Comprueba que los par?metros seleccionados son suficientes para pedir la
|
709 | * cobertura al servidor.
|
||
710 | 6122 | jaume | *
|
711 | 3166 | jaume | * @return boolean
|
712 | */
|
||
713 | public boolean isCorretlyConfigured() { |
||
714 | 6122 | jaume | |
715 | 4356 | jaume | if (getCurrentCoverageName()==null) return false; |
716 | 6122 | jaume | /*
|
717 | 3166 | jaume | * Seg?n el est?ndar WCS, si se especifica bounding box el par?metro TIME
|
718 | * no es necesario. ?ste es el caso de gvSIG, que siempre especifica BBOX
|
||
719 | * As? que, en teor?a, no deber?amos comprobar si se ha seleccionado algo
|
||
720 | * o no. Pero en las pruebas, el servidor que us?bamos respond?a con una
|
||
721 | * cobertura en blanco (negro) as? que se ha optado por evitar que se pueda
|
||
722 | * consultar sin ninguna posici?n para el tiempo (siempre que la cobertura
|
||
723 | * especifique posiciones para el tiempo).
|
||
724 | 6122 | jaume | *
|
725 | 3166 | jaume | * En cualquier caso con comentarizar la l?nea basta.
|
726 | */
|
||
727 | 4573 | jaume | if (timeRequired() && getTime()==null) return false; |
728 | 3166 | jaume | if (getCmbParam().getSelectedItem()!=null){ |
729 | 4573 | jaume | if (parameterType == SINGLE_VALUE && getParameterString()==null) return false; |
730 | if (parameterType == INTERVAL) {
|
||
731 | 3166 | jaume | } |
732 | } |
||
733 | if (getSRS()==null) return false; |
||
734 | if (getFormat()==null) return false; |
||
735 | 6122 | jaume | |
736 | 3166 | jaume | return true; |
737 | } |
||
738 | 6122 | jaume | |
739 | 3166 | jaume | /**
|
740 | 4573 | jaume | * Extracts the parameter query string.
|
741 | * @return
|
||
742 | 3166 | jaume | */
|
743 | 4573 | jaume | public String getParameterString() { |
744 | FMapWCSParameter p = (FMapWCSParameter) getCmbParam().getSelectedItem(); |
||
745 | if (p == null) return null; |
||
746 | // TODO missing intervals!!!
|
||
747 | if (p.getType() == FMapWCSParameter.VALUE_LIST) {
|
||
748 | Object[] v = getSingleParamValuesList().getSelectedValues(); |
||
749 | if (p!=null && v.length>0) { |
||
750 | String s = p.getName() + "=" + (String) v[0]; |
||
751 | for (int i = 1; i < v.length; i++) { |
||
752 | s += ","+v[i];
|
||
753 | 3166 | jaume | } |
754 | 6286 | jaume | System.out.println(s);
|
755 | 4573 | jaume | return s;
|
756 | 3166 | jaume | } |
757 | } |
||
758 | return null; |
||
759 | } |
||
760 | 6122 | jaume | /**
|
761 | 3166 | jaume | * True if the TIME parameter is required, else false.
|
762 | 6122 | jaume | *
|
763 | 3166 | jaume | * True si se requiere especificar una posici?n para el tiempo.
|
764 | * (jo crec que a?? no val per a res, per? per si de cas la tinc)
|
||
765 | 6122 | jaume | *
|
766 | 3166 | jaume | * @return
|
767 | */
|
||
768 | private boolean timeRequired(){ |
||
769 | 4573 | jaume | return getLstTimes().getModel().getSize() > 0; |
770 | 3166 | jaume | } |
771 | 6122 | jaume | |
772 | 3166 | jaume | /**
|
773 | 4573 | jaume | * Returns the time positions or null if none.
|
774 | 3166 | jaume | * @return String
|
775 | */
|
||
776 | 4573 | jaume | public String getTime(){ |
777 | 6286 | jaume | String[] ss = new String[getLstSelectedTimes().getModel().getSize()]; |
778 | for (int i = 0; i < ss.length; i++) { |
||
779 | ss[i] = (String) getLstSelectedTimes().getModel().getElementAt(i);
|
||
780 | } |
||
781 | 3166 | jaume | String s = null; |
782 | 6286 | jaume | if (ss.length > 0){ |
783 | s = ss[0];
|
||
784 | for (int i = 1; i < ss.length; i++) { |
||
785 | s += ","+ ss[i];
|
||
786 | 3166 | jaume | } |
787 | } |
||
788 | 6286 | jaume | System.out.println(s);
|
789 | 3166 | jaume | return s;
|
790 | } |
||
791 | 6122 | jaume | |
792 | 3166 | jaume | /**
|
793 | * Returns the selected CRS.
|
||
794 | 6122 | jaume | *
|
795 | 3166 | jaume | * Devuelve el CRS seleccionado.
|
796 | 6122 | jaume | *
|
797 | 3166 | jaume | * @return String
|
798 | */
|
||
799 | public String getSRS() { |
||
800 | return (String) getLstCRSs().getSelectedValue(); |
||
801 | } |
||
802 | 6122 | jaume | |
803 | 3166 | jaume | /**
|
804 | * Returns the selected format.
|
||
805 | 6122 | jaume | *
|
806 | 3166 | jaume | * Devuelve el formato seleccionado.
|
807 | 6122 | jaume | *
|
808 | 3166 | jaume | * @return String
|
809 | */
|
||
810 | public String getFormat() { |
||
811 | return (String) getLstFormats().getSelectedValue(); |
||
812 | } |
||
813 | 6122 | jaume | |
814 | 3166 | jaume | /**
|
815 | * Returns the name of the selected coverage.
|
||
816 | 6122 | jaume | *
|
817 | 3166 | jaume | * Devuelve el nombre de la cobertura seleccionada.
|
818 | 6122 | jaume | *
|
819 | 3166 | jaume | * @return String
|
820 | */
|
||
821 | public String getLayerName() { |
||
822 | 4414 | jaume | return getTxtName().getText();
|
823 | 3166 | jaume | } |
824 | |||
825 | /**
|
||
826 | * Cleans up the wizard's components but the server's layers list.
|
||
827 | 6122 | jaume | *
|
828 | 3166 | jaume | * Limpia todos los componentes del wizard excepto la lista de capas del
|
829 | * servidor.
|
||
830 | */
|
||
831 | 4414 | jaume | public void cleanupWizard() { |
832 | 3166 | jaume | Object[] nada = new Object[0]; |
833 | 6122 | jaume | |
834 | 3166 | jaume | getLstCRSs().clearSelection(); |
835 | getLstCRSs().setListData(nada); |
||
836 | |||
837 | getLstFormats().clearSelection(); |
||
838 | getLstFormats().setListData(nada); |
||
839 | |||
840 | 4573 | jaume | getLstTimes().clearSelection(); |
841 | getLstTimes().setListData(nada); |
||
842 | 3166 | jaume | |
843 | getLstSelectedTimes().clearSelection(); |
||
844 | getLstSelectedTimes().setListData(nada); |
||
845 | |||
846 | getCmbParam().removeAllItems(); |
||
847 | getSingleParamValuesList().setVisible(true);
|
||
848 | |||
849 | getSingleParamValuesList().clearSelection(); |
||
850 | getSingleParamValuesList().setListData(nada); |
||
851 | } |
||
852 | |||
853 | /**
|
||
854 | 4573 | jaume | * Returns the selected coverage name at the server. This is the value to use
|
855 | * in a GetCoverage request
|
||
856 | 6122 | jaume | *
|
857 | 3166 | jaume | * @return String
|
858 | */
|
||
859 | 4356 | jaume | public String getCurrentCoverageName(){ |
860 | 4414 | jaume | if (getLstCoverages().getSelectedValue()==null) return null; |
861 | 6122 | jaume | return ((WCSLayer) getLstCoverages().getSelectedValue()).getName();
|
862 | 3166 | jaume | } |
863 | |||
864 | /**
|
||
865 | * Refreshes the wizard components data each time a coverage is selected.
|
||
866 | 6122 | jaume | *
|
867 | 3166 | jaume | * Actualiza los datos de los componentes del wizard cada vez que se selecciona
|
868 | * una cobertura diferente.
|
||
869 | */
|
||
870 | 4414 | jaume | public void refreshData(){ |
871 | 4356 | jaume | String coverageName = getCurrentCoverageName();
|
872 | 4414 | jaume | cleanupWizard(); |
873 | 4356 | jaume | if (coverageName != null){ |
874 | WCSLayer lyr = data.getLayer(coverageName); |
||
875 | 4414 | jaume | getTxtName().setText(lyr.getTitle()); |
876 | 6122 | jaume | |
877 | 4414 | jaume | // CRS
|
878 | 3166 | jaume | getLstCRSs().clearSelection(); |
879 | 4356 | jaume | getLstCRSs().setListData(lyr.getSRSs().toArray()); |
880 | 3166 | jaume | |
881 | 4414 | jaume | // Formats
|
882 | 3166 | jaume | getLstFormats().clearSelection(); |
883 | 4356 | jaume | getLstFormats().setListData(lyr.getFormats().toArray()); |
884 | 6122 | jaume | |
885 | 4573 | jaume | // InterpolationMethods
|
886 | boolean b = lyr.getInterpolationMethods() != null; |
||
887 | cmbInterpolationMethods.removeAllItems(); |
||
888 | if (b) {
|
||
889 | ArrayList im = lyr.getInterpolationMethods();
|
||
890 | 6122 | jaume | for (int i = 0; i < im.size(); i++) |
891 | 4573 | jaume | cmbInterpolationMethods.addItem(im.get(i)); |
892 | } |
||
893 | getChkUseInterpolationMethod().setEnabled(b); |
||
894 | getCmbInterpolationMethods().setEnabled(b); |
||
895 | 6122 | jaume | |
896 | 4414 | jaume | // Time
|
897 | 4573 | jaume | getLstTimes().removeAll(); |
898 | ArrayList list = lyr.getTimePositions();
|
||
899 | b = !(list == null || list.isEmpty());
|
||
900 | 6122 | jaume | if (b)
|
901 | 4573 | jaume | getLstTimes().setListData(list.toArray()); |
902 | jTabbedPane.setEnabledAt(indTime, b); |
||
903 | 6122 | jaume | |
904 | 4573 | jaume | // Parameters
|
905 | cmbParam.removeAllItems(); |
||
906 | list = lyr.getParameterList(); |
||
907 | b = !(list == null || list.isEmpty());
|
||
908 | if (b) {
|
||
909 | 6122 | jaume | for (int i = 0; i < list.size(); i++) |
910 | 4573 | jaume | cmbParam.addItem(list.get(i)); |
911 | getSingleParamValuesList().setListData( |
||
912 | ((FMapWCSParameter) cmbParam.getSelectedItem()).getValueList().toArray() |
||
913 | ); |
||
914 | 4414 | jaume | } |
915 | 4573 | jaume | jTabbedPane.setEnabledAt(indParameter, b); |
916 | fireWizardComplete(isCorretlyConfigured()); |
||
917 | 6122 | jaume | } |
918 | 3166 | jaume | } |
919 | |||
920 | /**
|
||
921 | * Sets the object that holds the wizard data.
|
||
922 | 6122 | jaume | *
|
923 | 3166 | jaume | * Establece el objeto que contiene los datos del wizard.
|
924 | 6122 | jaume | *
|
925 | 3166 | jaume | * @param data
|
926 | */
|
||
927 | public void setWizardData(WCSWizardData data) { |
||
928 | this.data = data;
|
||
929 | 6442 | jaume | getLstCoverages().setListData(data.getCoverageList()); |
930 | 4614 | jaume | refreshInfo(); |
931 | 6122 | jaume | |
932 | 3166 | jaume | } |
933 | 6122 | jaume | |
934 | 3166 | jaume | /**
|
935 | * Adds the selected items from the time list to the selected times list.
|
||
936 | 6122 | jaume | *
|
937 | * A?ade los items seleccionados de la lista de tiempos a la
|
||
938 | 3166 | jaume | * lista de tiempos seleccionados.
|
939 | */
|
||
940 | 4573 | jaume | public void addTime() { |
941 | ArrayList times = new ArrayList(); |
||
942 | 3166 | jaume | for (int i = 0; i < getLstSelectedTimes() |
943 | .getModel().getSize(); i++) { |
||
944 | 4573 | jaume | times.add(getLstSelectedTimes().getModel() |
945 | 3166 | jaume | .getElementAt(i)); |
946 | } |
||
947 | |||
948 | 4573 | jaume | Object[] obj = getLstTimes().getSelectedValues(); |
949 | 3166 | jaume | for (int i = 0; i < obj.length; i++) { |
950 | 4573 | jaume | if (!times.contains(obj[i]))
|
951 | times.add(obj[i]); |
||
952 | 3166 | jaume | } |
953 | getLstSelectedTimes() |
||
954 | 4573 | jaume | .setListData(times.toArray()); |
955 | fireWizardComplete(isCorretlyConfigured()); |
||
956 | 3166 | jaume | } |
957 | 6122 | jaume | |
958 | 3166 | jaume | /**
|
959 | * Removes the selected items from the selected times list.
|
||
960 | 6122 | jaume | *
|
961 | 3166 | jaume | * Quita posiciones de tiempo de la lista de tiempos seleccionados.
|
962 | */
|
||
963 | 4573 | jaume | public void delTime() { |
964 | 3166 | jaume | ArrayList tiempos = new ArrayList(); |
965 | Object[] obj = getLstSelectedTimes() |
||
966 | .getSelectedValues(); |
||
967 | for (int i = 0; i < getLstSelectedTimes() |
||
968 | .getModel().getSize(); i++) |
||
969 | tiempos.add(getLstSelectedTimes().getModel() |
||
970 | .getElementAt(i)); |
||
971 | |||
972 | for (int j = 0; j < obj.length; j++) |
||
973 | if (tiempos.contains(obj[j]))
|
||
974 | tiempos.remove(obj[j]); |
||
975 | obj = new Object[tiempos.size()]; |
||
976 | for (int i = 0; i < obj.length; i++) { |
||
977 | obj[i] = tiempos.get(i); |
||
978 | } |
||
979 | getLstSelectedTimes() |
||
980 | .setListData(tiempos.toArray()); |
||
981 | 4573 | jaume | fireWizardComplete(isCorretlyConfigured()); |
982 | 3166 | jaume | } |
983 | 6122 | jaume | |
984 | 3166 | jaume | /**
|
985 | 4573 | jaume | * The coverage name (will be used at the TOC)
|
986 | 6122 | jaume | *
|
987 | 3166 | jaume | * La etiqueta de la cobertura
|
988 | * @return String
|
||
989 | */
|
||
990 | 4573 | jaume | public String getCoverageName() { |
991 | 4414 | jaume | return getTxtName().getText();
|
992 | 3166 | jaume | } |
993 | 6122 | jaume | |
994 | 3166 | jaume | /**
|
995 | * Returns the extent of the currently selected coverage for the currently
|
||
996 | * selected SRS.
|
||
997 | 6122 | jaume | *
|
998 | 3166 | jaume | * Devuelve el Extent de la cobertura actualmente seleccionada para el SRS
|
999 | * actualmente seleccionado
|
||
1000 | 6122 | jaume | *
|
1001 | 3166 | jaume | * @return Rectangle2D
|
1002 | */
|
||
1003 | 4356 | jaume | public Rectangle2D getExtent() { |
1004 | 4573 | jaume | String cName = getCurrentCoverageName();
|
1005 | if (cName!=null) { |
||
1006 | return data.getLayer(cName).getExtent(getSRS());
|
||
1007 | } |
||
1008 | return null; |
||
1009 | 3166 | jaume | } |
1010 | 6122 | jaume | |
1011 | 3166 | jaume | /**
|
1012 | * Sets the wizard's data source
|
||
1013 | 6122 | jaume | *
|
1014 | 3166 | jaume | * Establece el origen de los datos del wizard
|
1015 | * @param dataSource
|
||
1016 | */
|
||
1017 | 4356 | jaume | public void setDataSource(WCSWizardData dataSource) { |
1018 | this.data = dataSource;
|
||
1019 | 6122 | jaume | |
1020 | 3166 | jaume | } |
1021 | /**
|
||
1022 | * Returns the index of the coverage within the coverages list
|
||
1023 | 6122 | jaume | *
|
1024 | 3166 | jaume | * Devuelve la posici?n que ocupa la cobertura en la lista de coberturas
|
1025 | 6122 | jaume | *
|
1026 | 3166 | jaume | * @param coverageName
|
1027 | * @return The coverage's index if it exists, -1 if it not exists.
|
||
1028 | */
|
||
1029 | public int getCoverageIndex(String coverageName) { |
||
1030 | for (int i=0; i<getLstCoverages().getModel().getSize(); i++){ |
||
1031 | 4614 | jaume | if (coverageName.equals(((WCSLayer)getLstCoverages().getModel().getElementAt(i)).getName()))
|
1032 | 3166 | jaume | return i;
|
1033 | } |
||
1034 | return -1; |
||
1035 | } |
||
1036 | 6122 | jaume | |
1037 | 3166 | jaume | /**
|
1038 | * Returns the index of the CRS within the CRS list.
|
||
1039 | 6122 | jaume | *
|
1040 | 3166 | jaume | * Devuelve la posicion que ocupa el CRS en la lista de CRS
|
1041 | 6122 | jaume | *
|
1042 | 3166 | jaume | * @param crs
|
1043 | * @return The CRS's index if it exists, -1 if it not exists.
|
||
1044 | */
|
||
1045 | public int getSRSIndex(String crs) { |
||
1046 | for (int i=0; i<getLstCRSs().getModel().getSize(); i++){ |
||
1047 | if (crs.equals(getLstCRSs().getModel().getElementAt(i)))
|
||
1048 | return i;
|
||
1049 | } |
||
1050 | return -1; |
||
1051 | } |
||
1052 | 6122 | jaume | |
1053 | 3166 | jaume | /**
|
1054 | * Returns the index of the format within the formats list.
|
||
1055 | 6122 | jaume | *
|
1056 | 3166 | jaume | * Devuelve la posicion que ocupa el formato en la lista de formatos
|
1057 | * @param format
|
||
1058 | 6122 | jaume | *
|
1059 | 3166 | jaume | * @return The format's index if it exists, -1 if it not exists.
|
1060 | */
|
||
1061 | public int getFormatIndex(String format) { |
||
1062 | for (int i=0; i<getLstFormats().getModel().getSize(); i++){ |
||
1063 | if (format.equals(getLstFormats().getModel().getElementAt(i)))
|
||
1064 | return i;
|
||
1065 | } |
||
1066 | return -1; |
||
1067 | } |
||
1068 | 6122 | jaume | |
1069 | 3166 | jaume | /**
|
1070 | * Returns the parameter's name's index within the cmbBox.
|
||
1071 | 6122 | jaume | *
|
1072 | 3166 | jaume | * Devuelve la posicion que ocupa el nombre dle par?metro en el comboBox
|
1073 | * de par?metros
|
||
1074 | 6122 | jaume | *
|
1075 | 3166 | jaume | * @param nParam
|
1076 | * @return The index if it exists, -1 if it not exists.
|
||
1077 | */
|
||
1078 | public int getParamIndex(String nParam) { |
||
1079 | for (int i=0; i<getCmbParam().getModel().getSize(); i++){ |
||
1080 | 4615 | jaume | if (nParam.equals(((FMapWCSParameter)getCmbParam().getItemAt(i)).getName()))
|
1081 | 3166 | jaume | return i;
|
1082 | } |
||
1083 | return -1; |
||
1084 | } |
||
1085 | 6122 | jaume | |
1086 | 3166 | jaume | /**
|
1087 | * Returns the position for the parameter's value within the parameter
|
||
1088 | * values list.
|
||
1089 | 6122 | jaume | *
|
1090 | 3166 | jaume | * Devuelve la posicion que ocupa el valor para parametro
|
1091 | * en la lista de valores para par?metro
|
||
1092 | 6122 | jaume | *
|
1093 | 3166 | jaume | * @param valor
|
1094 | * @return The index if it exists, -1 if it not exists.
|
||
1095 | */
|
||
1096 | public int getValueIndex(String valor) { |
||
1097 | for (int i=0; i<getSingleParamValuesList().getModel().getSize(); i++){ |
||
1098 | if (valor.equals(getSingleParamValuesList().getModel().getElementAt(i)))
|
||
1099 | return i;
|
||
1100 | } |
||
1101 | return -1; |
||
1102 | } |
||
1103 | 6122 | jaume | |
1104 | 3166 | jaume | /**
|
1105 | * Returns the max supported resolution for the coverage.
|
||
1106 | 6122 | jaume | *
|
1107 | 3166 | jaume | * Recupera la resoluci?n m?xima soportada por la cobertura.
|
1108 | * @return double
|
||
1109 | */
|
||
1110 | public Point2D getMaxRes(){ |
||
1111 | 4356 | jaume | return data.getLayer(getCurrentCoverageName()).getMaxRes();
|
1112 | 3166 | jaume | } |
1113 | /**
|
||
1114 | * Returns the next enabled tab's index.
|
||
1115 | 6122 | jaume | *
|
1116 | 3166 | jaume | * Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay
|
1117 | * ninguna.
|
||
1118 | 6122 | jaume | *
|
1119 | 3166 | jaume | * @return The index or -1 if there is no one.
|
1120 | */
|
||
1121 | public int nextPageEnabled() { |
||
1122 | int currentPage = currentPage();
|
||
1123 | int nPages = getNumTabs();
|
||
1124 | if (currentPage == nPages)
|
||
1125 | return -1; |
||
1126 | for (int i=currentPage+1; i<nPages; i++){ |
||
1127 | if (getJTabbedPane().isEnabledAt(i)){
|
||
1128 | return i;
|
||
1129 | } |
||
1130 | } |
||
1131 | return -1; |
||
1132 | } |
||
1133 | 6122 | jaume | |
1134 | 3166 | jaume | /**
|
1135 | * Returns the index of the current tab.
|
||
1136 | 6122 | jaume | *
|
1137 | 3166 | jaume | * Devuelve el ?ndice de la p?gina actual del wizard.
|
1138 | 6122 | jaume | *
|
1139 | 3166 | jaume | * @return
|
1140 | */
|
||
1141 | 4356 | jaume | public int currentPage() { |
1142 | 3166 | jaume | return getJTabbedPane().getSelectedIndex();
|
1143 | } |
||
1144 | 6122 | jaume | |
1145 | 3166 | jaume | /**
|
1146 | * Returns the index of the previous enabled tab.
|
||
1147 | 6122 | jaume | *
|
1148 | 3166 | jaume | * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
|
1149 | * ninguna.
|
||
1150 | 6122 | jaume | *
|
1151 | 3166 | jaume | * @return The index, or -1 if there is no one.
|
1152 | */
|
||
1153 | 4356 | jaume | public int previousEnabledPage() { |
1154 | 3166 | jaume | int currentPage = currentPage();
|
1155 | int j=0; |
||
1156 | if (currentPage == 0) |
||
1157 | j= -1;
|
||
1158 | for (int i = currentPage-1; i>-1; i--){ |
||
1159 | if (getJTabbedPane().isEnabledAt(i)){
|
||
1160 | j= i; |
||
1161 | break;
|
||
1162 | } |
||
1163 | } |
||
1164 | return j;
|
||
1165 | } |
||
1166 | 4573 | jaume | |
1167 | 4356 | jaume | public FMapWCSDriver getDriver() {
|
1168 | return data.getDriver();
|
||
1169 | } |
||
1170 | 4398 | jaume | public void initWizard() { } |
1171 | public void execute() { } |
||
1172 | public FLayer getLayer() { return null; } |
||
1173 | public void setListenerSupport(WizardListenerSupport support) { |
||
1174 | listenerSupport = support; |
||
1175 | } |
||
1176 | 4417 | jaume | /**
|
1177 | 6122 | jaume | * This method initializes jComboBox
|
1178 | *
|
||
1179 | * @return javax.swing.JComboBox
|
||
1180 | 4417 | jaume | */
|
1181 | private JComboBox getCmbInterpolationMethods() { |
||
1182 | if (cmbInterpolationMethods == null) { |
||
1183 | cmbInterpolationMethods = new JComboBox(); |
||
1184 | 6501 | jaume | cmbInterpolationMethods.setBounds(new java.awt.Rectangle(273,45,215,20)); |
1185 | 4417 | jaume | cmbInterpolationMethods.setEnabled(false);
|
1186 | cmbInterpolationMethods.setEditable(false);
|
||
1187 | } |
||
1188 | return cmbInterpolationMethods;
|
||
1189 | } |
||
1190 | /**
|
||
1191 | 6122 | jaume | * This method initializes jCheckBox
|
1192 | *
|
||
1193 | * @return javax.swing.JCheckBox
|
||
1194 | 4417 | jaume | */
|
1195 | private JCheckBox getChkUseInterpolationMethod() { |
||
1196 | if (chkUseInterpolationMethod == null) { |
||
1197 | chkUseInterpolationMethod = new JCheckBox(); |
||
1198 | chkUseInterpolationMethod.setText(PluginServices.getText(this, "use_interpolation_method")); |
||
1199 | chkUseInterpolationMethod.setSelected(false);
|
||
1200 | 4614 | jaume | chkUseInterpolationMethod.setEnabled(false);
|
1201 | 6501 | jaume | chkUseInterpolationMethod.setBounds(new java.awt.Rectangle(273,19,210,20)); |
1202 | 4417 | jaume | chkUseInterpolationMethod.addItemListener(new java.awt.event.ItemListener() {
|
1203 | public void itemStateChanged(java.awt.event.ItemEvent e) { |
||
1204 | cmbInterpolationMethods.setEnabled(chkUseInterpolationMethod.isSelected()); |
||
1205 | } |
||
1206 | }); |
||
1207 | } |
||
1208 | return chkUseInterpolationMethod;
|
||
1209 | } |
||
1210 | 3166 | jaume | } |