root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSAreaPanel.java @ 10116
History | View | Annotate | Download (45.1 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Rectangle; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.FocusAdapter; |
10 |
import java.awt.event.FocusEvent; |
11 |
import java.awt.event.FocusListener; |
12 |
import java.awt.geom.Rectangle2D; |
13 |
import java.io.Serializable; |
14 |
|
15 |
import javax.swing.ImageIcon; |
16 |
import javax.swing.JComboBox; |
17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JOptionPane; |
19 |
import javax.swing.JPanel; |
20 |
import javax.swing.JRadioButton; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.SwingConstants; |
23 |
|
24 |
import com.iver.andami.PluginServices; |
25 |
import com.iver.cit.gvsig.fmap.MapControl; |
26 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
27 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
28 |
import com.iver.utiles.stringNumberUtilities.StringNumberUtilities; |
29 |
|
30 |
import javax.swing.JButton; |
31 |
|
32 |
import org.gvsig.gui.beans.swing.jComboBoxWithImageIconItems.ImageIconItemInfo; |
33 |
import org.gvsig.gui.beans.swing.jComboBoxWithImageIconItems.JPanelWithJComboBoxImageIconItems; |
34 |
import org.gvsig.gui.beans.swing.jTextFieldWithSpecificCaretPosition.JTextFieldWithSpecificCaretPosition; |
35 |
|
36 |
|
37 |
|
38 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
39 |
*
|
40 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
41 |
*
|
42 |
* This program is free software; you can redistribute it and/or
|
43 |
* modify it under the terms of the GNU General Public License
|
44 |
* as published by the Free Software Foundation; either version 2
|
45 |
* of the License, or (at your option) any later version.
|
46 |
*
|
47 |
* This program is distributed in the hope that it will be useful,
|
48 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
49 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
50 |
* GNU General Public License for more details.
|
51 |
*
|
52 |
* You should have received a copy of the GNU General Public License
|
53 |
* along with this program; if not, write to the Free Software
|
54 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
55 |
*
|
56 |
* For more information, contact:
|
57 |
*
|
58 |
* Generalitat Valenciana
|
59 |
* Conselleria d'Infraestructures i Transport
|
60 |
* Av. Blasco Ib??ez, 50
|
61 |
* 46010 VALENCIA
|
62 |
* SPAIN
|
63 |
*
|
64 |
* +34 963862235
|
65 |
* gvsig@gva.es
|
66 |
* www.gvsig.gva.es
|
67 |
*
|
68 |
* or
|
69 |
*
|
70 |
* IVER T.I. S.A
|
71 |
* Salamanca 50
|
72 |
* 46005 Valencia
|
73 |
* Spain
|
74 |
*
|
75 |
* +34 963163400
|
76 |
* dac@iver.es
|
77 |
*/
|
78 |
/* CVS MESSAGES:
|
79 |
*
|
80 |
* $Id: WFSAreaPanel.java 10116 2007-02-05 13:49:26Z ppiqueras $
|
81 |
* $Log$
|
82 |
* Revision 1.10 2007-02-05 13:49:26 ppiqueras
|
83 |
* Mejorada la interfaz y a?adidos componentes de tipo lista desplegable con iconos como ?tems.
|
84 |
*
|
85 |
* Revision 1.9 2007/02/02 12:22:03 ppiqueras
|
86 |
* Mejorada la interfaz.
|
87 |
*
|
88 |
* Revision 1.8 2007/01/26 14:23:56 ppiqueras
|
89 |
* Mejorada la interfaz
|
90 |
*
|
91 |
* Revision 1.7 2007/01/25 14:37:16 ppiqueras
|
92 |
* Utiliza JTextFieldWithSpecificCaretPosition
|
93 |
*
|
94 |
* Revision 1.6 2007/01/25 09:31:09 ppiqueras
|
95 |
* Mejorada la interfaz.
|
96 |
*
|
97 |
* Revision 1.5 2007/01/19 14:24:30 ppiqueras
|
98 |
* + Avanzada.
|
99 |
*
|
100 |
* Revision 1.4 2007/01/12 13:09:41 jorpiell
|
101 |
* added searches by area
|
102 |
*
|
103 |
* Revision 1.3 2007/01/10 09:01:25 jorpiell
|
104 |
* The coordinates panel is opened with the view coordinates
|
105 |
*
|
106 |
* Revision 1.2 2006/12/22 11:45:53 jorpiell
|
107 |
* Actualizado el driver del WFS
|
108 |
*
|
109 |
* Revision 1.1 2006/10/10 12:55:06 jorpiell
|
110 |
* Se ha a?adido el soporte de features complejas
|
111 |
*
|
112 |
*
|
113 |
*/
|
114 |
|
115 |
/**
|
116 |
* This panel allows user to select the area he/she wants to get in the view.
|
117 |
* There are two options to do this:
|
118 |
* - Indicating the coordinates of the top-left and down-right corners
|
119 |
* - Selecting the area with the mouse
|
120 |
*
|
121 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
122 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
123 |
*/
|
124 |
public class WFSAreaPanel extends JPanel { |
125 |
private final Rectangle DEFAULT_BOUNDS = new Rectangle(10, 5, 490, 380); |
126 |
private final Rectangle DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE = new Rectangle(8, 20, 481, 60); |
127 |
private final Rectangle DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE = new Rectangle(8, 115, 481, 265); |
128 |
|
129 |
// private final Rectangle DEFAULT_COORDINATES_CHECKBOX_RECTANGLE = new Rectangle(6, 19, 445, 20);
|
130 |
private final Rectangle DEFAULT_ERASER_ICON_BUTTON_RECTANGLE = new Rectangle (250, 85, 25, 25); |
131 |
private final Rectangle DEFAULT_PAN_ICON_BUTTON_RECTANGLE = new Rectangle(250, 85, 25, 25); |
132 |
private final Rectangle DEFAULT_TOOL_JCOMBOBOX_RECTANGLE = new Rectangle(10, 87, 230, 21); |
133 |
private final Rectangle DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE = new Rectangle(277, 85, 47, 25); |
134 |
// private final Rectangle DEFAULT_ZOOMIN_ICON_BUTTON_RECTANGLE = new Rectangle(297,100,25,25);
|
135 |
// private final Rectangle DEFAULT_ZOOMOUT_ICON_BUTTON_RECTANGLE = new Rectangle(324,100,25,25);
|
136 |
private final Rectangle DEFAULT_ZOOMRECTANGLESELECTION_ICON_BUTTON_RECTANGLE = new Rectangle(326, 85, 25, 25); |
137 |
private final Rectangle DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE = new Rectangle(353, 85, 25, 25); |
138 |
private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(380, 85, 25, 25); |
139 |
private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE = new Rectangle(407, 85, 47, 25); |
140 |
// private final Rectangle DEFAULT_ZOOMINVIEWCENTERED_ICON_BUTTON_RECTANGLE = new Rectangle(378,100,25,25);
|
141 |
// private final Rectangle DEFAULT_ZOOMOUTVIEWCENTERED_ICON_BUTTON_RECTANGLE = new Rectangle(405,100,25,25);
|
142 |
private final Rectangle DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V1 = new Rectangle(277, 85, 25, 25); |
143 |
private final Rectangle DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V2 = new Rectangle(456, 85, 25, 25); |
144 |
// private final Rectangle DEFAULT_TOOLS_ICON_BUTTON_RECTANGLE = new Rectangle(459,100,25,25);
|
145 |
|
146 |
private final int DISABLED_OPERATION = 0; |
147 |
private final int SELECTION_BY_COORDINATES_OPERATION = 1; |
148 |
private final int SELECTION_BY_AREA_OPERATION = 2; |
149 |
|
150 |
private WFSWizardData data = null; |
151 |
private WFSParamsPanel parent = null; |
152 |
private AreaCoordinatesPanel coordinatesPanel = null; |
153 |
private AreaMapControlPanel areaMapControlPanel = null; |
154 |
private JComboBox jComboBoxToolSelection = null; |
155 |
private JButton jButtonEraser = null; |
156 |
private JButton jButtonPan = null; |
157 |
// private JButton jButtonZoomIn = null;
|
158 |
// private JButton jButtonZoomOut = null;
|
159 |
private JButton jButtonZoomRectangleSelection = null; |
160 |
private JButton jButtonZoomPrevious = null; |
161 |
private JButton jButtonZoomComplete = null; |
162 |
// private JButton jButtonZoomInViewCentered = null;
|
163 |
// private JButton jButtonZoomOutViewCentered = null;
|
164 |
private JButton jButtonInfo = null; |
165 |
// private JButton jButtonTools = null;
|
166 |
private JPanelWithJComboBoxImageIconItems jComboBoxZoomInAndOut = null; |
167 |
private JPanelWithJComboBoxImageIconItems jComboBoxZoomInAndOutViewCentered = null; |
168 |
|
169 |
/**
|
170 |
* This method initializes
|
171 |
*/
|
172 |
public WFSAreaPanel(WFSParamsPanel parent) {
|
173 |
super();
|
174 |
this.parent = parent;
|
175 |
initialize(); |
176 |
} |
177 |
|
178 |
/**
|
179 |
* This method initializes this
|
180 |
*/
|
181 |
private void initialize() { |
182 |
this.setLayout(null); |
183 |
this.setBounds(DEFAULT_BOUNDS);
|
184 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
185 |
null, PluginServices.getText(this, "select_by_area"), |
186 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
187 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
188 |
|
189 |
// Adds JPanel with the coordinates
|
190 |
this.add(getCoordinatesPanel(), null); |
191 |
|
192 |
// Adds JComboBox to select a part of the graphical interface
|
193 |
this.add(getJComboBoxToolSelection(), null); |
194 |
this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element |
195 |
|
196 |
// Adds Icons
|
197 |
// this.add(getJButtonPan(), null);
|
198 |
//// this.add(getJButtonZoomIn(), null);
|
199 |
//// this.add(getJButtonZoomOut(), null);
|
200 |
// this.add(getJComboBoxZoomInAndOut(), null);
|
201 |
// this.add(getJButtonZoomRectangleSelection(), null);
|
202 |
// this.add(getJButtonZoomPrevious(), null);
|
203 |
// this.add(getJButtonZoomComplete(), null);
|
204 |
// this.add(getJComboBoxZoomInAndOutViewCentered(), null);
|
205 |
// this.add(getJButtonInfo(), null);
|
206 |
|
207 |
// Adds Jpanel with the view
|
208 |
this.add(getAreaMapControlPanel(), null); |
209 |
// this.add(get, null);
|
210 |
|
211 |
initCoordinates(); |
212 |
} |
213 |
|
214 |
/**
|
215 |
* Write the view coordinates into the coordinates panel
|
216 |
*/
|
217 |
private void initCoordinates(){ |
218 |
View activeView =
|
219 |
(View) PluginServices.getMDIManager().getActiveWindow();
|
220 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getAdjustedExtent();
|
221 |
if (r2d != null){ |
222 |
getCoordinatesPanel().setExtent(r2d); |
223 |
} |
224 |
} |
225 |
|
226 |
/**
|
227 |
* This method initializes coordinatesPanel
|
228 |
*
|
229 |
* @return javax.swing.JPanel
|
230 |
*/
|
231 |
private AreaCoordinatesPanel getCoordinatesPanel() {
|
232 |
if (coordinatesPanel == null) { |
233 |
coordinatesPanel = new AreaCoordinatesPanel();
|
234 |
} |
235 |
return coordinatesPanel;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* This method initializes jComboBoxToolSelection
|
240 |
*
|
241 |
* @return javax.swing.JComboBox
|
242 |
*/
|
243 |
private JComboBox getJComboBoxToolSelection() { |
244 |
if (jComboBoxToolSelection == null) { |
245 |
jComboBoxToolSelection = new JComboBox(); |
246 |
jComboBoxToolSelection.setBounds(DEFAULT_TOOL_JCOMBOBOX_RECTANGLE); |
247 |
jComboBoxToolSelection.setToolTipText(PluginServices.getText(this, "select_a_tool")); |
248 |
jComboBoxToolSelection.setEditable(false);
|
249 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION)); |
250 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION)); |
251 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION)); |
252 |
|
253 |
jComboBoxToolSelection.addActionListener(new ActionListener() { |
254 |
/*
|
255 |
* (non-Javadoc)
|
256 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
257 |
*/
|
258 |
public void actionPerformed(ActionEvent e) { |
259 |
JComboBox cb = (JComboBox)e.getSource(); |
260 |
switch(((ItemOperation)cb.getSelectedItem()).getOperation()) {
|
261 |
case DISABLED_OPERATION:
|
262 |
disableCoorderatesRegionOperation(); |
263 |
disableAreaRegionOperation(); |
264 |
// getJButtonInfo().setEnabled(false);
|
265 |
break;
|
266 |
case SELECTION_BY_COORDINATES_OPERATION:
|
267 |
disableAreaRegionOperation(); |
268 |
enableCoorderatesRegionOperation(); |
269 |
// getJButtonInfo().setEnabled(true);
|
270 |
break;
|
271 |
case SELECTION_BY_AREA_OPERATION:
|
272 |
disableCoorderatesRegionOperation(); |
273 |
enableAreaRegionOperation(); |
274 |
// getJButtonInfo().setEnabled(true);
|
275 |
break;
|
276 |
} |
277 |
} |
278 |
}); |
279 |
} |
280 |
return jComboBoxToolSelection;
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* Enables the components associated to the selection of area by coordinates
|
285 |
*/
|
286 |
private void enableCoorderatesRegionOperation() { |
287 |
// Adds associated icons
|
288 |
this.add(getJButtonEraser(), null); |
289 |
this.add(getJButtonInfo(), null); |
290 |
|
291 |
getCoordinatesPanel().setAllTextFieldsEnabled(true);
|
292 |
} |
293 |
|
294 |
/**
|
295 |
* Enables the components associated to the selection of area by view
|
296 |
*/
|
297 |
private void enableAreaRegionOperation() { |
298 |
// Adds associated icons
|
299 |
this.add(getJButtonPan(), null); |
300 |
// this.add(getJButtonZoomIn(), null);
|
301 |
// this.add(getJButtonZoomOut(), null);
|
302 |
this.add(getJComboBoxZoomInAndOut(), null); |
303 |
this.add(getJButtonZoomRectangleSelection(), null); |
304 |
this.add(getJButtonZoomPrevious(), null); |
305 |
this.add(getJButtonZoomComplete(), null); |
306 |
this.add(getJComboBoxZoomInAndOutViewCentered(), null); |
307 |
this.add(getJButtonInfo(), null); |
308 |
|
309 |
// Enables the icons
|
310 |
// getJButtonPan().setEnabled(true);
|
311 |
// getJComboBoxZoomInAndOut().setEnabled(true);
|
312 |
// getJButtonZoomRectangleSelection().setEnabled(true);
|
313 |
// getJButtonZoomPrevious().setEnabled(true);
|
314 |
// getJButtonZoomComplete().setEnabled(true);
|
315 |
// getJComboBoxZoomInAndOutViewCentered().setEnabled(true);
|
316 |
|
317 |
// Enables the MapControl area
|
318 |
getAreaMapControlPanel().setEnabled(true);
|
319 |
} |
320 |
|
321 |
/**
|
322 |
* Disables the components associated to the selection of area by coordinates
|
323 |
*/
|
324 |
private void disableCoorderatesRegionOperation() { |
325 |
// Removes associated icons
|
326 |
this.remove(getJButtonEraser());
|
327 |
|
328 |
if (jButtonInfo != null) |
329 |
this.remove(jButtonInfo);
|
330 |
|
331 |
getCoordinatesPanel().setAllTextFieldsEnabled(false);
|
332 |
} |
333 |
|
334 |
/**
|
335 |
* Disables the components associated to the selection of area by view
|
336 |
*/
|
337 |
private void disableAreaRegionOperation() { |
338 |
// Removes associated icons
|
339 |
this.remove(getJButtonPan());
|
340 |
// this.add(getJButtonZoomIn(), null);
|
341 |
// this.add(getJButtonZoomOut(), null);
|
342 |
this.remove(getJComboBoxZoomInAndOut());
|
343 |
this.remove(getJButtonZoomRectangleSelection());
|
344 |
this.remove(getJButtonZoomPrevious());
|
345 |
this.remove(getJButtonZoomComplete());
|
346 |
this.remove(getJComboBoxZoomInAndOutViewCentered());
|
347 |
|
348 |
if (jButtonInfo != null) |
349 |
this.remove(jButtonInfo);
|
350 |
|
351 |
|
352 |
// Disables the icons
|
353 |
// getJButtonPan().setEnabled(false);
|
354 |
// getJComboBoxZoomInAndOut().setEnabled(false);
|
355 |
// getJButtonZoomRectangleSelection().setEnabled(false);
|
356 |
// getJButtonZoomPrevious().setEnabled(false);
|
357 |
// getJButtonZoomComplete().setEnabled(false);
|
358 |
// getJComboBoxZoomInAndOutViewCentered().setEnabled(false);
|
359 |
|
360 |
// Disables the MapControl area
|
361 |
getAreaMapControlPanel().setEnabled(false);
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* This method initializes areaMapControlPanel
|
366 |
*
|
367 |
* @return A reference to an object of AreaMapControlPanel
|
368 |
*/
|
369 |
private AreaMapControlPanel getAreaMapControlPanel() {
|
370 |
if (areaMapControlPanel == null) { |
371 |
areaMapControlPanel = new AreaMapControlPanel();
|
372 |
} |
373 |
|
374 |
return areaMapControlPanel;
|
375 |
} |
376 |
|
377 |
/**
|
378 |
* This method initializes jButtonEraser
|
379 |
*
|
380 |
* @return javax.swing.JButton
|
381 |
*/
|
382 |
private JButton getJButtonEraser() { |
383 |
if (jButtonEraser == null) { |
384 |
jButtonEraser = new JButton(); |
385 |
jButtonEraser.setBounds(DEFAULT_ERASER_ICON_BUTTON_RECTANGLE); |
386 |
jButtonEraser.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/eraser.png"))); |
387 |
jButtonEraser.setToolTipText(PluginServices.getText(this, "erases_coordinates")); |
388 |
} |
389 |
return jButtonEraser;
|
390 |
} |
391 |
|
392 |
/**
|
393 |
* This method initializes jButtonPan
|
394 |
*
|
395 |
* @return javax.swing.JButton
|
396 |
*/
|
397 |
private JButton getJButtonPan() { |
398 |
if (jButtonPan == null) { |
399 |
jButtonPan = new JButton(); |
400 |
jButtonPan.setBounds(DEFAULT_PAN_ICON_BUTTON_RECTANGLE); |
401 |
jButtonPan.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Pan.png"))); |
402 |
jButtonPan.setToolTipText(PluginServices.getText(this, "Desplazamiento")); |
403 |
} |
404 |
return jButtonPan;
|
405 |
} |
406 |
|
407 |
/**
|
408 |
* This method initializes jComboBoxZoomInAndOut
|
409 |
*
|
410 |
* @return
|
411 |
*/
|
412 |
private JPanelWithJComboBoxImageIconItems getJComboBoxZoomInAndOut() {
|
413 |
if (jComboBoxZoomInAndOut == null) { |
414 |
jComboBoxZoomInAndOut = new JPanelWithJComboBoxImageIconItems();
|
415 |
jComboBoxZoomInAndOut.setBounds(DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE); |
416 |
jComboBoxZoomInAndOut.addImageIcon(new ImageIconItemInfo("images/ZoomIn.png", new ImageIcon(getClass().getClassLoader().getResource("images/ZoomIn.png")), PluginServices.getText(this, "Zoom_Mas"))); |
417 |
jComboBoxZoomInAndOut.addImageIcon(new ImageIconItemInfo("images/ZoomOut.png", new ImageIcon(getClass().getClassLoader().getResource("images/ZoomOut.png")), PluginServices.getText(this, "Zoom_Menos"))); |
418 |
} |
419 |
return jComboBoxZoomInAndOut;
|
420 |
} |
421 |
|
422 |
// /**
|
423 |
// * This method initializes jButtonZoomOut
|
424 |
// *
|
425 |
// * @return javax.swing.JButton
|
426 |
// */
|
427 |
// private JButton getJButtonZoomOut() {
|
428 |
// if (jButtonZoomOut == null) {
|
429 |
// jButtonZoomOut = new JButton();
|
430 |
// jButtonZoomOut.setBounds(DEFAULT_ZOOMOUT_ICON_BUTTON_RECTANGLE);
|
431 |
// jButtonZoomOut.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomOut.png")));
|
432 |
// }
|
433 |
// return jButtonZoomOut;
|
434 |
// }
|
435 |
//
|
436 |
// /**
|
437 |
// * This method initializes jButtonZoomIn
|
438 |
// *
|
439 |
// * @return javax.swing.JButton
|
440 |
// */
|
441 |
// private JButton getJButtonZoomIn() {
|
442 |
// if (jButtonZoomIn == null) {
|
443 |
// jButtonZoomIn = new JButton();
|
444 |
// jButtonZoomIn.setBounds(DEFAULT_ZOOMIN_ICON_BUTTON_RECTANGLE);
|
445 |
// jButtonZoomIn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomIn.png")));
|
446 |
// }
|
447 |
// return jButtonZoomIn;
|
448 |
// }
|
449 |
|
450 |
/**
|
451 |
* This method initializes jButtonZoomRectangleSelection
|
452 |
*
|
453 |
* @return javax.swing.JButton
|
454 |
*/
|
455 |
private JButton getJButtonZoomRectangleSelection() { |
456 |
if (jButtonZoomRectangleSelection == null) { |
457 |
jButtonZoomRectangleSelection = new JButton(); |
458 |
jButtonZoomRectangleSelection.setBounds(DEFAULT_ZOOMRECTANGLESELECTION_ICON_BUTTON_RECTANGLE); |
459 |
jButtonZoomRectangleSelection.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomSeleccion.png"))); |
460 |
jButtonZoomRectangleSelection.setToolTipText(PluginServices.getText(this, "seleccionar_por_rectangulo")); |
461 |
} |
462 |
return jButtonZoomRectangleSelection;
|
463 |
} |
464 |
|
465 |
/**
|
466 |
* This method initializes jButtonZoomPrevious
|
467 |
*
|
468 |
* @return javax.swing.JButton
|
469 |
*/
|
470 |
private JButton getJButtonZoomPrevious() { |
471 |
if (jButtonZoomPrevious == null) { |
472 |
jButtonZoomPrevious = new JButton(); |
473 |
jButtonZoomPrevious.setBounds(DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE); |
474 |
jButtonZoomPrevious.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomPrevio.png"))); |
475 |
jButtonZoomPrevious.setToolTipText(PluginServices.getText(this, "Zoom_Previo")); |
476 |
} |
477 |
return jButtonZoomPrevious;
|
478 |
} |
479 |
|
480 |
/**
|
481 |
* This method initializes jButtonZoomComplete
|
482 |
*
|
483 |
* @return javax.swing.JButton
|
484 |
*/
|
485 |
private JButton getJButtonZoomComplete() { |
486 |
if (jButtonZoomComplete == null) { |
487 |
jButtonZoomComplete = new JButton(); |
488 |
jButtonZoomComplete.setBounds(DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE); |
489 |
jButtonZoomComplete.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/MapContents.png"))); |
490 |
jButtonZoomComplete.setToolTipText(PluginServices.getText(this, "Zoom_Completo")); |
491 |
} |
492 |
return jButtonZoomComplete;
|
493 |
} |
494 |
|
495 |
// /**
|
496 |
// * This method initializes jButtonZoomInViewCentered
|
497 |
// *
|
498 |
// * @return javax.swing.JButton
|
499 |
// */
|
500 |
// private JButton getJButtonZoomInViewCentered() {
|
501 |
// if (jButtonZoomInViewCentered == null) {
|
502 |
// jButtonZoomInViewCentered = new JButton();
|
503 |
// jButtonZoomInViewCentered.setBounds(DEFAULT_ZOOMINVIEWCENTERED_ICON_BUTTON_RECTANGLE);
|
504 |
// jButtonZoomInViewCentered.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/zoommas.png")));
|
505 |
// }
|
506 |
// return jButtonZoomInViewCentered;
|
507 |
// }
|
508 |
//
|
509 |
// /**
|
510 |
// * This method initializes jButtonZoomOutViewCentered
|
511 |
// *
|
512 |
// * @return javax.swing.JButton
|
513 |
// */
|
514 |
// private JButton getJButtonZoomOutViewCentered() {
|
515 |
// if (jButtonZoomOutViewCentered == null) {
|
516 |
// jButtonZoomOutViewCentered = new JButton();
|
517 |
// jButtonZoomOutViewCentered.setBounds(DEFAULT_ZOOMOUTVIEWCENTERED_ICON_BUTTON_RECTANGLE);
|
518 |
// jButtonZoomOutViewCentered.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/zoommenos.png")));
|
519 |
// }
|
520 |
// return jButtonZoomOutViewCentered;
|
521 |
// }
|
522 |
|
523 |
/**
|
524 |
* This method initializes jComboBoxZoomInAndOut
|
525 |
*
|
526 |
* @return
|
527 |
*/
|
528 |
private JPanelWithJComboBoxImageIconItems getJComboBoxZoomInAndOutViewCentered() {
|
529 |
if (jComboBoxZoomInAndOutViewCentered == null) { |
530 |
jComboBoxZoomInAndOutViewCentered = new JPanelWithJComboBoxImageIconItems();
|
531 |
jComboBoxZoomInAndOutViewCentered.setBounds(DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE); |
532 |
jComboBoxZoomInAndOutViewCentered.addImageIcon(new ImageIconItemInfo("images/zoommas.png", new ImageIcon(getClass().getClassLoader().getResource("images/zoommas.png")), PluginServices.getText(this, "Zoom_Acercar"))); |
533 |
jComboBoxZoomInAndOutViewCentered.addImageIcon(new ImageIconItemInfo("images/ZoomOut.png", new ImageIcon(getClass().getClassLoader().getResource("images/zoommenos.png")), PluginServices.getText(this, "Zoom_Alejar"))); |
534 |
} |
535 |
return jComboBoxZoomInAndOutViewCentered;
|
536 |
} |
537 |
|
538 |
/**
|
539 |
* This method initializes jButtonInfo
|
540 |
*
|
541 |
* @return javax.swing.JButton
|
542 |
*/
|
543 |
private JButton getJButtonInfo() { |
544 |
switch (((ItemOperation)getJComboBoxToolSelection().getSelectedItem()).getOperation()) {
|
545 |
case SELECTION_BY_COORDINATES_OPERATION:
|
546 |
jButtonInfo = new JButton(); |
547 |
jButtonInfo.setBounds(DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V1); |
548 |
jButtonInfo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Identify.png"))); |
549 |
jButtonInfo.setToolTipText(PluginServices.getText(this, "informacion")); |
550 |
break;
|
551 |
case SELECTION_BY_AREA_OPERATION:
|
552 |
jButtonInfo = new JButton(); |
553 |
jButtonInfo.setBounds(DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V2); |
554 |
jButtonInfo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Identify.png"))); |
555 |
jButtonInfo.setToolTipText(PluginServices.getText(this, "informacion")); |
556 |
break;
|
557 |
case DISABLED_OPERATION: // Do nothing |
558 |
break;
|
559 |
} |
560 |
|
561 |
return jButtonInfo;
|
562 |
} |
563 |
|
564 |
// /**
|
565 |
// * This method initializes jButtonTools
|
566 |
// *
|
567 |
// * @return javax.swing.JButton
|
568 |
// */
|
569 |
// private JButton getJButtonTools() {
|
570 |
// if (jButtonTools == null) {
|
571 |
// jButtonTools = new JButton();
|
572 |
// jButtonTools.setBounds(DEFAULT_TOOLS_ICON_BUTTON_RECTANGLE);
|
573 |
// jButtonTools.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomOut.png")));
|
574 |
// }
|
575 |
// return jButtonTools;
|
576 |
// }
|
577 |
|
578 |
/**
|
579 |
* Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
|
580 |
*
|
581 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
582 |
*/
|
583 |
private class ItemOperation { |
584 |
String _name;
|
585 |
int _operation;
|
586 |
|
587 |
/**
|
588 |
* Default constructor with two parameters
|
589 |
*
|
590 |
* @param name Name of the operation
|
591 |
* @param operation A code that identifies the operation
|
592 |
*/
|
593 |
public ItemOperation(String name, int operation) { |
594 |
_name = new String(name); |
595 |
_operation = operation; |
596 |
} |
597 |
|
598 |
/**
|
599 |
* Returns the name of the operation
|
600 |
*
|
601 |
* @return An String
|
602 |
*/
|
603 |
public String getName() { |
604 |
return _name;
|
605 |
} |
606 |
|
607 |
/**
|
608 |
* Returns the code that identifies the operation
|
609 |
*
|
610 |
* @return An integer value
|
611 |
*/
|
612 |
public int getOperation() { |
613 |
return _operation;
|
614 |
} |
615 |
|
616 |
/**
|
617 |
* The name of the operation that will use JComboBox
|
618 |
*/
|
619 |
public String toString() { |
620 |
return _name;
|
621 |
} |
622 |
} |
623 |
|
624 |
/**
|
625 |
* This class is a panel width four fields for indicate the coordinates of two points:
|
626 |
* One for the ritgh-up point and another for the left-down point of a rectangle area
|
627 |
*
|
628 |
* @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
629 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
630 |
*/
|
631 |
private class AreaCoordinatesPanel extends JPanel implements Serializable { |
632 |
private final Rectangle DEFAULT_JRADIOBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 67, 50); // @jve:decl-index=0: |
633 |
private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20; |
634 |
private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20; |
635 |
private final int DEFAULT_TEXT_FIELDS_WIDTH = 132; |
636 |
private final int DEFAULT_X_LOCATION = 8; |
637 |
private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6; |
638 |
private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10; |
639 |
private final int DEFAULT_COORDINATE_HEIGHT = 25; |
640 |
private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT); // @jve:decl-index=0: |
641 |
private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ; |
642 |
|
643 |
private JPanel jPanelVertex1 = null; |
644 |
private JPanel jPanelVertex2 = null; |
645 |
private JPanel jPanelVertex1X = null; |
646 |
private JPanel jPanelVertex1Y = null; |
647 |
private JPanel jPanelVertex2X = null; |
648 |
private JPanel jPanelVertex2Y = null; |
649 |
|
650 |
private JLabel jLabelVertex1 = null; |
651 |
private JLabel jLabelVertex2 = null; |
652 |
private JLabel jLabelVertex1X = null; |
653 |
private JLabel jLabelVertex1Y = null; |
654 |
private JLabel jLabelVertex2X = null; |
655 |
private JLabel jLabelVertex2Y = null; |
656 |
private JTextFieldWithSpecificCaretPosition jTextFieldVertex1X = null; |
657 |
private JTextFieldWithSpecificCaretPosition jTextFieldVertex1Y = null; |
658 |
private JTextFieldWithSpecificCaretPosition jTextFieldVertex2X = null; |
659 |
private JTextFieldWithSpecificCaretPosition jTextFieldVertex2Y = null; |
660 |
private JRadioButton jRadioButtonGoToArea = null; |
661 |
|
662 |
private FocusListener focusListenerForCoordinateValidation = null; |
663 |
|
664 |
/**
|
665 |
* This is the default constructor
|
666 |
*/
|
667 |
public AreaCoordinatesPanel() {
|
668 |
super();
|
669 |
initialize(); |
670 |
} |
671 |
|
672 |
/**
|
673 |
* This method initializes this
|
674 |
*
|
675 |
* @return void
|
676 |
*/
|
677 |
private void initialize() { |
678 |
this.setLayout(null); |
679 |
this.setBounds(DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE);
|
680 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1)); |
681 |
this.setToolTipText(PluginServices.getText(this, "select_by_vertexes_coordinates")); |
682 |
// this.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
683 |
// null, PluginServices.getText(this, "select_by_vertexes_coordinates"),
|
684 |
// javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
685 |
// javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
686 |
this.add(getJPanelVertex1());
|
687 |
this.add(getJPanelVertex2());
|
688 |
this.add(getJRadioButtonGoToArea());
|
689 |
} |
690 |
|
691 |
/**
|
692 |
* Returns the default width of this component
|
693 |
*
|
694 |
* @return The default width
|
695 |
*/
|
696 |
public int getDefaultWidth() { |
697 |
return DEFAULT_COORDINATE_WIDTH * 2; |
698 |
} |
699 |
|
700 |
/**
|
701 |
* Returns the default height of this component
|
702 |
*
|
703 |
* @return The default height
|
704 |
*/
|
705 |
public int getDefaultHeight() { |
706 |
return DEFAULT_COORDINATE_HEIGHT * 2; |
707 |
} |
708 |
|
709 |
/**
|
710 |
* This method initializes jPanelVertex1
|
711 |
*
|
712 |
* @return javax.swing.JPanel
|
713 |
*/
|
714 |
private JPanel getJPanelVertex1() { |
715 |
if (jPanelVertex1 == null) { |
716 |
jPanelVertex1 = new JPanel(); |
717 |
jPanelVertex1.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT); |
718 |
jPanelVertex1.setLayout(new GridBagLayout()); |
719 |
jPanelVertex1.add(getJLabelVertex1(), null);
|
720 |
jPanelVertex1.add(getJPanelVertex1X(), null);
|
721 |
jPanelVertex1.add(getJPanelVertex1Y(), null);
|
722 |
} |
723 |
|
724 |
return jPanelVertex1;
|
725 |
} |
726 |
|
727 |
/**
|
728 |
* This method initializes jPanelVertex2
|
729 |
*
|
730 |
* @return javax.swing.JPanel
|
731 |
*/
|
732 |
private JPanel getJPanelVertex2() { |
733 |
if (jPanelVertex2 == null) { |
734 |
jPanelVertex2 = new JPanel(); |
735 |
jPanelVertex2.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION + DEFAULT_COORDINATE_HEIGHT, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT); |
736 |
jPanelVertex2.setLayout(new GridBagLayout()); |
737 |
jPanelVertex2.add(getJLabelVertex2(), null);
|
738 |
jPanelVertex2.add(getJPanelVertex2X(), null);
|
739 |
jPanelVertex2.add(getJPanelVertex2Y(), null);
|
740 |
} |
741 |
|
742 |
return jPanelVertex2;
|
743 |
} |
744 |
|
745 |
/**
|
746 |
* This method initializes jLabelVertex1
|
747 |
*
|
748 |
* @return javax.swing.JPanel
|
749 |
*/
|
750 |
private JLabel getJLabelVertex1() { |
751 |
if (jLabelVertex1 == null) { |
752 |
jLabelVertex1 = new JLabel(); |
753 |
jLabelVertex1.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION); |
754 |
jLabelVertex1.setToolTipText(PluginServices.getText(this, "coordinates_from_area_left_up_vertex")); |
755 |
jLabelVertex1.setText(PluginServices.getText(this, "vertex") + " 1:"); |
756 |
jLabelVertex1.setHorizontalAlignment(SwingConstants.LEFT);
|
757 |
jLabelVertex1.setVerticalAlignment(SwingConstants.CENTER);
|
758 |
jLabelVertex1.setForeground(new Color(0, 0, 255)); // Blue color for text |
759 |
} |
760 |
return jLabelVertex1;
|
761 |
} |
762 |
|
763 |
/**
|
764 |
* This method initializes jLabelVertex2
|
765 |
*
|
766 |
* @return javax.swing.JPanel
|
767 |
*/
|
768 |
private JLabel getJLabelVertex2() { |
769 |
if (jLabelVertex2 == null) { |
770 |
jLabelVertex2 = new JLabel(); |
771 |
jLabelVertex2.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION); |
772 |
jLabelVertex2.setToolTipText(PluginServices.getText(this, "coordinates_from_area_right_bottom_vertex")); |
773 |
jLabelVertex2.setText(PluginServices.getText(this, "vertex") + " 2:"); |
774 |
jLabelVertex2.setHorizontalAlignment(SwingConstants.LEFT);
|
775 |
jLabelVertex2.setVerticalAlignment(SwingConstants.CENTER);
|
776 |
jLabelVertex2.setForeground(new Color(128, 64, 0)); // Brown color for text |
777 |
} |
778 |
return jLabelVertex2;
|
779 |
} |
780 |
|
781 |
/**
|
782 |
* This method initializes jPanelVertex1X
|
783 |
*
|
784 |
* @return javax.swing.JPanel
|
785 |
*/
|
786 |
private JPanel getJPanelVertex1X() { |
787 |
if (jPanelVertex1X == null) { |
788 |
jPanelVertex1X = new JPanel(); |
789 |
jPanelVertex1X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
790 |
jPanelVertex1X.setLayout(new GridBagLayout()); |
791 |
jPanelVertex1X.add(getJLabelVertex1X(), null);
|
792 |
jPanelVertex1X.add(getJTextFieldVertex1X(), null);
|
793 |
} |
794 |
|
795 |
return jPanelVertex1X;
|
796 |
} |
797 |
|
798 |
/**
|
799 |
* This method initializes jPanelVertex1Y
|
800 |
*
|
801 |
* @return javax.swing.JPanel
|
802 |
*/
|
803 |
private JPanel getJPanelVertex1Y() { |
804 |
if (jPanelVertex1Y == null) { |
805 |
jPanelVertex1Y = new JPanel(); |
806 |
jPanelVertex1Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
807 |
jPanelVertex1Y.setLayout(new GridBagLayout()); |
808 |
jPanelVertex1Y.add(getJLabelVertex1Y(), null);
|
809 |
jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
|
810 |
} |
811 |
|
812 |
return jPanelVertex1Y;
|
813 |
} |
814 |
|
815 |
/**
|
816 |
* This method initializes jPanelVertex2X
|
817 |
*
|
818 |
* @return javax.swing.JPanel
|
819 |
*/
|
820 |
private JPanel getJPanelVertex2X() { |
821 |
if (jPanelVertex2X == null) { |
822 |
jPanelVertex2X = new JPanel(); |
823 |
jPanelVertex2X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
824 |
jPanelVertex2X.setLayout(new GridBagLayout()); |
825 |
jPanelVertex2X.add(getJLabelVertex2X(), null);
|
826 |
jPanelVertex2X.add(getJTextFieldVertex2X(), null);
|
827 |
} |
828 |
|
829 |
return jPanelVertex2X;
|
830 |
} |
831 |
|
832 |
/**
|
833 |
* This method initializes jPanelVertex2Y
|
834 |
*
|
835 |
* @return javax.swing.JPanel
|
836 |
*/
|
837 |
private JPanel getJPanelVertex2Y() { |
838 |
if (jPanelVertex2Y == null) { |
839 |
jPanelVertex2Y = new JPanel(); |
840 |
jPanelVertex2Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
841 |
jPanelVertex2Y.setLayout(new GridBagLayout()); |
842 |
jPanelVertex2Y.add(getJLabelVertex2Y(), null);
|
843 |
jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
|
844 |
} |
845 |
|
846 |
return jPanelVertex2Y;
|
847 |
} |
848 |
|
849 |
/**
|
850 |
* This method initializes jLabelVertex1X
|
851 |
*
|
852 |
* @return javax.swing.JLabel
|
853 |
*/
|
854 |
private JLabel getJLabelVertex1X() { |
855 |
if (jLabelVertex1X == null) { |
856 |
jLabelVertex1X = new JLabel(); |
857 |
jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
858 |
jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_up_vertex")); |
859 |
jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":"); |
860 |
jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
|
861 |
jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
|
862 |
jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text |
863 |
} |
864 |
|
865 |
return jLabelVertex1X;
|
866 |
} |
867 |
|
868 |
/**
|
869 |
* This method initializes jLabelVertex2X
|
870 |
*
|
871 |
* @return javax.swing.JLabel
|
872 |
*/
|
873 |
private JLabel getJLabelVertex2X() { |
874 |
if (jLabelVertex2X == null) { |
875 |
jLabelVertex2X = new JLabel(); |
876 |
jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
877 |
jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_bottom_vertex")); |
878 |
jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":"); |
879 |
jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
|
880 |
jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
|
881 |
jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text |
882 |
} |
883 |
|
884 |
return jLabelVertex2X;
|
885 |
} |
886 |
|
887 |
/**
|
888 |
* This method initializes jLabelVertex1Y
|
889 |
*
|
890 |
* @return javax.swing.JLabel
|
891 |
*/
|
892 |
private JLabel getJLabelVertex1Y() { |
893 |
if (jLabelVertex1Y == null) { |
894 |
jLabelVertex1Y = new JLabel(); |
895 |
jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
896 |
jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_up_vertex")); |
897 |
jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":"); |
898 |
jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
|
899 |
jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
|
900 |
jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text |
901 |
} |
902 |
|
903 |
return jLabelVertex1Y;
|
904 |
} |
905 |
|
906 |
/**
|
907 |
* This method initializes jLabelVertex2Y
|
908 |
*
|
909 |
* @return javax.swing.JLabel
|
910 |
*/
|
911 |
private JLabel getJLabelVertex2Y() { |
912 |
if (jLabelVertex2Y == null) { |
913 |
jLabelVertex2Y = new JLabel(); |
914 |
jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
915 |
jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_bottom_vertex")); |
916 |
jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":"); |
917 |
jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
|
918 |
jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
|
919 |
jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text |
920 |
} |
921 |
|
922 |
return jLabelVertex2Y;
|
923 |
} |
924 |
//
|
925 |
// /**
|
926 |
// * This method initializes a FocusAdapter event adapter, it's 'focusLost()' method for set the caret position of
|
927 |
// * the JTextField (source which generates the event of focusLost), to the first position.
|
928 |
// * This adapter is done for use only with the JTextFields of the coordinates
|
929 |
// *
|
930 |
// * @return java.awt.event.FocusAdapter
|
931 |
// */
|
932 |
// private FocusAdapter getJFocusAdapterForJTextFields() {
|
933 |
// if (focusAdapterForJTextFields == null) {
|
934 |
// focusAdapterForJTextFields = new FocusAdapter() {
|
935 |
// /*
|
936 |
// * (non-Javadoc)
|
937 |
// * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
938 |
// */
|
939 |
// public void focusLost(FocusEvent e) {
|
940 |
// ((JTextField)e.getSource()).setCaretPosition(0);
|
941 |
// }
|
942 |
// };
|
943 |
// }
|
944 |
// return focusAdapterForJTextFields;
|
945 |
// }
|
946 |
|
947 |
/**
|
948 |
* Returns a focus listener for validate the text of a JTextField when that component loses its focus
|
949 |
*
|
950 |
* @return java.awt.event.FocusListener
|
951 |
*/
|
952 |
private FocusListener getFocusListenerForCoordinateValidation() { |
953 |
if (focusListenerForCoordinateValidation == null) { |
954 |
focusListenerForCoordinateValidation = new FocusAdapter() { |
955 |
/*
|
956 |
* (non-Javadoc)
|
957 |
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
958 |
*/
|
959 |
public void focusLost(FocusEvent e) { |
960 |
validateCoordinate((JTextField)e.getSource());
|
961 |
} |
962 |
}; |
963 |
} |
964 |
|
965 |
return focusListenerForCoordinateValidation;
|
966 |
} |
967 |
|
968 |
/**
|
969 |
* This method initializes jTextFieldVertex1X
|
970 |
*
|
971 |
* @return javax.swing.JTextField
|
972 |
*/
|
973 |
private JTextField getJTextFieldVertex1X() { |
974 |
if (jTextFieldVertex1X == null) { |
975 |
jTextFieldVertex1X = new JTextFieldWithSpecificCaretPosition();
|
976 |
jTextFieldVertex1X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
977 |
jTextFieldVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_up_vertex")); |
978 |
jTextFieldVertex1X.addFocusListener(getFocusListenerForCoordinateValidation()); |
979 |
} |
980 |
return jTextFieldVertex1X;
|
981 |
} |
982 |
|
983 |
/**
|
984 |
* This method initializes jTextFieldVertex1Y
|
985 |
*
|
986 |
* @return javax.swing.JTextField
|
987 |
*/
|
988 |
private JTextField getJTextFieldVertex1Y() { |
989 |
if (jTextFieldVertex1Y == null) { |
990 |
jTextFieldVertex1Y = new JTextFieldWithSpecificCaretPosition();
|
991 |
jTextFieldVertex1Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
992 |
jTextFieldVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_up_vertex")); |
993 |
jTextFieldVertex1Y.addFocusListener(getFocusListenerForCoordinateValidation()); |
994 |
} |
995 |
return jTextFieldVertex1Y;
|
996 |
} |
997 |
|
998 |
/**
|
999 |
* This method initializes jTextFieldVertex2X
|
1000 |
*
|
1001 |
* @return javax.swing.JTextField
|
1002 |
*/
|
1003 |
private JTextField getJTextFieldVertex2X() { |
1004 |
if (jTextFieldVertex2X == null) { |
1005 |
jTextFieldVertex2X = new JTextFieldWithSpecificCaretPosition();
|
1006 |
jTextFieldVertex2X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1007 |
jTextFieldVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_bottom_vertex")); |
1008 |
jTextFieldVertex2X.addFocusListener(getFocusListenerForCoordinateValidation()); |
1009 |
} |
1010 |
return jTextFieldVertex2X;
|
1011 |
} |
1012 |
|
1013 |
/**
|
1014 |
* This method initializes jTextFieldVertex2Y
|
1015 |
*
|
1016 |
* @return javax.swing.JTextField
|
1017 |
*/
|
1018 |
private JTextField getJTextFieldVertex2Y() { |
1019 |
if (jTextFieldVertex2Y == null) { |
1020 |
jTextFieldVertex2Y = new JTextFieldWithSpecificCaretPosition();
|
1021 |
jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1022 |
jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_bottom_vertex")); |
1023 |
jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation()); |
1024 |
} |
1025 |
return jTextFieldVertex2Y;
|
1026 |
} |
1027 |
|
1028 |
/**
|
1029 |
* Validates the coordinate of a JTextField
|
1030 |
*
|
1031 |
* @param coordinate javax.swing.JTextField
|
1032 |
*/
|
1033 |
private void validateCoordinate(JTextField coordinate) { |
1034 |
if (coordinate != null) { |
1035 |
// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
1036 |
if ((coordinate.getText().compareTo("") != 0) &&(! StringNumberUtilities.isExponentialRealNumber(coordinate.getText()))) { |
1037 |
JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE); |
1038 |
coordinate.setText(""); // Reset text |
1039 |
} |
1040 |
} |
1041 |
} |
1042 |
|
1043 |
/**
|
1044 |
* This method initializes jbuttonGoToArea
|
1045 |
*
|
1046 |
* @return javax.swing.JRadioButton
|
1047 |
*/
|
1048 |
private JRadioButton getJRadioButtonGoToArea() { |
1049 |
if (jRadioButtonGoToArea == null) { |
1050 |
jRadioButtonGoToArea = new JRadioButton(); |
1051 |
jRadioButtonGoToArea.setBounds(DEFAULT_JRADIOBUTTON_GO_TO_AREA_RECTANGLE); |
1052 |
jRadioButtonGoToArea.setToolTipText(PluginServices.getText(this, "to_previsualize")); |
1053 |
jRadioButtonGoToArea.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/to_previsualize_area.png"))); |
1054 |
} |
1055 |
return jRadioButtonGoToArea;
|
1056 |
} |
1057 |
|
1058 |
/**
|
1059 |
* Sets the extent
|
1060 |
* @param extent
|
1061 |
*/
|
1062 |
public void setExtent(Rectangle2D extent){ |
1063 |
getJTextFieldVertex1X().setText(String.valueOf(extent.getMaxX()));
|
1064 |
getJTextFieldVertex1Y().setText(String.valueOf(extent.getMaxY()));
|
1065 |
getJTextFieldVertex2X().setText(String.valueOf(extent.getMinX()));
|
1066 |
getJTextFieldVertex2Y().setText(String.valueOf(extent.getMinY()));
|
1067 |
} |
1068 |
|
1069 |
/**
|
1070 |
* Gets the extent
|
1071 |
* @return
|
1072 |
*/
|
1073 |
public Rectangle2D getExtent(){ |
1074 |
if ((!getJTextFieldVertex1X().getText().equals("")) && |
1075 |
(!getJTextFieldVertex1Y().getText().equals("")) &&
|
1076 |
(!getJTextFieldVertex2X().getText().equals("")) &&
|
1077 |
(!getJTextFieldVertex2Y().getText().equals(""))){
|
1078 |
Rectangle2D r2d = new Rectangle2D.Double(new Double(getJTextFieldVertex1X().getText()).doubleValue(), |
1079 |
new Double(getJTextFieldVertex1Y().getText()).doubleValue(), |
1080 |
new Double(getJTextFieldVertex2X().getText()).doubleValue(), |
1081 |
new Double(getJTextFieldVertex2Y().getText()).doubleValue()); |
1082 |
return r2d;
|
1083 |
} |
1084 |
return null; |
1085 |
} |
1086 |
|
1087 |
/**
|
1088 |
* Enables or disables all inner JTextField
|
1089 |
*
|
1090 |
* @param b A boolean value
|
1091 |
*/
|
1092 |
public void setAllTextFieldsEnabled(boolean b) { |
1093 |
getJTextFieldVertex1X().setEnabled(b); |
1094 |
getJTextFieldVertex1Y().setEnabled(b); |
1095 |
getJTextFieldVertex2X().setEnabled(b); |
1096 |
getJTextFieldVertex2Y().setEnabled(b); |
1097 |
} |
1098 |
} |
1099 |
|
1100 |
/**
|
1101 |
* DOCUMENTAR!!
|
1102 |
*
|
1103 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
1104 |
*/
|
1105 |
public class AreaMapControlPanel extends MapControl { |
1106 |
// private final Rectangle DEFAULT_AREA_MAPCONTROL_RECTANGLE = new Rectangle(0, 0, DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.width, DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.height);
|
1107 |
|
1108 |
// private MapControl m_MapControl = null;
|
1109 |
|
1110 |
/**
|
1111 |
* Default constructor
|
1112 |
*/
|
1113 |
public AreaMapControlPanel() {
|
1114 |
this.initialize();
|
1115 |
} |
1116 |
|
1117 |
/**
|
1118 |
* This method initializes this
|
1119 |
*/
|
1120 |
private void initialize() { |
1121 |
this.setLayout(null); |
1122 |
this.setBounds(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE);
|
1123 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1)); |
1124 |
// this.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
1125 |
// null, PluginServices.getText(this, "select_by_graphical_area"),
|
1126 |
// javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
1127 |
// javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
1128 |
// this.add(this.getMapControl(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.getSize()));
|
1129 |
} |
1130 |
|
1131 |
// /*
|
1132 |
// * (non-Javadoc)
|
1133 |
// * @see java.awt.Component#setEnabled(boolean)
|
1134 |
// */
|
1135 |
// public void setEnabled(boolean enabled) {
|
1136 |
// this.setEnabled(false);
|
1137 |
// this.getMapControl().setEnabled(false);
|
1138 |
// }
|
1139 |
|
1140 |
// /*
|
1141 |
// * (non-Javadoc)
|
1142 |
// * @see com.iver.cit.gvsig.project.documents.view.gui.IView#getMapControl()
|
1143 |
// */
|
1144 |
// public MapControl getMapControl() {
|
1145 |
// return this.m_MapControl;
|
1146 |
// }
|
1147 |
|
1148 |
|
1149 |
/**
|
1150 |
* Adds listeners to the inner MapControl of the inner area JPanel ??
|
1151 |
* (SOBRAR?N ALGUNOS)
|
1152 |
*/
|
1153 |
private void addListeneresToAreaPanel() { |
1154 |
// //Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado
|
1155 |
// StatusBarListener sbl = new StatusBarListener(this.areaMapControlPanel.getMapControl());
|
1156 |
//
|
1157 |
// // Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
1158 |
// // No es dibujando un rect?ngulo, es solo pinchando.
|
1159 |
// ZoomOutListener zol = new ZoomOutListener(this.areaMapControlPanel.getMapControl());
|
1160 |
// this.areaMapControlPanel.getMapControl().addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)});
|
1161 |
//
|
1162 |
// // Pan
|
1163 |
// PanListener pl = new PanListener(this.areaMapControlPanel.getMapControl());
|
1164 |
// this.areaMapControlPanel.getMapControl().addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)});
|
1165 |
//
|
1166 |
// // Medir
|
1167 |
// MeasureListener mli = new MeasureListener(this.areaMapControlPanel.getMapControl());
|
1168 |
// this.areaMapControlPanel.getMapControl().addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)});
|
1169 |
//
|
1170 |
// // Area
|
1171 |
// AreaListener ali = new AreaListener(this.areaMapControlPanel.getMapControl());
|
1172 |
// this.areaMapControlPanel.getMapControl().addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
|
1173 |
//
|
1174 |
// // Seleccion por punto
|
1175 |
// PointSelectListener psl = new PointSelectListener(this.areaMapControlPanel.getMapControl());
|
1176 |
// this.areaMapControlPanel.getMapControl().addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)});
|
1177 |
//
|
1178 |
// // Info por punto
|
1179 |
// InfoListener il = new InfoListener(this.areaMapControlPanel.getMapControl());
|
1180 |
// this.areaMapControlPanel.getMapControl().addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)});
|
1181 |
//
|
1182 |
// // Link por punto
|
1183 |
// LinkListener ll = new LinkListener(this.areaMapControlPanel.getMapControl());
|
1184 |
// this.areaMapControlPanel.getMapControl().addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)});
|
1185 |
//
|
1186 |
// // Selecci?n por rect?ngulo
|
1187 |
// RectangleSelectListener rsl = new RectangleSelectListener(this.areaMapControlPanel.getMapControl());
|
1188 |
// this.areaMapControlPanel.getMapControl().addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)});
|
1189 |
//
|
1190 |
// // Selecci?n por pol?gono
|
1191 |
// PolygonSelectListener poligSel = new PolygonSelectListener(this.areaMapControlPanel.getMapControl());
|
1192 |
// this.areaMapControlPanel.getMapControl().addMapTool("polSelection", new Behavior[]{new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl)});
|
1193 |
//
|
1194 |
// // Zoom por rect?ngulo
|
1195 |
// ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(this.areaMapControlPanel.getMapControl());
|
1196 |
// ZoomInListener zil = new ZoomInListener(this.areaMapControlPanel.getMapControl());
|
1197 |
// this.areaMapControlPanel.getMapControl().addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil),
|
1198 |
// new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
|
1199 |
//
|
1200 |
// SelectImageListener sil = new SelectImageListener(this.areaMapControlPanel.getMapControl());
|
1201 |
// this.areaMapControlPanel.getMapControl().addMapTool("selectImage", new Behavior[]{
|
1202 |
// new PointBehavior(sil), new MouseMovementBehavior(sbl)});
|
1203 |
//
|
1204 |
// ZoomPixelCursorListener zp = new ZoomPixelCursorListener(this.areaMapControlPanel.getMapControl());
|
1205 |
// this.areaMapControlPanel.getMapControl().addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)});
|
1206 |
//
|
1207 |
// this.areaMapControlPanel.getMapControl().setTool("zoomIn"); // Por defecto
|
1208 |
// // m_MapControl.setPaintEnabled(true);
|
1209 |
} |
1210 |
|
1211 |
// /**
|
1212 |
// * This method initializes m_MapControl
|
1213 |
// *
|
1214 |
// * @return com.iver.cit.gvsig.fmap.MapControl
|
1215 |
// */
|
1216 |
// private MapControl getMapControl(Dimension d) {
|
1217 |
// if (m_MapControl == null) {
|
1218 |
// m_MapControl = new MapControl(); // Default is paintEnabled = false.
|
1219 |
// m_MapControl.setBounds(DEFAULT_AREA_MAPCONTROL_RECTANGLE);
|
1220 |
// }
|
1221 |
//
|
1222 |
// return m_MapControl;
|
1223 |
// }
|
1224 |
|
1225 |
/**
|
1226 |
* @see MapControl#drawMap(boolean)
|
1227 |
*/
|
1228 |
public void repaintMap() { |
1229 |
this.drawMap(false); |
1230 |
} |
1231 |
//
|
1232 |
// /**
|
1233 |
// * @see MapControl#getImage()
|
1234 |
// */
|
1235 |
// public BufferedImage getImage() {
|
1236 |
// return getMapControl().getImage();
|
1237 |
// }
|
1238 |
//
|
1239 |
// /**
|
1240 |
// * @see MapControl#setProjection(IProjection)
|
1241 |
// */
|
1242 |
// public void setProjection(IProjection proj)
|
1243 |
// {
|
1244 |
// getMapControl().setProjection(proj);
|
1245 |
// }
|
1246 |
//
|
1247 |
// /**
|
1248 |
// * @see MapControl#getProjection()
|
1249 |
// */
|
1250 |
// public IProjection getProjection()
|
1251 |
// {
|
1252 |
// return getMapControl().getProjection();
|
1253 |
// }
|
1254 |
} |
1255 |
} |