svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSAreaPanel.java @ 29248
History | View | Annotate | Download (286 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.GridBagConstraints; |
6 |
import java.awt.GridBagLayout; |
7 |
import java.awt.Rectangle; |
8 |
import java.awt.event.ActionEvent; |
9 |
import java.awt.event.ActionListener; |
10 |
import java.awt.event.FocusEvent; |
11 |
import java.awt.event.FocusListener; |
12 |
import java.awt.event.ItemEvent; |
13 |
import java.awt.event.ItemListener; |
14 |
import java.awt.event.KeyEvent; |
15 |
import java.awt.event.KeyListener; |
16 |
import java.awt.event.MouseAdapter; |
17 |
import java.awt.event.MouseEvent; |
18 |
import java.awt.event.MouseListener; |
19 |
import java.awt.event.MouseMotionListener; |
20 |
import java.awt.event.MouseWheelListener; |
21 |
import java.awt.geom.Rectangle2D; |
22 |
|
23 |
import javax.swing.AbstractButton; |
24 |
import javax.swing.JButton; |
25 |
import javax.swing.JCheckBox; |
26 |
import javax.swing.JComboBox; |
27 |
import javax.swing.JLabel; |
28 |
import javax.swing.JOptionPane; |
29 |
import javax.swing.JPanel; |
30 |
import javax.swing.JTextField; |
31 |
import javax.swing.JToggleButton; |
32 |
import javax.swing.SwingConstants; |
33 |
|
34 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer; |
35 |
import org.gvsig.fmap.geom.Geometry; |
36 |
import org.gvsig.fmap.geom.GeometryLocator; |
37 |
import org.gvsig.fmap.geom.GeometryManager; |
38 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
39 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
40 |
import org.gvsig.fmap.geom.primitive.Envelope; |
41 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
42 |
import org.gvsig.fmap.geom.primitive.Surface; |
43 |
import org.gvsig.fmap.mapcontext.ExtentHistory; |
44 |
import org.gvsig.fmap.mapcontext.MapContext; |
45 |
import org.gvsig.fmap.mapcontext.ViewPort; |
46 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
47 |
import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
48 |
import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
49 |
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
50 |
import org.gvsig.fmap.mapcontrol.MapControl; |
51 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
52 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
53 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
54 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
55 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
56 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolygonBehavior; |
57 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior; |
58 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
59 |
import org.gvsig.gui.beans.panelGroup.IPanelGroup; |
60 |
import org.gvsig.gui.beans.specificcaretposition.JTextFieldWithSCP; |
61 |
import org.gvsig.gui.beans.swing.jComboBoxWithImageIconItems.ImageIconItemInfo; |
62 |
import org.gvsig.gui.beans.swing.jComboBoxWithImageIconItems.JComboBoxWithImageIconItems; |
63 |
|
64 |
import com.iver.andami.PluginServices; |
65 |
import com.iver.andami.messages.NotificationManager; |
66 |
import com.iver.cit.gvsig.gui.panels.model.WFSSelectedFeature; |
67 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
68 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.AreaListener; |
69 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.MeasureListener; |
70 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.PanListener; |
71 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
72 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomInListener; |
73 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomOutListener; |
74 |
import com.iver.utiles.stringNumberUtilities.StringNumberUtilities; |
75 |
|
76 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
77 |
*
|
78 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
79 |
*
|
80 |
* This program is free software; you can redistribute it and/or
|
81 |
* modify it under the terms of the GNU General Public License
|
82 |
* as published by the Free Software Foundation; either version 2
|
83 |
* of the License, or (at your option) any later version.
|
84 |
*
|
85 |
* This program is distributed in the hope that it will be useful,
|
86 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
87 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
88 |
* GNU General Public License for more details.
|
89 |
*
|
90 |
* You should have received a copy of the GNU General Public License
|
91 |
* along with this program; if not, write to the Free Software
|
92 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
93 |
*
|
94 |
* For more information, contact:
|
95 |
*
|
96 |
* Generalitat Valenciana
|
97 |
* Conselleria d'Infraestructures i Transport
|
98 |
* Av. Blasco Ib??ez, 50
|
99 |
* 46010 VALENCIA
|
100 |
* SPAIN
|
101 |
*
|
102 |
* +34 963862235
|
103 |
* gvsig@gva.es
|
104 |
* www.gvsig.gva.es
|
105 |
*
|
106 |
* or
|
107 |
*
|
108 |
* IVER T.I. S.A
|
109 |
* Salamanca 50
|
110 |
* 46005 Valencia
|
111 |
* Spain
|
112 |
*
|
113 |
* +34 963163400
|
114 |
* dac@iver.es
|
115 |
*/
|
116 |
/* CVS MESSAGES:
|
117 |
*
|
118 |
* $Id: WFSAreaPanel.java 24625 2008-11-03 08:21:18Z vcaballero $
|
119 |
* $Log$
|
120 |
* Revision 1.29 2007-05-28 07:00:05 jcampos
|
121 |
* Fixed changes to 3D extension
|
122 |
*
|
123 |
* Revision 1.28 2007/04/11 12:04:58 ppiqueras
|
124 |
* Bug corregido: al pulsar "Aplicar" en el wizard de WFS, despu?s de haber seleccionado un ?rea distinta, se debe actualizar el ?rea visible del wizard con la de la vista activa.
|
125 |
*
|
126 |
* Revision 1.27 2007/03/15 13:32:44 ppiqueras
|
127 |
* -Corregido bug de excepci?n que se lanzaba cuando se filtraba y no se pod?a cargar la capa.
|
128 |
* - Mejorada la interfaz
|
129 |
*
|
130 |
* Revision 1.26 2007/03/06 18:01:03 caballero
|
131 |
* Exceptions
|
132 |
*
|
133 |
* Revision 1.25 2007/03/05 13:47:42 ppiqueras
|
134 |
* Eliminadas l?neas que sobraban.
|
135 |
*
|
136 |
* Revision 1.24 2007/03/01 13:13:58 ppiqueras
|
137 |
* A?adido m?todo para que si no se ha modificado el ?rea que no se aplique filtro por ?rea. Y mejorado el m?todo getExtent() (obtenci?n del Rectangle2D que define el ?rea: si el usuario no ha seleccionado un ?rea distinta, devolver? null).
|
138 |
*
|
139 |
* Revision 1.23 2007/02/26 13:40:28 ppiqueras
|
140 |
* - Eliminado bot?n zoom siguiente
|
141 |
* - En caso de que no haya vista cargada, que los botones de escalar y desplazar est?n deshabilitados
|
142 |
*
|
143 |
* Revision 1.22 2007/02/26 12:58:09 ppiqueras
|
144 |
* En caso de escribir una coordenada con formato incorrecto, avisa al usuario y restaura el valor anterior.
|
145 |
*
|
146 |
* Revision 1.21 2007/02/22 13:17:57 ppiqueras
|
147 |
* Mejor documentado el c?digo.
|
148 |
*
|
149 |
* Revision 1.20 2007/02/22 12:23:32 ppiqueras
|
150 |
* Varias mejoras:
|
151 |
* - Aviso de error en caso de intentar cargar capa con ?rea mal indicada.
|
152 |
* - Obtenci?n del ?rea de las coordenadas.
|
153 |
* - Alg?n bug corregido.
|
154 |
*
|
155 |
* Revision 1.19 2007/02/20 13:13:26 ppiqueras
|
156 |
* Se habilita el bot?n aplicar del panel padre en caso de alg?n cambio de coordendas, y mejora en la obtenci?n del ?rea del usuario.
|
157 |
*
|
158 |
* Revision 1.18 2007/02/20 11:31:11 ppiqueras
|
159 |
* Eliminados comentarios que sobraban.
|
160 |
*
|
161 |
* Revision 1.17 2007/02/16 13:36:53 ppiqueras
|
162 |
* Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar.
|
163 |
*
|
164 |
* Revision 1.16 2007/02/16 13:14:21 ppiqueras
|
165 |
* Mejorada la selecci?n por coordenadas absolutas y corregido alg?n bug.
|
166 |
*
|
167 |
* Revision 1.15 2007/02/15 11:36:57 ppiqueras
|
168 |
* Mejorada la interfaz: nuevas herramientas, mejoradas las de coordenadas absolutas. Y corregido alg?n bug de interacci?n con otros paneles.
|
169 |
*
|
170 |
* Revision 1.14 2007/02/12 11:29:37 ppiqueras
|
171 |
* Mejoras de la interfaz y uso de las herramientas
|
172 |
*
|
173 |
* Revision 1.13 2007/02/09 14:22:07 ppiqueras
|
174 |
* Mejoras de funcionalidad
|
175 |
*
|
176 |
* Revision 1.12 2007/02/09 13:56:56 ppiqueras
|
177 |
* Mejorada la funcionalidad de la interfaz: ya hay varias herramientas que se pueden usar.
|
178 |
*
|
179 |
* Revision 1.11 2007/02/08 14:18:57 ppiqueras
|
180 |
* Carga de la vista actual.
|
181 |
*
|
182 |
* Revision 1.10 2007/02/05 13:49:26 ppiqueras
|
183 |
* Mejorada la interfaz y a?adidos componentes de tipo lista desplegable con iconos como ?tems.
|
184 |
*
|
185 |
* Revision 1.9 2007/02/02 12:22:03 ppiqueras
|
186 |
* Mejorada la interfaz.
|
187 |
*
|
188 |
* Revision 1.8 2007/01/26 14:23:56 ppiqueras
|
189 |
* Mejorada la interfaz
|
190 |
*
|
191 |
* Revision 1.7 2007/01/25 14:37:16 ppiqueras
|
192 |
* Utiliza JTextFieldWithSpecificCaretPosition
|
193 |
*
|
194 |
* Revision 1.6 2007/01/25 09:31:09 ppiqueras
|
195 |
* Mejorada la interfaz.
|
196 |
*
|
197 |
* Revision 1.5 2007/01/19 14:24:30 ppiqueras
|
198 |
* + Avanzada.
|
199 |
*
|
200 |
* Revision 1.4 2007/01/12 13:09:41 jorpiell
|
201 |
* added searches by area
|
202 |
*
|
203 |
* Revision 1.3 2007/01/10 09:01:25 jorpiell
|
204 |
* The coordinates panel is opened with the view coordinates
|
205 |
*
|
206 |
* Revision 1.2 2006/12/22 11:45:53 jorpiell
|
207 |
* Actualizado el driver del WFS
|
208 |
*
|
209 |
* Revision 1.1 2006/10/10 12:55:06 jorpiell
|
210 |
* Se ha a?adido el soporte de features complejas
|
211 |
*
|
212 |
*
|
213 |
*/
|
214 |
|
215 |
|
216 |
/**
|
217 |
* VERSI?N PROVISIONAL ESTABLE
|
218 |
*
|
219 |
* This panel allows user to select the area he/she wants to get in the view.
|
220 |
* There are two options to do this:
|
221 |
* - Indicating the coordinates of the top-left and down-right corners
|
222 |
* - Selecting the area with some visual tool
|
223 |
*
|
224 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
225 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
226 |
*/
|
227 |
public class WFSAreaPanel extends AbstractWFSPanel { |
228 |
private final Rectangle DEFAULT_BOUNDS = new Rectangle(10, 5, 490, 380); |
229 |
private final Rectangle DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE = new Rectangle(8, 20, 481, 60); |
230 |
private final Rectangle DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE = new Rectangle(8, 115, 481, 265); |
231 |
private final Rectangle DEFAULT_UNDO_ICON_BUTTON_RECTANGLE = new Rectangle (250, 85, 25, 25); |
232 |
// private final Rectangle DEFAULT_REDO_ICON_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25);
|
233 |
// private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25);
|
234 |
// private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (331, 85, 25, 25);
|
235 |
private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25); |
236 |
private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25); |
237 |
private final Rectangle DEFAULT_PAN_ICON_BUTTON_RECTANGLE = new Rectangle(250, 85, 25, 25); |
238 |
private final Rectangle DEFAULT_TOOL_JCOMBOBOX_RECTANGLE = new Rectangle(10, 87, 230, 21); |
239 |
private final Rectangle DEFAULT_ENABLING_CHECKBOX_RECTANGLE = new Rectangle(10, 87, 150, 21); |
240 |
private final Rectangle DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE = new Rectangle(277, 85, 47, 25); |
241 |
private final Rectangle DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE = new Rectangle(326, 85, 25, 25); |
242 |
private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(353, 85, 25, 25); |
243 |
private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE = new Rectangle(380, 85, 47, 25); |
244 |
private final Rectangle DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE = new Rectangle(429, 85, 47, 25); |
245 |
|
246 |
private static GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
247 |
private final int DISABLED_OPERATION = 0; |
248 |
private final int SELECTION_BY_COORDINATES_OPERATION = 1; |
249 |
private final int SELECTION_BY_AREA_OPERATION = 2; |
250 |
private boolean hasUserDefinedAnArea = false; |
251 |
// private Rectangle2D lastExtentValid = null;
|
252 |
private ExtentHistory previousExtentValids = null; |
253 |
|
254 |
private WFSServerExplorer serverExplorer = null; |
255 |
private AreaCoordinatesPanel coordinatesPanel = null; |
256 |
private SelectableMapControlAreaPanel selectableMapAreaPanel = null; |
257 |
private JComboBox jComboBoxToolSelection = null; |
258 |
private JButton jButtonUndo = null; |
259 |
// private JButton jButtonRedo = null;
|
260 |
private JToggleButton jToggleButtonMove = null; |
261 |
private JToggleButton jToggleButtonScaling = null; |
262 |
private JButton jButtonPan = null; |
263 |
private JButton jButtonZoomPrevious = null; |
264 |
private JButton jButtonZoomComplete = null; |
265 |
private JComboBoxWithImageIconItems jComboBoxZoomInAndOut = null; |
266 |
private JComboBoxWithImageIconItems jComboBoxZoomInAndOutViewCentered = null; |
267 |
private JComboBoxWithImageIconItems jComboBoxOtherTools = null; |
268 |
private JCheckBox jEnablingCheckBox = null; |
269 |
|
270 |
/* Tool identifier constants */
|
271 |
private final String PAN_TOOL = "HAND"; |
272 |
private final String ZOOM_IN_TOOL = "zoomIn"; // This constant must be 'zoomIn' for a correct operation of the tools 'Zoom In' and 'Zoom In Map Centered' |
273 |
private final String ZOOM_OUT_TOOL = "zoomOut"; // This constant must be 'zoomOut' for a correct operation of the tools 'Zoom Out' and 'Zoom Out Map Centered' |
274 |
private final String ZOOM_IN_VIEW_CENTERED_TOOL = "ZOOM_IN_VIEW_CENTERED"; |
275 |
private final String ZOOM_OUT_VIEW_CENTERED_TOOL = "ZOOM_OUT_VIEW_CENTERED"; |
276 |
private final String MEASURE_DISTANCES_TOOL = "MEASURE_DISTANCES"; |
277 |
private final String MEASURE_AREA_TOOL = "MEASURE_AREA"; |
278 |
/* End tool identifier constants */
|
279 |
|
280 |
private JPanel northPanel = null; |
281 |
|
282 |
|
283 |
/**
|
284 |
* This method initializes
|
285 |
*/
|
286 |
public WFSAreaPanel() {
|
287 |
super();
|
288 |
initialize(); |
289 |
} |
290 |
|
291 |
/**
|
292 |
* Write the view coordinates into the coordinates panel
|
293 |
*/
|
294 |
private void initCoordinates(){ |
295 |
BaseView activeView = (BaseView) PluginServices.getMDIManager().getActiveWindow(); |
296 |
// We will use the adjusted extent because increases the usability
|
297 |
Envelope envelope = activeView.getMapControl().getViewPort().getAdjustedExtent(); |
298 |
// Rectangle2D r2d = activeView.getMapControl().getViewPort().getExtent();
|
299 |
|
300 |
if (envelope != null){ |
301 |
previousExtentValids.put(new Rectangle2D.Double(envelope.getMinimum(0), |
302 |
envelope.getMinimum(1),
|
303 |
envelope.getMaximum(0)-envelope.getMaximum(0), |
304 |
envelope.getMaximum(1)-envelope.getMinimum(1))); |
305 |
|
306 |
setCoordinates(envelope.getMaximum(0), envelope.getMaximum(1), |
307 |
envelope.getMinimum(0), envelope.getMinimum(1)); |
308 |
// System.out.println("Extent de la vista activa: " + r2d);
|
309 |
// getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMinX() + r2d.getWidth()));
|
310 |
// getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMaxX()));
|
311 |
//// getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(r2d.getMinY() + r2d.getHeight()));
|
312 |
// getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(r2d.getMaxY()));
|
313 |
// getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(r2d.getMinX()));
|
314 |
// getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(r2d.getMinY()));
|
315 |
} |
316 |
} |
317 |
|
318 |
/**
|
319 |
* Removes all registered extents
|
320 |
*/
|
321 |
public void clearCoordinates() { |
322 |
this.hasUserDefinedAnArea = false; |
323 |
|
324 |
while (previousExtentValids.hasPrevious()) {
|
325 |
previousExtentValids.removePrev(); |
326 |
} |
327 |
} |
328 |
|
329 |
/**
|
330 |
* <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p>
|
331 |
*
|
332 |
* @param v1x value of the x coordinate of the right-up corner of the rectangle
|
333 |
* @param v1y value of the y coordinate of the right-up corner of the rectangle
|
334 |
* @param v2x value of the x coordinate of the left-up corner of the rectangle
|
335 |
* @param v2y value of the y coordinate of the left-up corner of the rectangle
|
336 |
*/
|
337 |
private void setCoordinates(double v1x, double v1y, double v2x, double v2y) { |
338 |
getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(v1x));
|
339 |
getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(v1y));
|
340 |
getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(v2x));
|
341 |
getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(v2y));
|
342 |
} |
343 |
|
344 |
/**
|
345 |
* <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p>
|
346 |
*
|
347 |
* @param bbox the bounding box that represents a rectangle with the information of all coordinates
|
348 |
*/
|
349 |
private void setCoordinates(Rectangle2D bbox) { |
350 |
getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(bbox.getMaxX()));
|
351 |
getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(bbox.getMaxY()));
|
352 |
getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(bbox.getMinX()));
|
353 |
getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(bbox.getMinY()));
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* This method initializes coordinatesPanel
|
358 |
*
|
359 |
* @return javax.swing.JPanel
|
360 |
*/
|
361 |
private AreaCoordinatesPanel getCoordinatesPanel() {
|
362 |
if (coordinatesPanel == null) { |
363 |
coordinatesPanel = new AreaCoordinatesPanel();
|
364 |
} |
365 |
return coordinatesPanel;
|
366 |
} |
367 |
|
368 |
/**
|
369 |
* This method initializes jEnablingCheckBox
|
370 |
*
|
371 |
* @return javax.swing.JCheckBox
|
372 |
*/
|
373 |
private JCheckBox getEnablingJCheckBox() { |
374 |
if (jEnablingCheckBox == null) { |
375 |
jEnablingCheckBox = new JCheckBox(PluginServices.getText(this, "enabled")); |
376 |
jEnablingCheckBox.setBounds(DEFAULT_ENABLING_CHECKBOX_RECTANGLE); |
377 |
jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area")); |
378 |
jEnablingCheckBox.setSelected(false);
|
379 |
jEnablingCheckBox.addItemListener(new ItemListener() { |
380 |
/*
|
381 |
* (non-Javadoc)
|
382 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
383 |
*/
|
384 |
public void itemStateChanged(ItemEvent e) { |
385 |
if (e.getStateChange() == ItemEvent.SELECTED) { |
386 |
jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "disable_filter_by_area")); |
387 |
enableCoorderatesRegionOperation(); |
388 |
} |
389 |
else {
|
390 |
jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area")); |
391 |
disableCoorderatesRegionOperation(); |
392 |
} |
393 |
|
394 |
IPanelGroup panelGroup = getPanelGroup(); |
395 |
|
396 |
if (panelGroup == null) |
397 |
return;
|
398 |
|
399 |
((WFSParamsPanel)panelGroup).setApplicable(true);
|
400 |
} |
401 |
}); |
402 |
|
403 |
// By default, the tool is disabled
|
404 |
disableCoorderatesRegionOperation(); |
405 |
} |
406 |
return jEnablingCheckBox;
|
407 |
} |
408 |
|
409 |
/**
|
410 |
* This method initializes jComboBoxToolSelection
|
411 |
*
|
412 |
* @return javax.swing.JComboBox
|
413 |
*/
|
414 |
private JComboBox getJComboBoxToolSelection() { |
415 |
if (jComboBoxToolSelection == null) { |
416 |
jComboBoxToolSelection = new JComboBox(); |
417 |
jComboBoxToolSelection.setBounds(DEFAULT_TOOL_JCOMBOBOX_RECTANGLE); |
418 |
jComboBoxToolSelection.setToolTipText(PluginServices.getText(this, "select_a_tool")); |
419 |
jComboBoxToolSelection.setEditable(false);
|
420 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION)); |
421 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION)); |
422 |
jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION)); |
423 |
|
424 |
jComboBoxToolSelection.addActionListener(new ActionListener() { |
425 |
/*
|
426 |
* (non-Javadoc)
|
427 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
428 |
*/
|
429 |
public void actionPerformed(ActionEvent e) { |
430 |
JComboBox cb = (JComboBox)e.getSource(); |
431 |
switch(((ItemOperation)cb.getSelectedItem()).getOperation()) {
|
432 |
case DISABLED_OPERATION:
|
433 |
disableCoorderatesRegionOperation(); |
434 |
disableAreaRegionOperation(); |
435 |
break;
|
436 |
case SELECTION_BY_COORDINATES_OPERATION:
|
437 |
disableAreaRegionOperation(); |
438 |
enableCoorderatesRegionOperation(); |
439 |
break;
|
440 |
case SELECTION_BY_AREA_OPERATION:
|
441 |
// Only enable the area operation if there is data loaded in this MapControl
|
442 |
if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) { |
443 |
disableCoorderatesRegionOperation(); |
444 |
enableAreaRegionOperation(); |
445 |
} |
446 |
else {
|
447 |
JOptionPane.showMessageDialog(jComboBoxToolSelection, PluginServices.getText(null, "there_is_no_layer_loaded_in_the_active_view"), PluginServices.getText(null, "information"), JOptionPane.INFORMATION_MESSAGE); |
448 |
|
449 |
// Select: no tools
|
450 |
jComboBoxToolSelection.setSelectedIndex(0);
|
451 |
disableCoorderatesRegionOperation(); |
452 |
} |
453 |
|
454 |
break;
|
455 |
} |
456 |
} |
457 |
}); |
458 |
} |
459 |
return jComboBoxToolSelection;
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* Enables the components associated to the selection of area by coordinates
|
464 |
*/
|
465 |
private void enableCoorderatesRegionOperation() { |
466 |
// Adds associated icons
|
467 |
// this.add(getJButtonUndo(), null);
|
468 |
// this.add(getJButtonRedo(), null);
|
469 |
// this.add(getJToggleButtonMove(), null);
|
470 |
// this.add(getJToggleButtonScaling(), null);
|
471 |
|
472 |
getCoordinatesPanel().setAllTextFieldsEnabled(true);
|
473 |
|
474 |
// If the current active view has layers -> set the area in the fields:
|
475 |
// Adds the extent of the viewport of the current active view
|
476 |
BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow(); |
477 |
ViewPort vP = view.getMapControl().getMapContext().getViewPort(); |
478 |
|
479 |
// Update extent (we will use the adjusted extent because increases the usability)
|
480 |
Envelope envelope = vP.getAdjustedExtent(); |
481 |
// Rectangle2D r2D = vP.getExtent();
|
482 |
|
483 |
if (envelope != null) { |
484 |
// getJToggleButtonMove().setEnabled(false);
|
485 |
// getJToggleButtonScaling().setEnabled(false);
|
486 |
// }
|
487 |
// else {
|
488 |
getCoordinatesPanel().updateCoordinates(envelope); |
489 |
// getJToggleButtonMove().setEnabled(true);
|
490 |
// getJToggleButtonScaling().setEnabled(true);
|
491 |
// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
|
492 |
} |
493 |
|
494 |
getCoordinatesPanel().getJButtonValidateArea().setEnabled(true);
|
495 |
|
496 |
this.repaint();
|
497 |
} |
498 |
|
499 |
/**
|
500 |
* Enables the components associated to the selection of area by view
|
501 |
*/
|
502 |
private void enableAreaRegionOperation() { |
503 |
// Adds associated icons
|
504 |
this.add(getJButtonPan(), null); |
505 |
this.add(getJComboBoxZoomInAndOut(), null); |
506 |
getJComboBoxZoomInAndOut().revalidate(); // Force update this component
|
507 |
this.add(getJButtonZoomPrevious(), null); |
508 |
this.add(getJButtonZoomComplete(), null); |
509 |
this.add(getJComboBoxZoomInAndOutViewCentered(), null); |
510 |
getJComboBoxZoomInAndOutViewCentered().revalidate(); // Force update this component
|
511 |
this.add(getJComboBoxOtherTools(), null); |
512 |
getJComboBoxOtherTools().revalidate(); // Force update this component
|
513 |
|
514 |
// Enables the MapControl area
|
515 |
getSelectableMapAreaPanel().setEnabled(true);
|
516 |
} |
517 |
|
518 |
/**
|
519 |
* Disables the components associated to the selection of area by coordinates
|
520 |
*/
|
521 |
private void disableCoorderatesRegionOperation() { |
522 |
// Removes associated icons
|
523 |
// this.remove(getJButtonUndo());
|
524 |
// this.remove(getJButtonRedo());
|
525 |
// this.remove(getJToggleButtonMove());
|
526 |
// this.remove(getJToggleButtonScaling());
|
527 |
|
528 |
getCoordinatesPanel().setAllTextFieldsEnabled(false);
|
529 |
getCoordinatesPanel().getJButtonValidateArea().setEnabled(false);
|
530 |
|
531 |
this.repaint();
|
532 |
} |
533 |
|
534 |
/**
|
535 |
* Disables the components associated to the selection of area by view
|
536 |
*/
|
537 |
private void disableAreaRegionOperation() { |
538 |
// Removes associated icons
|
539 |
this.remove(getJButtonPan());
|
540 |
this.remove(getJComboBoxZoomInAndOut());
|
541 |
this.remove(getJButtonZoomPrevious());
|
542 |
this.remove(getJButtonZoomComplete());
|
543 |
this.remove(getJComboBoxZoomInAndOutViewCentered());
|
544 |
this.remove(getJComboBoxOtherTools());
|
545 |
|
546 |
// Disables the MapControl area
|
547 |
getSelectableMapAreaPanel().setEnabled(false);
|
548 |
} |
549 |
|
550 |
/**
|
551 |
* This method initializes areaMapControlPanel
|
552 |
*
|
553 |
* @return A reference to an object of SelectableMapControlAreaPanel
|
554 |
*/
|
555 |
private SelectableMapControlAreaPanel getSelectableMapAreaPanel() {
|
556 |
if (selectableMapAreaPanel == null) { |
557 |
selectableMapAreaPanel = new SelectableMapControlAreaPanel();
|
558 |
} |
559 |
|
560 |
return selectableMapAreaPanel;
|
561 |
} |
562 |
|
563 |
/**
|
564 |
* This method initializes jButtonUndo
|
565 |
*
|
566 |
* @return javax.swing.JButton
|
567 |
*/
|
568 |
private JButton getJButtonUndo() { |
569 |
if (jButtonUndo == null) { |
570 |
jButtonUndo = new JButton(); |
571 |
jButtonUndo.setBounds(DEFAULT_UNDO_ICON_BUTTON_RECTANGLE); |
572 |
jButtonUndo.setIcon(PluginServices.getIconTheme().get("edit-undo"));
|
573 |
jButtonUndo.setToolTipText(PluginServices.getText(this, "previous_area")); |
574 |
jButtonUndo.addMouseListener(new MouseAdapter() { |
575 |
/*
|
576 |
* (non-Javadoc)
|
577 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
578 |
*/
|
579 |
public void mouseClicked(MouseEvent e) { |
580 |
goToPreviousZoom(); |
581 |
} |
582 |
}); |
583 |
} |
584 |
|
585 |
return jButtonUndo;
|
586 |
} |
587 |
|
588 |
// /**
|
589 |
// * This method initializes jButtonUndo
|
590 |
// *
|
591 |
// * @return javax.swing.JButton
|
592 |
// */
|
593 |
// private JButton getJButtonRedo() {
|
594 |
// if (jButtonRedo == null) {
|
595 |
// jButtonRedo = new JButton();
|
596 |
// jButtonRedo.setBounds(DEFAULT_REDO_ICON_BUTTON_RECTANGLE);
|
597 |
// jButtonRedo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/edit-redo.png")));
|
598 |
// jButtonRedo.setToolTipText(PluginServices.getText(this, "following_area"));
|
599 |
// }
|
600 |
//
|
601 |
// return jButtonRedo;
|
602 |
// }
|
603 |
|
604 |
/**
|
605 |
* This method initializes jToggleButtonMove
|
606 |
*
|
607 |
* @return javax.swing.JButton
|
608 |
*/
|
609 |
private JToggleButton getJToggleButtonMove() { |
610 |
if (jToggleButtonMove == null) { |
611 |
jToggleButtonMove = new JToggleButton(); |
612 |
jToggleButtonMove.setBounds(DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE); |
613 |
jToggleButtonMove.setIcon(PluginServices.getIconTheme().get("WFS-move"));
|
614 |
jToggleButtonMove.setToolTipText(PluginServices.getText(this, "move") + ": " + PluginServices.getText(this, "area_move_explanation")); |
615 |
jToggleButtonMove.addItemListener(new ItemListener() { |
616 |
/*
|
617 |
* (non-Javadoc)
|
618 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
619 |
*/
|
620 |
public void itemStateChanged(ItemEvent e) { |
621 |
// Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
622 |
if (jToggleButtonMove.isSelected())
|
623 |
jToggleButtonScaling.setSelected(false);
|
624 |
} |
625 |
}); |
626 |
} |
627 |
|
628 |
return jToggleButtonMove;
|
629 |
} |
630 |
|
631 |
/**
|
632 |
* This method initializes jToggleButtonScaling
|
633 |
*
|
634 |
* @return javax.swing.JButton
|
635 |
*/
|
636 |
private JToggleButton getJToggleButtonScaling() { |
637 |
if (jToggleButtonScaling == null) { |
638 |
jToggleButtonScaling = new JToggleButton(); |
639 |
jToggleButtonScaling.setBounds(DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE); |
640 |
jToggleButtonScaling.setIcon(PluginServices.getIconTheme().get("WFS-scaling"));
|
641 |
jToggleButtonScaling.setToolTipText(PluginServices.getText(this, "scaling") + ": " + PluginServices.getText(this, "area_scaling_explanation")); |
642 |
jToggleButtonScaling.addItemListener(new ItemListener() { |
643 |
/*
|
644 |
* (non-Javadoc)
|
645 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
646 |
*/
|
647 |
public void itemStateChanged(ItemEvent e) { |
648 |
// Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
649 |
if (jToggleButtonScaling.isSelected())
|
650 |
jToggleButtonMove.setSelected(false);
|
651 |
} |
652 |
}); |
653 |
} |
654 |
|
655 |
return jToggleButtonScaling;
|
656 |
} |
657 |
/**
|
658 |
* This method initializes jButtonPan
|
659 |
*
|
660 |
* @return javax.swing.JButton
|
661 |
*/
|
662 |
private JButton getJButtonPan() { |
663 |
if (jButtonPan == null) { |
664 |
jButtonPan = new JButton(); |
665 |
jButtonPan.setBounds(DEFAULT_PAN_ICON_BUTTON_RECTANGLE); |
666 |
jButtonPan.setIcon(PluginServices.getIconTheme().get("view-pan"));
|
667 |
jButtonPan.setToolTipText(PluginServices.getText(this, "Desplazamiento")); |
668 |
jButtonPan.addMouseListener(new MouseAdapter() { |
669 |
/*
|
670 |
* (non-Javadoc)
|
671 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
672 |
*/
|
673 |
public void mouseClicked(MouseEvent e) { |
674 |
getSelectableMapAreaPanel().setTool(PAN_TOOL); |
675 |
} |
676 |
}); |
677 |
} |
678 |
return jButtonPan;
|
679 |
} |
680 |
|
681 |
/**
|
682 |
* This method initializes jComboBoxZoomInAndOut
|
683 |
*
|
684 |
* @return A JComboBoxWithImageIconItems object reference
|
685 |
*/
|
686 |
private JComboBoxWithImageIconItems getJComboBoxZoomInAndOut() {
|
687 |
if (jComboBoxZoomInAndOut == null) { |
688 |
jComboBoxZoomInAndOut = new JComboBoxWithImageIconItems();
|
689 |
jComboBoxZoomInAndOut.setBounds(DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE); |
690 |
jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomIn.png",PluginServices.getIconTheme().get("view-zoom-in"),PluginServices.getText(this, "Zoom_Mas"), ZOOM_IN_TOOL)); |
691 |
jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-out"), PluginServices.getText(this, "Zoom_Menos"), ZOOM_OUT_TOOL)); |
692 |
jComboBoxZoomInAndOut.addActionListener(new ActionListener() { |
693 |
/*
|
694 |
* (non-Javadoc)
|
695 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
696 |
*/
|
697 |
public void actionPerformed(ActionEvent e) { |
698 |
JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource(); |
699 |
ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem(); |
700 |
getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
701 |
} |
702 |
}); |
703 |
} |
704 |
|
705 |
return jComboBoxZoomInAndOut;
|
706 |
} |
707 |
|
708 |
/**
|
709 |
* This method initializes jButtonZoomPrevious
|
710 |
*
|
711 |
* @return javax.swing.JButton
|
712 |
*/
|
713 |
private JButton getJButtonZoomPrevious() { |
714 |
if (jButtonZoomPrevious == null) { |
715 |
jButtonZoomPrevious = new JButton(); |
716 |
jButtonZoomPrevious.setBounds(DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE); |
717 |
jButtonZoomPrevious.setIcon(PluginServices.getIconTheme().get("view-zoom-back"));
|
718 |
jButtonZoomPrevious.setToolTipText(PluginServices.getText(this, "Zoom_Previo")); |
719 |
jButtonZoomPrevious.addMouseListener(new MouseAdapter() { |
720 |
/*
|
721 |
* (non-Javadoc)
|
722 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
723 |
*/
|
724 |
public void mouseClicked(MouseEvent e) { |
725 |
goToPreviousZoom(); |
726 |
} |
727 |
}); |
728 |
} |
729 |
return jButtonZoomPrevious;
|
730 |
} |
731 |
|
732 |
/**
|
733 |
* This method initializes jButtonZoomComplete
|
734 |
*
|
735 |
* @return javax.swing.JButton
|
736 |
*/
|
737 |
private JButton getJButtonZoomComplete() { |
738 |
if (jButtonZoomComplete == null) { |
739 |
jButtonZoomComplete = new JButton(); |
740 |
jButtonZoomComplete.setBounds(DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE); |
741 |
jButtonZoomComplete.setIcon(PluginServices.getIconTheme().get("view-zoom-map-contents"));
|
742 |
jButtonZoomComplete.setToolTipText(PluginServices.getText(this, "Zoom_Completo")); |
743 |
jButtonZoomComplete.addMouseListener(new MouseAdapter() { |
744 |
/*
|
745 |
* (non-Javadoc)
|
746 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
747 |
*/
|
748 |
public void mouseClicked(MouseEvent e) { |
749 |
getSelectableMapAreaPanel().getViewPort().setEnvelope(getSelectableMapAreaPanel().getMapContext().getLayers().getFullEnvelope()); |
750 |
BaseView view =((BaseView)PluginServices.getMDIManager().getActiveWindow()); |
751 |
view.repaintMap(); |
752 |
} |
753 |
}); |
754 |
} |
755 |
return jButtonZoomComplete;
|
756 |
} |
757 |
|
758 |
/**
|
759 |
* This method initializes jComboBoxZoomInAndOut
|
760 |
*
|
761 |
* @return A JComboBoxWithImageIconItems object reference
|
762 |
*/
|
763 |
private JComboBoxWithImageIconItems getJComboBoxZoomInAndOutViewCentered() {
|
764 |
if (jComboBoxZoomInAndOutViewCentered == null) { |
765 |
jComboBoxZoomInAndOutViewCentered = new JComboBoxWithImageIconItems();
|
766 |
jComboBoxZoomInAndOutViewCentered.setBounds(DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE); |
767 |
jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/zoommas.png",PluginServices.getIconTheme().get("view-zoom-mas"), PluginServices.getText(this, "Zoom_Acercar"), ZOOM_IN_VIEW_CENTERED_TOOL)); |
768 |
jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-menos"), PluginServices.getText(this, "Zoom_Alejar"), ZOOM_OUT_VIEW_CENTERED_TOOL)); |
769 |
jComboBoxZoomInAndOutViewCentered.addActionListener(new ActionListener() { |
770 |
/*
|
771 |
* (non-Javadoc)
|
772 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
773 |
*/
|
774 |
public void actionPerformed(ActionEvent e) { |
775 |
JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource(); |
776 |
ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem(); |
777 |
|
778 |
if (((String)iiii.getItemValue()).compareTo(ZOOM_IN_VIEW_CENTERED_TOOL) == 0) { |
779 |
getSelectableMapAreaPanel().zoomIn(); |
780 |
} |
781 |
else {
|
782 |
getSelectableMapAreaPanel().zoomOut(); |
783 |
} |
784 |
} |
785 |
}); |
786 |
} |
787 |
return jComboBoxZoomInAndOutViewCentered;
|
788 |
} |
789 |
|
790 |
/**
|
791 |
* This method initializes jComboBoxOtherTools
|
792 |
*
|
793 |
* @return A JComboBoxWithImageIconItems object reference
|
794 |
*/
|
795 |
private JComboBoxWithImageIconItems getJComboBoxOtherTools() {
|
796 |
if (jComboBoxOtherTools == null) { |
797 |
jComboBoxOtherTools = new JComboBoxWithImageIconItems();
|
798 |
jComboBoxOtherTools.setBounds(DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE); |
799 |
jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Distancia.png",PluginServices.getIconTheme().get("view-query-distance"),PluginServices.getText(this, "medir_distancias"), MEASURE_DISTANCES_TOOL)); |
800 |
jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Poligono16.png",PluginServices.getIconTheme().get("view-query-area"), PluginServices.getText(this, "medir_area"), MEASURE_AREA_TOOL)); |
801 |
jComboBoxOtherTools.addActionListener(new ActionListener() { |
802 |
/*
|
803 |
* (non-Javadoc)
|
804 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
805 |
*/
|
806 |
public void actionPerformed(ActionEvent e) { |
807 |
JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource(); |
808 |
ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem(); |
809 |
getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
810 |
} |
811 |
}); |
812 |
} |
813 |
|
814 |
return jComboBoxOtherTools;
|
815 |
} |
816 |
|
817 |
/**
|
818 |
* Goes to previous zoom
|
819 |
*/
|
820 |
private void goToPreviousZoom() { |
821 |
// Gets the view port and sets its previous extent
|
822 |
ViewPort vp = getSelectableMapAreaPanel().getMapContext().getViewPort(); |
823 |
|
824 |
if (vp.getExtents().hasPrevious()) {
|
825 |
vp.setPreviousExtent(); |
826 |
|
827 |
// We will use the adjusted extent because increases the usability
|
828 |
getCoordinatesPanel().updateCoordinates(vp.getAdjustedExtent()); |
829 |
// getCoordinatesPanel().updateCoordinates(vp.getExtent());
|
830 |
} |
831 |
} |
832 |
|
833 |
/**
|
834 |
* Sets the extent
|
835 |
*
|
836 |
* @param java.awt.geom.Rectangle2D
|
837 |
*/
|
838 |
public void setEnvelope(Envelope envelope) { |
839 |
if (envelope != null) { |
840 |
// Update coordinates in text fields
|
841 |
getCoordinatesPanel().updateCoordinates(envelope); |
842 |
|
843 |
// If there is any layer loaded in the MapControl -> set the extent
|
844 |
if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) { |
845 |
getSelectableMapAreaPanel().getMapContext().getViewPort().setEnvelope(envelope); |
846 |
} |
847 |
} |
848 |
} |
849 |
|
850 |
/**
|
851 |
* Gets the extent: a 'Rectangle2D.Double' object reference or 'null' if there is no data or if the data is invalid or user hasn't defined an area
|
852 |
*
|
853 |
* @return java.awt.geom.Rectangle2D or null if the data is invalid
|
854 |
*/
|
855 |
public Geometry getArea() {
|
856 |
if (!getEnablingJCheckBox().isSelected())
|
857 |
return null; |
858 |
|
859 |
if (!hasUserDefinedAnArea)
|
860 |
return null; |
861 |
|
862 |
if (getCoordinatesPanel().areAllCoordinatesUndefined()) {
|
863 |
return null; // Return null if there is no coordinate |
864 |
} |
865 |
else {
|
866 |
if (getCoordinatesPanel().validVertexes()) {
|
867 |
Rectangle2D r2d = getCoordinatesPanel().getExtent();
|
868 |
GeneralPathX generalPath = new GeneralPathX();
|
869 |
generalPath.moveTo(r2d.getMinX(), r2d.getMinY()); |
870 |
generalPath.lineTo(r2d.getMaxX(), r2d.getMinY()); |
871 |
generalPath.lineTo(r2d.getMaxX(), r2d.getMaxY()); |
872 |
generalPath.lineTo(r2d.getMinX(), r2d.getMaxY()); |
873 |
generalPath.lineTo(r2d.getMinX(), r2d.getMinY()); |
874 |
try {
|
875 |
return geometryManager.createSurface(generalPath, SUBTYPES.GEOM2D);
|
876 |
} catch (CreateGeometryException e) {
|
877 |
logger.error("Creating the area", e);
|
878 |
return null; |
879 |
} |
880 |
} |
881 |
else {
|
882 |
return null; // Returns null if coordinates aren't valid |
883 |
} |
884 |
} |
885 |
} |
886 |
|
887 |
/**
|
888 |
* Set parent's 'Applicable' button enable or disable according the value of the parameter
|
889 |
*
|
890 |
* @param b A boolean value
|
891 |
*/
|
892 |
private void setApplicable(boolean b) { |
893 |
IPanelGroup panelGroup = getPanelGroup(); |
894 |
|
895 |
if (panelGroup == null) |
896 |
return;
|
897 |
|
898 |
if (! ((WFSParamsPanel)panelGroup).getFilterPanel().getWFSFilterPanelIsAsTabForWFSLayersLoad())
|
899 |
((WFSParamsPanel)panelGroup).setApplicable(b); |
900 |
// parent.isApplicable(true);
|
901 |
} |
902 |
|
903 |
/**
|
904 |
* If there is some coordinate text field that has text, returns true; else returns false
|
905 |
*
|
906 |
* @return A boolean value
|
907 |
*/
|
908 |
public boolean areThereSomeCoordinatesWritten() { |
909 |
return getCoordinatesPanel().areThereSomeCoordinatesWritten();
|
910 |
} |
911 |
|
912 |
/**
|
913 |
* If there is some coordinate text field that isn't undefined, returns true; else returns false
|
914 |
*
|
915 |
* @return A boolean value
|
916 |
*/
|
917 |
public boolean areThereSomeCoordinatesUndefined() { |
918 |
return getCoordinatesPanel().isThereAnyCoordinateUndefined();
|
919 |
} |
920 |
|
921 |
/**
|
922 |
* If user has or hasn't defined an area
|
923 |
*
|
924 |
* @return A boolean value
|
925 |
*/
|
926 |
public boolean hasUserDefinedAnArea() { |
927 |
return hasUserDefinedAnArea;
|
928 |
} |
929 |
|
930 |
/**
|
931 |
* Restores the inner attribute 'hasUserDefinedAnArea' to its default value (false)
|
932 |
*/
|
933 |
public void setUserHasntDefineAnArea() { |
934 |
hasUserDefinedAnArea = false;
|
935 |
} |
936 |
|
937 |
/**
|
938 |
* Updates the current area information with the area of the active view
|
939 |
*/
|
940 |
public void updateWFSArea() { |
941 |
this.getSelectableMapAreaPanel().disableAllMouseListeners();
|
942 |
|
943 |
// To prevent that events that take place (are produced) could be a nuisance to the load of the layers
|
944 |
this.getSelectableMapAreaPanel().getMapContext().beginAtomicEvent();
|
945 |
|
946 |
try {
|
947 |
MapContext mapContext = this.getSelectableMapAreaPanel().getMapContext();
|
948 |
|
949 |
// Removes all layers in the view area
|
950 |
int numberOfLayers = mapContext.getLayers().getLayersCount();
|
951 |
int i;
|
952 |
|
953 |
for (i = (numberOfLayers-1); i >= 0; i--) { |
954 |
mapContext.getLayers().removeLayer(i); |
955 |
} |
956 |
PluginServices.getMainFrame().enableControls(); |
957 |
// Adds the extent of the viewport of the current active view
|
958 |
BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow(); |
959 |
ViewPort vP = view.getMapControl().getMapContext().getViewPort(); |
960 |
|
961 |
// Update extent (we will use the adjusted extent because increases the usability)
|
962 |
Envelope envelope = vP.getAdjustedExtent(); |
963 |
// Rectangle2D r2D = vP.getExtent();
|
964 |
|
965 |
if (envelope == null) { |
966 |
// End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
967 |
this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
968 |
|
969 |
// No tools enabled
|
970 |
getJComboBoxToolSelection().setSelectedIndex(0);
|
971 |
|
972 |
return;
|
973 |
} |
974 |
|
975 |
getCoordinatesPanel().updateCoordinates(envelope); |
976 |
mapContext.getViewPort().setEnvelope(envelope); |
977 |
|
978 |
// Adds the active layers of the current active view
|
979 |
MapContext mC = view.getMapControl().getMapContext(); |
980 |
|
981 |
numberOfLayers = mC.getLayers().getLayersCount(); |
982 |
|
983 |
for (i = (numberOfLayers-1); i >= 0; i--) { |
984 |
mapContext.getLayers().addLayer(mC.getLayers().getLayer(i).cloneLayer()); |
985 |
} |
986 |
|
987 |
// If has to enable all listeners of all tools on the view area
|
988 |
if (((ItemOperation)this.getJComboBoxToolSelection().getSelectedItem()).getOperation() == SELECTION_BY_AREA_OPERATION) |
989 |
this.getSelectableMapAreaPanel().enableAllMouseListeners();
|
990 |
|
991 |
// End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
992 |
this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
993 |
|
994 |
// Refresh the view
|
995 |
this.getSelectableMapAreaPanel().getViewPort().refreshExtent();
|
996 |
} catch (Exception e) { |
997 |
NotificationManager.addError(e); |
998 |
|
999 |
// End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
1000 |
this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
1001 |
|
1002 |
// No tools enabled
|
1003 |
getJComboBoxToolSelection().setSelectedIndex(0);
|
1004 |
return;
|
1005 |
} |
1006 |
} |
1007 |
|
1008 |
/**
|
1009 |
* Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
|
1010 |
*
|
1011 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
1012 |
*/
|
1013 |
private class ItemOperation { |
1014 |
String _name;
|
1015 |
int _operation;
|
1016 |
|
1017 |
/**
|
1018 |
* Default constructor with two parameters
|
1019 |
*
|
1020 |
* @param name Name of the operation
|
1021 |
* @param operation A code that identifies the operation
|
1022 |
*/
|
1023 |
public ItemOperation(String name, int operation) { |
1024 |
_name = new String(name); |
1025 |
_operation = operation; |
1026 |
} |
1027 |
|
1028 |
/**
|
1029 |
* Returns the name of the operation
|
1030 |
*
|
1031 |
* @return An String
|
1032 |
*/
|
1033 |
public String getName() { |
1034 |
return _name;
|
1035 |
} |
1036 |
|
1037 |
/**
|
1038 |
* Returns the code that identifies the operation
|
1039 |
*
|
1040 |
* @return An integer value
|
1041 |
*/
|
1042 |
public int getOperation() { |
1043 |
return _operation;
|
1044 |
} |
1045 |
|
1046 |
/**
|
1047 |
* The name of the operation that will use JComboBox
|
1048 |
*/
|
1049 |
public String toString() { |
1050 |
return _name;
|
1051 |
} |
1052 |
} |
1053 |
|
1054 |
/**
|
1055 |
* This class is a panel width four fields for indicate the coordinates of two points:
|
1056 |
* One for the ritgh-up point and another for the left-down point of a rectangle area
|
1057 |
*
|
1058 |
* @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
1059 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
1060 |
*/
|
1061 |
private class AreaCoordinatesPanel extends JPanel { |
1062 |
private final Rectangle DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 62, 51); // @jve:decl-index=0: |
1063 |
private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20; |
1064 |
private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20; |
1065 |
private final int DEFAULT_TEXT_FIELDS_WIDTH = 132; |
1066 |
private final int DEFAULT_X_LOCATION = 8; |
1067 |
private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6; |
1068 |
private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10; |
1069 |
private final int DEFAULT_COORDINATE_HEIGHT = 25; |
1070 |
private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT); // @jve:decl-index=0: |
1071 |
private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ; |
1072 |
|
1073 |
private final String JTEXTFIELD_V1X_NAME = "V1X"; |
1074 |
private final String JTEXTFIELD_V1Y_NAME = "V1Y"; |
1075 |
private final String JTEXTFIELD_V2X_NAME = "V2X"; |
1076 |
private final String JTEXTFIELD_V2Y_NAME = "V2Y"; |
1077 |
|
1078 |
private final short JTEXTFIELD_V1X = 1; |
1079 |
private final short JTEXTFIELD_V1Y = 2; |
1080 |
private final short JTEXTFIELD_V2X = 3; |
1081 |
private final short JTEXTFIELD_V2Y = 4; |
1082 |
|
1083 |
private JPanel jPanelVertex1 = null; |
1084 |
private JPanel jPanelVertex2 = null; |
1085 |
private JPanel jPanelVertex1X = null; |
1086 |
private JPanel jPanelVertex1Y = null; |
1087 |
private JPanel jPanelVertex2X = null; |
1088 |
private JPanel jPanelVertex2Y = null; |
1089 |
|
1090 |
private JLabel jLabelVertex1 = null; |
1091 |
private JLabel jLabelVertex2 = null; |
1092 |
private JLabel jLabelVertex1X = null; |
1093 |
private JLabel jLabelVertex1Y = null; |
1094 |
private JLabel jLabelVertex2X = null; |
1095 |
private JLabel jLabelVertex2Y = null; |
1096 |
private JTextFieldWithSCP jTextFieldVertex1X = null; |
1097 |
private JTextFieldWithSCP jTextFieldVertex1Y = null; |
1098 |
private JTextFieldWithSCP jTextFieldVertex2X = null; |
1099 |
private JTextFieldWithSCP jTextFieldVertex2Y = null; |
1100 |
private JButton jButtonPreviewArea = null; |
1101 |
private String last_Coordinates[]; |
1102 |
private boolean hasChanged_v1X; |
1103 |
private boolean hasChanged_v1Y; |
1104 |
private boolean hasChanged_v2X; |
1105 |
private boolean hasChanged_v2Y; |
1106 |
private String previous_Coordinate_Value[]; |
1107 |
|
1108 |
private short current_coordinate_with_focus; |
1109 |
|
1110 |
private FocusListener focusListenerForCoordinateValidation = null; |
1111 |
private KeyListener keyListenerForCoordinateValidation = null; |
1112 |
|
1113 |
/**
|
1114 |
* This is the default constructor
|
1115 |
*/
|
1116 |
public AreaCoordinatesPanel() {
|
1117 |
super();
|
1118 |
initialize(); |
1119 |
} |
1120 |
|
1121 |
/**
|
1122 |
* This method initializes this
|
1123 |
*
|
1124 |
* @return void
|
1125 |
*/
|
1126 |
private void initialize() { |
1127 |
this.setLayout(new GridBagLayout()); |
1128 |
this.setBounds(DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE);
|
1129 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1)); |
1130 |
this.setToolTipText(PluginServices.getText(this, "select_by_vertexes_coordinates")); |
1131 |
|
1132 |
this.last_Coordinates = new String[4]; |
1133 |
this.last_Coordinates[0] = ""; |
1134 |
this.last_Coordinates[1] = ""; |
1135 |
this.last_Coordinates[2] = ""; |
1136 |
this.last_Coordinates[3] = ""; |
1137 |
this.previous_Coordinate_Value = new String[4]; |
1138 |
|
1139 |
// By default no coordinates have changed
|
1140 |
this.resetCoordinatesFlags();
|
1141 |
|
1142 |
GridBagConstraints gridBagConstraints = null; |
1143 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1144 |
gridBagConstraints.gridx = 0;
|
1145 |
gridBagConstraints.gridy = 0;
|
1146 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1147 |
gridBagConstraints.weightx = 1.0;
|
1148 |
this.add(getJPanelVertex1(), gridBagConstraints);
|
1149 |
|
1150 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1151 |
gridBagConstraints.gridx = 1;
|
1152 |
gridBagConstraints.gridy = 0;
|
1153 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1154 |
gridBagConstraints.weightx = 1.0;
|
1155 |
this.add(getJPanelVertex2(), gridBagConstraints);
|
1156 |
|
1157 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1158 |
gridBagConstraints.gridx = 2;
|
1159 |
gridBagConstraints.gridy = 0;
|
1160 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1161 |
gridBagConstraints.weightx = 1.0;
|
1162 |
this.add(getJButtonValidateArea(), gridBagConstraints);
|
1163 |
} |
1164 |
|
1165 |
/**
|
1166 |
* Returns the default width of this component
|
1167 |
*
|
1168 |
* @return The default width
|
1169 |
*/
|
1170 |
public int getDefaultWidth() { |
1171 |
return DEFAULT_COORDINATE_WIDTH * 2; |
1172 |
} |
1173 |
|
1174 |
/**
|
1175 |
* Returns the default height of this component
|
1176 |
*
|
1177 |
* @return The default height
|
1178 |
*/
|
1179 |
public int getDefaultHeight() { |
1180 |
return DEFAULT_COORDINATE_HEIGHT * 2; |
1181 |
} |
1182 |
|
1183 |
/**
|
1184 |
* Sets all flags about if a coordinate has change to false (haven't changed)
|
1185 |
*/
|
1186 |
private void resetCoordinatesFlags() { |
1187 |
hasChanged_v1X = false;
|
1188 |
hasChanged_v1Y = false;
|
1189 |
hasChanged_v2X = false;
|
1190 |
hasChanged_v2Y = false;
|
1191 |
} |
1192 |
|
1193 |
/**last_Coordinated_that_Changed
|
1194 |
* This method initializes jPanelVertex1
|
1195 |
*
|
1196 |
* @return javax.swing.JPanel
|
1197 |
*/
|
1198 |
private JPanel getJPanelVertex1() { |
1199 |
if (jPanelVertex1 == null) { |
1200 |
jPanelVertex1 = new JPanel(); |
1201 |
jPanelVertex1.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT); |
1202 |
jPanelVertex1.setLayout(new GridBagLayout()); |
1203 |
|
1204 |
GridBagConstraints gridBagConstraints = null; |
1205 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1206 |
gridBagConstraints.gridx = 0;
|
1207 |
gridBagConstraints.gridy = 0;
|
1208 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1209 |
gridBagConstraints.weightx = 1.0;
|
1210 |
jPanelVertex1.add(getJLabelVertex1(), gridBagConstraints); |
1211 |
|
1212 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1213 |
gridBagConstraints.gridx = 0;
|
1214 |
gridBagConstraints.gridy = 1;
|
1215 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1216 |
gridBagConstraints.weightx = 1.0;
|
1217 |
jPanelVertex1.add(getJPanelVertex1X(), gridBagConstraints); |
1218 |
|
1219 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1220 |
gridBagConstraints.gridx = 0;
|
1221 |
gridBagConstraints.gridy = 2;
|
1222 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1223 |
gridBagConstraints.weightx = 1.0;
|
1224 |
jPanelVertex1.add(getJPanelVertex1Y(), gridBagConstraints); |
1225 |
} |
1226 |
|
1227 |
return jPanelVertex1;
|
1228 |
} |
1229 |
|
1230 |
/**
|
1231 |
* This method initializes jPanelVertex2
|
1232 |
*
|
1233 |
* @return javax.swing.JPanel
|
1234 |
*/
|
1235 |
private JPanel getJPanelVertex2() { |
1236 |
if (jPanelVertex2 == null) { |
1237 |
jPanelVertex2 = new JPanel(); |
1238 |
jPanelVertex2.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION + DEFAULT_COORDINATE_HEIGHT, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT); |
1239 |
jPanelVertex2.setLayout(new GridBagLayout()); |
1240 |
|
1241 |
GridBagConstraints gridBagConstraints = null; |
1242 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1243 |
gridBagConstraints.gridx = 0;
|
1244 |
gridBagConstraints.gridy = 0;
|
1245 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1246 |
gridBagConstraints.weightx = 1.0;
|
1247 |
jPanelVertex2.add(getJLabelVertex2(), gridBagConstraints); |
1248 |
|
1249 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1250 |
gridBagConstraints.gridx = 0;
|
1251 |
gridBagConstraints.gridy = 1;
|
1252 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1253 |
gridBagConstraints.weightx = 1.0;
|
1254 |
jPanelVertex2.add(getJPanelVertex2X(), gridBagConstraints); |
1255 |
|
1256 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1257 |
gridBagConstraints.gridx = 0;
|
1258 |
gridBagConstraints.gridy = 2;
|
1259 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1260 |
gridBagConstraints.weightx = 1.0;
|
1261 |
jPanelVertex2.add(getJPanelVertex2Y(), gridBagConstraints); |
1262 |
} |
1263 |
|
1264 |
return jPanelVertex2;
|
1265 |
} |
1266 |
|
1267 |
/**
|
1268 |
* This method initializes jLabelVertex1
|
1269 |
*
|
1270 |
* @return javax.swing.JPanel
|
1271 |
*/
|
1272 |
private JLabel getJLabelVertex1() { |
1273 |
if (jLabelVertex1 == null) { |
1274 |
jLabelVertex1 = new JLabel(); |
1275 |
jLabelVertex1.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION); |
1276 |
jLabelVertex1.setToolTipText(PluginServices.getText(this, "coordinates_from_area_right_up_vertex")); |
1277 |
jLabelVertex1.setText(PluginServices.getText(this, "vertex") + " 1:"); |
1278 |
jLabelVertex1.setHorizontalAlignment(SwingConstants.LEFT);
|
1279 |
jLabelVertex1.setVerticalAlignment(SwingConstants.CENTER);
|
1280 |
jLabelVertex1.setForeground(new Color(0, 0, 255)); // Blue color for text |
1281 |
} |
1282 |
return jLabelVertex1;
|
1283 |
} |
1284 |
|
1285 |
/**
|
1286 |
* This method initializes jLabelVertex2
|
1287 |
*
|
1288 |
* @return javax.swing.JPanel
|
1289 |
*/
|
1290 |
private JLabel getJLabelVertex2() { |
1291 |
if (jLabelVertex2 == null) { |
1292 |
jLabelVertex2 = new JLabel(); |
1293 |
jLabelVertex2.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION); |
1294 |
jLabelVertex2.setToolTipText(PluginServices.getText(this, "coordinates_from_area_left_bottom_vertex")); |
1295 |
jLabelVertex2.setText(PluginServices.getText(this, "vertex") + " 2:"); |
1296 |
jLabelVertex2.setHorizontalAlignment(SwingConstants.LEFT);
|
1297 |
jLabelVertex2.setVerticalAlignment(SwingConstants.CENTER);
|
1298 |
jLabelVertex2.setForeground(new Color(128, 64, 0)); // Brown color for text |
1299 |
} |
1300 |
return jLabelVertex2;
|
1301 |
} |
1302 |
|
1303 |
/**
|
1304 |
* This method initializes jPanelVertex1X
|
1305 |
*
|
1306 |
* @return javax.swing.JPanel
|
1307 |
*/
|
1308 |
private JPanel getJPanelVertex1X() { |
1309 |
if (jPanelVertex1X == null) { |
1310 |
jPanelVertex1X = new JPanel(); |
1311 |
jPanelVertex1X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
1312 |
jPanelVertex1X.setLayout(new GridBagLayout()); |
1313 |
jPanelVertex1X.add(getJLabelVertex1X(), null);
|
1314 |
jPanelVertex1X.add(getJTextFieldVertex1X(), null);
|
1315 |
} |
1316 |
|
1317 |
return jPanelVertex1X;
|
1318 |
} |
1319 |
|
1320 |
/**
|
1321 |
* This method initializes jPanelVertex1Y
|
1322 |
*
|
1323 |
* @return javax.swing.JPanel
|
1324 |
*/
|
1325 |
private JPanel getJPanelVertex1Y() { |
1326 |
if (jPanelVertex1Y == null) { |
1327 |
jPanelVertex1Y = new JPanel(); |
1328 |
jPanelVertex1Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
1329 |
jPanelVertex1Y.setLayout(new GridBagLayout()); |
1330 |
jPanelVertex1Y.add(getJLabelVertex1Y(), null);
|
1331 |
jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
|
1332 |
} |
1333 |
|
1334 |
return jPanelVertex1Y;
|
1335 |
} |
1336 |
|
1337 |
/**
|
1338 |
* This method initializes jPanelVertex2X
|
1339 |
*
|
1340 |
* @return javax.swing.JPanel
|
1341 |
*/
|
1342 |
private JPanel getJPanelVertex2X() { |
1343 |
if (jPanelVertex2X == null) { |
1344 |
jPanelVertex2X = new JPanel(); |
1345 |
jPanelVertex2X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
1346 |
jPanelVertex2X.setLayout(new GridBagLayout()); |
1347 |
jPanelVertex2X.add(getJLabelVertex2X(), null);
|
1348 |
jPanelVertex2X.add(getJTextFieldVertex2X(), null);
|
1349 |
} |
1350 |
|
1351 |
return jPanelVertex2X;
|
1352 |
} |
1353 |
|
1354 |
/**
|
1355 |
* This method initializes jPanelVertex2Y
|
1356 |
*
|
1357 |
* @return javax.swing.JPanel
|
1358 |
*/
|
1359 |
private JPanel getJPanelVertex2Y() { |
1360 |
if (jPanelVertex2Y == null) { |
1361 |
jPanelVertex2Y = new JPanel(); |
1362 |
jPanelVertex2Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT))); |
1363 |
jPanelVertex2Y.setLayout(new GridBagLayout()); |
1364 |
jPanelVertex2Y.add(getJLabelVertex2Y(), null);
|
1365 |
jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
|
1366 |
} |
1367 |
|
1368 |
return jPanelVertex2Y;
|
1369 |
} |
1370 |
|
1371 |
/**
|
1372 |
* This method initializes jLabelVertex1X
|
1373 |
*
|
1374 |
* @return javax.swing.JLabel
|
1375 |
*/
|
1376 |
private JLabel getJLabelVertex1X() { |
1377 |
if (jLabelVertex1X == null) { |
1378 |
jLabelVertex1X = new JLabel(); |
1379 |
jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
1380 |
jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex")); |
1381 |
jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":"); |
1382 |
jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
|
1383 |
jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
|
1384 |
jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text |
1385 |
} |
1386 |
|
1387 |
return jLabelVertex1X;
|
1388 |
} |
1389 |
|
1390 |
/**
|
1391 |
* This method initializes jLabelVertex2X
|
1392 |
*
|
1393 |
* @return javax.swing.JLabel
|
1394 |
*/
|
1395 |
private JLabel getJLabelVertex2X() { |
1396 |
if (jLabelVertex2X == null) { |
1397 |
jLabelVertex2X = new JLabel(); |
1398 |
jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
1399 |
jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex")); |
1400 |
jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":"); |
1401 |
jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
|
1402 |
jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
|
1403 |
jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text |
1404 |
} |
1405 |
|
1406 |
return jLabelVertex2X;
|
1407 |
} |
1408 |
|
1409 |
/**
|
1410 |
* This method initializes jLabelVertex1Y
|
1411 |
*
|
1412 |
* @return javax.swing.JLabel
|
1413 |
*/
|
1414 |
private JLabel getJLabelVertex1Y() { |
1415 |
if (jLabelVertex1Y == null) { |
1416 |
jLabelVertex1Y = new JLabel(); |
1417 |
jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
1418 |
jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex")); |
1419 |
jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":"); |
1420 |
jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
|
1421 |
jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
|
1422 |
jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text |
1423 |
} |
1424 |
|
1425 |
return jLabelVertex1Y;
|
1426 |
} |
1427 |
|
1428 |
/**
|
1429 |
* This method initializes jLabelVertex2Y
|
1430 |
*
|
1431 |
* @return javax.swing.JLabel
|
1432 |
*/
|
1433 |
private JLabel getJLabelVertex2Y() { |
1434 |
if (jLabelVertex2Y == null) { |
1435 |
jLabelVertex2Y = new JLabel(); |
1436 |
jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
1437 |
jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex")); |
1438 |
jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":"); |
1439 |
jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
|
1440 |
jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
|
1441 |
jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text |
1442 |
} |
1443 |
|
1444 |
return jLabelVertex2Y;
|
1445 |
} |
1446 |
|
1447 |
/**
|
1448 |
* Returns a focus listener for validate the text of a JTextField when that component loses its focus
|
1449 |
*
|
1450 |
* @return java.awt.event.FocusListener
|
1451 |
*/
|
1452 |
private FocusListener getFocusListenerForCoordinateValidation() { |
1453 |
if (focusListenerForCoordinateValidation == null) { |
1454 |
focusListenerForCoordinateValidation = new FocusListener() { |
1455 |
|
1456 |
/*
|
1457 |
* (non-Javadoc)
|
1458 |
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
1459 |
*/
|
1460 |
public void focusGained(FocusEvent e) { |
1461 |
JTextField jTF = (JTextField)e.getSource(); |
1462 |
|
1463 |
// Stores which coordinate has gotten the focus
|
1464 |
if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) { |
1465 |
current_coordinate_with_focus = JTEXTFIELD_V1X; |
1466 |
|
1467 |
return;
|
1468 |
} |
1469 |
|
1470 |
if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) { |
1471 |
current_coordinate_with_focus = JTEXTFIELD_V1Y; |
1472 |
|
1473 |
return;
|
1474 |
} |
1475 |
|
1476 |
if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) { |
1477 |
current_coordinate_with_focus = JTEXTFIELD_V2X; |
1478 |
|
1479 |
return;
|
1480 |
} |
1481 |
|
1482 |
if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) { |
1483 |
current_coordinate_with_focus = JTEXTFIELD_V2Y; |
1484 |
|
1485 |
return;
|
1486 |
} |
1487 |
|
1488 |
} |
1489 |
|
1490 |
/*
|
1491 |
* (non-Javadoc)
|
1492 |
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
1493 |
*/
|
1494 |
public void focusLost(FocusEvent e) { |
1495 |
if (!getEnablingJCheckBox().isSelected())
|
1496 |
return;
|
1497 |
|
1498 |
JTextField jTF = (JTextField)e.getSource(); |
1499 |
|
1500 |
// If a coordinate has lost focus, is valid and has changed -> store the new value and set its related 'hasChanged' flag to true
|
1501 |
String text = jTF.getText();
|
1502 |
|
1503 |
if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) { |
1504 |
|
1505 |
if (text.compareTo(last_Coordinates[0]) != 0) { |
1506 |
// If the text written isn't a number, restores the previous value of that coordinate
|
1507 |
// if (! StringNumberUtilities.isNumber(text)) {
|
1508 |
// jTF.setText(last_Coordinates[0]);
|
1509 |
// return;
|
1510 |
// }
|
1511 |
|
1512 |
hasChanged_v1X = true;
|
1513 |
|
1514 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
1515 |
hasUserDefinedAnArea = true;
|
1516 |
// }
|
1517 |
} |
1518 |
|
1519 |
return;
|
1520 |
} |
1521 |
|
1522 |
if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) { |
1523 |
if (text.compareTo(last_Coordinates[1]) != 0) { |
1524 |
// If the text written isn't a number, restores the previous value of that coordinate
|
1525 |
// if (! StringNumberUtilities.isNumber(text)) {
|
1526 |
// jTF.setText(last_Coordinates[1]);
|
1527 |
// return;
|
1528 |
// }
|
1529 |
|
1530 |
hasChanged_v1Y = true;
|
1531 |
|
1532 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
1533 |
hasUserDefinedAnArea = true;
|
1534 |
// }
|
1535 |
} |
1536 |
|
1537 |
return;
|
1538 |
} |
1539 |
|
1540 |
if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) { |
1541 |
if (text.compareTo(last_Coordinates[2]) != 0) { |
1542 |
// If the text written isn't a number, restores the previous value of that coordinate
|
1543 |
// if (! StringNumberUtilities.isNumber(text)) {
|
1544 |
// jTF.setText(last_Coordinates[2]);
|
1545 |
// return;
|
1546 |
// }
|
1547 |
|
1548 |
hasChanged_v2X = true;
|
1549 |
|
1550 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
1551 |
hasUserDefinedAnArea = true;
|
1552 |
// }
|
1553 |
} |
1554 |
|
1555 |
return;
|
1556 |
} |
1557 |
|
1558 |
if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) { |
1559 |
if (text.compareTo(last_Coordinates[3]) != 0) { |
1560 |
// If the text written isn't a number, restores the previous value of that coordinate
|
1561 |
// if (! StringNumberUtilities.isNumber(text)) {
|
1562 |
// jTF.setText(last_Coordinates[3]);
|
1563 |
// return;
|
1564 |
// }
|
1565 |
|
1566 |
hasChanged_v2Y = true;
|
1567 |
|
1568 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
1569 |
hasUserDefinedAnArea = true;
|
1570 |
// }
|
1571 |
} |
1572 |
|
1573 |
return;
|
1574 |
} |
1575 |
} |
1576 |
}; |
1577 |
} |
1578 |
|
1579 |
return focusListenerForCoordinateValidation;
|
1580 |
} |
1581 |
|
1582 |
private KeyListener getKeyListenerForCoordinateValidation() { |
1583 |
if (keyListenerForCoordinateValidation == null) { |
1584 |
keyListenerForCoordinateValidation = new KeyListener() { |
1585 |
|
1586 |
public void keyPressed(KeyEvent e) { |
1587 |
} |
1588 |
|
1589 |
public void keyReleased(KeyEvent e) { |
1590 |
validateCoordinate(current_coordinate_with_focus); |
1591 |
} |
1592 |
|
1593 |
public void keyTyped(KeyEvent e) { |
1594 |
} |
1595 |
}; |
1596 |
} |
1597 |
|
1598 |
return keyListenerForCoordinateValidation;
|
1599 |
} |
1600 |
|
1601 |
/**
|
1602 |
* This method initializes jTextFieldVertex1X
|
1603 |
*
|
1604 |
* @return JTextFieldWithSCP
|
1605 |
*/
|
1606 |
private JTextFieldWithSCP getJTextFieldVertex1X() {
|
1607 |
if (jTextFieldVertex1X == null) { |
1608 |
jTextFieldVertex1X = new JTextFieldWithSCP(""); |
1609 |
jTextFieldVertex1X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1610 |
jTextFieldVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex")); |
1611 |
jTextFieldVertex1X.addFocusListener(getFocusListenerForCoordinateValidation()); |
1612 |
jTextFieldVertex1X.addKeyListener(getKeyListenerForCoordinateValidation()); |
1613 |
jTextFieldVertex1X.setName(JTEXTFIELD_V1X_NAME); |
1614 |
} |
1615 |
return jTextFieldVertex1X;
|
1616 |
} |
1617 |
|
1618 |
/**
|
1619 |
* This method initializes jTextFieldVertex1Y
|
1620 |
*
|
1621 |
* @return JTextFieldWithSCP
|
1622 |
*/
|
1623 |
private JTextFieldWithSCP getJTextFieldVertex1Y() {
|
1624 |
if (jTextFieldVertex1Y == null) { |
1625 |
jTextFieldVertex1Y = new JTextFieldWithSCP(""); |
1626 |
jTextFieldVertex1Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1627 |
jTextFieldVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex")); |
1628 |
jTextFieldVertex1Y.addFocusListener(getFocusListenerForCoordinateValidation()); |
1629 |
jTextFieldVertex1Y.addKeyListener(getKeyListenerForCoordinateValidation()); |
1630 |
jTextFieldVertex1Y.setName(JTEXTFIELD_V1Y_NAME); |
1631 |
} |
1632 |
return jTextFieldVertex1Y;
|
1633 |
} |
1634 |
|
1635 |
/**
|
1636 |
* This method initializes jTextFieldVertex2X
|
1637 |
*
|
1638 |
* @return JTextFieldWithSCP
|
1639 |
*/
|
1640 |
private JTextFieldWithSCP getJTextFieldVertex2X() {
|
1641 |
if (jTextFieldVertex2X == null) { |
1642 |
jTextFieldVertex2X = new JTextFieldWithSCP(""); |
1643 |
jTextFieldVertex2X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1644 |
jTextFieldVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex")); |
1645 |
jTextFieldVertex2X.addFocusListener(getFocusListenerForCoordinateValidation()); |
1646 |
jTextFieldVertex2X.addKeyListener(getKeyListenerForCoordinateValidation()); |
1647 |
jTextFieldVertex2X.setName(JTEXTFIELD_V2X_NAME); |
1648 |
} |
1649 |
return jTextFieldVertex2X;
|
1650 |
} |
1651 |
|
1652 |
/**
|
1653 |
* This method initializes jTextFieldVertex2Y
|
1654 |
*
|
1655 |
* @return JTextFieldWithSCP
|
1656 |
*/
|
1657 |
private JTextFieldWithSCP getJTextFieldVertex2Y() {
|
1658 |
if (jTextFieldVertex2Y == null) { |
1659 |
jTextFieldVertex2Y = new JTextFieldWithSCP(""); |
1660 |
jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT)); |
1661 |
jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex")); |
1662 |
jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation()); |
1663 |
jTextFieldVertex2Y.addKeyListener(getKeyListenerForCoordinateValidation()); |
1664 |
jTextFieldVertex2Y.setName(JTEXTFIELD_V2Y_NAME); |
1665 |
} |
1666 |
return jTextFieldVertex2Y;
|
1667 |
} |
1668 |
|
1669 |
/**
|
1670 |
* Returns the double value of the text field V1X
|
1671 |
*
|
1672 |
* @return A double number type
|
1673 |
*/
|
1674 |
public double getDoubleValueOfJTextFieldV1X() { |
1675 |
return Double.parseDouble(getJTextFieldVertex1X().getText()); |
1676 |
} |
1677 |
|
1678 |
/**
|
1679 |
* Returns the double value of the text field V1Y
|
1680 |
*
|
1681 |
* @return A double number type
|
1682 |
*/
|
1683 |
public double getDoubleValueOfJTextFieldV1Y() { |
1684 |
return Double.parseDouble(getJTextFieldVertex1Y().getText()); |
1685 |
} |
1686 |
|
1687 |
/**
|
1688 |
* Returns the double value of the text field V2X
|
1689 |
*
|
1690 |
* @return A double number type
|
1691 |
*/
|
1692 |
public double getDoubleValueOfJTextFieldV2X() { |
1693 |
return Double.parseDouble(getJTextFieldVertex2X().getText()); |
1694 |
} |
1695 |
|
1696 |
/**
|
1697 |
* Returns the double value of the text field V2Y
|
1698 |
*
|
1699 |
* @return A double number type
|
1700 |
*/
|
1701 |
public double getDoubleValueOfJTextFieldV2Y() { |
1702 |
return Double.parseDouble(getJTextFieldVertex2Y().getText()); |
1703 |
} |
1704 |
|
1705 |
/**
|
1706 |
* Retuns the double value of the last text field V1X value
|
1707 |
*
|
1708 |
* @return A double number type
|
1709 |
*/
|
1710 |
public double getDoubleValueOfLastJTextFieldV1XValue() { |
1711 |
return Double.parseDouble(last_Coordinates[0]); |
1712 |
} |
1713 |
|
1714 |
/**
|
1715 |
* Retuns the double value of the last text field V1Y value
|
1716 |
*
|
1717 |
* @return A double number type
|
1718 |
*/
|
1719 |
public double getDoubleValueOfLastJTextFieldV1YValue() { |
1720 |
return Double.parseDouble(last_Coordinates[1]); |
1721 |
} |
1722 |
|
1723 |
/**
|
1724 |
* Retuns the double value of the last text field V2X value
|
1725 |
*
|
1726 |
* @return A double number type
|
1727 |
*/
|
1728 |
public double getDoubleValueOfLastJTextFieldV2XValue() { |
1729 |
return Double.parseDouble(last_Coordinates[2]); |
1730 |
} |
1731 |
|
1732 |
/**
|
1733 |
* Retuns the double value of the last text field V2Y value
|
1734 |
*
|
1735 |
* @return A double number type
|
1736 |
*/
|
1737 |
public double getDoubleValueOfLastJTextFieldV2YValue() { |
1738 |
return Double.parseDouble(last_Coordinates[3]); |
1739 |
} |
1740 |
|
1741 |
/**
|
1742 |
* Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
1743 |
*
|
1744 |
* @param coordinate javax.swing.JTextField
|
1745 |
* @return A boolean value
|
1746 |
*/
|
1747 |
private boolean validateCoordinate(JTextField coordinate) { |
1748 |
if (coordinate != null) { |
1749 |
// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
1750 |
if ((coordinate.getText().compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(coordinate.getText()))) { |
1751 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
1752 |
// switch (last_Coordinate_that_Loose_the_Focus) {
|
1753 |
// case 1:
|
1754 |
// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
1755 |
// break;
|
1756 |
// case 2:
|
1757 |
// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
1758 |
// break;
|
1759 |
// case 3:
|
1760 |
// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
1761 |
// break;
|
1762 |
// case 4:
|
1763 |
// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
1764 |
// break;
|
1765 |
// default:
|
1766 |
// // Do nothing
|
1767 |
// }
|
1768 |
|
1769 |
return false; |
1770 |
} |
1771 |
else {
|
1772 |
return true; |
1773 |
} |
1774 |
} |
1775 |
|
1776 |
return false; // If coordinate is null |
1777 |
} |
1778 |
|
1779 |
/**
|
1780 |
* Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
1781 |
*
|
1782 |
* @param coordinate javax.swing.JTextField
|
1783 |
* @return A boolean value
|
1784 |
*/
|
1785 |
private boolean validateCoordinate(int coordinate_ID) { |
1786 |
JTextField coordinate = null; |
1787 |
String text;
|
1788 |
|
1789 |
switch (coordinate_ID) {
|
1790 |
case JTEXTFIELD_V1X:
|
1791 |
coordinate = getJTextFieldVertex1X(); |
1792 |
text = coordinate.getText(); |
1793 |
|
1794 |
if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) { |
1795 |
JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE); |
1796 |
coordinate.setText(previous_Coordinate_Value[0]); // Set last value |
1797 |
return false; |
1798 |
} |
1799 |
else {
|
1800 |
previous_Coordinate_Value[0] = text;
|
1801 |
return true; |
1802 |
} |
1803 |
|
1804 |
// break;
|
1805 |
case JTEXTFIELD_V1Y:
|
1806 |
coordinate = getJTextFieldVertex1Y(); |
1807 |
text = coordinate.getText(); |
1808 |
|
1809 |
if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) { |
1810 |
JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE); |
1811 |
coordinate.setText(previous_Coordinate_Value[1]); // Set last value |
1812 |
return false; |
1813 |
} |
1814 |
else {
|
1815 |
previous_Coordinate_Value[1] = text;
|
1816 |
return true; |
1817 |
} |
1818 |
|
1819 |
// break;
|
1820 |
case JTEXTFIELD_V2X:
|
1821 |
coordinate = getJTextFieldVertex2X(); |
1822 |
text = coordinate.getText(); |
1823 |
|
1824 |
if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) { |
1825 |
JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE); |
1826 |
coordinate.setText(previous_Coordinate_Value[2]); // Set last value |
1827 |
return false; |
1828 |
} |
1829 |
else {
|
1830 |
previous_Coordinate_Value[2] = text;
|
1831 |
return true; |
1832 |
} |
1833 |
|
1834 |
// break;
|
1835 |
case JTEXTFIELD_V2Y:
|
1836 |
coordinate = getJTextFieldVertex2Y(); |
1837 |
text = coordinate.getText(); |
1838 |
|
1839 |
if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) { |
1840 |
JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE); |
1841 |
coordinate.setText(previous_Coordinate_Value[3]); // Set last value |
1842 |
return false; |
1843 |
} |
1844 |
else {
|
1845 |
previous_Coordinate_Value[3] = text;
|
1846 |
return true; |
1847 |
} |
1848 |
|
1849 |
// break;
|
1850 |
default:
|
1851 |
return true; // Avoid problems |
1852 |
} |
1853 |
|
1854 |
// if (coordinate != null) {
|
1855 |
// // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
1856 |
// switch (coordinate_ID) {
|
1857 |
// case 1:
|
1858 |
// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
1859 |
// break;
|
1860 |
// case 2:
|
1861 |
// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
1862 |
// break;
|
1863 |
// case 3:
|
1864 |
// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
1865 |
// break;
|
1866 |
// case 4:
|
1867 |
// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
1868 |
// break;
|
1869 |
// default:
|
1870 |
// // Do nothing
|
1871 |
// }
|
1872 |
|
1873 |
// return false;
|
1874 |
// }
|
1875 |
// else
|
1876 |
// return true;
|
1877 |
//// }
|
1878 |
//
|
1879 |
// return false; // If coordinate is null
|
1880 |
} |
1881 |
|
1882 |
/**
|
1883 |
* This method initializes jButtonPreviewArea
|
1884 |
*
|
1885 |
* @return javax.swing.JButton
|
1886 |
*/
|
1887 |
private JButton getJButtonValidateArea() { |
1888 |
if (jButtonPreviewArea == null) { |
1889 |
jButtonPreviewArea = new JButton(); |
1890 |
jButtonPreviewArea.setBounds(DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE); |
1891 |
// jButtonPreviewArea.setToolTipText(PluginServices.getText(this, "to_previsualize"));
|
1892 |
jButtonPreviewArea.setToolTipText(PluginServices.getText(this, "to_validate_coodinates")); |
1893 |
jButtonPreviewArea.setVerticalTextPosition(AbstractButton.CENTER);
|
1894 |
jButtonPreviewArea.setHorizontalTextPosition(AbstractButton.CENTER);
|
1895 |
jButtonPreviewArea.setIcon(PluginServices.getIconTheme().get("validate-area"));
|
1896 |
jButtonPreviewArea.addMouseListener(new MouseAdapter() { |
1897 |
/*
|
1898 |
* (non-Javadoc)
|
1899 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
1900 |
*/
|
1901 |
public void mouseClicked(MouseEvent e) { |
1902 |
validVertexes(); |
1903 |
} |
1904 |
|
1905 |
// /*
|
1906 |
// * (non-Javadoc)
|
1907 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
1908 |
// */
|
1909 |
// public void mouseClicked(MouseEvent e) {
|
1910 |
// // Only enable the area operation if there is data loaded in this MapControl
|
1911 |
//
|
1912 |
// // Do nothing if there is no layer in the map control
|
1913 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() == 0) {
|
1914 |
// return;
|
1915 |
// }
|
1916 |
//
|
1917 |
// if ((validateCoordinate(getJTextFieldVertex1X())) && (validateCoordinate(getJTextFieldVertex1Y())) && (validateCoordinate(getJTextFieldVertex2X())) && (validateCoordinate(getJTextFieldVertex2Y()))) {
|
1918 |
// ViewPort vP = getSelectableMapAreaPanel().getViewPort();
|
1919 |
// if (vP != null) {
|
1920 |
// // If has to scale the area
|
1921 |
// if (getJToggleButtonScaling().isSelected()) {
|
1922 |
// // Scale Vertex 1
|
1923 |
// if ((hasChanged_v1X) || (hasChanged_v1Y)) {
|
1924 |
// double cx = getDoubleValueOfJTextFieldV1X();
|
1925 |
// double cy = getDoubleValueOfJTextFieldV1Y();
|
1926 |
// double sx, sy, aux;
|
1927 |
//
|
1928 |
// if (hasChanged_v1X) {
|
1929 |
// aux = getDoubleValueOfLastJTextFieldV1XValue();
|
1930 |
// if (aux == 0.0)
|
1931 |
// sx = 1.0; // Don't scale if new coordenate is zero
|
1932 |
// else
|
1933 |
// sx = cx / aux;
|
1934 |
// }
|
1935 |
// else
|
1936 |
// sx = 1.0;
|
1937 |
//
|
1938 |
// if (hasChanged_v1Y) {
|
1939 |
// aux = getDoubleValueOfLastJTextFieldV1YValue();
|
1940 |
// if (aux == 0.0)
|
1941 |
// sy = 1.0; // Don't scale if new coordenate is zero
|
1942 |
// else
|
1943 |
// sy = cy / aux;
|
1944 |
// }
|
1945 |
// else
|
1946 |
// sy = 1.0;
|
1947 |
//
|
1948 |
// if (sx == 1.0) {
|
1949 |
// // It's supposed that sy != 1.0
|
1950 |
// cx *= sy;
|
1951 |
//
|
1952 |
// if (cx < getDoubleValueOfJTextFieldV2X()) {
|
1953 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
1954 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
1955 |
// return;
|
1956 |
// }
|
1957 |
//
|
1958 |
// getJTextFieldVertex1X().setText(Double.toString(cx));
|
1959 |
// }
|
1960 |
// else {
|
1961 |
// if (sy == 1.0) {
|
1962 |
// // It's supposed that sx != 1.0
|
1963 |
// cy *= sx;
|
1964 |
//
|
1965 |
// if (cy < getDoubleValueOfJTextFieldV2Y()) {
|
1966 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
1967 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
1968 |
// return;
|
1969 |
// }
|
1970 |
//
|
1971 |
// getJTextFieldVertex1Y().setText(Double.toString(cy));
|
1972 |
// }
|
1973 |
// else {
|
1974 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
1975 |
// if (sx != sy) {
|
1976 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
1977 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
1978 |
// return;
|
1979 |
// }
|
1980 |
// }
|
1981 |
// }
|
1982 |
// }
|
1983 |
//
|
1984 |
// // Scale Vertex2
|
1985 |
// if ((hasChanged_v2X) || (hasChanged_v2Y)) {
|
1986 |
// double cx = getDoubleValueOfJTextFieldV2X();
|
1987 |
// double cy = getDoubleValueOfJTextFieldV2Y();
|
1988 |
// double sx, sy, aux;
|
1989 |
//
|
1990 |
// if (hasChanged_v2X) {
|
1991 |
// aux = getDoubleValueOfLastJTextFieldV2XValue();
|
1992 |
// if (aux == 0.0)
|
1993 |
// sx = 1.0; // Don't scale if new coordenate is zero
|
1994 |
// else
|
1995 |
// sx = cx / aux;
|
1996 |
// }
|
1997 |
// else
|
1998 |
// sx = 1.0;
|
1999 |
//
|
2000 |
// if (hasChanged_v2Y) {
|
2001 |
// aux = getDoubleValueOfLastJTextFieldV2YValue();
|
2002 |
// if (aux == 0.0)
|
2003 |
// sy = 1.0; // Don't scale if new coordenate is zero
|
2004 |
// else
|
2005 |
// sy = cy / aux;
|
2006 |
// }
|
2007 |
// else
|
2008 |
// sy = 1.0;
|
2009 |
//
|
2010 |
// if (sx == 1.0) {
|
2011 |
// // It's supposed that sy != 1.0
|
2012 |
// cx *= sy;
|
2013 |
//
|
2014 |
// if (cx > getDoubleValueOfJTextFieldV1X()) {
|
2015 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2016 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2017 |
// return;
|
2018 |
// }
|
2019 |
//
|
2020 |
// getJTextFieldVertex2X().setText(Double.toString(cx));
|
2021 |
// }
|
2022 |
// else {
|
2023 |
// if (sy == 1.0) {
|
2024 |
// // It's supposed that sx != 1.0
|
2025 |
// cy *= sx;
|
2026 |
//
|
2027 |
// if (cy > getDoubleValueOfJTextFieldV1Y()) {
|
2028 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2029 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2030 |
// return;
|
2031 |
// }
|
2032 |
//
|
2033 |
// getJTextFieldVertex2Y().setText(Double.toString(cy));
|
2034 |
// }
|
2035 |
// else {
|
2036 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
2037 |
// if (sx != sy) {
|
2038 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2039 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2040 |
// return;
|
2041 |
// }
|
2042 |
// }
|
2043 |
// }
|
2044 |
// }
|
2045 |
// }
|
2046 |
// else {
|
2047 |
// // If has to move the area
|
2048 |
// if (getJToggleButtonMove().isSelected()) {
|
2049 |
// // Move in X
|
2050 |
// if ((hasChanged_v1X) || (hasChanged_v2X)) {
|
2051 |
// double c1 = getDoubleValueOfJTextFieldV1X();
|
2052 |
// double c2 = getDoubleValueOfJTextFieldV2X();
|
2053 |
// double d1, d2;
|
2054 |
//
|
2055 |
// if (hasChanged_v1X)
|
2056 |
// d1 = c1 - getDoubleValueOfLastJTextFieldV1XValue();
|
2057 |
// else
|
2058 |
// d1 = 0.0;
|
2059 |
//
|
2060 |
// if (hasChanged_v2X)
|
2061 |
// d2 = c2 - getDoubleValueOfLastJTextFieldV2XValue();
|
2062 |
// else
|
2063 |
// d2 = 0.0;
|
2064 |
//
|
2065 |
// if (d1 == 0.0) {
|
2066 |
// // It's supposed that d2 != 0
|
2067 |
// c1 += d2;
|
2068 |
//
|
2069 |
// if (c1 < getDoubleValueOfJTextFieldV2X()) {
|
2070 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2071 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2072 |
// return;
|
2073 |
// }
|
2074 |
//
|
2075 |
// getJTextFieldVertex1X().setText(Double.toString(c1));
|
2076 |
// }
|
2077 |
// else {
|
2078 |
// if (d2 == 0.0) {
|
2079 |
// // It's supposed that d1 != 0
|
2080 |
// c2 += d1;
|
2081 |
//
|
2082 |
// if (c2 > getDoubleValueOfJTextFieldV1X()) {
|
2083 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2084 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2085 |
// return;
|
2086 |
// }
|
2087 |
//
|
2088 |
// getJTextFieldVertex2X().setText(Double.toString(c2));
|
2089 |
// }
|
2090 |
// else {
|
2091 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
2092 |
// if (d1 != d2) {
|
2093 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_X"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2094 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2095 |
// return;
|
2096 |
// }
|
2097 |
// }
|
2098 |
// }
|
2099 |
// }
|
2100 |
//
|
2101 |
// // Move in Y
|
2102 |
// if ((hasChanged_v1Y) || (hasChanged_v2Y)) {
|
2103 |
// double c1 = getDoubleValueOfJTextFieldV1Y();
|
2104 |
// double c2 = getDoubleValueOfJTextFieldV2Y();
|
2105 |
// double d1, d2;
|
2106 |
//
|
2107 |
// if (hasChanged_v1Y)
|
2108 |
// d1 = c1 - getDoubleValueOfLastJTextFieldV1YValue();
|
2109 |
// else
|
2110 |
// d1 = 0.0;
|
2111 |
//
|
2112 |
// if (hasChanged_v2Y)
|
2113 |
// d2 = c2 - getDoubleValueOfLastJTextFieldV2YValue();
|
2114 |
// else
|
2115 |
// d2 = 0.0;
|
2116 |
//
|
2117 |
// if (d1 == 0.0) {
|
2118 |
// // It's supposed that d2 != 0
|
2119 |
// c1 += d2;
|
2120 |
//
|
2121 |
// if (c1 < getDoubleValueOfJTextFieldV2Y()) {
|
2122 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2123 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2124 |
// return;
|
2125 |
// }
|
2126 |
//
|
2127 |
// getJTextFieldVertex1Y().setText(Double.toString(c1));
|
2128 |
// }
|
2129 |
// else {
|
2130 |
// if (d2 == 0.0) {
|
2131 |
// // It's supposed that d1 != 0
|
2132 |
// c2 += d1;
|
2133 |
//
|
2134 |
// if (c2 > getDoubleValueOfJTextFieldV1Y()) {
|
2135 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2136 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2137 |
// return;
|
2138 |
// }
|
2139 |
//
|
2140 |
// getJTextFieldVertex2Y().setText(Double.toString(c2));
|
2141 |
// }
|
2142 |
// else {
|
2143 |
// // If there has been an error -> can't move different distances in Y the two vertexes
|
2144 |
// if (d1 != d2) {
|
2145 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_Y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2146 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2147 |
// return;
|
2148 |
// }
|
2149 |
// }
|
2150 |
// }
|
2151 |
// }
|
2152 |
// }
|
2153 |
// else {
|
2154 |
// boolean canSetExtent = true;
|
2155 |
//
|
2156 |
// // Check if there is a impossible coordinate
|
2157 |
// if (hasChanged_v1X) {
|
2158 |
// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
2159 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2160 |
// canSetExtent = false;
|
2161 |
// }
|
2162 |
// }
|
2163 |
//
|
2164 |
// if (hasChanged_v1Y) {
|
2165 |
// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
2166 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2167 |
// canSetExtent = false;
|
2168 |
// }
|
2169 |
// }
|
2170 |
//
|
2171 |
// if (hasChanged_v2X) {
|
2172 |
// if (getDoubleValueOfJTextFieldV2X() > getDoubleValueOfJTextFieldV1X()) {
|
2173 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2174 |
// canSetExtent = false;
|
2175 |
// }
|
2176 |
// }
|
2177 |
//
|
2178 |
// if (hasChanged_v2Y) {
|
2179 |
// if (getDoubleValueOfJTextFieldV2Y() > getDoubleValueOfJTextFieldV1Y()) {
|
2180 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2181 |
// canSetExtent = false;
|
2182 |
// }
|
2183 |
// }
|
2184 |
//
|
2185 |
// // If can set the new Extent -> finish
|
2186 |
// if (!canSetExtent) {
|
2187 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
2188 |
// return;
|
2189 |
// }
|
2190 |
// }
|
2191 |
// }
|
2192 |
//
|
2193 |
// //Rectangle2D r2d = vP.getExtent();
|
2194 |
// if (vP.getExtent() != null){
|
2195 |
// vP.setExtent(getNewRectangleByCoordinates());
|
2196 |
// vP.refreshExtent();
|
2197 |
// }
|
2198 |
// }
|
2199 |
// }
|
2200 |
// else {
|
2201 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "at_least_one_incorrect_coordinate"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
2202 |
// }
|
2203 |
// }
|
2204 |
}); |
2205 |
} |
2206 |
return jButtonPreviewArea;
|
2207 |
} |
2208 |
|
2209 |
/**
|
2210 |
* Calculates the new rectangle using the coordinates of the text fields
|
2211 |
*
|
2212 |
* @return java.awt.geom.Rectangle2D
|
2213 |
*/
|
2214 |
private Rectangle2D getNewRectangleByCoordinates() { |
2215 |
return new Rectangle2D.Double(getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV2Y(), getDoubleValueOfJTextFieldV1X() - getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV1Y() - getDoubleValueOfJTextFieldV2Y()); |
2216 |
} |
2217 |
|
2218 |
/**
|
2219 |
* Restores the value of all text fields with coordinates modified to their last value
|
2220 |
*/
|
2221 |
private void restoreAllModifiedCoordinates() { |
2222 |
if (hasChanged_v1X) {
|
2223 |
getJTextFieldVertex1X().setText(last_Coordinates[0]);
|
2224 |
hasChanged_v1X = false;
|
2225 |
} |
2226 |
|
2227 |
if (hasChanged_v1Y) {
|
2228 |
getJTextFieldVertex1Y().setText(last_Coordinates[1]);
|
2229 |
hasChanged_v1Y = false;
|
2230 |
} |
2231 |
|
2232 |
if (hasChanged_v2X) {
|
2233 |
getJTextFieldVertex2X().setText(last_Coordinates[2]);
|
2234 |
hasChanged_v2X = false;
|
2235 |
} |
2236 |
|
2237 |
if (hasChanged_v2Y) {
|
2238 |
getJTextFieldVertex2Y().setText(last_Coordinates[3]);
|
2239 |
hasChanged_v2Y = false;
|
2240 |
} |
2241 |
} |
2242 |
|
2243 |
/**
|
2244 |
* Enables or disables all inner JTextField
|
2245 |
*
|
2246 |
* @param b A boolean value
|
2247 |
*/
|
2248 |
public void setAllTextFieldsEnabled(boolean b) { |
2249 |
getJTextFieldVertex1X().setEnabled(b); |
2250 |
getJTextFieldVertex1Y().setEnabled(b); |
2251 |
getJTextFieldVertex2X().setEnabled(b); |
2252 |
getJTextFieldVertex2Y().setEnabled(b); |
2253 |
} |
2254 |
|
2255 |
/**
|
2256 |
* Sets the extent into the text fields
|
2257 |
*
|
2258 |
* @param envelope java.awt.geom.Rectangle2D
|
2259 |
*/
|
2260 |
public void updateCoordinates(Envelope envelope){ |
2261 |
getJTextFieldVertex1X().setText(String.valueOf(envelope.getMaximum(0))); |
2262 |
last_Coordinates[0] = getJTextFieldVertex1X().getText();
|
2263 |
previous_Coordinate_Value[0] = last_Coordinates[0]; |
2264 |
|
2265 |
getJTextFieldVertex1Y().setText(String.valueOf(envelope.getMaximum(1))); |
2266 |
last_Coordinates[1] = getJTextFieldVertex1Y().getText();
|
2267 |
previous_Coordinate_Value[1] = last_Coordinates[1]; |
2268 |
|
2269 |
getJTextFieldVertex2X().setText(String.valueOf(envelope.getMinimum(0))); |
2270 |
last_Coordinates[2] = getJTextFieldVertex2X().getText();
|
2271 |
previous_Coordinate_Value[2] = last_Coordinates[2]; |
2272 |
|
2273 |
getJTextFieldVertex2Y().setText(String.valueOf(envelope.getMinimum(0))); |
2274 |
last_Coordinates[3] = getJTextFieldVertex2Y().getText();
|
2275 |
previous_Coordinate_Value[3] = last_Coordinates[3]; |
2276 |
|
2277 |
resetCoordinatesFlags(); |
2278 |
|
2279 |
// Enable the 'Applicate' button
|
2280 |
// setApplicable(true);
|
2281 |
} |
2282 |
|
2283 |
/**
|
2284 |
* Changes the color of all coordinates text fields to <code>c</code>.
|
2285 |
*
|
2286 |
* @param c the new background color
|
2287 |
*/
|
2288 |
private void setBackGroundColorToCoordinatesFields(Color c) { |
2289 |
getJTextFieldVertex1X().setBackground(c); |
2290 |
getJTextFieldVertex1Y().setBackground(c); |
2291 |
getJTextFieldVertex2X().setBackground(c); |
2292 |
getJTextFieldVertex2Y().setBackground(c); |
2293 |
} |
2294 |
|
2295 |
/**
|
2296 |
* Validates all coordinates of both vertexes separately
|
2297 |
*
|
2298 |
* @return A ValidationInfo object reference
|
2299 |
*/
|
2300 |
private ValidationInfo validVertexesCoordinates() {
|
2301 |
String infoPrefix = null, infoSufix = null; |
2302 |
|
2303 |
if (! validateCoordinate(getJTextFieldVertex1X())) {
|
2304 |
if (infoSufix == null) { |
2305 |
infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": "; |
2306 |
infoSufix = PluginServices.getText(this, "v1x"); |
2307 |
} |
2308 |
|
2309 |
getJTextFieldVertex1X().setBackground(Color.RED);
|
2310 |
|
2311 |
// else {
|
2312 |
// infoSufix += ", " + PluginServices.getText(this, "v1x");
|
2313 |
// }
|
2314 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
2315 |
} |
2316 |
|
2317 |
if (! validateCoordinate(getJTextFieldVertex1Y())) {
|
2318 |
if (infoSufix == null) { |
2319 |
infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": "; |
2320 |
infoSufix = PluginServices.getText(this, "v1y"); |
2321 |
} |
2322 |
else {
|
2323 |
infoPrefix = PluginServices.getText(this, "invalid_coordinates") + ": "; |
2324 |
infoSufix += ", " + PluginServices.getText(this, "v1y"); |
2325 |
} |
2326 |
|
2327 |
getJTextFieldVertex1Y().setBackground(Color.RED);
|
2328 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
2329 |
} |
2330 |
|
2331 |
if (! validateCoordinate(getJTextFieldVertex2X())) {
|
2332 |
if (infoSufix == null) { |
2333 |
infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": "; |
2334 |
infoSufix = PluginServices.getText(this, "v2x"); |
2335 |
} |
2336 |
else {
|
2337 |
infoPrefix = PluginServices.getText(this, "invalid_coordinates") + ": "; |
2338 |
infoSufix += ", " + PluginServices.getText(this, "v2x"); |
2339 |
} |
2340 |
|
2341 |
getJTextFieldVertex2X().setBackground(Color.RED);
|
2342 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
2343 |
} |
2344 |
|
2345 |
if (! validateCoordinate(getJTextFieldVertex2Y())) {
|
2346 |
if (infoSufix == null) { |
2347 |
infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": "; |
2348 |
infoSufix = PluginServices.getText(this, "v2y"); |
2349 |
} |
2350 |
else {
|
2351 |
infoPrefix = PluginServices.getText(this, "invalid_coordinates") + ": "; |
2352 |
infoSufix += ", " + PluginServices.getText(this, "v2y"); |
2353 |
} |
2354 |
|
2355 |
getJTextFieldVertex2Y().setBackground(Color.RED);
|
2356 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
2357 |
} |
2358 |
|
2359 |
if (infoPrefix != null) |
2360 |
return new ValidationInfo(false, infoPrefix + infoSufix); |
2361 |
|
2362 |
// If arrives here, all coordinates are valid
|
2363 |
setBackGroundColorToCoordinatesFields(Color.GREEN);
|
2364 |
return new ValidationInfo(true, ""); |
2365 |
} |
2366 |
|
2367 |
/**
|
2368 |
* Validates that Vertex1 is in the right-up corner and the Vertex2 in the left-down corner of the area/rectangle <br>
|
2369 |
* (It's supposed that coordinates of the vertexes are valid) <br>
|
2370 |
* (It's supposed that going to right or up, the coordinate value increases)
|
2371 |
*
|
2372 |
* @return A ValidationInfo object reference
|
2373 |
*/
|
2374 |
private ValidationInfo validVertexesPositions() {
|
2375 |
String infoPrefix = null, infoSufix = null; |
2376 |
|
2377 |
// Check if no coordinate it's defined
|
2378 |
if (getJTextFieldVertex1X().getText().compareTo("") == 0) { |
2379 |
if (infoSufix == null) { |
2380 |
infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": "; |
2381 |
infoSufix = PluginServices.getText(this, "v1x"); |
2382 |
} |
2383 |
|
2384 |
getJTextFieldVertex1X().setBackground(Color.RED);
|
2385 |
|
2386 |
// else {
|
2387 |
// infoSufix += ", " + PluginServices.getText(this, "v1x");
|
2388 |
// }
|
2389 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
2390 |
} |
2391 |
|
2392 |
if (getJTextFieldVertex1Y().getText().compareTo("") == 0) { |
2393 |
if (infoSufix == null) { |
2394 |
infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": "; |
2395 |
infoSufix = PluginServices.getText(this, "v1y"); |
2396 |
} |
2397 |
else {
|
2398 |
infoPrefix = PluginServices.getText(this, "undefined_coordinates") + ": "; |
2399 |
infoSufix += ", " + PluginServices.getText(this, "v1y"); |
2400 |
} |
2401 |
|
2402 |
getJTextFieldVertex1Y().setBackground(Color.RED);
|
2403 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
2404 |
} |
2405 |
|
2406 |
if (getJTextFieldVertex2X().getText().compareTo("") == 0) { |
2407 |
if (infoSufix == null) { |
2408 |
infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": "; |
2409 |
infoSufix = PluginServices.getText(this, "v2x"); |
2410 |
} |
2411 |
else {
|
2412 |
infoPrefix = PluginServices.getText(this, "undefined_coordinates") + ": "; |
2413 |
infoSufix += ", " + PluginServices.getText(this, "v2x"); |
2414 |
} |
2415 |
|
2416 |
getJTextFieldVertex2X().setBackground(Color.RED);
|
2417 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
2418 |
} |
2419 |
|
2420 |
if (getJTextFieldVertex2Y().getText().compareTo("") == 0) { |
2421 |
if (infoSufix == null) { |
2422 |
infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": "; |
2423 |
infoSufix = PluginServices.getText(this, "v2y"); |
2424 |
} |
2425 |
else {
|
2426 |
infoPrefix = PluginServices.getText(this, "undefined_coordinates") + ": "; |
2427 |
infoSufix += ", " + PluginServices.getText(this, "v2y"); |
2428 |
} |
2429 |
|
2430 |
getJTextFieldVertex2Y().setBackground(Color.RED);
|
2431 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
2432 |
} |
2433 |
|
2434 |
if (infoPrefix != null) |
2435 |
return new ValidationInfo(false, infoPrefix + infoSufix); |
2436 |
|
2437 |
// Check if the vertex V1 is in the right-up corner and the vertex V2 is in the left-down corner
|
2438 |
if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
2439 |
getJTextFieldVertex1X().setBackground(Color.RED);
|
2440 |
getJTextFieldVertex2X().setBackground(Color.RED);
|
2441 |
return new ValidationInfo(false, PluginServices.getText(this, "v1x") + " < " + PluginServices.getText(this, "v2x")); |
2442 |
} |
2443 |
|
2444 |
if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
2445 |
getJTextFieldVertex1Y().setBackground(Color.RED);
|
2446 |
getJTextFieldVertex2Y().setBackground(Color.RED);
|
2447 |
return new ValidationInfo(false, PluginServices.getText(this, "v1y") + " < " + PluginServices.getText(this, "v2y")); |
2448 |
} |
2449 |
|
2450 |
// If arrives here -> vertexes positions are valid
|
2451 |
setBackGroundColorToCoordinatesFields(Color.GREEN);
|
2452 |
return new ValidationInfo(true, ""); |
2453 |
} |
2454 |
|
2455 |
// /** OLD VERSION
|
2456 |
// * Validates all coordinates of both vertexes separately
|
2457 |
// *
|
2458 |
// * @return A ValidationInfo object reference
|
2459 |
// */
|
2460 |
// private ValidationInfo validVertexesCoordinates() {
|
2461 |
// if (! validateCoordinate(getJTextFieldVertex1X())) {
|
2462 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
2463 |
// }
|
2464 |
//
|
2465 |
// if (! validateCoordinate(getJTextFieldVertex1Y())) {
|
2466 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
2467 |
// }
|
2468 |
//
|
2469 |
// if (! validateCoordinate(getJTextFieldVertex2X())) {
|
2470 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
2471 |
// }
|
2472 |
//
|
2473 |
// if (! validateCoordinate(getJTextFieldVertex2Y())) {
|
2474 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
2475 |
// }
|
2476 |
//
|
2477 |
// // If arrives here, all coordinates are valid
|
2478 |
// return new ValidationInfo(true, "");
|
2479 |
// }
|
2480 |
//
|
2481 |
// /** OLD VERSION
|
2482 |
// * Validates that Vertex1 is in the right-up corner and the Vertex2 in the left-down corner of the area/rectangle <br>
|
2483 |
// * (It's supposed that coordinates of the vertexes are valid) <br>
|
2484 |
// * (It's supposed that going to right or up, the coordinate value increases)
|
2485 |
// *
|
2486 |
// * @return A ValidationInfo object reference
|
2487 |
// */
|
2488 |
// private ValidationInfo validVertexesPositions() {
|
2489 |
// // Check if no coordinate it's defined
|
2490 |
// if (getJTextFieldVertex1X().getText().compareTo("") == 0) {
|
2491 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
2492 |
// }
|
2493 |
//
|
2494 |
// if (getJTextFieldVertex2X().getText().compareTo("") == 0) {
|
2495 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
2496 |
// }
|
2497 |
//
|
2498 |
// if (getJTextFieldVertex1Y().getText().compareTo("") == 0) {
|
2499 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
2500 |
// }
|
2501 |
//
|
2502 |
// if (getJTextFieldVertex2Y().getText().compareTo("") == 0) {
|
2503 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
2504 |
// }
|
2505 |
//
|
2506 |
// // Check if the vertex V1 is in the right-up corner and the vertex V2 is in the left-down corner
|
2507 |
// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
2508 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1x") + " < " + PluginServices.getText(this, "v2x"));
|
2509 |
// }
|
2510 |
//
|
2511 |
// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
2512 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1y") + " < " + PluginServices.getText(this, "v2y"));
|
2513 |
// }
|
2514 |
//
|
2515 |
// // If arrives here -> vertexes positions are valid
|
2516 |
// return new ValidationInfo(true, "");
|
2517 |
// }
|
2518 |
|
2519 |
/**
|
2520 |
* Validate each coordinate of each vertex and the position of the vertexes
|
2521 |
*
|
2522 |
* @return A boolean value
|
2523 |
*/
|
2524 |
public boolean validVertexes() { |
2525 |
ValidationInfo v1 = validVertexesCoordinates(); |
2526 |
|
2527 |
if (!v1.isValid()) {
|
2528 |
|
2529 |
// setApplicable(false);
|
2530 |
|
2531 |
// Notify to user that no filter area will be applied
|
2532 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v1.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
2533 |
|
2534 |
// Restore the previous valid extent
|
2535 |
if (previousExtentValids.hasPrevious()) {
|
2536 |
Rectangle2D previousExtent = previousExtentValids.removePrev();
|
2537 |
setCoordinates(previousExtent); |
2538 |
|
2539 |
if (!previousExtentValids.hasPrevious()) {
|
2540 |
hasUserDefinedAnArea = false;
|
2541 |
setApplicable(false);
|
2542 |
} |
2543 |
|
2544 |
previousExtentValids.put(previousExtent); |
2545 |
} |
2546 |
|
2547 |
return false; |
2548 |
} |
2549 |
else {
|
2550 |
ValidationInfo v2 = validVertexesPositions(); |
2551 |
if (!v2.isValid()) {
|
2552 |
// setApplicable(false);
|
2553 |
|
2554 |
// Notify to user that no filter area will be applied
|
2555 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v2.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
2556 |
|
2557 |
// Restore the previous valid extent
|
2558 |
if (previousExtentValids.hasPrevious()) {
|
2559 |
Rectangle2D previousExtent = previousExtentValids.removePrev();
|
2560 |
setCoordinates(previousExtent); |
2561 |
|
2562 |
if (!previousExtentValids.hasPrevious()) {
|
2563 |
hasUserDefinedAnArea = false;
|
2564 |
setApplicable(false);
|
2565 |
} |
2566 |
|
2567 |
previousExtentValids.put(previousExtent); |
2568 |
} |
2569 |
|
2570 |
return false; |
2571 |
} |
2572 |
else {
|
2573 |
// Once has been validated -> allow apply with the new extent, and save it
|
2574 |
if (previousExtentValids.hasPrevious()) {
|
2575 |
Rectangle2D previousExtent = previousExtentValids.removePrev();
|
2576 |
if (! areEqual(previousExtent, getExtent())) {
|
2577 |
previousExtentValids.put(previousExtent); |
2578 |
previousExtentValids.put(getExtent()); |
2579 |
setApplicable(true);
|
2580 |
} |
2581 |
else {
|
2582 |
previousExtentValids.put(previousExtent); |
2583 |
} |
2584 |
} |
2585 |
else {
|
2586 |
previousExtentValids.put(getExtent()); |
2587 |
setApplicable(true);
|
2588 |
} |
2589 |
|
2590 |
return true; |
2591 |
} |
2592 |
} |
2593 |
} |
2594 |
|
2595 |
/**
|
2596 |
* <p>Compares two bi-dimensional rectangles, and returns <code>true</code> if both are equals.</p>
|
2597 |
*
|
2598 |
* @param rect1 first rectangle 2D to compare
|
2599 |
* @param rect2 second rectangle 2D to compare
|
2600 |
*
|
2601 |
* @return <code>true</code> if both are equals; otherwise <code>false</code>
|
2602 |
*/
|
2603 |
private boolean areEqual(Rectangle2D rect1, Rectangle2D rect2) { |
2604 |
return ((rect1.getX() == rect2.getX()) && (rect1.getY() == rect2.getY()) &&
|
2605 |
(rect1.getWidth() == rect2.getWidth()) && (rect1.getHeight() == rect2.getHeight())); |
2606 |
} |
2607 |
|
2608 |
/**
|
2609 |
* Gets the extent (rectangle) represented by the values of the coordinate text fields
|
2610 |
*
|
2611 |
* @return java.awt.geom.Rectangle2D
|
2612 |
*/
|
2613 |
public Rectangle2D getExtent() { |
2614 |
double v1x = getDoubleValueOfJTextFieldV1X();
|
2615 |
double v1y = getDoubleValueOfJTextFieldV1Y();
|
2616 |
double v2x = getDoubleValueOfJTextFieldV2X();
|
2617 |
double v2y = getDoubleValueOfJTextFieldV2Y();
|
2618 |
|
2619 |
return new Rectangle2D.Double(v2x, v2y, (v1x - v2x), (v1y - v2y)); |
2620 |
} |
2621 |
|
2622 |
/**
|
2623 |
* Returns true if there is some coordinate text field with data; else returns false
|
2624 |
*
|
2625 |
* @return A boolean value
|
2626 |
*/
|
2627 |
public boolean areThereSomeCoordinatesWritten() { |
2628 |
return ((getJTextFieldVertex1X().getText().compareTo("") != 0) | (getJTextFieldVertex1Y().getText().compareTo("") != 0) | (getJTextFieldVertex2X().getText().compareTo("") != 0) | (getJTextFieldVertex2Y().getText().compareTo("") != 0)); |
2629 |
} |
2630 |
|
2631 |
/**
|
2632 |
* Returns true if all coordinate text fields are undefined (without values)
|
2633 |
*
|
2634 |
* @return A boolean value
|
2635 |
*/
|
2636 |
public boolean areAllCoordinatesUndefined() { |
2637 |
return ((getJTextFieldVertex1X().getText().compareTo("") == 0) & (getJTextFieldVertex1Y().getText().compareTo("") == 0) & (getJTextFieldVertex2X().getText().compareTo("") == 0) & (getJTextFieldVertex2Y().getText().compareTo("") == 0)); |
2638 |
} |
2639 |
|
2640 |
|
2641 |
/**
|
2642 |
* Returns true if there is some coordinate undefined (without values)
|
2643 |
*
|
2644 |
* @return A boolean value
|
2645 |
*/
|
2646 |
public boolean isThereAnyCoordinateUndefined() { |
2647 |
return ((getJTextFieldVertex1X().getText().compareTo("") == 0) | (getJTextFieldVertex1Y().getText().compareTo("") == 0) | (getJTextFieldVertex2X().getText().compareTo("") == 0) | (getJTextFieldVertex2Y().getText().compareTo("") == 0)); |
2648 |
} |
2649 |
} |
2650 |
|
2651 |
/**
|
2652 |
* This class is a MapControl JComponent that has visual information and allows user interact with some tools and view the results
|
2653 |
*
|
2654 |
* @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
2655 |
*/
|
2656 |
private class SelectableMapControlAreaPanel extends MapControl { |
2657 |
private MouseListener[] mouseListeners; |
2658 |
private MouseWheelListener[] mouseWheelListeners; |
2659 |
private MouseMotionListener[] mouseMotionListeners; |
2660 |
|
2661 |
/**
|
2662 |
* Default constructor
|
2663 |
*/
|
2664 |
public SelectableMapControlAreaPanel() {
|
2665 |
super();
|
2666 |
initialize(); |
2667 |
} |
2668 |
|
2669 |
/**
|
2670 |
* This method initializes this component
|
2671 |
*/
|
2672 |
public void initialize() { |
2673 |
/* Sets Bounds of this graphical component */
|
2674 |
this.setBounds(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE);
|
2675 |
|
2676 |
/* Sets border to this graphical component */
|
2677 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1)); |
2678 |
|
2679 |
MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext(); |
2680 |
|
2681 |
this.setMapContext(mp.cloneFMap());
|
2682 |
ViewPort vP = this.getViewPort();
|
2683 |
|
2684 |
// We will use the adjusted extent because increases the usability
|
2685 |
Envelope envelope = vP.getAdjustedExtent(); |
2686 |
// Rectangle2D r2D = vP.getExtent();
|
2687 |
|
2688 |
if (envelope != null) { |
2689 |
vP.refreshExtent(); |
2690 |
getCoordinatesPanel().updateCoordinates(envelope); |
2691 |
} |
2692 |
|
2693 |
/* Adds listeners to this MapControl */
|
2694 |
this.addToolsListeners();
|
2695 |
|
2696 |
/* Sets default tool */
|
2697 |
this.setTool(PAN_TOOL);
|
2698 |
} |
2699 |
|
2700 |
/**
|
2701 |
* Refresh the active view
|
2702 |
*/
|
2703 |
public void refreshWithTheActiveView() { |
2704 |
MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext(); |
2705 |
this.setMapContext(mp.cloneFMap());
|
2706 |
ViewPort vP = this.getViewPort();
|
2707 |
|
2708 |
// We will use the adjusted extent because increases the usability
|
2709 |
Envelope envelope = vP.getAdjustedExtent(); |
2710 |
// Rectangle2D r2D = vP.getExtent();
|
2711 |
|
2712 |
if (envelope != null) { |
2713 |
vP.refreshExtent(); |
2714 |
getCoordinatesPanel().updateCoordinates(envelope); |
2715 |
} |
2716 |
} |
2717 |
|
2718 |
/**
|
2719 |
* Adds listeners that allows user interact with it's mouse over this component and that represents different tools
|
2720 |
*/
|
2721 |
private void addToolsListeners() { |
2722 |
// MOVEMENT EVENTS LISTENER: sets mouse coordinates to the status bar
|
2723 |
StatusBarListener sbl = new StatusBarListener(this); |
2724 |
|
2725 |
// ZOOM OUT (Presses on the map and it will be centered showing a bigger area)
|
2726 |
// Only pressing, not selecting a rectangle area
|
2727 |
ZoomOutListener zol = new ZoomOutListener(this); |
2728 |
this.addMapTool(ZOOM_OUT_TOOL, new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
2729 |
|
2730 |
// ZOOM IN (Using a Rectangle or a simple mouse click)
|
2731 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(this); |
2732 |
ZoomInListener zil = new ZoomInListener(this); |
2733 |
this.addMapTool(ZOOM_IN_TOOL, new Behavior[]{new RectangleBehavior(zil), |
2734 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
2735 |
|
2736 |
// PAN
|
2737 |
PanListener pl = new PanListener(this); |
2738 |
this.addMapTool(PAN_TOOL, new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
2739 |
|
2740 |
// MEASURE DISTANCES
|
2741 |
MeasureListener mli = new MeasureListener(this); |
2742 |
this.addMapTool(MEASURE_DISTANCES_TOOL, new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
2743 |
|
2744 |
// MEASURE AREA
|
2745 |
AreaListener ali = new AreaListener(this); |
2746 |
this.addMapTool(MEASURE_AREA_TOOL, new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
2747 |
|
2748 |
this.getViewPort().addViewPortListener(new ViewPortListener() { |
2749 |
/*
|
2750 |
* (non-Javadoc)
|
2751 |
* @see com.iver.cit.gvsig.fmap.ViewPortListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
2752 |
*/
|
2753 |
public void extentChanged(ExtentEvent e) { |
2754 |
if (!getEnablingJCheckBox().isSelected())
|
2755 |
return;
|
2756 |
|
2757 |
if (getMapContext().getViewPort().getExtents().hasPrevious()) {
|
2758 |
// We will use the adjusted extent because increases the usability
|
2759 |
Envelope envelope = getViewPort().getAdjustedExtent(); |
2760 |
// Rectangle2D r2d = getViewPort().getExtent();
|
2761 |
|
2762 |
if (envelope != null) { |
2763 |
getCoordinatesPanel().updateCoordinates(envelope); |
2764 |
|
2765 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
2766 |
hasUserDefinedAnArea = true;
|
2767 |
// }
|
2768 |
} |
2769 |
|
2770 |
getJButtonZoomPrevious().setEnabled(true);
|
2771 |
getJButtonUndo().setEnabled(true);
|
2772 |
} |
2773 |
else {
|
2774 |
getJButtonZoomPrevious().setEnabled(false);
|
2775 |
getJButtonUndo().setEnabled(false);
|
2776 |
} |
2777 |
} |
2778 |
|
2779 |
/*
|
2780 |
* (non-Javadoc)
|
2781 |
* @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
2782 |
*/
|
2783 |
public void backColorChanged(ColorEvent e) { |
2784 |
} |
2785 |
|
2786 |
/*
|
2787 |
* (non-Javadoc)
|
2788 |
* @see com.iver.cit.gvsig.fmap.ViewPortListener#projectionChanged(com.iver.cit.gvsig.fmap.ProjectionEvent)
|
2789 |
*/
|
2790 |
public void projectionChanged(ProjectionEvent e) { |
2791 |
} |
2792 |
|
2793 |
}); |
2794 |
} |
2795 |
|
2796 |
/*
|
2797 |
* (non-Javadoc)
|
2798 |
* @see java.awt.Component#setEnabled(boolean)
|
2799 |
*/
|
2800 |
public void setEnabled(boolean b) { |
2801 |
super.setEnabled(b);
|
2802 |
|
2803 |
if (b)
|
2804 |
enableAllMouseListeners(); |
2805 |
else
|
2806 |
disableAllMouseListeners(); |
2807 |
} |
2808 |
|
2809 |
/**
|
2810 |
* Disables all mouse listeners
|
2811 |
*/
|
2812 |
public void disableAllMouseListeners() { |
2813 |
int i;
|
2814 |
|
2815 |
// Only disable listeners if there are listeners to remove (it's supposed that there are always the same number of mouse listeners, and this listeners
|
2816 |
// are referenciated by this component or by the private attribute 'mouseListeners')
|
2817 |
|
2818 |
// Mouse Button Listeners
|
2819 |
if (mouseListeners == null) { |
2820 |
mouseListeners = this.getMouseListeners();
|
2821 |
|
2822 |
for (i = 0; i < mouseListeners.length; i++) { |
2823 |
removeMouseListener(mouseListeners[i]); |
2824 |
} |
2825 |
} |
2826 |
|
2827 |
// Mouse Wheel Listeners
|
2828 |
if (mouseWheelListeners == null) { |
2829 |
mouseWheelListeners = this.getMouseWheelListeners();
|
2830 |
|
2831 |
for (i = 0; i < mouseWheelListeners.length; i++) { |
2832 |
removeMouseWheelListener(mouseWheelListeners[i]); |
2833 |
} |
2834 |
} |
2835 |
|
2836 |
// Mouse motion listeners
|
2837 |
if (mouseMotionListeners == null) { |
2838 |
mouseMotionListeners = this.getMouseMotionListeners();
|
2839 |
|
2840 |
for (i = 0; i < mouseMotionListeners.length; i++) { |
2841 |
removeMouseMotionListener(mouseMotionListeners[i]); |
2842 |
} |
2843 |
} |
2844 |
} |
2845 |
|
2846 |
/**
|
2847 |
* Enables all mouse listeners
|
2848 |
*/
|
2849 |
public void enableAllMouseListeners() { |
2850 |
int i;
|
2851 |
|
2852 |
// Mouse Button Listeners
|
2853 |
for (i = 0; i < mouseListeners.length; i++) { |
2854 |
addMouseListener(mouseListeners[i]); |
2855 |
} |
2856 |
|
2857 |
mouseListeners = null;
|
2858 |
|
2859 |
// Mouse Wheel Listeners
|
2860 |
for (i = 0; i < mouseWheelListeners.length; i++) { |
2861 |
addMouseWheelListener(mouseWheelListeners[i]); |
2862 |
} |
2863 |
|
2864 |
mouseWheelListeners = null;
|
2865 |
|
2866 |
// Mouse motion listeners
|
2867 |
for (i = 0; i < mouseMotionListeners.length; i++) { |
2868 |
addMouseMotionListener(mouseMotionListeners[i]); |
2869 |
} |
2870 |
|
2871 |
mouseMotionListeners = null;
|
2872 |
} |
2873 |
} |
2874 |
|
2875 |
/**
|
2876 |
* This class has information about a validation: <br>
|
2877 |
* - A boolean value -> if has been or not validated <br>
|
2878 |
* - An String -> a message about the invalid
|
2879 |
*
|
2880 |
* @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
2881 |
*/
|
2882 |
private class ValidationInfo { |
2883 |
private boolean _valid; |
2884 |
private String _message; |
2885 |
|
2886 |
/**
|
2887 |
* Default constructor with two parameters
|
2888 |
*
|
2889 |
* @param valid If was valid or not
|
2890 |
* @param message A message associate to the validation (If has been valid, this attribute should be "", in the other case should have a message with
|
2891 |
* an explanation about the invalidation)
|
2892 |
*/
|
2893 |
public ValidationInfo(boolean valid, String message) { |
2894 |
_valid = valid; |
2895 |
_message = message; |
2896 |
} |
2897 |
|
2898 |
/**
|
2899 |
* Returns the value of the inner attribute '_valid'
|
2900 |
*
|
2901 |
* @return A boolean value
|
2902 |
*/
|
2903 |
public boolean isValid() { |
2904 |
return _valid;
|
2905 |
} |
2906 |
|
2907 |
/**
|
2908 |
* Returns the value of the inner attribute '_message'
|
2909 |
*
|
2910 |
* @return java.lang.String
|
2911 |
*/
|
2912 |
public String getMessage() { |
2913 |
return _message;
|
2914 |
} |
2915 |
} |
2916 |
|
2917 |
/*
|
2918 |
* (non-Javadoc)
|
2919 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#initialize()
|
2920 |
*/
|
2921 |
protected void initialize() { |
2922 |
setLabel(PluginServices.getText(this, "area")); |
2923 |
setLabelGroup(PluginServices.getText(this, "wfs")); |
2924 |
this.setLayout(new java.awt.BorderLayout()); |
2925 |
java.awt.GridBagConstraints gridBagConstraints; |
2926 |
|
2927 |
northPanel = new JPanel(); |
2928 |
northPanel.setLayout(new java.awt.GridBagLayout());
|
2929 |
|
2930 |
northPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
2931 |
null, PluginServices.getText(this, "select_by_area"), |
2932 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
2933 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
2934 |
|
2935 |
// By default, user hasn't defined an area
|
2936 |
this.hasUserDefinedAnArea = false; |
2937 |
|
2938 |
// Adds JPanel with the coordinates
|
2939 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
2940 |
gridBagConstraints.gridx = 0;
|
2941 |
gridBagConstraints.gridy = 0;
|
2942 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
2943 |
gridBagConstraints.weightx = 1.0;
|
2944 |
northPanel.add(getCoordinatesPanel(), gridBagConstraints); |
2945 |
|
2946 |
// Adds a check box to enable or enable this kind of filtering
|
2947 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
2948 |
gridBagConstraints.gridx = 0;
|
2949 |
gridBagConstraints.gridy = 1;
|
2950 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
2951 |
gridBagConstraints.weightx = 1.0;
|
2952 |
northPanel.add(getEnablingJCheckBox(), gridBagConstraints); |
2953 |
|
2954 |
// Adds JComboBox to select a part of the graphical interface
|
2955 |
// this.add(getJComboBoxToolSelection(), null);
|
2956 |
// this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element
|
2957 |
|
2958 |
// Adds JPanel with the view
|
2959 |
// this.add(getSelectableMapAreaPanel(), null);
|
2960 |
|
2961 |
previousExtentValids = new ExtentHistory();
|
2962 |
initCoordinates(); |
2963 |
|
2964 |
add(northPanel, java.awt.BorderLayout.NORTH); |
2965 |
} |
2966 |
|
2967 |
/*
|
2968 |
* (non-Javadoc)
|
2969 |
* @see com.iver.cit.gvsig.gui.panels.IWFSPanel#refresh(com.iver.cit.gvsig.fmap.layers.WFSLayerNode)
|
2970 |
*/
|
2971 |
public void refresh(WFSSelectedFeature layer) { |
2972 |
} |
2973 |
} |
2974 |
|
2975 |
|
2976 |
|
2977 |
///**
|
2978 |
// * VERSI?N PROVISIONAL
|
2979 |
// *
|
2980 |
// * This panel allows user to select the area he/she wants to get in the view.
|
2981 |
// * There are two options to do this:
|
2982 |
// * - Indicating the coordinates of the top-left and down-right corners
|
2983 |
// * - Selecting the area with some visual tool
|
2984 |
// *
|
2985 |
// * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
2986 |
// * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
2987 |
// */
|
2988 |
//public class WFSAreaPanel extends JPanel {
|
2989 |
// private final Rectangle DEFAULT_BOUNDS = new Rectangle(10, 5, 490, 380);
|
2990 |
// private final Rectangle DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE = new Rectangle(8, 20, 481, 60);
|
2991 |
// private final Rectangle DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE = new Rectangle(8, 115, 481, 265);
|
2992 |
// private final Rectangle DEFAULT_UNDO_ICON_BUTTON_RECTANGLE = new Rectangle (250, 85, 25, 25);
|
2993 |
//// private final Rectangle DEFAULT_REDO_ICON_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25);
|
2994 |
//// private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25);
|
2995 |
//// private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (331, 85, 25, 25);
|
2996 |
// private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25);
|
2997 |
// private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25);
|
2998 |
// private final Rectangle DEFAULT_PAN_ICON_BUTTON_RECTANGLE = new Rectangle(250, 85, 25, 25);
|
2999 |
// private final Rectangle DEFAULT_TOOL_JCOMBOBOX_RECTANGLE = new Rectangle(10, 87, 230, 21);
|
3000 |
// private final Rectangle DEFAULT_ENABLING_CHECKBOX_RECTANGLE = new Rectangle(10, 87, 150, 21);
|
3001 |
// private final Rectangle DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE = new Rectangle(277, 85, 47, 25);
|
3002 |
// private final Rectangle DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE = new Rectangle(326, 85, 25, 25);
|
3003 |
// private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(353, 85, 25, 25);
|
3004 |
// private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE = new Rectangle(380, 85, 47, 25);
|
3005 |
// private final Rectangle DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE = new Rectangle(429, 85, 47, 25);
|
3006 |
//
|
3007 |
// private final int DISABLED_OPERATION = 0;
|
3008 |
// private final int SELECTION_BY_COORDINATES_OPERATION = 1;
|
3009 |
// private final int SELECTION_BY_AREA_OPERATION = 2;
|
3010 |
// private boolean hasUserDefinedAnArea;
|
3011 |
//
|
3012 |
// private WFSWizardData data = null;
|
3013 |
// private WFSParamsPanel parent = null;
|
3014 |
// private AreaCoordinatesPanel coordinatesPanel = null;
|
3015 |
// private SelectableMapControlAreaPanel selectableMapAreaPanel = null;
|
3016 |
// private JComboBox jComboBoxToolSelection = null;
|
3017 |
// private JButton jButtonUndo = null;
|
3018 |
//// private JButton jButtonRedo = null;
|
3019 |
// private JToggleButton jToggleButtonMove = null;
|
3020 |
// private JToggleButton jToggleButtonScaling = null;
|
3021 |
// private JButton jButtonPan = null;
|
3022 |
// private JButton jButtonZoomPrevious = null;
|
3023 |
// private JButton jButtonZoomComplete = null;
|
3024 |
// private JComboBoxWithImageIconItems jComboBoxZoomInAndOut = null;
|
3025 |
// private JComboBoxWithImageIconItems jComboBoxZoomInAndOutViewCentered = null;
|
3026 |
// private JComboBoxWithImageIconItems jComboBoxOtherTools = null;
|
3027 |
// private JCheckBox jEnablingCheckBox = null;
|
3028 |
//
|
3029 |
// /* Tool identifier constants */
|
3030 |
// private final String PAN_TOOL = "HAND";
|
3031 |
// private final String ZOOM_IN_TOOL = "zoomIn"; // This constant must be 'zoomIn' for a correct operation of the tools 'Zoom In' and 'Zoom In Map Centered'
|
3032 |
// private final String ZOOM_OUT_TOOL = "zoomOut"; // This constant must be 'zoomOut' for a correct operation of the tools 'Zoom Out' and 'Zoom Out Map Centered'
|
3033 |
// private final String ZOOM_IN_VIEW_CENTERED_TOOL = "ZOOM_IN_VIEW_CENTERED";
|
3034 |
// private final String ZOOM_OUT_VIEW_CENTERED_TOOL = "ZOOM_OUT_VIEW_CENTERED";
|
3035 |
// private final String MEASURE_DISTANCES_TOOL = "MEASURE_DISTANCES";
|
3036 |
// private final String MEASURE_AREA_TOOL = "MEASURE_AREA";
|
3037 |
// /* End tool identifier constants */
|
3038 |
//
|
3039 |
//
|
3040 |
// /**
|
3041 |
// * This method initializes
|
3042 |
// */
|
3043 |
// public WFSAreaPanel(WFSParamsPanel parent) {
|
3044 |
// super();
|
3045 |
// this.parent = parent;
|
3046 |
// initialize();
|
3047 |
// }
|
3048 |
//
|
3049 |
// /**
|
3050 |
// * This method initializes this
|
3051 |
// */
|
3052 |
// private void initialize() {
|
3053 |
// this.setLayout(null);
|
3054 |
// this.setBounds(DEFAULT_BOUNDS);
|
3055 |
// this.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
3056 |
// null, PluginServices.getText(this, "select_by_area"),
|
3057 |
// javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
3058 |
// javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
3059 |
//
|
3060 |
// // By default, user hasn't defined an area
|
3061 |
// this.hasUserDefinedAnArea = false;
|
3062 |
//
|
3063 |
// // Adds JPanel with the coordinates
|
3064 |
// this.add(getCoordinatesPanel(), null);
|
3065 |
//
|
3066 |
// // Adds a check box to enable or enable this kind of filtering
|
3067 |
// this.add(getEnablingJCheckBox());
|
3068 |
//
|
3069 |
// // Adds JComboBox to select a part of the graphical interface
|
3070 |
//// this.add(getJComboBoxToolSelection(), null);
|
3071 |
//// this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element
|
3072 |
//
|
3073 |
// // Adds JPanel with the view
|
3074 |
//// this.add(getSelectableMapAreaPanel(), null);
|
3075 |
//
|
3076 |
// initCoordinates();
|
3077 |
// }
|
3078 |
//
|
3079 |
// /**
|
3080 |
// * Write the view coordinates into the coordinates panel
|
3081 |
// */
|
3082 |
// private void initCoordinates(){
|
3083 |
// BaseView activeView = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
3084 |
// Rectangle2D r2d = activeView.getMapControl().getViewPort().getExtent();
|
3085 |
// if (r2d != null){
|
3086 |
// System.out.println("Extent de la vista activa: " + r2d);
|
3087 |
//// getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMinX() + r2d.getWidth()));
|
3088 |
// getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMaxX()));
|
3089 |
//// getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(r2d.getMinY() + r2d.getHeight()));
|
3090 |
// getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(r2d.getMaxY()));
|
3091 |
// getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(r2d.getMinX()));
|
3092 |
// getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(r2d.getMinY()));
|
3093 |
// }
|
3094 |
// }
|
3095 |
//
|
3096 |
// /**
|
3097 |
// * This method initializes coordinatesPanel
|
3098 |
// *
|
3099 |
// * @return javax.swing.JPanel
|
3100 |
// */
|
3101 |
// private AreaCoordinatesPanel getCoordinatesPanel() {
|
3102 |
// if (coordinatesPanel == null) {
|
3103 |
// coordinatesPanel = new AreaCoordinatesPanel();
|
3104 |
// }
|
3105 |
// return coordinatesPanel;
|
3106 |
// }
|
3107 |
//
|
3108 |
// private JCheckBox getEnablingJCheckBox() {
|
3109 |
// if (jEnablingCheckBox == null) {
|
3110 |
// jEnablingCheckBox = new JCheckBox(PluginServices.getText(this, "enabled"));
|
3111 |
// jEnablingCheckBox.setBounds(DEFAULT_ENABLING_CHECKBOX_RECTANGLE);
|
3112 |
// jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area"));
|
3113 |
// jEnablingCheckBox.setSelected(false);
|
3114 |
// jEnablingCheckBox.addItemListener(new ItemListener() {
|
3115 |
// /*
|
3116 |
// * (non-Javadoc)
|
3117 |
// * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
3118 |
// */
|
3119 |
// public void itemStateChanged(ItemEvent e) {
|
3120 |
// if (e.getStateChange() == ItemEvent.SELECTED) {
|
3121 |
// jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "disable_filter_by_area"));
|
3122 |
// enableCoorderatesRegionOperation();
|
3123 |
// }
|
3124 |
// else {
|
3125 |
// jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area"));
|
3126 |
// disableCoorderatesRegionOperation();
|
3127 |
// }
|
3128 |
// }
|
3129 |
// });
|
3130 |
//
|
3131 |
// // By default, the tool is disabled
|
3132 |
// disableCoorderatesRegionOperation();
|
3133 |
// }
|
3134 |
// return jEnablingCheckBox;
|
3135 |
// }
|
3136 |
//
|
3137 |
// /**
|
3138 |
// * This method initializes jComboBoxToolSelection
|
3139 |
// *
|
3140 |
// * @return javax.swing.JComboBox
|
3141 |
// */
|
3142 |
// private JComboBox getJComboBoxToolSelection() {
|
3143 |
// if (jComboBoxToolSelection == null) {
|
3144 |
// jComboBoxToolSelection = new JComboBox();
|
3145 |
// jComboBoxToolSelection.setBounds(DEFAULT_TOOL_JCOMBOBOX_RECTANGLE);
|
3146 |
// jComboBoxToolSelection.setToolTipText(PluginServices.getText(this, "select_a_tool"));
|
3147 |
// jComboBoxToolSelection.setEditable(false);
|
3148 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION));
|
3149 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION));
|
3150 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION));
|
3151 |
//
|
3152 |
// jComboBoxToolSelection.addActionListener(new ActionListener() {
|
3153 |
// /*
|
3154 |
// * (non-Javadoc)
|
3155 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
3156 |
// */
|
3157 |
// public void actionPerformed(ActionEvent e) {
|
3158 |
// JComboBox cb = (JComboBox)e.getSource();
|
3159 |
// switch(((ItemOperation)cb.getSelectedItem()).getOperation()) {
|
3160 |
// case DISABLED_OPERATION:
|
3161 |
// disableCoorderatesRegionOperation();
|
3162 |
// disableAreaRegionOperation();
|
3163 |
// break;
|
3164 |
// case SELECTION_BY_COORDINATES_OPERATION:
|
3165 |
// disableAreaRegionOperation();
|
3166 |
// enableCoorderatesRegionOperation();
|
3167 |
// break;
|
3168 |
// case SELECTION_BY_AREA_OPERATION:
|
3169 |
// // Only enable the area operation if there is data loaded in this MapControl
|
3170 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
|
3171 |
// disableCoorderatesRegionOperation();
|
3172 |
// enableAreaRegionOperation();
|
3173 |
// }
|
3174 |
// else {
|
3175 |
// JOptionPane.showMessageDialog(jComboBoxToolSelection, PluginServices.getText(null, "there_is_no_layer_loaded_in_the_active_view"), PluginServices.getText(null, "information"), JOptionPane.INFORMATION_MESSAGE);
|
3176 |
//
|
3177 |
// // Select: no tools
|
3178 |
// jComboBoxToolSelection.setSelectedIndex(0);
|
3179 |
// disableCoorderatesRegionOperation();
|
3180 |
// }
|
3181 |
//
|
3182 |
// break;
|
3183 |
// }
|
3184 |
// }
|
3185 |
// });
|
3186 |
// }
|
3187 |
// return jComboBoxToolSelection;
|
3188 |
// }
|
3189 |
//
|
3190 |
// /**
|
3191 |
// * Enables the components associated to the selection of area by coordinates
|
3192 |
// */
|
3193 |
// private void enableCoorderatesRegionOperation() {
|
3194 |
//// Adds associated icons
|
3195 |
// this.add(getJButtonUndo(), null);
|
3196 |
//// this.add(getJButtonRedo(), null);
|
3197 |
//// this.add(getJToggleButtonMove(), null);
|
3198 |
//// this.add(getJToggleButtonScaling(), null);
|
3199 |
//
|
3200 |
// getCoordinatesPanel().setAllTextFieldsEnabled(true);
|
3201 |
//
|
3202 |
// // If the current active view has layers -> set the area in the fields:
|
3203 |
// // Adds the extent of the viewport of the current active view
|
3204 |
// BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
3205 |
// ViewPort vP = view.getMapControl().getMapContext().getViewPort();
|
3206 |
//
|
3207 |
// // Update extent
|
3208 |
// Rectangle2D r2D = vP.getExtent();
|
3209 |
//
|
3210 |
// if (r2D != null) {
|
3211 |
//// getJToggleButtonMove().setEnabled(false);
|
3212 |
//// getJToggleButtonScaling().setEnabled(false);
|
3213 |
//// }
|
3214 |
//// else {
|
3215 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
3216 |
//// getJToggleButtonMove().setEnabled(true);
|
3217 |
//// getJToggleButtonScaling().setEnabled(true);
|
3218 |
//// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
|
3219 |
// }
|
3220 |
//
|
3221 |
// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
|
3222 |
//
|
3223 |
// this.repaint();
|
3224 |
// }
|
3225 |
//
|
3226 |
// /**
|
3227 |
// * Enables the components associated to the selection of area by view
|
3228 |
// */
|
3229 |
// private void enableAreaRegionOperation() {
|
3230 |
// // Adds associated icons
|
3231 |
// this.add(getJButtonPan(), null);
|
3232 |
// this.add(getJComboBoxZoomInAndOut(), null);
|
3233 |
// getJComboBoxZoomInAndOut().revalidate(); // Force update this component
|
3234 |
// this.add(getJButtonZoomPrevious(), null);
|
3235 |
// this.add(getJButtonZoomComplete(), null);
|
3236 |
// this.add(getJComboBoxZoomInAndOutViewCentered(), null);
|
3237 |
// getJComboBoxZoomInAndOutViewCentered().revalidate(); // Force update this component
|
3238 |
// this.add(getJComboBoxOtherTools(), null);
|
3239 |
// getJComboBoxOtherTools().revalidate(); // Force update this component
|
3240 |
//
|
3241 |
// // Enables the MapControl area
|
3242 |
// getSelectableMapAreaPanel().setEnabled(true);
|
3243 |
// }
|
3244 |
//
|
3245 |
// /**
|
3246 |
// * Disables the components associated to the selection of area by coordinates
|
3247 |
// */
|
3248 |
// private void disableCoorderatesRegionOperation() {
|
3249 |
// // Removes associated icons
|
3250 |
// this.remove(getJButtonUndo());
|
3251 |
//// this.remove(getJButtonRedo());
|
3252 |
//// this.remove(getJToggleButtonMove());
|
3253 |
//// this.remove(getJToggleButtonScaling());
|
3254 |
//
|
3255 |
// getCoordinatesPanel().setAllTextFieldsEnabled(false);
|
3256 |
// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(false);
|
3257 |
//
|
3258 |
// this.repaint();
|
3259 |
// }
|
3260 |
//
|
3261 |
// /**
|
3262 |
// * Disables the components associated to the selection of area by view
|
3263 |
// */
|
3264 |
// private void disableAreaRegionOperation() {
|
3265 |
// // Removes associated icons
|
3266 |
// this.remove(getJButtonPan());
|
3267 |
// this.remove(getJComboBoxZoomInAndOut());
|
3268 |
// this.remove(getJButtonZoomPrevious());
|
3269 |
// this.remove(getJButtonZoomComplete());
|
3270 |
// this.remove(getJComboBoxZoomInAndOutViewCentered());
|
3271 |
// this.remove(getJComboBoxOtherTools());
|
3272 |
//
|
3273 |
// // Disables the MapControl area
|
3274 |
// getSelectableMapAreaPanel().setEnabled(false);
|
3275 |
// }
|
3276 |
//
|
3277 |
// /**
|
3278 |
// * This method initializes areaMapControlPanel
|
3279 |
// *
|
3280 |
// * @return A reference to an object of SelectableMapControlAreaPanel
|
3281 |
// */
|
3282 |
// private SelectableMapControlAreaPanel getSelectableMapAreaPanel() {
|
3283 |
// if (selectableMapAreaPanel == null) {
|
3284 |
// selectableMapAreaPanel = new SelectableMapControlAreaPanel();
|
3285 |
// }
|
3286 |
//
|
3287 |
// return selectableMapAreaPanel;
|
3288 |
// }
|
3289 |
//
|
3290 |
// /**
|
3291 |
// * This method initializes jButtonUndo
|
3292 |
// *
|
3293 |
// * @return javax.swing.JButton
|
3294 |
// */
|
3295 |
// private JButton getJButtonUndo() {
|
3296 |
// if (jButtonUndo == null) {
|
3297 |
// jButtonUndo = new JButton();
|
3298 |
// jButtonUndo.setBounds(DEFAULT_UNDO_ICON_BUTTON_RECTANGLE);
|
3299 |
// jButtonUndo.setIcon(PluginServices.getIconTheme().get("edit-undo"));
|
3300 |
// jButtonUndo.setToolTipText(PluginServices.getText(this, "previous_area"));
|
3301 |
// jButtonUndo.addMouseListener(new MouseAdapter() {
|
3302 |
// /*
|
3303 |
// * (non-Javadoc)
|
3304 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
3305 |
// */
|
3306 |
// public void mouseClicked(MouseEvent e) {
|
3307 |
// goToPreviousZoom();
|
3308 |
// }
|
3309 |
// });
|
3310 |
// }
|
3311 |
//
|
3312 |
// return jButtonUndo;
|
3313 |
// }
|
3314 |
//
|
3315 |
//// /**
|
3316 |
//// * This method initializes jButtonUndo
|
3317 |
//// *
|
3318 |
//// * @return javax.swing.JButton
|
3319 |
//// */
|
3320 |
//// private JButton getJButtonRedo() {
|
3321 |
//// if (jButtonRedo == null) {
|
3322 |
//// jButtonRedo = new JButton();
|
3323 |
//// jButtonRedo.setBounds(DEFAULT_REDO_ICON_BUTTON_RECTANGLE);
|
3324 |
//// jButtonRedo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/edit-redo.png")));
|
3325 |
//// jButtonRedo.setToolTipText(PluginServices.getText(this, "following_area"));
|
3326 |
//// }
|
3327 |
////
|
3328 |
//// return jButtonRedo;
|
3329 |
//// }
|
3330 |
//
|
3331 |
// /**
|
3332 |
// * This method initializes jToggleButtonMove
|
3333 |
// *
|
3334 |
// * @return javax.swing.JButton
|
3335 |
// */
|
3336 |
// private JToggleButton getJToggleButtonMove() {
|
3337 |
// if (jToggleButtonMove == null) {
|
3338 |
// jToggleButtonMove = new JToggleButton();
|
3339 |
// jToggleButtonMove.setBounds(DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE);
|
3340 |
// jToggleButtonMove.setIcon(PluginServices.getIconTheme().get("WFS-move"));
|
3341 |
// jToggleButtonMove.setToolTipText(PluginServices.getText(this, "move") + ": " + PluginServices.getText(this, "area_move_explanation"));
|
3342 |
// jToggleButtonMove.addItemListener(new ItemListener() {
|
3343 |
// /*
|
3344 |
// * (non-Javadoc)
|
3345 |
// * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
3346 |
// */
|
3347 |
// public void itemStateChanged(ItemEvent e) {
|
3348 |
// // Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
3349 |
// if (jToggleButtonMove.isSelected())
|
3350 |
// jToggleButtonScaling.setSelected(false);
|
3351 |
// }
|
3352 |
// });
|
3353 |
// }
|
3354 |
//
|
3355 |
// return jToggleButtonMove;
|
3356 |
// }
|
3357 |
//
|
3358 |
// /**
|
3359 |
// * This method initializes jToggleButtonScaling
|
3360 |
// *
|
3361 |
// * @return javax.swing.JButton
|
3362 |
// */
|
3363 |
// private JToggleButton getJToggleButtonScaling() {
|
3364 |
// if (jToggleButtonScaling == null) {
|
3365 |
// jToggleButtonScaling = new JToggleButton();
|
3366 |
// jToggleButtonScaling.setBounds(DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE);
|
3367 |
// jToggleButtonScaling.setIcon(PluginServices.getIconTheme().get("WFS-scaling"));
|
3368 |
// jToggleButtonScaling.setToolTipText(PluginServices.getText(this, "scaling") + ": " + PluginServices.getText(this, "area_scaling_explanation"));
|
3369 |
// jToggleButtonScaling.addItemListener(new ItemListener() {
|
3370 |
// /*
|
3371 |
// * (non-Javadoc)
|
3372 |
// * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
3373 |
// */
|
3374 |
// public void itemStateChanged(ItemEvent e) {
|
3375 |
// // Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
3376 |
// if (jToggleButtonScaling.isSelected())
|
3377 |
// jToggleButtonMove.setSelected(false);
|
3378 |
// }
|
3379 |
// });
|
3380 |
// }
|
3381 |
//
|
3382 |
// return jToggleButtonScaling;
|
3383 |
// }
|
3384 |
// /**
|
3385 |
// * This method initializes jButtonPan
|
3386 |
// *
|
3387 |
// * @return javax.swing.JButton
|
3388 |
// */
|
3389 |
// private JButton getJButtonPan() {
|
3390 |
// if (jButtonPan == null) {
|
3391 |
// jButtonPan = new JButton();
|
3392 |
// jButtonPan.setBounds(DEFAULT_PAN_ICON_BUTTON_RECTANGLE);
|
3393 |
// jButtonPan.setIcon(PluginServices.getIconTheme().get("view-pan"));
|
3394 |
// jButtonPan.setToolTipText(PluginServices.getText(this, "Desplazamiento"));
|
3395 |
// jButtonPan.addMouseListener(new MouseAdapter() {
|
3396 |
// /*
|
3397 |
// * (non-Javadoc)
|
3398 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
3399 |
// */
|
3400 |
// public void mouseClicked(MouseEvent e) {
|
3401 |
// getSelectableMapAreaPanel().setTool(PAN_TOOL);
|
3402 |
// }
|
3403 |
// });
|
3404 |
// }
|
3405 |
// return jButtonPan;
|
3406 |
// }
|
3407 |
//
|
3408 |
// /**
|
3409 |
// * This method initializes jComboBoxZoomInAndOut
|
3410 |
// *
|
3411 |
// * @return A JComboBoxWithImageIconItems object reference
|
3412 |
// */
|
3413 |
// private JComboBoxWithImageIconItems getJComboBoxZoomInAndOut() {
|
3414 |
// if (jComboBoxZoomInAndOut == null) {
|
3415 |
// jComboBoxZoomInAndOut = new JComboBoxWithImageIconItems();
|
3416 |
// jComboBoxZoomInAndOut.setBounds(DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE);
|
3417 |
// jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomIn.png",PluginServices.getIconTheme().get("view-zoom-in"),PluginServices.getText(this, "Zoom_Mas"), ZOOM_IN_TOOL));
|
3418 |
// jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-out"), PluginServices.getText(this, "Zoom_Menos"), ZOOM_OUT_TOOL));
|
3419 |
// jComboBoxZoomInAndOut.addActionListener(new ActionListener() {
|
3420 |
// /*
|
3421 |
// * (non-Javadoc)
|
3422 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
3423 |
// */
|
3424 |
// public void actionPerformed(ActionEvent e) {
|
3425 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
3426 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
3427 |
// getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
3428 |
// }
|
3429 |
// });
|
3430 |
// }
|
3431 |
//
|
3432 |
// return jComboBoxZoomInAndOut;
|
3433 |
// }
|
3434 |
//
|
3435 |
// /**
|
3436 |
// * This method initializes jButtonZoomPrevious
|
3437 |
// *
|
3438 |
// * @return javax.swing.JButton
|
3439 |
// */
|
3440 |
// private JButton getJButtonZoomPrevious() {
|
3441 |
// if (jButtonZoomPrevious == null) {
|
3442 |
// jButtonZoomPrevious = new JButton();
|
3443 |
// jButtonZoomPrevious.setBounds(DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE);
|
3444 |
// jButtonZoomPrevious.setIcon(PluginServices.getIconTheme().get("view-zoom-back"));
|
3445 |
// jButtonZoomPrevious.setToolTipText(PluginServices.getText(this, "Zoom_Previo"));
|
3446 |
// jButtonZoomPrevious.addMouseListener(new MouseAdapter() {
|
3447 |
// /*
|
3448 |
// * (non-Javadoc)
|
3449 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
3450 |
// */
|
3451 |
// public void mouseClicked(MouseEvent e) {
|
3452 |
// goToPreviousZoom();
|
3453 |
// }
|
3454 |
// });
|
3455 |
// }
|
3456 |
// return jButtonZoomPrevious;
|
3457 |
// }
|
3458 |
//
|
3459 |
// /**
|
3460 |
// * This method initializes jButtonZoomComplete
|
3461 |
// *
|
3462 |
// * @return javax.swing.JButton
|
3463 |
// */
|
3464 |
// private JButton getJButtonZoomComplete() {
|
3465 |
// if (jButtonZoomComplete == null) {
|
3466 |
// jButtonZoomComplete = new JButton();
|
3467 |
// jButtonZoomComplete.setBounds(DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE);
|
3468 |
// jButtonZoomComplete.setIcon(PluginServices.getIconTheme().get("view-zoom-map-contents"));
|
3469 |
// jButtonZoomComplete.setToolTipText(PluginServices.getText(this, "Zoom_Completo"));
|
3470 |
// jButtonZoomComplete.addMouseListener(new MouseAdapter() {
|
3471 |
// /*
|
3472 |
// * (non-Javadoc)
|
3473 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
3474 |
// */
|
3475 |
// public void mouseClicked(MouseEvent e) {
|
3476 |
// getSelectableMapAreaPanel().getViewPort().setExtent(getSelectableMapAreaPanel().getMapContext().getLayers().getFullExtent());
|
3477 |
// BaseView view =((BaseView)PluginServices.getMDIManager().getActiveWindow());
|
3478 |
// view.repaintMap();
|
3479 |
// }
|
3480 |
// });
|
3481 |
// }
|
3482 |
// return jButtonZoomComplete;
|
3483 |
// }
|
3484 |
//
|
3485 |
// /**
|
3486 |
// * This method initializes jComboBoxZoomInAndOut
|
3487 |
// *
|
3488 |
// * @return A JComboBoxWithImageIconItems object reference
|
3489 |
// */
|
3490 |
// private JComboBoxWithImageIconItems getJComboBoxZoomInAndOutViewCentered() {
|
3491 |
// if (jComboBoxZoomInAndOutViewCentered == null) {
|
3492 |
// jComboBoxZoomInAndOutViewCentered = new JComboBoxWithImageIconItems();
|
3493 |
// jComboBoxZoomInAndOutViewCentered.setBounds(DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE);
|
3494 |
// jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/zoommas.png",PluginServices.getIconTheme().get("view-zoom-mas"), PluginServices.getText(this, "Zoom_Acercar"), ZOOM_IN_VIEW_CENTERED_TOOL));
|
3495 |
// jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-menos"), PluginServices.getText(this, "Zoom_Alejar"), ZOOM_OUT_VIEW_CENTERED_TOOL));
|
3496 |
// jComboBoxZoomInAndOutViewCentered.addActionListener(new ActionListener() {
|
3497 |
// /*
|
3498 |
// * (non-Javadoc)
|
3499 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
3500 |
// */
|
3501 |
// public void actionPerformed(ActionEvent e) {
|
3502 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
3503 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
3504 |
//
|
3505 |
// if (((String)iiii.getItemValue()).compareTo(ZOOM_IN_VIEW_CENTERED_TOOL) == 0) {
|
3506 |
// getSelectableMapAreaPanel().zoomIn();
|
3507 |
// }
|
3508 |
// else {
|
3509 |
// getSelectableMapAreaPanel().zoomOut();
|
3510 |
// }
|
3511 |
// }
|
3512 |
// });
|
3513 |
// }
|
3514 |
// return jComboBoxZoomInAndOutViewCentered;
|
3515 |
// }
|
3516 |
//
|
3517 |
// /**
|
3518 |
// * This method initializes jComboBoxOtherTools
|
3519 |
// *
|
3520 |
// * @return A JComboBoxWithImageIconItems object reference
|
3521 |
// */
|
3522 |
// private JComboBoxWithImageIconItems getJComboBoxOtherTools() {
|
3523 |
// if (jComboBoxOtherTools == null) {
|
3524 |
// jComboBoxOtherTools = new JComboBoxWithImageIconItems();
|
3525 |
// jComboBoxOtherTools.setBounds(DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE);
|
3526 |
// jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Distancia.png",PluginServices.getIconTheme().get("view-query-distance"),PluginServices.getText(this, "medir_distancias"), MEASURE_DISTANCES_TOOL));
|
3527 |
// jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Poligono16.png",PluginServices.getIconTheme().get("view-query-area"), PluginServices.getText(this, "medir_area"), MEASURE_AREA_TOOL));
|
3528 |
// jComboBoxOtherTools.addActionListener(new ActionListener() {
|
3529 |
// /*
|
3530 |
// * (non-Javadoc)
|
3531 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
3532 |
// */
|
3533 |
// public void actionPerformed(ActionEvent e) {
|
3534 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
3535 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
3536 |
// getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
3537 |
// }
|
3538 |
// });
|
3539 |
// }
|
3540 |
//
|
3541 |
// return jComboBoxOtherTools;
|
3542 |
// }
|
3543 |
//
|
3544 |
// /**
|
3545 |
// * Goes to previous zoom
|
3546 |
// */
|
3547 |
// private void goToPreviousZoom() {
|
3548 |
// // Gets the view port and sets its previous extent
|
3549 |
// ViewPort vp = getSelectableMapAreaPanel().getMapContext().getViewPort();
|
3550 |
//
|
3551 |
// if (vp.getExtents().hasPrevious()) {
|
3552 |
// vp.setPreviousExtent();
|
3553 |
// getCoordinatesPanel().updateCoordinates(vp.getExtent());
|
3554 |
// }
|
3555 |
// }
|
3556 |
//
|
3557 |
// /**
|
3558 |
// * Sets the extent
|
3559 |
// *
|
3560 |
// * @param java.awt.geom.Rectangle2D
|
3561 |
// */
|
3562 |
// public void setExtent(Rectangle2D extent) {
|
3563 |
// if (extent != null) {
|
3564 |
// // Update coordinates in text fields
|
3565 |
// getCoordinatesPanel().updateCoordinates(extent);
|
3566 |
//
|
3567 |
// // If there is any layer loaded in the MapControl -> set the extent
|
3568 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
|
3569 |
// getSelectableMapAreaPanel().getMapContext().getViewPort().setExtent(extent);
|
3570 |
// }
|
3571 |
// }
|
3572 |
// }
|
3573 |
//
|
3574 |
// /**
|
3575 |
// * Gets the extent: a 'Rectangle2D.Double' object reference or 'null' if there is no data or if the data is invalid or user hasn't defined an area
|
3576 |
// *
|
3577 |
// * @return java.awt.geom.Rectangle2D or null if the data is invalid
|
3578 |
// */
|
3579 |
// public Rectangle2D getExtent() {
|
3580 |
// if (!getEnablingJCheckBox().isSelected())
|
3581 |
// return null;
|
3582 |
//
|
3583 |
//// if (!hasUserDefinedAnArea)
|
3584 |
//// return null;
|
3585 |
//
|
3586 |
// if (getCoordinatesPanel().areAllCoordinatesUndefined()) {
|
3587 |
// return null; // Return null if there is no coordinate
|
3588 |
// }
|
3589 |
// else {
|
3590 |
// if (getCoordinatesPanel().validVertexes()) {
|
3591 |
// System.out.println("Extent que devuelve: " + getCoordinatesPanel().getExtent());
|
3592 |
// return getCoordinatesPanel().getExtent();
|
3593 |
// }
|
3594 |
// else {
|
3595 |
// return null; // Returns null if coordinates aren't valid
|
3596 |
// }
|
3597 |
// }
|
3598 |
// }
|
3599 |
//
|
3600 |
// /**
|
3601 |
// * Set parent's 'Applicable' button enable or disable according the value of the parameter
|
3602 |
// *
|
3603 |
// * @param b A boolean value
|
3604 |
// */
|
3605 |
// private void setApplicable(boolean b) {
|
3606 |
// if (!parent.getWFSFilterPanelIsAsTabForWFSLayersLoad())
|
3607 |
// parent.isApplicable(true);
|
3608 |
// }
|
3609 |
//
|
3610 |
// /**
|
3611 |
// * If there is some coordinate text field that has text, returns true; else returns false
|
3612 |
// *
|
3613 |
// * @return A boolean value
|
3614 |
// */
|
3615 |
// public boolean areThereSomeCoordinatesWritten() {
|
3616 |
// return getCoordinatesPanel().areThereSomeCoordinatesWritten();
|
3617 |
// }
|
3618 |
//
|
3619 |
// /**
|
3620 |
// * If there is some coordinate text field that isn't undefined, returns true; else returns false
|
3621 |
// *
|
3622 |
// * @return A boolean value
|
3623 |
// */
|
3624 |
// public boolean areThereSomeCoordinatesUndefined() {
|
3625 |
// return getCoordinatesPanel().isThereAnyCoordinateUndefined();
|
3626 |
// }
|
3627 |
//
|
3628 |
// /**
|
3629 |
// * If user has or hasn't defined an area
|
3630 |
// *
|
3631 |
// * @return A boolean value
|
3632 |
// */
|
3633 |
// public boolean hasUserDefinedAnArea() {
|
3634 |
// return hasUserDefinedAnArea;
|
3635 |
// }
|
3636 |
//
|
3637 |
// /**
|
3638 |
// * Restores the inner attribute 'hasUserDefinedAnArea' to its default value (false)
|
3639 |
// */
|
3640 |
// public void setUserHasntDefineAnArea() {
|
3641 |
// hasUserDefinedAnArea = false;
|
3642 |
// }
|
3643 |
//
|
3644 |
// /**
|
3645 |
// * Updates the current area information with the area of the active view
|
3646 |
// */
|
3647 |
// public void updateWFSArea() {
|
3648 |
// this.getSelectableMapAreaPanel().disableAllMouseListeners();
|
3649 |
//
|
3650 |
// // To prevent that events that take place (are produced) could be a nuisance to the load of the layers
|
3651 |
// this.getSelectableMapAreaPanel().getMapContext().beginAtomicEvent();
|
3652 |
//
|
3653 |
// try {
|
3654 |
// MapContext mapContext = this.getSelectableMapAreaPanel().getMapContext();
|
3655 |
//
|
3656 |
// // Removes all layers in the view area
|
3657 |
// int numberOfLayers = mapContext.getLayers().getLayersCount();
|
3658 |
// int i;
|
3659 |
//
|
3660 |
// for (i = (numberOfLayers-1); i >= 0; i--) {
|
3661 |
// mapContext.getLayers().removeLayer(i);
|
3662 |
// }
|
3663 |
//
|
3664 |
// // Adds the extent of the viewport of the current active view
|
3665 |
// BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
3666 |
// ViewPort vP = view.getMapControl().getMapContext().getViewPort();
|
3667 |
//
|
3668 |
// // Update extent
|
3669 |
// Rectangle2D r2D = vP.getExtent();
|
3670 |
//
|
3671 |
// if (r2D == null) {
|
3672 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
3673 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
3674 |
//
|
3675 |
// // No tools enabled
|
3676 |
// getJComboBoxToolSelection().setSelectedIndex(0);
|
3677 |
//
|
3678 |
// return;
|
3679 |
// }
|
3680 |
//
|
3681 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
3682 |
// mapContext.getViewPort().setExtent(r2D);
|
3683 |
//
|
3684 |
// // Adds the active layers of the current active view
|
3685 |
// MapContext mC = view.getMapControl().getMapContext();
|
3686 |
//
|
3687 |
// numberOfLayers = mC.getLayers().getLayersCount();
|
3688 |
//
|
3689 |
// for (i = (numberOfLayers-1); i >= 0; i--) {
|
3690 |
// mapContext.getLayers().addLayer(mC.getLayers().getLayer(i).cloneLayer());
|
3691 |
// }
|
3692 |
//
|
3693 |
// // If has to enable all listeners of all tools on the view area
|
3694 |
// if (((ItemOperation)this.getJComboBoxToolSelection().getSelectedItem()).getOperation() == SELECTION_BY_AREA_OPERATION)
|
3695 |
// this.getSelectableMapAreaPanel().enableAllMouseListeners();
|
3696 |
//
|
3697 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
3698 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
3699 |
//
|
3700 |
// // Refresh the view
|
3701 |
// this.getSelectableMapAreaPanel().getViewPort().refreshExtent();
|
3702 |
// } catch (Exception e) {
|
3703 |
// e.printStackTrace();
|
3704 |
//
|
3705 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
3706 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
3707 |
//
|
3708 |
// // No tools enabled
|
3709 |
// getJComboBoxToolSelection().setSelectedIndex(0);
|
3710 |
// return;
|
3711 |
// }
|
3712 |
// }
|
3713 |
//
|
3714 |
// /**
|
3715 |
// * Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
|
3716 |
// *
|
3717 |
// * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
3718 |
// */
|
3719 |
// private class ItemOperation {
|
3720 |
// String _name;
|
3721 |
// int _operation;
|
3722 |
//
|
3723 |
// /**
|
3724 |
// * Default constructor with two parameters
|
3725 |
// *
|
3726 |
// * @param name Name of the operation
|
3727 |
// * @param operation A code that identifies the operation
|
3728 |
// */
|
3729 |
// public ItemOperation(String name, int operation) {
|
3730 |
// _name = new String(name);
|
3731 |
// _operation = operation;
|
3732 |
// }
|
3733 |
//
|
3734 |
// /**
|
3735 |
// * Returns the name of the operation
|
3736 |
// *
|
3737 |
// * @return An String
|
3738 |
// */
|
3739 |
// public String getName() {
|
3740 |
// return _name;
|
3741 |
// }
|
3742 |
//
|
3743 |
// /**
|
3744 |
// * Returns the code that identifies the operation
|
3745 |
// *
|
3746 |
// * @return An integer value
|
3747 |
// */
|
3748 |
// public int getOperation() {
|
3749 |
// return _operation;
|
3750 |
// }
|
3751 |
//
|
3752 |
// /**
|
3753 |
// * The name of the operation that will use JComboBox
|
3754 |
// */
|
3755 |
// public String toString() {
|
3756 |
// return _name;
|
3757 |
// }
|
3758 |
// }
|
3759 |
//
|
3760 |
// /**
|
3761 |
// * This class is a panel width four fields for indicate the coordinates of two points:
|
3762 |
// * One for the ritgh-up point and another for the left-down point of a rectangle area
|
3763 |
// *
|
3764 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
3765 |
// * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
3766 |
// */
|
3767 |
// private class AreaCoordinatesPanel extends JPanel {
|
3768 |
// private final Rectangle DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 62, 51); // @jve:decl-index=0:
|
3769 |
// private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20;
|
3770 |
// private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20;
|
3771 |
// private final int DEFAULT_TEXT_FIELDS_WIDTH = 132;
|
3772 |
// private final int DEFAULT_X_LOCATION = 8;
|
3773 |
// private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6;
|
3774 |
// private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10;
|
3775 |
// private final int DEFAULT_COORDINATE_HEIGHT = 25;
|
3776 |
// private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT); // @jve:decl-index=0:
|
3777 |
// private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ;
|
3778 |
//
|
3779 |
// private final String JTEXTFIELD_V1X_NAME = "V1X";
|
3780 |
// private final String JTEXTFIELD_V1Y_NAME = "V1Y";
|
3781 |
// private final String JTEXTFIELD_V2X_NAME = "V2X";
|
3782 |
// private final String JTEXTFIELD_V2Y_NAME = "V2Y";
|
3783 |
//
|
3784 |
// private final short JTEXTFIELD_V1X = 1;
|
3785 |
// private final short JTEXTFIELD_V1Y = 2;
|
3786 |
// private final short JTEXTFIELD_V2X = 3;
|
3787 |
// private final short JTEXTFIELD_V2Y = 4;
|
3788 |
//
|
3789 |
// private JPanel jPanelVertex1 = null;
|
3790 |
// private JPanel jPanelVertex2 = null;
|
3791 |
// private JPanel jPanelVertex1X = null;
|
3792 |
// private JPanel jPanelVertex1Y = null;
|
3793 |
// private JPanel jPanelVertex2X = null;
|
3794 |
// private JPanel jPanelVertex2Y = null;
|
3795 |
//
|
3796 |
// private JLabel jLabelVertex1 = null;
|
3797 |
// private JLabel jLabelVertex2 = null;
|
3798 |
// private JLabel jLabelVertex1X = null;
|
3799 |
// private JLabel jLabelVertex1Y = null;
|
3800 |
// private JLabel jLabelVertex2X = null;
|
3801 |
// private JLabel jLabelVertex2Y = null;
|
3802 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex1X = null;
|
3803 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex1Y = null;
|
3804 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex2X = null;
|
3805 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex2Y = null;
|
3806 |
// private JButton jButtonPreviewArea = null;
|
3807 |
// private String last_Coordinates[];
|
3808 |
// private boolean hasChanged_v1X;
|
3809 |
// private boolean hasChanged_v1Y;
|
3810 |
// private boolean hasChanged_v2X;
|
3811 |
// private boolean hasChanged_v2Y;
|
3812 |
// private String previous_Coordinate_Value[];
|
3813 |
//
|
3814 |
// private short current_coordinate_with_focus;
|
3815 |
//
|
3816 |
// private FocusListener focusListenerForCoordinateValidation = null;
|
3817 |
// private KeyListener keyListenerForCoordinateValidation = null;
|
3818 |
//
|
3819 |
// /**
|
3820 |
// * This is the default constructor
|
3821 |
// */
|
3822 |
// public AreaCoordinatesPanel() {
|
3823 |
// super();
|
3824 |
// initialize();
|
3825 |
// }
|
3826 |
//
|
3827 |
// /**
|
3828 |
// * This method initializes this
|
3829 |
// *
|
3830 |
// * @return void
|
3831 |
// */
|
3832 |
// private void initialize() {
|
3833 |
// this.setLayout(null);
|
3834 |
// this.setBounds(DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE);
|
3835 |
// this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
|
3836 |
// this.setToolTipText(PluginServices.getText(this, "select_by_vertexes_coordinates"));
|
3837 |
//
|
3838 |
// this.last_Coordinates = new String[4];
|
3839 |
// this.last_Coordinates[0] = "";
|
3840 |
// this.last_Coordinates[1] = "";
|
3841 |
// this.last_Coordinates[2] = "";
|
3842 |
// this.last_Coordinates[3] = "";
|
3843 |
// this.previous_Coordinate_Value = new String[4];
|
3844 |
//
|
3845 |
// // By default no coordinates have changed
|
3846 |
// this.resetCoordinatesFlags();
|
3847 |
//
|
3848 |
// this.add(getJPanelVertex1());
|
3849 |
// this.add(getJPanelVertex2());
|
3850 |
// this.add(getJButtonPreviewArea());
|
3851 |
// }
|
3852 |
//
|
3853 |
// /**
|
3854 |
// * Returns the default width of this component
|
3855 |
// *
|
3856 |
// * @return The default width
|
3857 |
// */
|
3858 |
// public int getDefaultWidth() {
|
3859 |
// return DEFAULT_COORDINATE_WIDTH * 2;
|
3860 |
// }
|
3861 |
//
|
3862 |
// /**
|
3863 |
// * Returns the default height of this component
|
3864 |
// *
|
3865 |
// * @return The default height
|
3866 |
// */
|
3867 |
// public int getDefaultHeight() {
|
3868 |
// return DEFAULT_COORDINATE_HEIGHT * 2;
|
3869 |
// }
|
3870 |
//
|
3871 |
// /**
|
3872 |
// * Sets all flags about if a coordinate has change to false (haven't changed)
|
3873 |
// */
|
3874 |
// private void resetCoordinatesFlags() {
|
3875 |
// hasChanged_v1X = false;
|
3876 |
// hasChanged_v1Y = false;
|
3877 |
// hasChanged_v2X = false;
|
3878 |
// hasChanged_v2Y = false;
|
3879 |
// }
|
3880 |
//
|
3881 |
// /**last_Coordinated_that_Changed
|
3882 |
// * This method initializes jPanelVertex1
|
3883 |
// *
|
3884 |
// * @return javax.swing.JPanel
|
3885 |
// */
|
3886 |
// private JPanel getJPanelVertex1() {
|
3887 |
// if (jPanelVertex1 == null) {
|
3888 |
// jPanelVertex1 = new JPanel();
|
3889 |
// jPanelVertex1.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
|
3890 |
// jPanelVertex1.setLayout(new GridBagLayout());
|
3891 |
// jPanelVertex1.add(getJLabelVertex1(), null);
|
3892 |
// jPanelVertex1.add(getJPanelVertex1X(), null);
|
3893 |
// jPanelVertex1.add(getJPanelVertex1Y(), null);
|
3894 |
// }
|
3895 |
//
|
3896 |
// return jPanelVertex1;
|
3897 |
// }
|
3898 |
//
|
3899 |
// /**
|
3900 |
// * This method initializes jPanelVertex2
|
3901 |
// *
|
3902 |
// * @return javax.swing.JPanel
|
3903 |
// */
|
3904 |
// private JPanel getJPanelVertex2() {
|
3905 |
// if (jPanelVertex2 == null) {
|
3906 |
// jPanelVertex2 = new JPanel();
|
3907 |
// jPanelVertex2.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION + DEFAULT_COORDINATE_HEIGHT, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
|
3908 |
// jPanelVertex2.setLayout(new GridBagLayout());
|
3909 |
// jPanelVertex2.add(getJLabelVertex2(), null);
|
3910 |
// jPanelVertex2.add(getJPanelVertex2X(), null);
|
3911 |
// jPanelVertex2.add(getJPanelVertex2Y(), null);
|
3912 |
// }
|
3913 |
//
|
3914 |
// return jPanelVertex2;
|
3915 |
// }
|
3916 |
//
|
3917 |
// /**
|
3918 |
// * This method initializes jLabelVertex1
|
3919 |
// *
|
3920 |
// * @return javax.swing.JPanel
|
3921 |
// */
|
3922 |
// private JLabel getJLabelVertex1() {
|
3923 |
// if (jLabelVertex1 == null) {
|
3924 |
// jLabelVertex1 = new JLabel();
|
3925 |
// jLabelVertex1.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
|
3926 |
// jLabelVertex1.setToolTipText(PluginServices.getText(this, "coordinates_from_area_right_up_vertex"));
|
3927 |
// jLabelVertex1.setText(PluginServices.getText(this, "vertex") + " 1:");
|
3928 |
// jLabelVertex1.setHorizontalAlignment(SwingConstants.LEFT);
|
3929 |
// jLabelVertex1.setVerticalAlignment(SwingConstants.CENTER);
|
3930 |
// jLabelVertex1.setForeground(new Color(0, 0, 255)); // Blue color for text
|
3931 |
// }
|
3932 |
// return jLabelVertex1;
|
3933 |
// }
|
3934 |
//
|
3935 |
// /**
|
3936 |
// * This method initializes jLabelVertex2
|
3937 |
// *
|
3938 |
// * @return javax.swing.JPanel
|
3939 |
// */
|
3940 |
// private JLabel getJLabelVertex2() {
|
3941 |
// if (jLabelVertex2 == null) {
|
3942 |
// jLabelVertex2 = new JLabel();
|
3943 |
// jLabelVertex2.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
|
3944 |
// jLabelVertex2.setToolTipText(PluginServices.getText(this, "coordinates_from_area_left_bottom_vertex"));
|
3945 |
// jLabelVertex2.setText(PluginServices.getText(this, "vertex") + " 2:");
|
3946 |
// jLabelVertex2.setHorizontalAlignment(SwingConstants.LEFT);
|
3947 |
// jLabelVertex2.setVerticalAlignment(SwingConstants.CENTER);
|
3948 |
// jLabelVertex2.setForeground(new Color(128, 64, 0)); // Brown color for text
|
3949 |
// }
|
3950 |
// return jLabelVertex2;
|
3951 |
// }
|
3952 |
//
|
3953 |
// /**
|
3954 |
// * This method initializes jPanelVertex1X
|
3955 |
// *
|
3956 |
// * @return javax.swing.JPanel
|
3957 |
// */
|
3958 |
// private JPanel getJPanelVertex1X() {
|
3959 |
// if (jPanelVertex1X == null) {
|
3960 |
// jPanelVertex1X = new JPanel();
|
3961 |
// jPanelVertex1X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
3962 |
// jPanelVertex1X.setLayout(new GridBagLayout());
|
3963 |
// jPanelVertex1X.add(getJLabelVertex1X(), null);
|
3964 |
// jPanelVertex1X.add(getJTextFieldVertex1X(), null);
|
3965 |
// }
|
3966 |
//
|
3967 |
// return jPanelVertex1X;
|
3968 |
// }
|
3969 |
//
|
3970 |
// /**
|
3971 |
// * This method initializes jPanelVertex1Y
|
3972 |
// *
|
3973 |
// * @return javax.swing.JPanel
|
3974 |
// */
|
3975 |
// private JPanel getJPanelVertex1Y() {
|
3976 |
// if (jPanelVertex1Y == null) {
|
3977 |
// jPanelVertex1Y = new JPanel();
|
3978 |
// jPanelVertex1Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
3979 |
// jPanelVertex1Y.setLayout(new GridBagLayout());
|
3980 |
// jPanelVertex1Y.add(getJLabelVertex1Y(), null);
|
3981 |
// jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
|
3982 |
// }
|
3983 |
//
|
3984 |
// return jPanelVertex1Y;
|
3985 |
// }
|
3986 |
//
|
3987 |
// /**
|
3988 |
// * This method initializes jPanelVertex2X
|
3989 |
// *
|
3990 |
// * @return javax.swing.JPanel
|
3991 |
// */
|
3992 |
// private JPanel getJPanelVertex2X() {
|
3993 |
// if (jPanelVertex2X == null) {
|
3994 |
// jPanelVertex2X = new JPanel();
|
3995 |
// jPanelVertex2X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
3996 |
// jPanelVertex2X.setLayout(new GridBagLayout());
|
3997 |
// jPanelVertex2X.add(getJLabelVertex2X(), null);
|
3998 |
// jPanelVertex2X.add(getJTextFieldVertex2X(), null);
|
3999 |
// }
|
4000 |
//
|
4001 |
// return jPanelVertex2X;
|
4002 |
// }
|
4003 |
//
|
4004 |
// /**
|
4005 |
// * This method initializes jPanelVertex2Y
|
4006 |
// *
|
4007 |
// * @return javax.swing.JPanel
|
4008 |
// */
|
4009 |
// private JPanel getJPanelVertex2Y() {
|
4010 |
// if (jPanelVertex2Y == null) {
|
4011 |
// jPanelVertex2Y = new JPanel();
|
4012 |
// jPanelVertex2Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
4013 |
// jPanelVertex2Y.setLayout(new GridBagLayout());
|
4014 |
// jPanelVertex2Y.add(getJLabelVertex2Y(), null);
|
4015 |
// jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
|
4016 |
// }
|
4017 |
//
|
4018 |
// return jPanelVertex2Y;
|
4019 |
// }
|
4020 |
//
|
4021 |
// /**
|
4022 |
// * This method initializes jLabelVertex1X
|
4023 |
// *
|
4024 |
// * @return javax.swing.JLabel
|
4025 |
// */
|
4026 |
// private JLabel getJLabelVertex1X() {
|
4027 |
// if (jLabelVertex1X == null) {
|
4028 |
// jLabelVertex1X = new JLabel();
|
4029 |
// jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4030 |
// jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex"));
|
4031 |
// jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":");
|
4032 |
// jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
|
4033 |
// jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
|
4034 |
// jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text
|
4035 |
// }
|
4036 |
//
|
4037 |
// return jLabelVertex1X;
|
4038 |
// }
|
4039 |
//
|
4040 |
// /**
|
4041 |
// * This method initializes jLabelVertex2X
|
4042 |
// *
|
4043 |
// * @return javax.swing.JLabel
|
4044 |
// */
|
4045 |
// private JLabel getJLabelVertex2X() {
|
4046 |
// if (jLabelVertex2X == null) {
|
4047 |
// jLabelVertex2X = new JLabel();
|
4048 |
// jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4049 |
// jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex"));
|
4050 |
// jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":");
|
4051 |
// jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
|
4052 |
// jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
|
4053 |
// jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text
|
4054 |
// }
|
4055 |
//
|
4056 |
// return jLabelVertex2X;
|
4057 |
// }
|
4058 |
//
|
4059 |
// /**
|
4060 |
// * This method initializes jLabelVertex1Y
|
4061 |
// *
|
4062 |
// * @return javax.swing.JLabel
|
4063 |
// */
|
4064 |
// private JLabel getJLabelVertex1Y() {
|
4065 |
// if (jLabelVertex1Y == null) {
|
4066 |
// jLabelVertex1Y = new JLabel();
|
4067 |
// jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4068 |
// jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex"));
|
4069 |
// jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":");
|
4070 |
// jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
|
4071 |
// jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
|
4072 |
// jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text
|
4073 |
// }
|
4074 |
//
|
4075 |
// return jLabelVertex1Y;
|
4076 |
// }
|
4077 |
//
|
4078 |
// /**
|
4079 |
// * This method initializes jLabelVertex2Y
|
4080 |
// *
|
4081 |
// * @return javax.swing.JLabel
|
4082 |
// */
|
4083 |
// private JLabel getJLabelVertex2Y() {
|
4084 |
// if (jLabelVertex2Y == null) {
|
4085 |
// jLabelVertex2Y = new JLabel();
|
4086 |
// jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4087 |
// jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
|
4088 |
// jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":");
|
4089 |
// jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
|
4090 |
// jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
|
4091 |
// jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text
|
4092 |
// }
|
4093 |
//
|
4094 |
// return jLabelVertex2Y;
|
4095 |
// }
|
4096 |
//
|
4097 |
// /**
|
4098 |
// * Returns a focus listener for validate the text of a JTextField when that component loses its focus
|
4099 |
// *
|
4100 |
// * @return java.awt.event.FocusListener
|
4101 |
// */
|
4102 |
// private FocusListener getFocusListenerForCoordinateValidation() {
|
4103 |
// if (focusListenerForCoordinateValidation == null) {
|
4104 |
// focusListenerForCoordinateValidation = new FocusListener() {
|
4105 |
//
|
4106 |
// /*
|
4107 |
// * (non-Javadoc)
|
4108 |
// * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
4109 |
// */
|
4110 |
// public void focusGained(FocusEvent e) {
|
4111 |
// JTextField jTF = (JTextField)e.getSource();
|
4112 |
//
|
4113 |
// // Stores which coordinate has gotten the focus
|
4114 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) {
|
4115 |
// current_coordinate_with_focus = JTEXTFIELD_V1X;
|
4116 |
//
|
4117 |
// return;
|
4118 |
// }
|
4119 |
//
|
4120 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) {
|
4121 |
// current_coordinate_with_focus = JTEXTFIELD_V1Y;
|
4122 |
//
|
4123 |
// return;
|
4124 |
// }
|
4125 |
//
|
4126 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) {
|
4127 |
// current_coordinate_with_focus = JTEXTFIELD_V2X;
|
4128 |
//
|
4129 |
// return;
|
4130 |
// }
|
4131 |
//
|
4132 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) {
|
4133 |
// current_coordinate_with_focus = JTEXTFIELD_V2Y;
|
4134 |
//
|
4135 |
// return;
|
4136 |
// }
|
4137 |
//
|
4138 |
// }
|
4139 |
//
|
4140 |
// /*
|
4141 |
// * (non-Javadoc)
|
4142 |
// * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
4143 |
// */
|
4144 |
// public void focusLost(FocusEvent e) {
|
4145 |
// JTextField jTF = (JTextField)e.getSource();
|
4146 |
//
|
4147 |
// // If a coordinate has lost focus, is valid and has changed -> store the new value and set its related 'hasChanged' flag to true
|
4148 |
// String text = jTF.getText();
|
4149 |
//
|
4150 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) {
|
4151 |
//
|
4152 |
// if (text.compareTo(last_Coordinates[0]) != 0) {
|
4153 |
// hasChanged_v1X = true;
|
4154 |
//
|
4155 |
//// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
4156 |
// hasUserDefinedAnArea = true;
|
4157 |
//// }
|
4158 |
// }
|
4159 |
//
|
4160 |
// return;
|
4161 |
// }
|
4162 |
//
|
4163 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) {
|
4164 |
// if (text.compareTo(last_Coordinates[1]) != 0) {
|
4165 |
// hasChanged_v1Y = true;
|
4166 |
//
|
4167 |
//// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
4168 |
// hasUserDefinedAnArea = true;
|
4169 |
//// }
|
4170 |
// }
|
4171 |
//
|
4172 |
// return;
|
4173 |
// }
|
4174 |
//
|
4175 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) {
|
4176 |
// if (text.compareTo(last_Coordinates[2]) != 0) {
|
4177 |
// hasChanged_v2X = true;
|
4178 |
//
|
4179 |
//// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
4180 |
// hasUserDefinedAnArea = true;
|
4181 |
//// }
|
4182 |
// }
|
4183 |
//
|
4184 |
// return;
|
4185 |
// }
|
4186 |
//
|
4187 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) {
|
4188 |
// if (text.compareTo(last_Coordinates[3]) != 0) {
|
4189 |
// hasChanged_v2Y = true;
|
4190 |
//
|
4191 |
//// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
4192 |
// hasUserDefinedAnArea = true;
|
4193 |
//// }
|
4194 |
// }
|
4195 |
//
|
4196 |
// return;
|
4197 |
// }
|
4198 |
// }
|
4199 |
// };
|
4200 |
// }
|
4201 |
//
|
4202 |
// return focusListenerForCoordinateValidation;
|
4203 |
// }
|
4204 |
//
|
4205 |
// private KeyListener getKeyListenerForCoordinateValidation() {
|
4206 |
// if (keyListenerForCoordinateValidation == null) {
|
4207 |
// keyListenerForCoordinateValidation = new KeyListener() {
|
4208 |
//
|
4209 |
// public void keyPressed(KeyEvent e) {
|
4210 |
// }
|
4211 |
//
|
4212 |
// public void keyReleased(KeyEvent e) {
|
4213 |
// validateCoordinate(current_coordinate_with_focus);
|
4214 |
// }
|
4215 |
//
|
4216 |
// public void keyTyped(KeyEvent e) {
|
4217 |
// }
|
4218 |
// };
|
4219 |
// }
|
4220 |
//
|
4221 |
// return keyListenerForCoordinateValidation;
|
4222 |
// }
|
4223 |
//
|
4224 |
// /**
|
4225 |
// * This method initializes jTextFieldVertex1X
|
4226 |
// *
|
4227 |
// * @return JTextFieldWithSpecificCaretPosition
|
4228 |
// */
|
4229 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1X() {
|
4230 |
// if (jTextFieldVertex1X == null) {
|
4231 |
// jTextFieldVertex1X = new JTextFieldWithSpecificCaretPosition("");
|
4232 |
// jTextFieldVertex1X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4233 |
// jTextFieldVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex"));
|
4234 |
// jTextFieldVertex1X.addFocusListener(getFocusListenerForCoordinateValidation());
|
4235 |
// jTextFieldVertex1X.addKeyListener(getKeyListenerForCoordinateValidation());
|
4236 |
// jTextFieldVertex1X.setName(JTEXTFIELD_V1X_NAME);
|
4237 |
// }
|
4238 |
// return jTextFieldVertex1X;
|
4239 |
// }
|
4240 |
//
|
4241 |
// /**
|
4242 |
// * This method initializes jTextFieldVertex1Y
|
4243 |
// *
|
4244 |
// * @return JTextFieldWithSpecificCaretPosition
|
4245 |
// */
|
4246 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1Y() {
|
4247 |
// if (jTextFieldVertex1Y == null) {
|
4248 |
// jTextFieldVertex1Y = new JTextFieldWithSpecificCaretPosition("");
|
4249 |
// jTextFieldVertex1Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4250 |
// jTextFieldVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex"));
|
4251 |
// jTextFieldVertex1Y.addFocusListener(getFocusListenerForCoordinateValidation());
|
4252 |
// jTextFieldVertex1Y.addKeyListener(getKeyListenerForCoordinateValidation());
|
4253 |
// jTextFieldVertex1Y.setName(JTEXTFIELD_V1Y_NAME);
|
4254 |
// }
|
4255 |
// return jTextFieldVertex1Y;
|
4256 |
// }
|
4257 |
//
|
4258 |
// /**
|
4259 |
// * This method initializes jTextFieldVertex2X
|
4260 |
// *
|
4261 |
// * @return JTextFieldWithSpecificCaretPosition
|
4262 |
// */
|
4263 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2X() {
|
4264 |
// if (jTextFieldVertex2X == null) {
|
4265 |
// jTextFieldVertex2X = new JTextFieldWithSpecificCaretPosition("");
|
4266 |
// jTextFieldVertex2X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4267 |
// jTextFieldVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex"));
|
4268 |
// jTextFieldVertex2X.addFocusListener(getFocusListenerForCoordinateValidation());
|
4269 |
// jTextFieldVertex2X.addKeyListener(getKeyListenerForCoordinateValidation());
|
4270 |
// jTextFieldVertex2X.setName(JTEXTFIELD_V2X_NAME);
|
4271 |
// }
|
4272 |
// return jTextFieldVertex2X;
|
4273 |
// }
|
4274 |
//
|
4275 |
// /**
|
4276 |
// * This method initializes jTextFieldVertex2Y
|
4277 |
// *
|
4278 |
// * @return JTextFieldWithSpecificCaretPosition
|
4279 |
// */
|
4280 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2Y() {
|
4281 |
// if (jTextFieldVertex2Y == null) {
|
4282 |
// jTextFieldVertex2Y = new JTextFieldWithSpecificCaretPosition("");
|
4283 |
// jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
4284 |
// jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
|
4285 |
// jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation());
|
4286 |
// jTextFieldVertex2Y.addKeyListener(getKeyListenerForCoordinateValidation());
|
4287 |
// jTextFieldVertex2Y.setName(JTEXTFIELD_V2Y_NAME);
|
4288 |
// }
|
4289 |
// return jTextFieldVertex2Y;
|
4290 |
// }
|
4291 |
//
|
4292 |
// /**
|
4293 |
// * Retuns the double value of the text field V1X
|
4294 |
// *
|
4295 |
// * @return A double number type
|
4296 |
// */
|
4297 |
// public double getDoubleValueOfJTextFieldV1X() {
|
4298 |
// return Double.parseDouble(getJTextFieldVertex1X().getText());
|
4299 |
// }
|
4300 |
//
|
4301 |
// /**
|
4302 |
// * Retuns the double value of the text field V1Y
|
4303 |
// *
|
4304 |
// * @return A double number type
|
4305 |
// */
|
4306 |
// public double getDoubleValueOfJTextFieldV1Y() {
|
4307 |
// return Double.parseDouble(getJTextFieldVertex1Y().getText());
|
4308 |
// }
|
4309 |
//
|
4310 |
// /**
|
4311 |
// * Retuns the double value of the text field V2X
|
4312 |
// *
|
4313 |
// * @return A double number type
|
4314 |
// */
|
4315 |
// public double getDoubleValueOfJTextFieldV2X() {
|
4316 |
// return Double.parseDouble(getJTextFieldVertex2X().getText());
|
4317 |
// }
|
4318 |
//
|
4319 |
// /**
|
4320 |
// * Retuns the double value of the text field V2Y
|
4321 |
// *
|
4322 |
// * @return A double number type
|
4323 |
// */
|
4324 |
// public double getDoubleValueOfJTextFieldV2Y() {
|
4325 |
// return Double.parseDouble(getJTextFieldVertex2Y().getText());
|
4326 |
// }
|
4327 |
//
|
4328 |
// /**
|
4329 |
// * Retuns the double value of the last text field V1X value
|
4330 |
// *
|
4331 |
// * @return A double number type
|
4332 |
// */
|
4333 |
// public double getDoubleValueOfLastJTextFieldV1XValue() {
|
4334 |
// return Double.parseDouble(last_Coordinates[0]);
|
4335 |
// }
|
4336 |
//
|
4337 |
// /**
|
4338 |
// * Retuns the double value of the last text field V1Y value
|
4339 |
// *
|
4340 |
// * @return A double number type
|
4341 |
// */
|
4342 |
// public double getDoubleValueOfLastJTextFieldV1YValue() {
|
4343 |
// return Double.parseDouble(last_Coordinates[1]);
|
4344 |
// }
|
4345 |
//
|
4346 |
// /**
|
4347 |
// * Retuns the double value of the last text field V2X value
|
4348 |
// *
|
4349 |
// * @return A double number type
|
4350 |
// */
|
4351 |
// public double getDoubleValueOfLastJTextFieldV2XValue() {
|
4352 |
// return Double.parseDouble(last_Coordinates[2]);
|
4353 |
// }
|
4354 |
//
|
4355 |
// /**
|
4356 |
// * Retuns the double value of the last text field V2Y value
|
4357 |
// *
|
4358 |
// * @return A double number type
|
4359 |
// */
|
4360 |
// public double getDoubleValueOfLastJTextFieldV2YValue() {
|
4361 |
// return Double.parseDouble(last_Coordinates[3]);
|
4362 |
// }
|
4363 |
//
|
4364 |
// /**
|
4365 |
// * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
4366 |
// *
|
4367 |
// * @param coordinate javax.swing.JTextField
|
4368 |
// * @return A boolean value
|
4369 |
// */
|
4370 |
// private boolean validateCoordinate(JTextField coordinate) {
|
4371 |
// if (coordinate != null) {
|
4372 |
// // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
4373 |
// if ((coordinate.getText().compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(coordinate.getText()))) {
|
4374 |
//// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
4375 |
//// switch (last_Coordinate_that_Loose_the_Focus) {
|
4376 |
//// case 1:
|
4377 |
//// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
4378 |
//// break;
|
4379 |
//// case 2:
|
4380 |
//// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
4381 |
//// break;
|
4382 |
//// case 3:
|
4383 |
//// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
4384 |
//// break;
|
4385 |
//// case 4:
|
4386 |
//// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
4387 |
//// break;
|
4388 |
//// default:
|
4389 |
//// // Do nothing
|
4390 |
//// }
|
4391 |
//
|
4392 |
// return false;
|
4393 |
// }
|
4394 |
// else {
|
4395 |
// return true;
|
4396 |
// }
|
4397 |
// }
|
4398 |
//
|
4399 |
// return false; // If coordinate is null
|
4400 |
// }
|
4401 |
//
|
4402 |
// /**
|
4403 |
// * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
4404 |
// *
|
4405 |
// * @param coordinate javax.swing.JTextField
|
4406 |
// * @return A boolean value
|
4407 |
// */
|
4408 |
// private boolean validateCoordinate(int coordinate_ID) {
|
4409 |
// JTextField coordinate = null;
|
4410 |
// String text;
|
4411 |
//
|
4412 |
// switch (coordinate_ID) {
|
4413 |
// case JTEXTFIELD_V1X:
|
4414 |
// coordinate = getJTextFieldVertex1X();
|
4415 |
// text = coordinate.getText();
|
4416 |
//
|
4417 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
4418 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
4419 |
// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
4420 |
// return false;
|
4421 |
// }
|
4422 |
// else {
|
4423 |
// previous_Coordinate_Value[0] = text;
|
4424 |
// return true;
|
4425 |
// }
|
4426 |
//
|
4427 |
//// break;
|
4428 |
// case JTEXTFIELD_V1Y:
|
4429 |
// coordinate = getJTextFieldVertex1Y();
|
4430 |
// text = coordinate.getText();
|
4431 |
//
|
4432 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
4433 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
4434 |
// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
4435 |
// return false;
|
4436 |
// }
|
4437 |
// else {
|
4438 |
// previous_Coordinate_Value[1] = text;
|
4439 |
// return true;
|
4440 |
// }
|
4441 |
//
|
4442 |
//// break;
|
4443 |
// case JTEXTFIELD_V2X:
|
4444 |
// coordinate = getJTextFieldVertex2X();
|
4445 |
// text = coordinate.getText();
|
4446 |
//
|
4447 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
4448 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
4449 |
// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
4450 |
// return false;
|
4451 |
// }
|
4452 |
// else {
|
4453 |
// previous_Coordinate_Value[2] = text;
|
4454 |
// return true;
|
4455 |
// }
|
4456 |
//
|
4457 |
//// break;
|
4458 |
// case JTEXTFIELD_V2Y:
|
4459 |
// coordinate = getJTextFieldVertex2Y();
|
4460 |
// text = coordinate.getText();
|
4461 |
//
|
4462 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
4463 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
4464 |
// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
4465 |
// return false;
|
4466 |
// }
|
4467 |
// else {
|
4468 |
// previous_Coordinate_Value[3] = text;
|
4469 |
// return true;
|
4470 |
// }
|
4471 |
//
|
4472 |
//// break;
|
4473 |
// default:
|
4474 |
// return true; // Avoid problems
|
4475 |
// }
|
4476 |
//
|
4477 |
//// if (coordinate != null) {
|
4478 |
//// // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
4479 |
//// switch (coordinate_ID) {
|
4480 |
//// case 1:
|
4481 |
//// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
4482 |
//// break;
|
4483 |
//// case 2:
|
4484 |
//// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
4485 |
//// break;
|
4486 |
//// case 3:
|
4487 |
//// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
4488 |
//// break;
|
4489 |
//// case 4:
|
4490 |
//// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
4491 |
//// break;
|
4492 |
//// default:
|
4493 |
//// // Do nothing
|
4494 |
//// }
|
4495 |
//
|
4496 |
//// return false;
|
4497 |
//// }
|
4498 |
//// else
|
4499 |
//// return true;
|
4500 |
////// }
|
4501 |
////
|
4502 |
//// return false; // If coordinate is null
|
4503 |
// }
|
4504 |
//
|
4505 |
// /**
|
4506 |
// * This method initializes jButtonPreviewArea
|
4507 |
// *
|
4508 |
// * @return javax.swing.JButton
|
4509 |
// */
|
4510 |
// private JButton getJButtonPreviewArea() {
|
4511 |
// if (jButtonPreviewArea == null) {
|
4512 |
// jButtonPreviewArea = new JButton();
|
4513 |
// jButtonPreviewArea.setBounds(DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE);
|
4514 |
//// jButtonPreviewArea.setToolTipText(PluginServices.getText(this, "to_previsualize"));
|
4515 |
// jButtonPreviewArea.setToolTipText(PluginServices.getText(this, "to_validate_coodinates"));
|
4516 |
// jButtonPreviewArea.setVerticalTextPosition(AbstractButton.CENTER);
|
4517 |
// jButtonPreviewArea.setHorizontalTextPosition(AbstractButton.CENTER);
|
4518 |
// jButtonPreviewArea.setIcon(PluginServices.getIconTheme().get("view-previsualize-area"));
|
4519 |
// jButtonPreviewArea.addMouseListener(new MouseAdapter() {
|
4520 |
// /*
|
4521 |
// * (non-Javadoc)
|
4522 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
4523 |
// */
|
4524 |
// public void mouseClicked(MouseEvent e) {
|
4525 |
// validVertexes();
|
4526 |
// }
|
4527 |
//
|
4528 |
//// /*
|
4529 |
//// * (non-Javadoc)
|
4530 |
//// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
4531 |
//// */
|
4532 |
//// public void mouseClicked(MouseEvent e) {
|
4533 |
//// // Only enable the area operation if there is data loaded in this MapControl
|
4534 |
////
|
4535 |
//// // Do nothing if there is no layer in the map control
|
4536 |
//// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() == 0) {
|
4537 |
//// return;
|
4538 |
//// }
|
4539 |
////
|
4540 |
//// if ((validateCoordinate(getJTextFieldVertex1X())) && (validateCoordinate(getJTextFieldVertex1Y())) && (validateCoordinate(getJTextFieldVertex2X())) && (validateCoordinate(getJTextFieldVertex2Y()))) {
|
4541 |
//// ViewPort vP = getSelectableMapAreaPanel().getViewPort();
|
4542 |
//// if (vP != null) {
|
4543 |
//// // If has to scale the area
|
4544 |
//// if (getJToggleButtonScaling().isSelected()) {
|
4545 |
//// // Scale Vertex 1
|
4546 |
//// if ((hasChanged_v1X) || (hasChanged_v1Y)) {
|
4547 |
//// double cx = getDoubleValueOfJTextFieldV1X();
|
4548 |
//// double cy = getDoubleValueOfJTextFieldV1Y();
|
4549 |
//// double sx, sy, aux;
|
4550 |
////
|
4551 |
//// if (hasChanged_v1X) {
|
4552 |
//// aux = getDoubleValueOfLastJTextFieldV1XValue();
|
4553 |
//// if (aux == 0.0)
|
4554 |
//// sx = 1.0; // Don't scale if new coordenate is zero
|
4555 |
//// else
|
4556 |
//// sx = cx / aux;
|
4557 |
//// }
|
4558 |
//// else
|
4559 |
//// sx = 1.0;
|
4560 |
////
|
4561 |
//// if (hasChanged_v1Y) {
|
4562 |
//// aux = getDoubleValueOfLastJTextFieldV1YValue();
|
4563 |
//// if (aux == 0.0)
|
4564 |
//// sy = 1.0; // Don't scale if new coordenate is zero
|
4565 |
//// else
|
4566 |
//// sy = cy / aux;
|
4567 |
//// }
|
4568 |
//// else
|
4569 |
//// sy = 1.0;
|
4570 |
////
|
4571 |
//// if (sx == 1.0) {
|
4572 |
//// // It's supposed that sy != 1.0
|
4573 |
//// cx *= sy;
|
4574 |
////
|
4575 |
//// if (cx < getDoubleValueOfJTextFieldV2X()) {
|
4576 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4577 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4578 |
//// return;
|
4579 |
//// }
|
4580 |
////
|
4581 |
//// getJTextFieldVertex1X().setText(Double.toString(cx));
|
4582 |
//// }
|
4583 |
//// else {
|
4584 |
//// if (sy == 1.0) {
|
4585 |
//// // It's supposed that sx != 1.0
|
4586 |
//// cy *= sx;
|
4587 |
////
|
4588 |
//// if (cy < getDoubleValueOfJTextFieldV2Y()) {
|
4589 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4590 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4591 |
//// return;
|
4592 |
//// }
|
4593 |
////
|
4594 |
//// getJTextFieldVertex1Y().setText(Double.toString(cy));
|
4595 |
//// }
|
4596 |
//// else {
|
4597 |
//// // If there has been an error -> can't move different distances in X the two vertexes
|
4598 |
//// if (sx != sy) {
|
4599 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4600 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4601 |
//// return;
|
4602 |
//// }
|
4603 |
//// }
|
4604 |
//// }
|
4605 |
//// }
|
4606 |
////
|
4607 |
//// // Scale Vertex2
|
4608 |
//// if ((hasChanged_v2X) || (hasChanged_v2Y)) {
|
4609 |
//// double cx = getDoubleValueOfJTextFieldV2X();
|
4610 |
//// double cy = getDoubleValueOfJTextFieldV2Y();
|
4611 |
//// double sx, sy, aux;
|
4612 |
////
|
4613 |
//// if (hasChanged_v2X) {
|
4614 |
//// aux = getDoubleValueOfLastJTextFieldV2XValue();
|
4615 |
//// if (aux == 0.0)
|
4616 |
//// sx = 1.0; // Don't scale if new coordenate is zero
|
4617 |
//// else
|
4618 |
//// sx = cx / aux;
|
4619 |
//// }
|
4620 |
//// else
|
4621 |
//// sx = 1.0;
|
4622 |
////
|
4623 |
//// if (hasChanged_v2Y) {
|
4624 |
//// aux = getDoubleValueOfLastJTextFieldV2YValue();
|
4625 |
//// if (aux == 0.0)
|
4626 |
//// sy = 1.0; // Don't scale if new coordenate is zero
|
4627 |
//// else
|
4628 |
//// sy = cy / aux;
|
4629 |
//// }
|
4630 |
//// else
|
4631 |
//// sy = 1.0;
|
4632 |
////
|
4633 |
//// if (sx == 1.0) {
|
4634 |
//// // It's supposed that sy != 1.0
|
4635 |
//// cx *= sy;
|
4636 |
////
|
4637 |
//// if (cx > getDoubleValueOfJTextFieldV1X()) {
|
4638 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4639 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4640 |
//// return;
|
4641 |
//// }
|
4642 |
////
|
4643 |
//// getJTextFieldVertex2X().setText(Double.toString(cx));
|
4644 |
//// }
|
4645 |
//// else {
|
4646 |
//// if (sy == 1.0) {
|
4647 |
//// // It's supposed that sx != 1.0
|
4648 |
//// cy *= sx;
|
4649 |
////
|
4650 |
//// if (cy > getDoubleValueOfJTextFieldV1Y()) {
|
4651 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4652 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4653 |
//// return;
|
4654 |
//// }
|
4655 |
////
|
4656 |
//// getJTextFieldVertex2Y().setText(Double.toString(cy));
|
4657 |
//// }
|
4658 |
//// else {
|
4659 |
//// // If there has been an error -> can't move different distances in X the two vertexes
|
4660 |
//// if (sx != sy) {
|
4661 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4662 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4663 |
//// return;
|
4664 |
//// }
|
4665 |
//// }
|
4666 |
//// }
|
4667 |
//// }
|
4668 |
//// }
|
4669 |
//// else {
|
4670 |
//// // If has to move the area
|
4671 |
//// if (getJToggleButtonMove().isSelected()) {
|
4672 |
//// // Move in X
|
4673 |
//// if ((hasChanged_v1X) || (hasChanged_v2X)) {
|
4674 |
//// double c1 = getDoubleValueOfJTextFieldV1X();
|
4675 |
//// double c2 = getDoubleValueOfJTextFieldV2X();
|
4676 |
//// double d1, d2;
|
4677 |
////
|
4678 |
//// if (hasChanged_v1X)
|
4679 |
//// d1 = c1 - getDoubleValueOfLastJTextFieldV1XValue();
|
4680 |
//// else
|
4681 |
//// d1 = 0.0;
|
4682 |
////
|
4683 |
//// if (hasChanged_v2X)
|
4684 |
//// d2 = c2 - getDoubleValueOfLastJTextFieldV2XValue();
|
4685 |
//// else
|
4686 |
//// d2 = 0.0;
|
4687 |
////
|
4688 |
//// if (d1 == 0.0) {
|
4689 |
//// // It's supposed that d2 != 0
|
4690 |
//// c1 += d2;
|
4691 |
////
|
4692 |
//// if (c1 < getDoubleValueOfJTextFieldV2X()) {
|
4693 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4694 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4695 |
//// return;
|
4696 |
//// }
|
4697 |
////
|
4698 |
//// getJTextFieldVertex1X().setText(Double.toString(c1));
|
4699 |
//// }
|
4700 |
//// else {
|
4701 |
//// if (d2 == 0.0) {
|
4702 |
//// // It's supposed that d1 != 0
|
4703 |
//// c2 += d1;
|
4704 |
////
|
4705 |
//// if (c2 > getDoubleValueOfJTextFieldV1X()) {
|
4706 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4707 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4708 |
//// return;
|
4709 |
//// }
|
4710 |
////
|
4711 |
//// getJTextFieldVertex2X().setText(Double.toString(c2));
|
4712 |
//// }
|
4713 |
//// else {
|
4714 |
//// // If there has been an error -> can't move different distances in X the two vertexes
|
4715 |
//// if (d1 != d2) {
|
4716 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_X"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4717 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4718 |
//// return;
|
4719 |
//// }
|
4720 |
//// }
|
4721 |
//// }
|
4722 |
//// }
|
4723 |
////
|
4724 |
//// // Move in Y
|
4725 |
//// if ((hasChanged_v1Y) || (hasChanged_v2Y)) {
|
4726 |
//// double c1 = getDoubleValueOfJTextFieldV1Y();
|
4727 |
//// double c2 = getDoubleValueOfJTextFieldV2Y();
|
4728 |
//// double d1, d2;
|
4729 |
////
|
4730 |
//// if (hasChanged_v1Y)
|
4731 |
//// d1 = c1 - getDoubleValueOfLastJTextFieldV1YValue();
|
4732 |
//// else
|
4733 |
//// d1 = 0.0;
|
4734 |
////
|
4735 |
//// if (hasChanged_v2Y)
|
4736 |
//// d2 = c2 - getDoubleValueOfLastJTextFieldV2YValue();
|
4737 |
//// else
|
4738 |
//// d2 = 0.0;
|
4739 |
////
|
4740 |
//// if (d1 == 0.0) {
|
4741 |
//// // It's supposed that d2 != 0
|
4742 |
//// c1 += d2;
|
4743 |
////
|
4744 |
//// if (c1 < getDoubleValueOfJTextFieldV2Y()) {
|
4745 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4746 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4747 |
//// return;
|
4748 |
//// }
|
4749 |
////
|
4750 |
//// getJTextFieldVertex1Y().setText(Double.toString(c1));
|
4751 |
//// }
|
4752 |
//// else {
|
4753 |
//// if (d2 == 0.0) {
|
4754 |
//// // It's supposed that d1 != 0
|
4755 |
//// c2 += d1;
|
4756 |
////
|
4757 |
//// if (c2 > getDoubleValueOfJTextFieldV1Y()) {
|
4758 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4759 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4760 |
//// return;
|
4761 |
//// }
|
4762 |
////
|
4763 |
//// getJTextFieldVertex2Y().setText(Double.toString(c2));
|
4764 |
//// }
|
4765 |
//// else {
|
4766 |
//// // If there has been an error -> can't move different distances in Y the two vertexes
|
4767 |
//// if (d1 != d2) {
|
4768 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_Y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4769 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4770 |
//// return;
|
4771 |
//// }
|
4772 |
//// }
|
4773 |
//// }
|
4774 |
//// }
|
4775 |
//// }
|
4776 |
//// else {
|
4777 |
//// boolean canSetExtent = true;
|
4778 |
////
|
4779 |
//// // Check if there is a impossible coordinate
|
4780 |
//// if (hasChanged_v1X) {
|
4781 |
//// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
4782 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4783 |
//// canSetExtent = false;
|
4784 |
//// }
|
4785 |
//// }
|
4786 |
////
|
4787 |
//// if (hasChanged_v1Y) {
|
4788 |
//// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
4789 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4790 |
//// canSetExtent = false;
|
4791 |
//// }
|
4792 |
//// }
|
4793 |
////
|
4794 |
//// if (hasChanged_v2X) {
|
4795 |
//// if (getDoubleValueOfJTextFieldV2X() > getDoubleValueOfJTextFieldV1X()) {
|
4796 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4797 |
//// canSetExtent = false;
|
4798 |
//// }
|
4799 |
//// }
|
4800 |
////
|
4801 |
//// if (hasChanged_v2Y) {
|
4802 |
//// if (getDoubleValueOfJTextFieldV2Y() > getDoubleValueOfJTextFieldV1Y()) {
|
4803 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4804 |
//// canSetExtent = false;
|
4805 |
//// }
|
4806 |
//// }
|
4807 |
////
|
4808 |
//// // If can set the new Extent -> finish
|
4809 |
//// if (!canSetExtent) {
|
4810 |
//// restoreAllModifiedCoordinates(); // restores the coordinates
|
4811 |
//// return;
|
4812 |
//// }
|
4813 |
//// }
|
4814 |
//// }
|
4815 |
////
|
4816 |
//// //Rectangle2D r2d = vP.getExtent();
|
4817 |
//// if (vP.getExtent() != null){
|
4818 |
//// vP.setExtent(getNewRectangleByCoordinates());
|
4819 |
//// vP.refreshExtent();
|
4820 |
//// }
|
4821 |
//// }
|
4822 |
//// }
|
4823 |
//// else {
|
4824 |
//// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "at_least_one_incorrect_coordinate"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
4825 |
//// }
|
4826 |
//// }
|
4827 |
// });
|
4828 |
// }
|
4829 |
// return jButtonPreviewArea;
|
4830 |
// }
|
4831 |
//
|
4832 |
// /**
|
4833 |
// * Calculates the new rectangle using the coordinates of the text fields
|
4834 |
// *
|
4835 |
// * @return java.awt.geom.Rectangle2D
|
4836 |
// */
|
4837 |
// private Rectangle2D getNewRectangleByCoordinates() {
|
4838 |
// return new Rectangle2D.Double(getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV2Y(), getDoubleValueOfJTextFieldV1X() - getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV1Y() - getDoubleValueOfJTextFieldV2Y());
|
4839 |
// }
|
4840 |
//
|
4841 |
// /**
|
4842 |
// * Restores the value of all text fields with coordinates modified to their last value
|
4843 |
// */
|
4844 |
// private void restoreAllModifiedCoordinates() {
|
4845 |
// if (hasChanged_v1X) {
|
4846 |
// getJTextFieldVertex1X().setText(last_Coordinates[0]);
|
4847 |
// hasChanged_v1X = false;
|
4848 |
// }
|
4849 |
//
|
4850 |
// if (hasChanged_v1Y) {
|
4851 |
// getJTextFieldVertex1Y().setText(last_Coordinates[1]);
|
4852 |
// hasChanged_v1Y = false;
|
4853 |
// }
|
4854 |
//
|
4855 |
// if (hasChanged_v2X) {
|
4856 |
// getJTextFieldVertex2X().setText(last_Coordinates[2]);
|
4857 |
// hasChanged_v2X = false;
|
4858 |
// }
|
4859 |
//
|
4860 |
// if (hasChanged_v2Y) {
|
4861 |
// getJTextFieldVertex2Y().setText(last_Coordinates[3]);
|
4862 |
// hasChanged_v2Y = false;
|
4863 |
// }
|
4864 |
// }
|
4865 |
//
|
4866 |
// /**
|
4867 |
// * Enables or disables all inner JTextField
|
4868 |
// *
|
4869 |
// * @param b A boolean value
|
4870 |
// */
|
4871 |
// public void setAllTextFieldsEnabled(boolean b) {
|
4872 |
// getJTextFieldVertex1X().setEnabled(b);
|
4873 |
// getJTextFieldVertex1Y().setEnabled(b);
|
4874 |
// getJTextFieldVertex2X().setEnabled(b);
|
4875 |
// getJTextFieldVertex2Y().setEnabled(b);
|
4876 |
// }
|
4877 |
//
|
4878 |
// /**
|
4879 |
// * Sets the extent into the text fields
|
4880 |
// *
|
4881 |
// * @param extent java.awt.geom.Rectangle2D
|
4882 |
// */
|
4883 |
// public void updateCoordinates(Rectangle2D extent){
|
4884 |
// getJTextFieldVertex1X().setText(String.valueOf(extent.getMaxX()));
|
4885 |
// last_Coordinates[0] = getJTextFieldVertex1X().getText();
|
4886 |
// previous_Coordinate_Value[0] = last_Coordinates[0];
|
4887 |
//
|
4888 |
// getJTextFieldVertex1Y().setText(String.valueOf(extent.getMaxY()));
|
4889 |
// last_Coordinates[1] = getJTextFieldVertex1Y().getText();
|
4890 |
// previous_Coordinate_Value[1] = last_Coordinates[1];
|
4891 |
//
|
4892 |
// getJTextFieldVertex2X().setText(String.valueOf(extent.getMinX()));
|
4893 |
// last_Coordinates[2] = getJTextFieldVertex2X().getText();
|
4894 |
// previous_Coordinate_Value[2] = last_Coordinates[2];
|
4895 |
//
|
4896 |
// getJTextFieldVertex2Y().setText(String.valueOf(extent.getMinY()));
|
4897 |
// last_Coordinates[3] = getJTextFieldVertex2Y().getText();
|
4898 |
// previous_Coordinate_Value[3] = last_Coordinates[3];
|
4899 |
//
|
4900 |
// resetCoordinatesFlags();
|
4901 |
//
|
4902 |
// // Enable the 'Applicate' button
|
4903 |
// setApplicable(true);
|
4904 |
// }
|
4905 |
//
|
4906 |
// /**
|
4907 |
// * Validates all coordinates of both vertexes separately
|
4908 |
// *
|
4909 |
// * @return A ValidationInfo object reference
|
4910 |
// */
|
4911 |
// private ValidationInfo validVertexesCoordinates() {
|
4912 |
// if (! validateCoordinate(getJTextFieldVertex1X())) {
|
4913 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
4914 |
// }
|
4915 |
//
|
4916 |
// if (! validateCoordinate(getJTextFieldVertex1Y())) {
|
4917 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
4918 |
// }
|
4919 |
//
|
4920 |
// if (! validateCoordinate(getJTextFieldVertex2X())) {
|
4921 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
4922 |
// }
|
4923 |
//
|
4924 |
// if (! validateCoordinate(getJTextFieldVertex2Y())) {
|
4925 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
4926 |
// }
|
4927 |
//
|
4928 |
// // If arrives here, all coordinates are valid
|
4929 |
// return new ValidationInfo(true, "");
|
4930 |
// }
|
4931 |
//
|
4932 |
// /**
|
4933 |
// * Validates that Vertex1 is in the right-up corner and the Vertex2 in the left-down corner of the area/rectangle <br>
|
4934 |
// * (It's supposed that coordinates of the vertexes are valid) <br>
|
4935 |
// * (It's supposed that going to right or up, the coordinate value increases)
|
4936 |
// *
|
4937 |
// * @return A ValidationInfo object reference
|
4938 |
// */
|
4939 |
// private ValidationInfo validVertexesPositions() {
|
4940 |
// // Check if no coordinate it's defined
|
4941 |
// if (getJTextFieldVertex1X().getText().compareTo("") == 0) {
|
4942 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
4943 |
// }
|
4944 |
//
|
4945 |
// if (getJTextFieldVertex2X().getText().compareTo("") == 0) {
|
4946 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
4947 |
// }
|
4948 |
//
|
4949 |
// if (getJTextFieldVertex1Y().getText().compareTo("") == 0) {
|
4950 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
4951 |
// }
|
4952 |
//
|
4953 |
// if (getJTextFieldVertex2Y().getText().compareTo("") == 0) {
|
4954 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
4955 |
// }
|
4956 |
//
|
4957 |
// // Check if the vertex V1 is in the right-up corner and the vertex V2 is in the left-down corner
|
4958 |
// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
4959 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1x") + " < " + PluginServices.getText(this, "v2x"));
|
4960 |
// }
|
4961 |
//
|
4962 |
// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
4963 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1y") + " < " + PluginServices.getText(this, "v2y"));
|
4964 |
// }
|
4965 |
//
|
4966 |
// // If arrives here -> vertexes positions are valid
|
4967 |
// return new ValidationInfo(true, "");
|
4968 |
// }
|
4969 |
//
|
4970 |
// /**
|
4971 |
// * Validate each coordinate of each vertex and the position of the vertexes
|
4972 |
// *
|
4973 |
// * @return A boolean value
|
4974 |
// */
|
4975 |
// public boolean validVertexes() {
|
4976 |
// ValidationInfo v1 = validVertexesCoordinates();
|
4977 |
//
|
4978 |
// if (!v1.isValid()) {
|
4979 |
// // Notify to user that no filter area will be applied
|
4980 |
// JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v1.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE);
|
4981 |
//
|
4982 |
// return false;
|
4983 |
// }
|
4984 |
// else {
|
4985 |
// ValidationInfo v2 = validVertexesPositions();
|
4986 |
// if (!v2.isValid()) {
|
4987 |
// // Notify to user that no filter area will be applied
|
4988 |
// JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v2.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE);
|
4989 |
//
|
4990 |
// return false;
|
4991 |
// }
|
4992 |
// else {
|
4993 |
// return true;
|
4994 |
// }
|
4995 |
// }
|
4996 |
// }
|
4997 |
//
|
4998 |
// /**
|
4999 |
// * Gets the extent (rectangle) represented by the values of the coordinate text fields
|
5000 |
// *
|
5001 |
// * @return java.awt.geom.Rectangle2D
|
5002 |
// */
|
5003 |
// public Rectangle2D getExtent() {
|
5004 |
// double v1x = getDoubleValueOfJTextFieldV1X();
|
5005 |
// double v1y = getDoubleValueOfJTextFieldV1Y();
|
5006 |
// double v2x = getDoubleValueOfJTextFieldV2X();
|
5007 |
// double v2y = getDoubleValueOfJTextFieldV2Y();
|
5008 |
//
|
5009 |
// return new Rectangle2D.Double(v2x, v2y, (v1x - v2x), (v1y - v2y));
|
5010 |
// }
|
5011 |
//
|
5012 |
// /**
|
5013 |
// * Returns true if there is some coordinate text field with data; else returns false
|
5014 |
// *
|
5015 |
// * @return A boolean value
|
5016 |
// */
|
5017 |
// public boolean areThereSomeCoordinatesWritten() {
|
5018 |
// return ((getJTextFieldVertex1X().getText().compareTo("") != 0) | (getJTextFieldVertex1Y().getText().compareTo("") != 0) | (getJTextFieldVertex2X().getText().compareTo("") != 0) | (getJTextFieldVertex2Y().getText().compareTo("") != 0));
|
5019 |
// }
|
5020 |
//
|
5021 |
// /**
|
5022 |
// * Returns true if all coordinate text fields are undefined (without values)
|
5023 |
// *
|
5024 |
// * @return A boolean value
|
5025 |
// */
|
5026 |
// public boolean areAllCoordinatesUndefined() {
|
5027 |
// return ((getJTextFieldVertex1X().getText().compareTo("") == 0) & (getJTextFieldVertex1Y().getText().compareTo("") == 0) & (getJTextFieldVertex2X().getText().compareTo("") == 0) & (getJTextFieldVertex2Y().getText().compareTo("") == 0));
|
5028 |
// }
|
5029 |
//
|
5030 |
//
|
5031 |
// /**
|
5032 |
// * Returns true if there is some coordinate undefined (without values)
|
5033 |
// *
|
5034 |
// * @return A boolean value
|
5035 |
// */
|
5036 |
// public boolean isThereAnyCoordinateUndefined() {
|
5037 |
// return ((getJTextFieldVertex1X().getText().compareTo("") == 0) | (getJTextFieldVertex1Y().getText().compareTo("") == 0) | (getJTextFieldVertex2X().getText().compareTo("") == 0) | (getJTextFieldVertex2Y().getText().compareTo("") == 0));
|
5038 |
// }
|
5039 |
// }
|
5040 |
//
|
5041 |
// /**
|
5042 |
// * This class is a MapControl JComponent that has visual information and allows user interact with some tools and view the results
|
5043 |
// *
|
5044 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
5045 |
// */
|
5046 |
// private class SelectableMapControlAreaPanel extends MapControl {
|
5047 |
// private MouseListener[] mouseListeners;
|
5048 |
// private MouseWheelListener[] mouseWheelListeners;
|
5049 |
// private MouseMotionListener[] mouseMotionListeners;
|
5050 |
//
|
5051 |
// /**
|
5052 |
// * Default constructor
|
5053 |
// */
|
5054 |
// public SelectableMapControlAreaPanel() {
|
5055 |
// super();
|
5056 |
// initialize();
|
5057 |
// }
|
5058 |
//
|
5059 |
// /**
|
5060 |
// * This method initializes this component
|
5061 |
// */
|
5062 |
// public void initialize() {
|
5063 |
// /* Sets Bounds of this graphical component */
|
5064 |
// this.setBounds(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE);
|
5065 |
//
|
5066 |
// /* Sets border to this graphical component */
|
5067 |
// this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
|
5068 |
//
|
5069 |
// /* Sets a clone of the current active view map context to this MapControl */
|
5070 |
// try {
|
5071 |
// MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext();
|
5072 |
//
|
5073 |
// this.setMapContext(mp.cloneFMap());
|
5074 |
// ViewPort vP = this.getViewPort();
|
5075 |
//
|
5076 |
// Rectangle2D r2D = vP.getExtent();
|
5077 |
//
|
5078 |
// if (r2D != null) {
|
5079 |
// vP.refreshExtent();
|
5080 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
5081 |
// }
|
5082 |
// } catch (XMLException e) {
|
5083 |
// e.printStackTrace();
|
5084 |
// }
|
5085 |
//
|
5086 |
// /* Adds listeners to this MapControl */
|
5087 |
// this.addToolsListeners();
|
5088 |
//
|
5089 |
// /* Sets default tool */
|
5090 |
// this.setTool(PAN_TOOL);
|
5091 |
// }
|
5092 |
//
|
5093 |
// /**
|
5094 |
// * Refresh the active view
|
5095 |
// */
|
5096 |
// public void refreshWithTheActiveView() {
|
5097 |
// try {
|
5098 |
// MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext();
|
5099 |
// this.setMapContext(mp.cloneFMap());
|
5100 |
// ViewPort vP = this.getViewPort();
|
5101 |
//
|
5102 |
// Rectangle2D r2D = vP.getExtent();
|
5103 |
//
|
5104 |
// if (r2D != null) {
|
5105 |
// vP.refreshExtent();
|
5106 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
5107 |
// }
|
5108 |
// } catch (XMLException e) {
|
5109 |
// e.printStackTrace();
|
5110 |
// }
|
5111 |
// }
|
5112 |
//
|
5113 |
// /**
|
5114 |
// * Adds listeners that allows user interact with it's mouse over this component and that represents different tools
|
5115 |
// */
|
5116 |
// private void addToolsListeners() {
|
5117 |
// // MOVEMENT EVENTS LISTENER: sets mouse coordinates to the status bar
|
5118 |
// StatusBarListener sbl = new StatusBarListener(this);
|
5119 |
//
|
5120 |
// // ZOOM OUT (Presses on the map and it will be centered showing a bigger area)
|
5121 |
// // Only pressing, not selecting a rectangle area
|
5122 |
// ZoomOutListener zol = new ZoomOutListener(this);
|
5123 |
// this.addMapTool(ZOOM_OUT_TOOL, new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)});
|
5124 |
//
|
5125 |
// // ZOOM IN (Using a Rectangle or a simple mouse click)
|
5126 |
// ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(this);
|
5127 |
// ZoomInListener zil = new ZoomInListener(this);
|
5128 |
// this.addMapTool(ZOOM_IN_TOOL, new Behavior[]{new RectangleBehavior(zil),
|
5129 |
// new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
|
5130 |
//
|
5131 |
// // PAN
|
5132 |
// PanListener pl = new PanListener(this);
|
5133 |
// this.addMapTool(PAN_TOOL, new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)});
|
5134 |
//
|
5135 |
// // MEASURE DISTANCES
|
5136 |
// MeasureListener mli = new MeasureListener(this);
|
5137 |
// this.addMapTool(MEASURE_DISTANCES_TOOL, new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)});
|
5138 |
//
|
5139 |
// // MEASURE AREA
|
5140 |
// AreaListener ali = new AreaListener(this);
|
5141 |
// this.addMapTool(MEASURE_AREA_TOOL, new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
|
5142 |
//
|
5143 |
// this.getViewPort().addViewPortListener(new ViewPortListener() {
|
5144 |
// /*
|
5145 |
// * (non-Javadoc)
|
5146 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
5147 |
// */
|
5148 |
// public void extentChanged(ExtentEvent e) {
|
5149 |
// if (getMapContext().getViewPort().getExtents().hasPrevious()) {
|
5150 |
// Rectangle2D r2d = getViewPort().getExtent();
|
5151 |
//
|
5152 |
// if (r2d != null) {
|
5153 |
// getCoordinatesPanel().updateCoordinates(r2d);
|
5154 |
//
|
5155 |
//// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
5156 |
// hasUserDefinedAnArea = true;
|
5157 |
//// }
|
5158 |
// }
|
5159 |
//
|
5160 |
// getJButtonZoomPrevious().setEnabled(true);
|
5161 |
// getJButtonUndo().setEnabled(true);
|
5162 |
// }
|
5163 |
// else {
|
5164 |
// getJButtonZoomPrevious().setEnabled(false);
|
5165 |
// getJButtonUndo().setEnabled(false);
|
5166 |
// }
|
5167 |
// }
|
5168 |
//
|
5169 |
// /*
|
5170 |
// * (non-Javadoc)
|
5171 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
5172 |
// */
|
5173 |
// public void backColorChanged(ColorEvent e) {
|
5174 |
// }
|
5175 |
//
|
5176 |
// /*
|
5177 |
// * (non-Javadoc)
|
5178 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#projectionChanged(com.iver.cit.gvsig.fmap.ProjectionEvent)
|
5179 |
// */
|
5180 |
// public void projectionChanged(ProjectionEvent e) {
|
5181 |
// }
|
5182 |
//
|
5183 |
// });
|
5184 |
// }
|
5185 |
//
|
5186 |
// /*
|
5187 |
// * (non-Javadoc)
|
5188 |
// * @see java.awt.Component#setEnabled(boolean)
|
5189 |
// */
|
5190 |
// public void setEnabled(boolean b) {
|
5191 |
// super.setEnabled(b);
|
5192 |
//
|
5193 |
// if (b)
|
5194 |
// enableAllMouseListeners();
|
5195 |
// else
|
5196 |
// disableAllMouseListeners();
|
5197 |
// }
|
5198 |
//
|
5199 |
// /**
|
5200 |
// * Disables all mouse listeners
|
5201 |
// */
|
5202 |
// public void disableAllMouseListeners() {
|
5203 |
// int i;
|
5204 |
//
|
5205 |
// // Only disable listeners if there are listeners to remove (it's supposed that there are always the same number of mouse listeners, and this listeners
|
5206 |
// // are referenciated by this component or by the private attribute 'mouseListeners')
|
5207 |
//
|
5208 |
// // Mouse Button Listeners
|
5209 |
// if (mouseListeners == null) {
|
5210 |
// mouseListeners = this.getMouseListeners();
|
5211 |
//
|
5212 |
// for (i = 0; i < mouseListeners.length; i++) {
|
5213 |
// removeMouseListener(mouseListeners[i]);
|
5214 |
// }
|
5215 |
// }
|
5216 |
//
|
5217 |
// // Mouse Wheel Listeners
|
5218 |
// if (mouseWheelListeners == null) {
|
5219 |
// mouseWheelListeners = this.getMouseWheelListeners();
|
5220 |
//
|
5221 |
// for (i = 0; i < mouseWheelListeners.length; i++) {
|
5222 |
// removeMouseWheelListener(mouseWheelListeners[i]);
|
5223 |
// }
|
5224 |
// }
|
5225 |
//
|
5226 |
// // Mouse motion listeners
|
5227 |
// if (mouseMotionListeners == null) {
|
5228 |
// mouseMotionListeners = this.getMouseMotionListeners();
|
5229 |
//
|
5230 |
// for (i = 0; i < mouseMotionListeners.length; i++) {
|
5231 |
// removeMouseMotionListener(mouseMotionListeners[i]);
|
5232 |
// }
|
5233 |
// }
|
5234 |
// }
|
5235 |
//
|
5236 |
// /**
|
5237 |
// * Enables all mouse listeners
|
5238 |
// */
|
5239 |
// public void enableAllMouseListeners() {
|
5240 |
// int i;
|
5241 |
//
|
5242 |
// // Mouse Button Listeners
|
5243 |
// for (i = 0; i < mouseListeners.length; i++) {
|
5244 |
// addMouseListener(mouseListeners[i]);
|
5245 |
// }
|
5246 |
//
|
5247 |
// mouseListeners = null;
|
5248 |
//
|
5249 |
// // Mouse Wheel Listeners
|
5250 |
// for (i = 0; i < mouseWheelListeners.length; i++) {
|
5251 |
// addMouseWheelListener(mouseWheelListeners[i]);
|
5252 |
// }
|
5253 |
//
|
5254 |
// mouseWheelListeners = null;
|
5255 |
//
|
5256 |
// // Mouse motion listeners
|
5257 |
// for (i = 0; i < mouseMotionListeners.length; i++) {
|
5258 |
// addMouseMotionListener(mouseMotionListeners[i]);
|
5259 |
// }
|
5260 |
//
|
5261 |
// mouseMotionListeners = null;
|
5262 |
// }
|
5263 |
// }
|
5264 |
//
|
5265 |
// /**
|
5266 |
// * This class has information about a validation: <br>
|
5267 |
// * - A boolean value -> if has been or not validated <br>
|
5268 |
// * - An String -> a message about the invalid
|
5269 |
// *
|
5270 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
5271 |
// */
|
5272 |
// private class ValidationInfo {
|
5273 |
// private boolean _valid;
|
5274 |
// private String _message;
|
5275 |
//
|
5276 |
// /**
|
5277 |
// * Default constructor with two parameters
|
5278 |
// *
|
5279 |
// * @param valid If was valid or not
|
5280 |
// * @param message A message associate to the validation (If has been valid, this attribute should be "", in the other case should have a message with
|
5281 |
// * an explanation about the invalidation)
|
5282 |
// */
|
5283 |
// public ValidationInfo(boolean valid, String message) {
|
5284 |
// _valid = valid;
|
5285 |
// _message = message;
|
5286 |
// }
|
5287 |
//
|
5288 |
// /**
|
5289 |
// * Returns the value of the inner attribute '_valid'
|
5290 |
// *
|
5291 |
// * @return A boolean value
|
5292 |
// */
|
5293 |
// public boolean isValid() {
|
5294 |
// return _valid;
|
5295 |
// }
|
5296 |
//
|
5297 |
// /**
|
5298 |
// * Returns the value of the inner attribute '_message'
|
5299 |
// *
|
5300 |
// * @return java.lang.String
|
5301 |
// */
|
5302 |
// public String getMessage() {
|
5303 |
// return _message;
|
5304 |
// }
|
5305 |
// }
|
5306 |
//}
|
5307 |
|
5308 |
|
5309 |
//
|
5310 |
// VERSI?N PREVIA -> ESTA ES LA VERSI?N BUENA, PERO HAY QUE EVITAR QUE CLONE MAPCONTROL
|
5311 |
//
|
5312 |
//
|
5313 |
///**
|
5314 |
// * This panel allows user to select the area he/she wants to get in the view.
|
5315 |
// * There are two options to do this:
|
5316 |
// * - Indicating the coordinates of the top-left and down-right corners
|
5317 |
// * - Selecting the area with some visual tool
|
5318 |
// *
|
5319 |
// * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
5320 |
// * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
5321 |
// */
|
5322 |
//public class WFSAreaPanel extends JPanel {
|
5323 |
// private final Rectangle DEFAULT_BOUNDS = new Rectangle(10, 5, 490, 380);
|
5324 |
// private final Rectangle DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE = new Rectangle(8, 20, 481, 60);
|
5325 |
// private final Rectangle DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE = new Rectangle(8, 115, 481, 265);
|
5326 |
// private final Rectangle DEFAULT_UNDO_ICON_BUTTON_RECTANGLE = new Rectangle (250, 85, 25, 25);
|
5327 |
//// private final Rectangle DEFAULT_REDO_ICON_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25);
|
5328 |
//// private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25);
|
5329 |
//// private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (331, 85, 25, 25);
|
5330 |
// private final Rectangle DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (277, 85, 25, 25);
|
5331 |
// private final Rectangle DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE = new Rectangle (304, 85, 25, 25);
|
5332 |
// private final Rectangle DEFAULT_PAN_ICON_BUTTON_RECTANGLE = new Rectangle(250, 85, 25, 25);
|
5333 |
// private final Rectangle DEFAULT_TOOL_JCOMBOBOX_RECTANGLE = new Rectangle(10, 87, 230, 21);
|
5334 |
// private final Rectangle DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE = new Rectangle(277, 85, 47, 25);
|
5335 |
// private final Rectangle DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE = new Rectangle(326, 85, 25, 25);
|
5336 |
// private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(353, 85, 25, 25);
|
5337 |
// private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE = new Rectangle(380, 85, 47, 25);
|
5338 |
// private final Rectangle DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE = new Rectangle(429, 85, 47, 25);
|
5339 |
//
|
5340 |
// private final int DISABLED_OPERATION = 0;
|
5341 |
// private final int SELECTION_BY_COORDINATES_OPERATION = 1;
|
5342 |
// private final int SELECTION_BY_AREA_OPERATION = 2;
|
5343 |
// private boolean hasUserDefinedAnArea;
|
5344 |
//
|
5345 |
// private WFSWizardData data = null;
|
5346 |
// private WFSParamsPanel parent = null;
|
5347 |
// private AreaCoordinatesPanel coordinatesPanel = null;
|
5348 |
// private SelectableMapControlAreaPanel selectableMapAreaPanel = null;
|
5349 |
// private JComboBox jComboBoxToolSelection = null;
|
5350 |
// private JButton jButtonUndo = null;
|
5351 |
//// private JButton jButtonRedo = null;
|
5352 |
// private JToggleButton jToggleButtonMove = null;
|
5353 |
// private JToggleButton jToggleButtonScaling = null;
|
5354 |
// private JButton jButtonPan = null;
|
5355 |
// private JButton jButtonZoomPrevious = null;
|
5356 |
// private JButton jButtonZoomComplete = null;
|
5357 |
// private JComboBoxWithImageIconItems jComboBoxZoomInAndOut = null;
|
5358 |
// private JComboBoxWithImageIconItems jComboBoxZoomInAndOutViewCentered = null;
|
5359 |
// private JComboBoxWithImageIconItems jComboBoxOtherTools = null;
|
5360 |
//
|
5361 |
// /* Tool identifier constants */
|
5362 |
// private final String PAN_TOOL = "HAND";
|
5363 |
// private final String ZOOM_IN_TOOL = "zoomIn"; // This constant must be 'zoomIn' for a correct operation of the tools 'Zoom In' and 'Zoom In Map Centered'
|
5364 |
// private final String ZOOM_OUT_TOOL = "zoomOut"; // This constant must be 'zoomOut' for a correct operation of the tools 'Zoom Out' and 'Zoom Out Map Centered'
|
5365 |
// private final String ZOOM_IN_VIEW_CENTERED_TOOL = "ZOOM_IN_VIEW_CENTERED";
|
5366 |
// private final String ZOOM_OUT_VIEW_CENTERED_TOOL = "ZOOM_OUT_VIEW_CENTERED";
|
5367 |
// private final String MEASURE_DISTANCES_TOOL = "MEASURE_DISTANCES";
|
5368 |
// private final String MEASURE_AREA_TOOL = "MEASURE_AREA";
|
5369 |
// /* End tool identifier constants */
|
5370 |
//
|
5371 |
//
|
5372 |
// /**
|
5373 |
// * This method initializes
|
5374 |
// */
|
5375 |
// public WFSAreaPanel(WFSParamsPanel parent) {
|
5376 |
// super();
|
5377 |
// this.parent = parent;
|
5378 |
// initialize();
|
5379 |
// }
|
5380 |
//
|
5381 |
// /**
|
5382 |
// * This method initializes this
|
5383 |
// */
|
5384 |
// private void initialize() {
|
5385 |
// this.setLayout(null);
|
5386 |
// this.setBounds(DEFAULT_BOUNDS);
|
5387 |
// this.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
5388 |
// null, PluginServices.getText(this, "select_by_area"),
|
5389 |
// javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
5390 |
// javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
5391 |
//
|
5392 |
// // By default, user hasn't defined an area
|
5393 |
// this.hasUserDefinedAnArea = false;
|
5394 |
//
|
5395 |
// // Adds JPanel with the coordinates
|
5396 |
// this.add(getCoordinatesPanel(), null);
|
5397 |
//
|
5398 |
// // Adds JComboBox to select a part of the graphical interface
|
5399 |
// this.add(getJComboBoxToolSelection(), null);
|
5400 |
// this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element
|
5401 |
//
|
5402 |
// // Adds JPanel with the view
|
5403 |
// this.add(getSelectableMapAreaPanel(), null);
|
5404 |
//
|
5405 |
// initCoordinates();
|
5406 |
// }
|
5407 |
//
|
5408 |
// /**
|
5409 |
// * Write the view coordinates into the coordinates panel
|
5410 |
// */
|
5411 |
// private void initCoordinates(){
|
5412 |
// BaseView activeView = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
5413 |
// Rectangle2D r2d = activeView.getMapControl().getViewPort().getExtent();
|
5414 |
// if (r2d != null){
|
5415 |
// getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMaxX()));
|
5416 |
// getCoordinatesPanel().getJTextFieldVertex1Y().setText(Double.toString(r2d.getMaxY()));
|
5417 |
// getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(r2d.getMinX()));
|
5418 |
// getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(r2d.getMinY()));
|
5419 |
// }
|
5420 |
// }
|
5421 |
//
|
5422 |
// /**
|
5423 |
// * This method initializes coordinatesPanel
|
5424 |
// *
|
5425 |
// * @return javax.swing.JPanel
|
5426 |
// */
|
5427 |
// private AreaCoordinatesPanel getCoordinatesPanel() {
|
5428 |
// if (coordinatesPanel == null) {
|
5429 |
// coordinatesPanel = new AreaCoordinatesPanel();
|
5430 |
// }
|
5431 |
// return coordinatesPanel;
|
5432 |
// }
|
5433 |
//
|
5434 |
// /**
|
5435 |
// * This method initializes jComboBoxToolSelection
|
5436 |
// *
|
5437 |
// * @return javax.swing.JComboBox
|
5438 |
// */
|
5439 |
// private JComboBox getJComboBoxToolSelection() {
|
5440 |
// if (jComboBoxToolSelection == null) {
|
5441 |
// jComboBoxToolSelection = new JComboBox();
|
5442 |
// jComboBoxToolSelection.setBounds(DEFAULT_TOOL_JCOMBOBOX_RECTANGLE);
|
5443 |
// jComboBoxToolSelection.setToolTipText(PluginServices.getText(this, "select_a_tool"));
|
5444 |
// jComboBoxToolSelection.setEditable(false);
|
5445 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION));
|
5446 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION));
|
5447 |
// jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION));
|
5448 |
//
|
5449 |
// jComboBoxToolSelection.addActionListener(new ActionListener() {
|
5450 |
// /*
|
5451 |
// * (non-Javadoc)
|
5452 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
5453 |
// */
|
5454 |
// public void actionPerformed(ActionEvent e) {
|
5455 |
// JComboBox cb = (JComboBox)e.getSource();
|
5456 |
// switch(((ItemOperation)cb.getSelectedItem()).getOperation()) {
|
5457 |
// case DISABLED_OPERATION:
|
5458 |
// disableCoorderatesRegionOperation();
|
5459 |
// disableAreaRegionOperation();
|
5460 |
// break;
|
5461 |
// case SELECTION_BY_COORDINATES_OPERATION:
|
5462 |
// disableAreaRegionOperation();
|
5463 |
// enableCoorderatesRegionOperation();
|
5464 |
// break;
|
5465 |
// case SELECTION_BY_AREA_OPERATION:
|
5466 |
// // Only enable the area operation if there is data loaded in this MapControl
|
5467 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
|
5468 |
// disableCoorderatesRegionOperation();
|
5469 |
// enableAreaRegionOperation();
|
5470 |
// }
|
5471 |
// else {
|
5472 |
// JOptionPane.showMessageDialog(jComboBoxToolSelection, PluginServices.getText(null, "there_is_no_layer_loaded_in_the_active_view"), PluginServices.getText(null, "information"), JOptionPane.INFORMATION_MESSAGE);
|
5473 |
//
|
5474 |
// // Select: no tools
|
5475 |
// jComboBoxToolSelection.setSelectedIndex(0);
|
5476 |
// disableCoorderatesRegionOperation();
|
5477 |
// }
|
5478 |
//
|
5479 |
// break;
|
5480 |
// }
|
5481 |
// }
|
5482 |
// });
|
5483 |
// }
|
5484 |
// return jComboBoxToolSelection;
|
5485 |
// }
|
5486 |
//
|
5487 |
// /**
|
5488 |
// * Enables the components associated to the selection of area by coordinates
|
5489 |
// */
|
5490 |
// private void enableCoorderatesRegionOperation() {
|
5491 |
// // Adds associated icons
|
5492 |
// this.add(getJButtonUndo(), null);
|
5493 |
//// this.add(getJButtonRedo(), null);
|
5494 |
// this.add(getJToggleButtonMove(), null);
|
5495 |
// this.add(getJToggleButtonScaling(), null);
|
5496 |
//
|
5497 |
// getCoordinatesPanel().setAllTextFieldsEnabled(true);
|
5498 |
//
|
5499 |
// // Only enable the area operation if there is data loaded in this MapControl
|
5500 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
|
5501 |
// getJToggleButtonMove().setEnabled(true);
|
5502 |
// getJToggleButtonScaling().setEnabled(true);
|
5503 |
// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
|
5504 |
// }
|
5505 |
// else {
|
5506 |
// getJToggleButtonMove().setEnabled(false);
|
5507 |
// getJToggleButtonScaling().setEnabled(false);
|
5508 |
// }
|
5509 |
// }
|
5510 |
//
|
5511 |
// /**
|
5512 |
// * Enables the components associated to the selection of area by view
|
5513 |
// */
|
5514 |
// private void enableAreaRegionOperation() {
|
5515 |
// // Adds associated icons
|
5516 |
// this.add(getJButtonPan(), null);
|
5517 |
// this.add(getJComboBoxZoomInAndOut(), null);
|
5518 |
// getJComboBoxZoomInAndOut().revalidate(); // Force update this component
|
5519 |
// this.add(getJButtonZoomPrevious(), null);
|
5520 |
// this.add(getJButtonZoomComplete(), null);
|
5521 |
// this.add(getJComboBoxZoomInAndOutViewCentered(), null);
|
5522 |
// getJComboBoxZoomInAndOutViewCentered().revalidate(); // Force update this component
|
5523 |
// this.add(getJComboBoxOtherTools(), null);
|
5524 |
// getJComboBoxOtherTools().revalidate(); // Force update this component
|
5525 |
//
|
5526 |
// // Enables the MapControl area
|
5527 |
// getSelectableMapAreaPanel().setEnabled(true);
|
5528 |
// }
|
5529 |
//
|
5530 |
// /**
|
5531 |
// * Disables the components associated to the selection of area by coordinates
|
5532 |
// */
|
5533 |
// private void disableCoorderatesRegionOperation() {
|
5534 |
// // Removes associated icons
|
5535 |
// this.remove(getJButtonUndo());
|
5536 |
//// this.remove(getJButtonRedo());
|
5537 |
// this.remove(getJToggleButtonMove());
|
5538 |
// this.remove(getJToggleButtonScaling());
|
5539 |
//
|
5540 |
// getCoordinatesPanel().setAllTextFieldsEnabled(false);
|
5541 |
// getCoordinatesPanel().getJButtonPreviewArea().setEnabled(false);
|
5542 |
// }
|
5543 |
//
|
5544 |
// /**
|
5545 |
// * Disables the components associated to the selection of area by view
|
5546 |
// */
|
5547 |
// private void disableAreaRegionOperation() {
|
5548 |
// // Removes associated icons
|
5549 |
// this.remove(getJButtonPan());
|
5550 |
// this.remove(getJComboBoxZoomInAndOut());
|
5551 |
// this.remove(getJButtonZoomPrevious());
|
5552 |
// this.remove(getJButtonZoomComplete());
|
5553 |
// this.remove(getJComboBoxZoomInAndOutViewCentered());
|
5554 |
// this.remove(getJComboBoxOtherTools());
|
5555 |
//
|
5556 |
// // Disables the MapControl area
|
5557 |
// getSelectableMapAreaPanel().setEnabled(false);
|
5558 |
// }
|
5559 |
//
|
5560 |
// /**
|
5561 |
// * This method initializes areaMapControlPanel
|
5562 |
// *
|
5563 |
// * @return A reference to an object of SelectableMapControlAreaPanel
|
5564 |
// */
|
5565 |
// private SelectableMapControlAreaPanel getSelectableMapAreaPanel() {
|
5566 |
// if (selectableMapAreaPanel == null) {
|
5567 |
// selectableMapAreaPanel = new SelectableMapControlAreaPanel();
|
5568 |
// }
|
5569 |
//
|
5570 |
// return selectableMapAreaPanel;
|
5571 |
// }
|
5572 |
//
|
5573 |
// /**
|
5574 |
// * This method initializes jButtonUndo
|
5575 |
// *
|
5576 |
// * @return javax.swing.JButton
|
5577 |
// */
|
5578 |
// private JButton getJButtonUndo() {
|
5579 |
// if (jButtonUndo == null) {
|
5580 |
// jButtonUndo = new JButton();
|
5581 |
// jButtonUndo.setBounds(DEFAULT_UNDO_ICON_BUTTON_RECTANGLE);
|
5582 |
// jButtonUndo.setIcon(PluginServices.getIconTheme().get("edit-undo"));
|
5583 |
// jButtonUndo.setToolTipText(PluginServices.getText(this, "previous_area"));
|
5584 |
// jButtonUndo.addMouseListener(new MouseAdapter() {
|
5585 |
// /*
|
5586 |
// * (non-Javadoc)
|
5587 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
5588 |
// */
|
5589 |
// public void mouseClicked(MouseEvent e) {
|
5590 |
// goToPreviousZoom();
|
5591 |
// }
|
5592 |
// });
|
5593 |
// }
|
5594 |
//
|
5595 |
// return jButtonUndo;
|
5596 |
// }
|
5597 |
//
|
5598 |
//// /**
|
5599 |
//// * This method initializes jButtonUndo
|
5600 |
//// *
|
5601 |
//// * @return javax.swing.JButton
|
5602 |
//// */
|
5603 |
//// private JButton getJButtonRedo() {
|
5604 |
//// if (jButtonRedo == null) {
|
5605 |
//// jButtonRedo = new JButton();
|
5606 |
//// jButtonRedo.setBounds(DEFAULT_REDO_ICON_BUTTON_RECTANGLE);
|
5607 |
//// jButtonRedo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/edit-redo.png")));
|
5608 |
//// jButtonRedo.setToolTipText(PluginServices.getText(this, "following_area"));
|
5609 |
//// }
|
5610 |
////
|
5611 |
//// return jButtonRedo;
|
5612 |
//// }
|
5613 |
//
|
5614 |
// /**
|
5615 |
// * This method initializes jToggleButtonMove
|
5616 |
// *
|
5617 |
// * @return javax.swing.JButton
|
5618 |
// */
|
5619 |
// private JToggleButton getJToggleButtonMove() {
|
5620 |
// if (jToggleButtonMove == null) {
|
5621 |
// jToggleButtonMove = new JToggleButton();
|
5622 |
// jToggleButtonMove.setBounds(DEFAULT_MOVE_ICON_TOGGLE_BUTTON_RECTANGLE);
|
5623 |
// jToggleButtonMove.setIcon(PluginServices.getIconTheme().get("WFS-move"));
|
5624 |
// jToggleButtonMove.setToolTipText(PluginServices.getText(this, "move") + ": " + PluginServices.getText(this, "area_move_explanation"));
|
5625 |
// jToggleButtonMove.addItemListener(new ItemListener() {
|
5626 |
// /*
|
5627 |
// * (non-Javadoc)
|
5628 |
// * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
5629 |
// */
|
5630 |
// public void itemStateChanged(ItemEvent e) {
|
5631 |
// // Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
5632 |
// if (jToggleButtonMove.isSelected())
|
5633 |
// jToggleButtonScaling.setSelected(false);
|
5634 |
// }
|
5635 |
// });
|
5636 |
// }
|
5637 |
//
|
5638 |
// return jToggleButtonMove;
|
5639 |
// }
|
5640 |
//
|
5641 |
// /**
|
5642 |
// * This method initializes jToggleButtonScaling
|
5643 |
// *
|
5644 |
// * @return javax.swing.JButton
|
5645 |
// */
|
5646 |
// private JToggleButton getJToggleButtonScaling() {
|
5647 |
// if (jToggleButtonScaling == null) {
|
5648 |
// jToggleButtonScaling = new JToggleButton();
|
5649 |
// jToggleButtonScaling.setBounds(DEFAULT_SCALING_ICON_TOGGLE_BUTTON_RECTANGLE);
|
5650 |
// jToggleButtonScaling.setIcon(PluginServices.getIconTheme().get("WFS-scaling"));
|
5651 |
// jToggleButtonScaling.setToolTipText(PluginServices.getText(this, "scaling") + ": " + PluginServices.getText(this, "area_scaling_explanation"));
|
5652 |
// jToggleButtonScaling.addItemListener(new ItemListener() {
|
5653 |
// /*
|
5654 |
// * (non-Javadoc)
|
5655 |
// * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
5656 |
// */
|
5657 |
// public void itemStateChanged(ItemEvent e) {
|
5658 |
// // Isn't allowed that the two JToggleButton would be selected (can't move and scale)
|
5659 |
// if (jToggleButtonScaling.isSelected())
|
5660 |
// jToggleButtonMove.setSelected(false);
|
5661 |
// }
|
5662 |
// });
|
5663 |
// }
|
5664 |
//
|
5665 |
// return jToggleButtonScaling;
|
5666 |
// }
|
5667 |
// /**
|
5668 |
// * This method initializes jButtonPan
|
5669 |
// *
|
5670 |
// * @return javax.swing.JButton
|
5671 |
// */
|
5672 |
// private JButton getJButtonPan() {
|
5673 |
// if (jButtonPan == null) {
|
5674 |
// jButtonPan = new JButton();
|
5675 |
// jButtonPan.setBounds(DEFAULT_PAN_ICON_BUTTON_RECTANGLE);
|
5676 |
// jButtonPan.setIcon(PluginServices.getIconTheme().get("view-pan"));
|
5677 |
// jButtonPan.setToolTipText(PluginServices.getText(this, "Desplazamiento"));
|
5678 |
// jButtonPan.addMouseListener(new MouseAdapter() {
|
5679 |
// /*
|
5680 |
// * (non-Javadoc)
|
5681 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
5682 |
// */
|
5683 |
// public void mouseClicked(MouseEvent e) {
|
5684 |
// getSelectableMapAreaPanel().setTool(PAN_TOOL);
|
5685 |
// }
|
5686 |
// });
|
5687 |
// }
|
5688 |
// return jButtonPan;
|
5689 |
// }
|
5690 |
//
|
5691 |
// /**
|
5692 |
// * This method initializes jComboBoxZoomInAndOut
|
5693 |
// *
|
5694 |
// * @return A JComboBoxWithImageIconItems object reference
|
5695 |
// */
|
5696 |
// private JComboBoxWithImageIconItems getJComboBoxZoomInAndOut() {
|
5697 |
// if (jComboBoxZoomInAndOut == null) {
|
5698 |
// jComboBoxZoomInAndOut = new JComboBoxWithImageIconItems();
|
5699 |
// jComboBoxZoomInAndOut.setBounds(DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE);
|
5700 |
// jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomIn.png",PluginServices.getIconTheme().get("view-zoom-in"),PluginServices.getText(this, "Zoom_Mas"), ZOOM_IN_TOOL));
|
5701 |
// jComboBoxZoomInAndOut.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-out"), PluginServices.getText(this, "Zoom_Menos"), ZOOM_OUT_TOOL));
|
5702 |
// jComboBoxZoomInAndOut.addActionListener(new ActionListener() {
|
5703 |
// /*
|
5704 |
// * (non-Javadoc)
|
5705 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
5706 |
// */
|
5707 |
// public void actionPerformed(ActionEvent e) {
|
5708 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
5709 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
5710 |
// getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
5711 |
// }
|
5712 |
// });
|
5713 |
// }
|
5714 |
//
|
5715 |
// return jComboBoxZoomInAndOut;
|
5716 |
// }
|
5717 |
//
|
5718 |
// /**
|
5719 |
// * This method initializes jButtonZoomPrevious
|
5720 |
// *
|
5721 |
// * @return javax.swing.JButton
|
5722 |
// */
|
5723 |
// private JButton getJButtonZoomPrevious() {
|
5724 |
// if (jButtonZoomPrevious == null) {
|
5725 |
// jButtonZoomPrevious = new JButton();
|
5726 |
// jButtonZoomPrevious.setBounds(DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE);
|
5727 |
// jButtonZoomPrevious.setIcon(PluginServices.getIconTheme().get("view-zoom-back"));
|
5728 |
// jButtonZoomPrevious.setToolTipText(PluginServices.getText(this, "Zoom_Previo"));
|
5729 |
// jButtonZoomPrevious.addMouseListener(new MouseAdapter() {
|
5730 |
// /*
|
5731 |
// * (non-Javadoc)
|
5732 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
5733 |
// */
|
5734 |
// public void mouseClicked(MouseEvent e) {
|
5735 |
// goToPreviousZoom();
|
5736 |
// }
|
5737 |
// });
|
5738 |
// }
|
5739 |
// return jButtonZoomPrevious;
|
5740 |
// }
|
5741 |
//
|
5742 |
// /**
|
5743 |
// * This method initializes jButtonZoomComplete
|
5744 |
// *
|
5745 |
// * @return javax.swing.JButton
|
5746 |
// */
|
5747 |
// private JButton getJButtonZoomComplete() {
|
5748 |
// if (jButtonZoomComplete == null) {
|
5749 |
// jButtonZoomComplete = new JButton();
|
5750 |
// jButtonZoomComplete.setBounds(DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE);
|
5751 |
// jButtonZoomComplete.setIcon(PluginServices.getIconTheme().get("view-zoom-map-contents"));
|
5752 |
// jButtonZoomComplete.setToolTipText(PluginServices.getText(this, "Zoom_Completo"));
|
5753 |
// jButtonZoomComplete.addMouseListener(new MouseAdapter() {
|
5754 |
// /*
|
5755 |
// * (non-Javadoc)
|
5756 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
5757 |
// */
|
5758 |
// public void mouseClicked(MouseEvent e) {
|
5759 |
// getSelectableMapAreaPanel().getViewPort().setExtent(getSelectableMapAreaPanel().getMapContext().getLayers().getFullExtent());
|
5760 |
// BaseView view =((BaseView)PluginServices.getMDIManager().getActiveWindow());
|
5761 |
// view.repaintMap();
|
5762 |
// }
|
5763 |
// });
|
5764 |
// }
|
5765 |
// return jButtonZoomComplete;
|
5766 |
// }
|
5767 |
//
|
5768 |
// /**
|
5769 |
// * This method initializes jComboBoxZoomInAndOut
|
5770 |
// *
|
5771 |
// * @return A JComboBoxWithImageIconItems object reference
|
5772 |
// */
|
5773 |
// private JComboBoxWithImageIconItems getJComboBoxZoomInAndOutViewCentered() {
|
5774 |
// if (jComboBoxZoomInAndOutViewCentered == null) {
|
5775 |
// jComboBoxZoomInAndOutViewCentered = new JComboBoxWithImageIconItems();
|
5776 |
// jComboBoxZoomInAndOutViewCentered.setBounds(DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE);
|
5777 |
// jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/zoommas.png",PluginServices.getIconTheme().get("view-zoom-mas"), PluginServices.getText(this, "Zoom_Acercar"), ZOOM_IN_VIEW_CENTERED_TOOL));
|
5778 |
// jComboBoxZoomInAndOutViewCentered.addImageIconItem(new ImageIconItemInfo("images/ZoomOut.png",PluginServices.getIconTheme().get("view-zoom-menos"), PluginServices.getText(this, "Zoom_Alejar"), ZOOM_OUT_VIEW_CENTERED_TOOL));
|
5779 |
// jComboBoxZoomInAndOutViewCentered.addActionListener(new ActionListener() {
|
5780 |
// /*
|
5781 |
// * (non-Javadoc)
|
5782 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
5783 |
// */
|
5784 |
// public void actionPerformed(ActionEvent e) {
|
5785 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
5786 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
5787 |
//
|
5788 |
// if (((String)iiii.getItemValue()).compareTo(ZOOM_IN_VIEW_CENTERED_TOOL) == 0) {
|
5789 |
// getSelectableMapAreaPanel().zoomIn();
|
5790 |
// }
|
5791 |
// else {
|
5792 |
// getSelectableMapAreaPanel().zoomOut();
|
5793 |
// }
|
5794 |
// }
|
5795 |
// });
|
5796 |
// }
|
5797 |
// return jComboBoxZoomInAndOutViewCentered;
|
5798 |
// }
|
5799 |
//
|
5800 |
// /**
|
5801 |
// * This method initializes jComboBoxOtherTools
|
5802 |
// *
|
5803 |
// * @return A JComboBoxWithImageIconItems object reference
|
5804 |
// */
|
5805 |
// private JComboBoxWithImageIconItems getJComboBoxOtherTools() {
|
5806 |
// if (jComboBoxOtherTools == null) {
|
5807 |
// jComboBoxOtherTools = new JComboBoxWithImageIconItems();
|
5808 |
// jComboBoxOtherTools.setBounds(DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE);
|
5809 |
// jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Distancia.png",PluginServices.getIconTheme().get("view-query-distance"),PluginServices.getText(this, "medir_distancias"), MEASURE_DISTANCES_TOOL));
|
5810 |
// jComboBoxOtherTools.addImageIconItem(new ImageIconItemInfo("images/Poligono16.png",PluginServices.getIconTheme().get("view-query-area"), PluginServices.getText(this, "medir_area"), MEASURE_AREA_TOOL));
|
5811 |
// jComboBoxOtherTools.addActionListener(new ActionListener() {
|
5812 |
// /*
|
5813 |
// * (non-Javadoc)
|
5814 |
// * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
5815 |
// */
|
5816 |
// public void actionPerformed(ActionEvent e) {
|
5817 |
// JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
|
5818 |
// ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
|
5819 |
// getSelectableMapAreaPanel().setTool((String)iiii.getItemValue());
|
5820 |
// }
|
5821 |
// });
|
5822 |
// }
|
5823 |
//
|
5824 |
// return jComboBoxOtherTools;
|
5825 |
// }
|
5826 |
//
|
5827 |
// /**
|
5828 |
// * Goes to previous zoom
|
5829 |
// */
|
5830 |
// private void goToPreviousZoom() {
|
5831 |
// // Gets the view port and sets its previous extent
|
5832 |
// ViewPort vp = getSelectableMapAreaPanel().getMapContext().getViewPort();
|
5833 |
//
|
5834 |
// if (vp.getExtents().hasPrevious()) {
|
5835 |
// vp.setPreviousExtent();
|
5836 |
// getCoordinatesPanel().updateCoordinates(vp.getExtent());
|
5837 |
// }
|
5838 |
// }
|
5839 |
//
|
5840 |
// /**
|
5841 |
// * Sets the extent
|
5842 |
// *
|
5843 |
// * @param java.awt.geom.Rectangle2D
|
5844 |
// */
|
5845 |
// public void setExtent(Rectangle2D extent) {
|
5846 |
// if (extent != null) {
|
5847 |
// // Update coordinates in text fields
|
5848 |
// getCoordinatesPanel().updateCoordinates(extent);
|
5849 |
//
|
5850 |
// // If there is any layer loaded in the MapControl -> set the extent
|
5851 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
|
5852 |
// getSelectableMapAreaPanel().getMapContext().getViewPort().setExtent(extent);
|
5853 |
// }
|
5854 |
// }
|
5855 |
// }
|
5856 |
//
|
5857 |
// /**
|
5858 |
// * Gets the extent: a 'Rectangle2D.Double' object reference or 'null' if there is no data or if the data is invalid or user hasn't defined an area
|
5859 |
// *
|
5860 |
// * @return java.awt.geom.Rectangle2D or null if the data is invalid
|
5861 |
// */
|
5862 |
// public Rectangle2D getExtent() {
|
5863 |
// if (!hasUserDefinedAnArea)
|
5864 |
// return null;
|
5865 |
//
|
5866 |
// if (getCoordinatesPanel().areAllCoordinatesUndefined()) {
|
5867 |
// return null; // Return null if there is no coordinate
|
5868 |
// }
|
5869 |
// else {
|
5870 |
// if (getCoordinatesPanel().validVertexes()) {
|
5871 |
// return getCoordinatesPanel().getExtent();
|
5872 |
// }
|
5873 |
// else {
|
5874 |
// return null; // Returns null if coordinates aren't valid
|
5875 |
// }
|
5876 |
// }
|
5877 |
// }
|
5878 |
//
|
5879 |
// /**
|
5880 |
// * Set parent's 'Applicable' button enable or disable according the value of the parameter
|
5881 |
// *
|
5882 |
// * @param b A boolean value
|
5883 |
// */
|
5884 |
// private void setApplicable(boolean b) {
|
5885 |
// if (!parent.getWFSFilterPanelIsAsTabForWFSLayersLoad())
|
5886 |
// parent.isApplicable(true);
|
5887 |
// }
|
5888 |
//
|
5889 |
// /**
|
5890 |
// * If there is some coordinate text field that has text, returns true; else returns false
|
5891 |
// *
|
5892 |
// * @return A boolean value
|
5893 |
// */
|
5894 |
// public boolean areThereSomeCoordinatesWritten() {
|
5895 |
// return getCoordinatesPanel().areThereSomeCoordinatesWritten();
|
5896 |
// }
|
5897 |
//
|
5898 |
// /**
|
5899 |
// * If there is some coordinate text field that isn't undefined, returns true; else returns false
|
5900 |
// *
|
5901 |
// * @return A boolean value
|
5902 |
// */
|
5903 |
// public boolean areThereSomeCoordinatesUndefined() {
|
5904 |
// return getCoordinatesPanel().isThereAnyCoordinateUndefined();
|
5905 |
// }
|
5906 |
//
|
5907 |
// /**
|
5908 |
// * If user has or hasn't defined an area
|
5909 |
// *
|
5910 |
// * @return A boolean value
|
5911 |
// */
|
5912 |
// public boolean hasUserDefinedAnArea() {
|
5913 |
// return hasUserDefinedAnArea;
|
5914 |
// }
|
5915 |
//
|
5916 |
// /**
|
5917 |
// * Restores the inner attribute 'hasUserDefinedAnArea' to its default value (false)
|
5918 |
// */
|
5919 |
// public void setUserHasntDefineAnArea() {
|
5920 |
// hasUserDefinedAnArea = false;
|
5921 |
// }
|
5922 |
//
|
5923 |
// /**
|
5924 |
// * Updates the current area information with the area of the active view
|
5925 |
// */
|
5926 |
// public void updateWFSArea() {
|
5927 |
// this.getSelectableMapAreaPanel().disableAllMouseListeners();
|
5928 |
//
|
5929 |
// // To prevent that events that take place (are produced) could be a nuisance to the load of the layers
|
5930 |
// this.getSelectableMapAreaPanel().getMapContext().beginAtomicEvent();
|
5931 |
//
|
5932 |
// try {
|
5933 |
// MapContext mapContext = this.getSelectableMapAreaPanel().getMapContext();
|
5934 |
//
|
5935 |
// // Removes all layers in the view area
|
5936 |
// int numberOfLayers = mapContext.getLayers().getLayersCount();
|
5937 |
// int i;
|
5938 |
//
|
5939 |
// for (i = (numberOfLayers-1); i >= 0; i--) {
|
5940 |
// mapContext.getLayers().removeLayer(i);
|
5941 |
// }
|
5942 |
//
|
5943 |
// // Adds the extent of the viewport of the current active view
|
5944 |
// BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
5945 |
// ViewPort vP = view.getMapControl().getMapContext().getViewPort();
|
5946 |
//
|
5947 |
// // Update extent
|
5948 |
// Rectangle2D r2D = vP.getExtent();
|
5949 |
//
|
5950 |
// if (r2D == null) {
|
5951 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
5952 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
5953 |
//
|
5954 |
// // No tools enabled
|
5955 |
// getJComboBoxToolSelection().setSelectedIndex(0);
|
5956 |
//
|
5957 |
// return;
|
5958 |
// }
|
5959 |
//
|
5960 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
5961 |
// mapContext.getViewPort().setExtent(r2D);
|
5962 |
//
|
5963 |
// // Adds the active layers of the current active view
|
5964 |
// MapContext mC = view.getMapControl().getMapContext();
|
5965 |
//
|
5966 |
// numberOfLayers = mC.getLayers().getLayersCount();
|
5967 |
//
|
5968 |
// for (i = (numberOfLayers-1); i >= 0; i--) {
|
5969 |
// mapContext.getLayers().addLayer(mC.getLayers().getLayer(i).cloneLayer());
|
5970 |
// }
|
5971 |
//
|
5972 |
// // If has to enable all listeners of all tools on the view area
|
5973 |
// if (((ItemOperation)this.getJComboBoxToolSelection().getSelectedItem()).getOperation() == SELECTION_BY_AREA_OPERATION)
|
5974 |
// this.getSelectableMapAreaPanel().enableAllMouseListeners();
|
5975 |
//
|
5976 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
5977 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
5978 |
//
|
5979 |
// // Refresh the view
|
5980 |
// this.getSelectableMapAreaPanel().getViewPort().refreshExtent();
|
5981 |
// } catch (Exception e) {
|
5982 |
// e.printStackTrace();
|
5983 |
//
|
5984 |
// // End To prevent that events that take place(are produced) could be a nuisance to the load of the layers
|
5985 |
// this.getSelectableMapAreaPanel().getMapContext().endAtomicEvent();
|
5986 |
//
|
5987 |
// // No tools enabled
|
5988 |
// getJComboBoxToolSelection().setSelectedIndex(0);
|
5989 |
// return;
|
5990 |
// }
|
5991 |
// }
|
5992 |
//
|
5993 |
// /**
|
5994 |
// * Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
|
5995 |
// *
|
5996 |
// * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
5997 |
// */
|
5998 |
// private class ItemOperation {
|
5999 |
// String _name;
|
6000 |
// int _operation;
|
6001 |
//
|
6002 |
// /**
|
6003 |
// * Default constructor with two parameters
|
6004 |
// *
|
6005 |
// * @param name Name of the operation
|
6006 |
// * @param operation A code that identifies the operation
|
6007 |
// */
|
6008 |
// public ItemOperation(String name, int operation) {
|
6009 |
// _name = new String(name);
|
6010 |
// _operation = operation;
|
6011 |
// }
|
6012 |
//
|
6013 |
// /**
|
6014 |
// * Returns the name of the operation
|
6015 |
// *
|
6016 |
// * @return An String
|
6017 |
// */
|
6018 |
// public String getName() {
|
6019 |
// return _name;
|
6020 |
// }
|
6021 |
//
|
6022 |
// /**
|
6023 |
// * Returns the code that identifies the operation
|
6024 |
// *
|
6025 |
// * @return An integer value
|
6026 |
// */
|
6027 |
// public int getOperation() {
|
6028 |
// return _operation;
|
6029 |
// }
|
6030 |
//
|
6031 |
// /**
|
6032 |
// * The name of the operation that will use JComboBox
|
6033 |
// */
|
6034 |
// public String toString() {
|
6035 |
// return _name;
|
6036 |
// }
|
6037 |
// }
|
6038 |
//
|
6039 |
// /**
|
6040 |
// * This class is a panel width four fields for indicate the coordinates of two points:
|
6041 |
// * One for the ritgh-up point and another for the left-down point of a rectangle area
|
6042 |
// *
|
6043 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
6044 |
// * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
6045 |
// */
|
6046 |
// private class AreaCoordinatesPanel extends JPanel {
|
6047 |
// private final Rectangle DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 62, 51); // @jve:decl-index=0:
|
6048 |
// private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20;
|
6049 |
// private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20;
|
6050 |
// private final int DEFAULT_TEXT_FIELDS_WIDTH = 132;
|
6051 |
// private final int DEFAULT_X_LOCATION = 8;
|
6052 |
// private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6;
|
6053 |
// private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10;
|
6054 |
// private final int DEFAULT_COORDINATE_HEIGHT = 25;
|
6055 |
// private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT); // @jve:decl-index=0:
|
6056 |
// private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ;
|
6057 |
//
|
6058 |
// private final String JTEXTFIELD_V1X_NAME = "V1X";
|
6059 |
// private final String JTEXTFIELD_V1Y_NAME = "V1Y";
|
6060 |
// private final String JTEXTFIELD_V2X_NAME = "V2X";
|
6061 |
// private final String JTEXTFIELD_V2Y_NAME = "V2Y";
|
6062 |
//
|
6063 |
// private final short JTEXTFIELD_V1X = 1;
|
6064 |
// private final short JTEXTFIELD_V1Y = 2;
|
6065 |
// private final short JTEXTFIELD_V2X = 3;
|
6066 |
// private final short JTEXTFIELD_V2Y = 4;
|
6067 |
//
|
6068 |
// private JPanel jPanelVertex1 = null;
|
6069 |
// private JPanel jPanelVertex2 = null;
|
6070 |
// private JPanel jPanelVertex1X = null;
|
6071 |
// private JPanel jPanelVertex1Y = null;
|
6072 |
// private JPanel jPanelVertex2X = null;
|
6073 |
// private JPanel jPanelVertex2Y = null;
|
6074 |
//
|
6075 |
// private JLabel jLabelVertex1 = null;
|
6076 |
// private JLabel jLabelVertex2 = null;
|
6077 |
// private JLabel jLabelVertex1X = null;
|
6078 |
// private JLabel jLabelVertex1Y = null;
|
6079 |
// private JLabel jLabelVertex2X = null;
|
6080 |
// private JLabel jLabelVertex2Y = null;
|
6081 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex1X = null;
|
6082 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex1Y = null;
|
6083 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex2X = null;
|
6084 |
// private JTextFieldWithSpecificCaretPosition jTextFieldVertex2Y = null;
|
6085 |
// private JButton jButtonPreviewArea = null;
|
6086 |
// private String last_Coordinates[];
|
6087 |
// private boolean hasChanged_v1X;
|
6088 |
// private boolean hasChanged_v1Y;
|
6089 |
// private boolean hasChanged_v2X;
|
6090 |
// private boolean hasChanged_v2Y;
|
6091 |
// private String previous_Coordinate_Value[];
|
6092 |
//
|
6093 |
// private short current_coordinate_with_focus;
|
6094 |
//
|
6095 |
// private FocusListener focusListenerForCoordinateValidation = null;
|
6096 |
// private KeyListener keyListenerForCoordinateValidation = null;
|
6097 |
//
|
6098 |
// /**
|
6099 |
// * This is the default constructor
|
6100 |
// */
|
6101 |
// public AreaCoordinatesPanel() {
|
6102 |
// super();
|
6103 |
// initialize();
|
6104 |
// }
|
6105 |
//
|
6106 |
// /**
|
6107 |
// * This method initializes this
|
6108 |
// *
|
6109 |
// * @return void
|
6110 |
// */
|
6111 |
// private void initialize() {
|
6112 |
// this.setLayout(null);
|
6113 |
// this.setBounds(DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE);
|
6114 |
// this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
|
6115 |
// this.setToolTipText(PluginServices.getText(this, "select_by_vertexes_coordinates"));
|
6116 |
//
|
6117 |
// this.last_Coordinates = new String[4];
|
6118 |
// this.last_Coordinates[0] = "";
|
6119 |
// this.last_Coordinates[1] = "";
|
6120 |
// this.last_Coordinates[2] = "";
|
6121 |
// this.last_Coordinates[3] = "";
|
6122 |
// this.previous_Coordinate_Value = new String[4];
|
6123 |
//
|
6124 |
// // By default no coordinates have changed
|
6125 |
// this.resetCoordinatesFlags();
|
6126 |
//
|
6127 |
// this.add(getJPanelVertex1());
|
6128 |
// this.add(getJPanelVertex2());
|
6129 |
// this.add(getJButtonPreviewArea());
|
6130 |
// }
|
6131 |
//
|
6132 |
// /**
|
6133 |
// * Returns the default width of this component
|
6134 |
// *
|
6135 |
// * @return The default width
|
6136 |
// */
|
6137 |
// public int getDefaultWidth() {
|
6138 |
// return DEFAULT_COORDINATE_WIDTH * 2;
|
6139 |
// }
|
6140 |
//
|
6141 |
// /**
|
6142 |
// * Returns the default height of this component
|
6143 |
// *
|
6144 |
// * @return The default height
|
6145 |
// */
|
6146 |
// public int getDefaultHeight() {
|
6147 |
// return DEFAULT_COORDINATE_HEIGHT * 2;
|
6148 |
// }
|
6149 |
//
|
6150 |
// /**
|
6151 |
// * Sets all flags about if a coordinate has change to false (haven't changed)
|
6152 |
// */
|
6153 |
// private void resetCoordinatesFlags() {
|
6154 |
// hasChanged_v1X = false;
|
6155 |
// hasChanged_v1Y = false;
|
6156 |
// hasChanged_v2X = false;
|
6157 |
// hasChanged_v2Y = false;
|
6158 |
// }
|
6159 |
//
|
6160 |
// /**last_Coordinated_that_Changed
|
6161 |
// * This method initializes jPanelVertex1
|
6162 |
// *
|
6163 |
// * @return javax.swing.JPanel
|
6164 |
// */
|
6165 |
// private JPanel getJPanelVertex1() {
|
6166 |
// if (jPanelVertex1 == null) {
|
6167 |
// jPanelVertex1 = new JPanel();
|
6168 |
// jPanelVertex1.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
|
6169 |
// jPanelVertex1.setLayout(new GridBagLayout());
|
6170 |
// jPanelVertex1.add(getJLabelVertex1(), null);
|
6171 |
// jPanelVertex1.add(getJPanelVertex1X(), null);
|
6172 |
// jPanelVertex1.add(getJPanelVertex1Y(), null);
|
6173 |
// }
|
6174 |
//
|
6175 |
// return jPanelVertex1;
|
6176 |
// }
|
6177 |
//
|
6178 |
// /**
|
6179 |
// * This method initializes jPanelVertex2
|
6180 |
// *
|
6181 |
// * @return javax.swing.JPanel
|
6182 |
// */
|
6183 |
// private JPanel getJPanelVertex2() {
|
6184 |
// if (jPanelVertex2 == null) {
|
6185 |
// jPanelVertex2 = new JPanel();
|
6186 |
// jPanelVertex2.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION + DEFAULT_COORDINATE_HEIGHT, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
|
6187 |
// jPanelVertex2.setLayout(new GridBagLayout());
|
6188 |
// jPanelVertex2.add(getJLabelVertex2(), null);
|
6189 |
// jPanelVertex2.add(getJPanelVertex2X(), null);
|
6190 |
// jPanelVertex2.add(getJPanelVertex2Y(), null);
|
6191 |
// }
|
6192 |
//
|
6193 |
// return jPanelVertex2;
|
6194 |
// }
|
6195 |
//
|
6196 |
// /**
|
6197 |
// * This method initializes jLabelVertex1
|
6198 |
// *
|
6199 |
// * @return javax.swing.JPanel
|
6200 |
// */
|
6201 |
// private JLabel getJLabelVertex1() {
|
6202 |
// if (jLabelVertex1 == null) {
|
6203 |
// jLabelVertex1 = new JLabel();
|
6204 |
// jLabelVertex1.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
|
6205 |
// jLabelVertex1.setToolTipText(PluginServices.getText(this, "coordinates_from_area_right_up_vertex"));
|
6206 |
// jLabelVertex1.setText(PluginServices.getText(this, "vertex") + " 1:");
|
6207 |
// jLabelVertex1.setHorizontalAlignment(SwingConstants.LEFT);
|
6208 |
// jLabelVertex1.setVerticalAlignment(SwingConstants.CENTER);
|
6209 |
// jLabelVertex1.setForeground(new Color(0, 0, 255)); // Blue color for text
|
6210 |
// }
|
6211 |
// return jLabelVertex1;
|
6212 |
// }
|
6213 |
//
|
6214 |
// /**
|
6215 |
// * This method initializes jLabelVertex2
|
6216 |
// *
|
6217 |
// * @return javax.swing.JPanel
|
6218 |
// */
|
6219 |
// private JLabel getJLabelVertex2() {
|
6220 |
// if (jLabelVertex2 == null) {
|
6221 |
// jLabelVertex2 = new JLabel();
|
6222 |
// jLabelVertex2.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
|
6223 |
// jLabelVertex2.setToolTipText(PluginServices.getText(this, "coordinates_from_area_left_bottom_vertex"));
|
6224 |
// jLabelVertex2.setText(PluginServices.getText(this, "vertex") + " 2:");
|
6225 |
// jLabelVertex2.setHorizontalAlignment(SwingConstants.LEFT);
|
6226 |
// jLabelVertex2.setVerticalAlignment(SwingConstants.CENTER);
|
6227 |
// jLabelVertex2.setForeground(new Color(128, 64, 0)); // Brown color for text
|
6228 |
// }
|
6229 |
// return jLabelVertex2;
|
6230 |
// }
|
6231 |
//
|
6232 |
// /**
|
6233 |
// * This method initializes jPanelVertex1X
|
6234 |
// *
|
6235 |
// * @return javax.swing.JPanel
|
6236 |
// */
|
6237 |
// private JPanel getJPanelVertex1X() {
|
6238 |
// if (jPanelVertex1X == null) {
|
6239 |
// jPanelVertex1X = new JPanel();
|
6240 |
// jPanelVertex1X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
6241 |
// jPanelVertex1X.setLayout(new GridBagLayout());
|
6242 |
// jPanelVertex1X.add(getJLabelVertex1X(), null);
|
6243 |
// jPanelVertex1X.add(getJTextFieldVertex1X(), null);
|
6244 |
// }
|
6245 |
//
|
6246 |
// return jPanelVertex1X;
|
6247 |
// }
|
6248 |
//
|
6249 |
// /**
|
6250 |
// * This method initializes jPanelVertex1Y
|
6251 |
// *
|
6252 |
// * @return javax.swing.JPanel
|
6253 |
// */
|
6254 |
// private JPanel getJPanelVertex1Y() {
|
6255 |
// if (jPanelVertex1Y == null) {
|
6256 |
// jPanelVertex1Y = new JPanel();
|
6257 |
// jPanelVertex1Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
6258 |
// jPanelVertex1Y.setLayout(new GridBagLayout());
|
6259 |
// jPanelVertex1Y.add(getJLabelVertex1Y(), null);
|
6260 |
// jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
|
6261 |
// }
|
6262 |
//
|
6263 |
// return jPanelVertex1Y;
|
6264 |
// }
|
6265 |
//
|
6266 |
// /**
|
6267 |
// * This method initializes jPanelVertex2X
|
6268 |
// *
|
6269 |
// * @return javax.swing.JPanel
|
6270 |
// */
|
6271 |
// private JPanel getJPanelVertex2X() {
|
6272 |
// if (jPanelVertex2X == null) {
|
6273 |
// jPanelVertex2X = new JPanel();
|
6274 |
// jPanelVertex2X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
6275 |
// jPanelVertex2X.setLayout(new GridBagLayout());
|
6276 |
// jPanelVertex2X.add(getJLabelVertex2X(), null);
|
6277 |
// jPanelVertex2X.add(getJTextFieldVertex2X(), null);
|
6278 |
// }
|
6279 |
//
|
6280 |
// return jPanelVertex2X;
|
6281 |
// }
|
6282 |
//
|
6283 |
// /**
|
6284 |
// * This method initializes jPanelVertex2Y
|
6285 |
// *
|
6286 |
// * @return javax.swing.JPanel
|
6287 |
// */
|
6288 |
// private JPanel getJPanelVertex2Y() {
|
6289 |
// if (jPanelVertex2Y == null) {
|
6290 |
// jPanelVertex2Y = new JPanel();
|
6291 |
// jPanelVertex2Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
|
6292 |
// jPanelVertex2Y.setLayout(new GridBagLayout());
|
6293 |
// jPanelVertex2Y.add(getJLabelVertex2Y(), null);
|
6294 |
// jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
|
6295 |
// }
|
6296 |
//
|
6297 |
// return jPanelVertex2Y;
|
6298 |
// }
|
6299 |
//
|
6300 |
// /**
|
6301 |
// * This method initializes jLabelVertex1X
|
6302 |
// *
|
6303 |
// * @return javax.swing.JLabel
|
6304 |
// */
|
6305 |
// private JLabel getJLabelVertex1X() {
|
6306 |
// if (jLabelVertex1X == null) {
|
6307 |
// jLabelVertex1X = new JLabel();
|
6308 |
// jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6309 |
// jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex"));
|
6310 |
// jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":");
|
6311 |
// jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
|
6312 |
// jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
|
6313 |
// jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text
|
6314 |
// }
|
6315 |
//
|
6316 |
// return jLabelVertex1X;
|
6317 |
// }
|
6318 |
//
|
6319 |
// /**
|
6320 |
// * This method initializes jLabelVertex2X
|
6321 |
// *
|
6322 |
// * @return javax.swing.JLabel
|
6323 |
// */
|
6324 |
// private JLabel getJLabelVertex2X() {
|
6325 |
// if (jLabelVertex2X == null) {
|
6326 |
// jLabelVertex2X = new JLabel();
|
6327 |
// jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6328 |
// jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex"));
|
6329 |
// jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":");
|
6330 |
// jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
|
6331 |
// jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
|
6332 |
// jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text
|
6333 |
// }
|
6334 |
//
|
6335 |
// return jLabelVertex2X;
|
6336 |
// }
|
6337 |
//
|
6338 |
// /**
|
6339 |
// * This method initializes jLabelVertex1Y
|
6340 |
// *
|
6341 |
// * @return javax.swing.JLabel
|
6342 |
// */
|
6343 |
// private JLabel getJLabelVertex1Y() {
|
6344 |
// if (jLabelVertex1Y == null) {
|
6345 |
// jLabelVertex1Y = new JLabel();
|
6346 |
// jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6347 |
// jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex"));
|
6348 |
// jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":");
|
6349 |
// jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
|
6350 |
// jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
|
6351 |
// jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text
|
6352 |
// }
|
6353 |
//
|
6354 |
// return jLabelVertex1Y;
|
6355 |
// }
|
6356 |
//
|
6357 |
// /**
|
6358 |
// * This method initializes jLabelVertex2Y
|
6359 |
// *
|
6360 |
// * @return javax.swing.JLabel
|
6361 |
// */
|
6362 |
// private JLabel getJLabelVertex2Y() {
|
6363 |
// if (jLabelVertex2Y == null) {
|
6364 |
// jLabelVertex2Y = new JLabel();
|
6365 |
// jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6366 |
// jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
|
6367 |
// jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":");
|
6368 |
// jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
|
6369 |
// jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
|
6370 |
// jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text
|
6371 |
// }
|
6372 |
//
|
6373 |
// return jLabelVertex2Y;
|
6374 |
// }
|
6375 |
//
|
6376 |
// /**
|
6377 |
// * Returns a focus listener for validate the text of a JTextField when that component loses its focus
|
6378 |
// *
|
6379 |
// * @return java.awt.event.FocusListener
|
6380 |
// */
|
6381 |
// private FocusListener getFocusListenerForCoordinateValidation() {
|
6382 |
// if (focusListenerForCoordinateValidation == null) {
|
6383 |
// focusListenerForCoordinateValidation = new FocusListener() {
|
6384 |
//
|
6385 |
// /*
|
6386 |
// * (non-Javadoc)
|
6387 |
// * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
6388 |
// */
|
6389 |
// public void focusGained(FocusEvent e) {
|
6390 |
// JTextField jTF = (JTextField)e.getSource();
|
6391 |
//
|
6392 |
// // Stores which coordinate has gotten the focus
|
6393 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) {
|
6394 |
// current_coordinate_with_focus = JTEXTFIELD_V1X;
|
6395 |
//
|
6396 |
// return;
|
6397 |
// }
|
6398 |
//
|
6399 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) {
|
6400 |
// current_coordinate_with_focus = JTEXTFIELD_V1Y;
|
6401 |
//
|
6402 |
// return;
|
6403 |
// }
|
6404 |
//
|
6405 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) {
|
6406 |
// current_coordinate_with_focus = JTEXTFIELD_V2X;
|
6407 |
//
|
6408 |
// return;
|
6409 |
// }
|
6410 |
//
|
6411 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) {
|
6412 |
// current_coordinate_with_focus = JTEXTFIELD_V2Y;
|
6413 |
//
|
6414 |
// return;
|
6415 |
// }
|
6416 |
//
|
6417 |
// }
|
6418 |
//
|
6419 |
// /*
|
6420 |
// * (non-Javadoc)
|
6421 |
// * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
|
6422 |
// */
|
6423 |
// public void focusLost(FocusEvent e) {
|
6424 |
// JTextField jTF = (JTextField)e.getSource();
|
6425 |
//
|
6426 |
// // If a coordinate has lost focus, is valid and has changed -> store the new value and set its related 'hasChanged' flag to true
|
6427 |
// String text = jTF.getText();
|
6428 |
//
|
6429 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1X_NAME) == 0) {
|
6430 |
//
|
6431 |
// if (text.compareTo(last_Coordinates[0]) != 0) {
|
6432 |
// hasChanged_v1X = true;
|
6433 |
//
|
6434 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
6435 |
// hasUserDefinedAnArea = true;
|
6436 |
// }
|
6437 |
// }
|
6438 |
//
|
6439 |
// return;
|
6440 |
// }
|
6441 |
//
|
6442 |
// if (jTF.getName().compareTo(JTEXTFIELD_V1Y_NAME) == 0) {
|
6443 |
// if (text.compareTo(last_Coordinates[1]) != 0) {
|
6444 |
// hasChanged_v1Y = true;
|
6445 |
//
|
6446 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
6447 |
// hasUserDefinedAnArea = true;
|
6448 |
// }
|
6449 |
// }
|
6450 |
//
|
6451 |
// return;
|
6452 |
// }
|
6453 |
//
|
6454 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) {
|
6455 |
// if (text.compareTo(last_Coordinates[2]) != 0) {
|
6456 |
// hasChanged_v2X = true;
|
6457 |
//
|
6458 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
6459 |
// hasUserDefinedAnArea = true;
|
6460 |
// }
|
6461 |
// }
|
6462 |
//
|
6463 |
// return;
|
6464 |
// }
|
6465 |
//
|
6466 |
// if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) {
|
6467 |
// if (text.compareTo(last_Coordinates[3]) != 0) {
|
6468 |
// hasChanged_v2Y = true;
|
6469 |
//
|
6470 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
6471 |
// hasUserDefinedAnArea = true;
|
6472 |
// }
|
6473 |
// }
|
6474 |
//
|
6475 |
// return;
|
6476 |
// }
|
6477 |
// }
|
6478 |
// };
|
6479 |
// }
|
6480 |
//
|
6481 |
// return focusListenerForCoordinateValidation;
|
6482 |
// }
|
6483 |
//
|
6484 |
// private KeyListener getKeyListenerForCoordinateValidation() {
|
6485 |
// if (keyListenerForCoordinateValidation == null) {
|
6486 |
// keyListenerForCoordinateValidation = new KeyListener() {
|
6487 |
//
|
6488 |
// public void keyPressed(KeyEvent e) {
|
6489 |
// }
|
6490 |
//
|
6491 |
// public void keyReleased(KeyEvent e) {
|
6492 |
// validateCoordinate(current_coordinate_with_focus);
|
6493 |
// }
|
6494 |
//
|
6495 |
// public void keyTyped(KeyEvent e) {
|
6496 |
// }
|
6497 |
// };
|
6498 |
// }
|
6499 |
//
|
6500 |
// return keyListenerForCoordinateValidation;
|
6501 |
// }
|
6502 |
//
|
6503 |
// /**
|
6504 |
// * This method initializes jTextFieldVertex1X
|
6505 |
// *
|
6506 |
// * @return JTextFieldWithSpecificCaretPosition
|
6507 |
// */
|
6508 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1X() {
|
6509 |
// if (jTextFieldVertex1X == null) {
|
6510 |
// jTextFieldVertex1X = new JTextFieldWithSpecificCaretPosition("");
|
6511 |
// jTextFieldVertex1X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6512 |
// jTextFieldVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex"));
|
6513 |
// jTextFieldVertex1X.addFocusListener(getFocusListenerForCoordinateValidation());
|
6514 |
// jTextFieldVertex1X.addKeyListener(getKeyListenerForCoordinateValidation());
|
6515 |
// jTextFieldVertex1X.setName(JTEXTFIELD_V1X_NAME);
|
6516 |
// }
|
6517 |
// return jTextFieldVertex1X;
|
6518 |
// }
|
6519 |
//
|
6520 |
// /**
|
6521 |
// * This method initializes jTextFieldVertex1Y
|
6522 |
// *
|
6523 |
// * @return JTextFieldWithSpecificCaretPosition
|
6524 |
// */
|
6525 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1Y() {
|
6526 |
// if (jTextFieldVertex1Y == null) {
|
6527 |
// jTextFieldVertex1Y = new JTextFieldWithSpecificCaretPosition("");
|
6528 |
// jTextFieldVertex1Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6529 |
// jTextFieldVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex"));
|
6530 |
// jTextFieldVertex1Y.addFocusListener(getFocusListenerForCoordinateValidation());
|
6531 |
// jTextFieldVertex1Y.addKeyListener(getKeyListenerForCoordinateValidation());
|
6532 |
// jTextFieldVertex1Y.setName(JTEXTFIELD_V1Y_NAME);
|
6533 |
// }
|
6534 |
// return jTextFieldVertex1Y;
|
6535 |
// }
|
6536 |
//
|
6537 |
// /**
|
6538 |
// * This method initializes jTextFieldVertex2X
|
6539 |
// *
|
6540 |
// * @return JTextFieldWithSpecificCaretPosition
|
6541 |
// */
|
6542 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2X() {
|
6543 |
// if (jTextFieldVertex2X == null) {
|
6544 |
// jTextFieldVertex2X = new JTextFieldWithSpecificCaretPosition("");
|
6545 |
// jTextFieldVertex2X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6546 |
// jTextFieldVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex"));
|
6547 |
// jTextFieldVertex2X.addFocusListener(getFocusListenerForCoordinateValidation());
|
6548 |
// jTextFieldVertex2X.addKeyListener(getKeyListenerForCoordinateValidation());
|
6549 |
// jTextFieldVertex2X.setName(JTEXTFIELD_V2X_NAME);
|
6550 |
// }
|
6551 |
// return jTextFieldVertex2X;
|
6552 |
// }
|
6553 |
//
|
6554 |
// /**
|
6555 |
// * This method initializes jTextFieldVertex2Y
|
6556 |
// *
|
6557 |
// * @return JTextFieldWithSpecificCaretPosition
|
6558 |
// */
|
6559 |
// private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2Y() {
|
6560 |
// if (jTextFieldVertex2Y == null) {
|
6561 |
// jTextFieldVertex2Y = new JTextFieldWithSpecificCaretPosition("");
|
6562 |
// jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
|
6563 |
// jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
|
6564 |
// jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation());
|
6565 |
// jTextFieldVertex2Y.addKeyListener(getKeyListenerForCoordinateValidation());
|
6566 |
// jTextFieldVertex2Y.setName(JTEXTFIELD_V2Y_NAME);
|
6567 |
// }
|
6568 |
// return jTextFieldVertex2Y;
|
6569 |
// }
|
6570 |
//
|
6571 |
// /**
|
6572 |
// * Retuns the double value of the text field V1X
|
6573 |
// *
|
6574 |
// * @return A double number type
|
6575 |
// */
|
6576 |
// public double getDoubleValueOfJTextFieldV1X() {
|
6577 |
// return Double.parseDouble(getJTextFieldVertex1X().getText());
|
6578 |
// }
|
6579 |
//
|
6580 |
// /**
|
6581 |
// * Retuns the double value of the text field V1Y
|
6582 |
// *
|
6583 |
// * @return A double number type
|
6584 |
// */
|
6585 |
// public double getDoubleValueOfJTextFieldV1Y() {
|
6586 |
// return Double.parseDouble(getJTextFieldVertex1Y().getText());
|
6587 |
// }
|
6588 |
//
|
6589 |
// /**
|
6590 |
// * Retuns the double value of the text field V2X
|
6591 |
// *
|
6592 |
// * @return A double number type
|
6593 |
// */
|
6594 |
// public double getDoubleValueOfJTextFieldV2X() {
|
6595 |
// return Double.parseDouble(getJTextFieldVertex2X().getText());
|
6596 |
// }
|
6597 |
//
|
6598 |
// /**
|
6599 |
// * Retuns the double value of the text field V2Y
|
6600 |
// *
|
6601 |
// * @return A double number type
|
6602 |
// */
|
6603 |
// public double getDoubleValueOfJTextFieldV2Y() {
|
6604 |
// return Double.parseDouble(getJTextFieldVertex2Y().getText());
|
6605 |
// }
|
6606 |
//
|
6607 |
// /**
|
6608 |
// * Retuns the double value of the last text field V1X value
|
6609 |
// *
|
6610 |
// * @return A double number type
|
6611 |
// */
|
6612 |
// public double getDoubleValueOfLastJTextFieldV1XValue() {
|
6613 |
// return Double.parseDouble(last_Coordinates[0]);
|
6614 |
// }
|
6615 |
//
|
6616 |
// /**
|
6617 |
// * Retuns the double value of the last text field V1Y value
|
6618 |
// *
|
6619 |
// * @return A double number type
|
6620 |
// */
|
6621 |
// public double getDoubleValueOfLastJTextFieldV1YValue() {
|
6622 |
// return Double.parseDouble(last_Coordinates[1]);
|
6623 |
// }
|
6624 |
//
|
6625 |
// /**
|
6626 |
// * Retuns the double value of the last text field V2X value
|
6627 |
// *
|
6628 |
// * @return A double number type
|
6629 |
// */
|
6630 |
// public double getDoubleValueOfLastJTextFieldV2XValue() {
|
6631 |
// return Double.parseDouble(last_Coordinates[2]);
|
6632 |
// }
|
6633 |
//
|
6634 |
// /**
|
6635 |
// * Retuns the double value of the last text field V2Y value
|
6636 |
// *
|
6637 |
// * @return A double number type
|
6638 |
// */
|
6639 |
// public double getDoubleValueOfLastJTextFieldV2YValue() {
|
6640 |
// return Double.parseDouble(last_Coordinates[3]);
|
6641 |
// }
|
6642 |
//
|
6643 |
// /**
|
6644 |
// * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
6645 |
// *
|
6646 |
// * @param coordinate javax.swing.JTextField
|
6647 |
// * @return A boolean value
|
6648 |
// */
|
6649 |
// private boolean validateCoordinate(JTextField coordinate) {
|
6650 |
// if (coordinate != null) {
|
6651 |
// // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
6652 |
// if ((coordinate.getText().compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(coordinate.getText()))) {
|
6653 |
//// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
6654 |
//// switch (last_Coordinate_that_Loose_the_Focus) {
|
6655 |
//// case 1:
|
6656 |
//// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
6657 |
//// break;
|
6658 |
//// case 2:
|
6659 |
//// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
6660 |
//// break;
|
6661 |
//// case 3:
|
6662 |
//// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
6663 |
//// break;
|
6664 |
//// case 4:
|
6665 |
//// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
6666 |
//// break;
|
6667 |
//// default:
|
6668 |
//// // Do nothing
|
6669 |
//// }
|
6670 |
//
|
6671 |
// return false;
|
6672 |
// }
|
6673 |
// else {
|
6674 |
// return true;
|
6675 |
// }
|
6676 |
// }
|
6677 |
//
|
6678 |
// return false; // If coordinate is null
|
6679 |
// }
|
6680 |
//
|
6681 |
// /**
|
6682 |
// * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
|
6683 |
// *
|
6684 |
// * @param coordinate javax.swing.JTextField
|
6685 |
// * @return A boolean value
|
6686 |
// */
|
6687 |
// private boolean validateCoordinate(int coordinate_ID) {
|
6688 |
// JTextField coordinate = null;
|
6689 |
// String text;
|
6690 |
//
|
6691 |
// switch (coordinate_ID) {
|
6692 |
// case JTEXTFIELD_V1X:
|
6693 |
// coordinate = getJTextFieldVertex1X();
|
6694 |
// text = coordinate.getText();
|
6695 |
//
|
6696 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
6697 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
6698 |
// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
6699 |
// return false;
|
6700 |
// }
|
6701 |
// else {
|
6702 |
// previous_Coordinate_Value[0] = text;
|
6703 |
// return true;
|
6704 |
// }
|
6705 |
//
|
6706 |
//// break;
|
6707 |
// case JTEXTFIELD_V1Y:
|
6708 |
// coordinate = getJTextFieldVertex1Y();
|
6709 |
// text = coordinate.getText();
|
6710 |
//
|
6711 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
6712 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
6713 |
// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
6714 |
// return false;
|
6715 |
// }
|
6716 |
// else {
|
6717 |
// previous_Coordinate_Value[1] = text;
|
6718 |
// return true;
|
6719 |
// }
|
6720 |
//
|
6721 |
//// break;
|
6722 |
// case JTEXTFIELD_V2X:
|
6723 |
// coordinate = getJTextFieldVertex2X();
|
6724 |
// text = coordinate.getText();
|
6725 |
//
|
6726 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
6727 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
6728 |
// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
6729 |
// return false;
|
6730 |
// }
|
6731 |
// else {
|
6732 |
// previous_Coordinate_Value[2] = text;
|
6733 |
// return true;
|
6734 |
// }
|
6735 |
//
|
6736 |
//// break;
|
6737 |
// case JTEXTFIELD_V2Y:
|
6738 |
// coordinate = getJTextFieldVertex2Y();
|
6739 |
// text = coordinate.getText();
|
6740 |
//
|
6741 |
// if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
|
6742 |
// JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
|
6743 |
// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
6744 |
// return false;
|
6745 |
// }
|
6746 |
// else {
|
6747 |
// previous_Coordinate_Value[3] = text;
|
6748 |
// return true;
|
6749 |
// }
|
6750 |
//
|
6751 |
//// break;
|
6752 |
// default:
|
6753 |
// return true; // Avoid problems
|
6754 |
// }
|
6755 |
//
|
6756 |
//// if (coordinate != null) {
|
6757 |
//// // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
|
6758 |
//// switch (coordinate_ID) {
|
6759 |
//// case 1:
|
6760 |
//// coordinate.setText(previous_Coordinate_Value[0]); // Set last value
|
6761 |
//// break;
|
6762 |
//// case 2:
|
6763 |
//// coordinate.setText(previous_Coordinate_Value[1]); // Set last value
|
6764 |
//// break;
|
6765 |
//// case 3:
|
6766 |
//// coordinate.setText(previous_Coordinate_Value[2]); // Set last value
|
6767 |
//// break;
|
6768 |
//// case 4:
|
6769 |
//// coordinate.setText(previous_Coordinate_Value[3]); // Set last value
|
6770 |
//// break;
|
6771 |
//// default:
|
6772 |
//// // Do nothing
|
6773 |
//// }
|
6774 |
//
|
6775 |
//// return false;
|
6776 |
//// }
|
6777 |
//// else
|
6778 |
//// return true;
|
6779 |
////// }
|
6780 |
////
|
6781 |
//// return false; // If coordinate is null
|
6782 |
// }
|
6783 |
//
|
6784 |
// /**
|
6785 |
// * This method initializes jButtonPreviewArea
|
6786 |
// *
|
6787 |
// * @return javax.swing.JButton
|
6788 |
// */
|
6789 |
// private JButton getJButtonPreviewArea() {
|
6790 |
// if (jButtonPreviewArea == null) {
|
6791 |
// jButtonPreviewArea = new JButton();
|
6792 |
// jButtonPreviewArea.setBounds(DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE);
|
6793 |
// jButtonPreviewArea.setToolTipText(PluginServices.getText(this, "to_previsualize"));
|
6794 |
// jButtonPreviewArea.setVerticalTextPosition(AbstractButton.CENTER);
|
6795 |
// jButtonPreviewArea.setHorizontalTextPosition(AbstractButton.CENTER);
|
6796 |
// jButtonPreviewArea.setIcon(PluginServices.getIconTheme().get("view-previsualize-area"));
|
6797 |
// jButtonPreviewArea.addMouseListener(new MouseAdapter() {
|
6798 |
// /*
|
6799 |
// * (non-Javadoc)
|
6800 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
6801 |
// */
|
6802 |
// public void mouseClicked(MouseEvent e) {
|
6803 |
// // Only enable the area operation if there is data loaded in this MapControl
|
6804 |
//
|
6805 |
// // Do nothing if there is no layer in the map control
|
6806 |
// if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() == 0) {
|
6807 |
// return;
|
6808 |
// }
|
6809 |
//
|
6810 |
// if ((validateCoordinate(getJTextFieldVertex1X())) && (validateCoordinate(getJTextFieldVertex1Y())) && (validateCoordinate(getJTextFieldVertex2X())) && (validateCoordinate(getJTextFieldVertex2Y()))) {
|
6811 |
// ViewPort vP = getSelectableMapAreaPanel().getViewPort();
|
6812 |
// if (vP != null) {
|
6813 |
// // If has to scale the area
|
6814 |
// if (getJToggleButtonScaling().isSelected()) {
|
6815 |
// // Scale Vertex 1
|
6816 |
// if ((hasChanged_v1X) || (hasChanged_v1Y)) {
|
6817 |
// double cx = getDoubleValueOfJTextFieldV1X();
|
6818 |
// double cy = getDoubleValueOfJTextFieldV1Y();
|
6819 |
// double sx, sy, aux;
|
6820 |
//
|
6821 |
// if (hasChanged_v1X) {
|
6822 |
// aux = getDoubleValueOfLastJTextFieldV1XValue();
|
6823 |
// if (aux == 0.0)
|
6824 |
// sx = 1.0; // Don't scale if new coordenate is zero
|
6825 |
// else
|
6826 |
// sx = cx / aux;
|
6827 |
// }
|
6828 |
// else
|
6829 |
// sx = 1.0;
|
6830 |
//
|
6831 |
// if (hasChanged_v1Y) {
|
6832 |
// aux = getDoubleValueOfLastJTextFieldV1YValue();
|
6833 |
// if (aux == 0.0)
|
6834 |
// sy = 1.0; // Don't scale if new coordenate is zero
|
6835 |
// else
|
6836 |
// sy = cy / aux;
|
6837 |
// }
|
6838 |
// else
|
6839 |
// sy = 1.0;
|
6840 |
//
|
6841 |
// if (sx == 1.0) {
|
6842 |
// // It's supposed that sy != 1.0
|
6843 |
// cx *= sy;
|
6844 |
//
|
6845 |
// if (cx < getDoubleValueOfJTextFieldV2X()) {
|
6846 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6847 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6848 |
// return;
|
6849 |
// }
|
6850 |
//
|
6851 |
// getJTextFieldVertex1X().setText(Double.toString(cx));
|
6852 |
// }
|
6853 |
// else {
|
6854 |
// if (sy == 1.0) {
|
6855 |
// // It's supposed that sx != 1.0
|
6856 |
// cy *= sx;
|
6857 |
//
|
6858 |
// if (cy < getDoubleValueOfJTextFieldV2Y()) {
|
6859 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6860 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6861 |
// return;
|
6862 |
// }
|
6863 |
//
|
6864 |
// getJTextFieldVertex1Y().setText(Double.toString(cy));
|
6865 |
// }
|
6866 |
// else {
|
6867 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
6868 |
// if (sx != sy) {
|
6869 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6870 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6871 |
// return;
|
6872 |
// }
|
6873 |
// }
|
6874 |
// }
|
6875 |
// }
|
6876 |
//
|
6877 |
// // Scale Vertex2
|
6878 |
// if ((hasChanged_v2X) || (hasChanged_v2Y)) {
|
6879 |
// double cx = getDoubleValueOfJTextFieldV2X();
|
6880 |
// double cy = getDoubleValueOfJTextFieldV2Y();
|
6881 |
// double sx, sy, aux;
|
6882 |
//
|
6883 |
// if (hasChanged_v2X) {
|
6884 |
// aux = getDoubleValueOfLastJTextFieldV2XValue();
|
6885 |
// if (aux == 0.0)
|
6886 |
// sx = 1.0; // Don't scale if new coordenate is zero
|
6887 |
// else
|
6888 |
// sx = cx / aux;
|
6889 |
// }
|
6890 |
// else
|
6891 |
// sx = 1.0;
|
6892 |
//
|
6893 |
// if (hasChanged_v2Y) {
|
6894 |
// aux = getDoubleValueOfLastJTextFieldV2YValue();
|
6895 |
// if (aux == 0.0)
|
6896 |
// sy = 1.0; // Don't scale if new coordenate is zero
|
6897 |
// else
|
6898 |
// sy = cy / aux;
|
6899 |
// }
|
6900 |
// else
|
6901 |
// sy = 1.0;
|
6902 |
//
|
6903 |
// if (sx == 1.0) {
|
6904 |
// // It's supposed that sy != 1.0
|
6905 |
// cx *= sy;
|
6906 |
//
|
6907 |
// if (cx > getDoubleValueOfJTextFieldV1X()) {
|
6908 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6909 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6910 |
// return;
|
6911 |
// }
|
6912 |
//
|
6913 |
// getJTextFieldVertex2X().setText(Double.toString(cx));
|
6914 |
// }
|
6915 |
// else {
|
6916 |
// if (sy == 1.0) {
|
6917 |
// // It's supposed that sx != 1.0
|
6918 |
// cy *= sx;
|
6919 |
//
|
6920 |
// if (cy > getDoubleValueOfJTextFieldV1Y()) {
|
6921 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6922 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6923 |
// return;
|
6924 |
// }
|
6925 |
//
|
6926 |
// getJTextFieldVertex2Y().setText(Double.toString(cy));
|
6927 |
// }
|
6928 |
// else {
|
6929 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
6930 |
// if (sx != sy) {
|
6931 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "different_scale_factors"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6932 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6933 |
// return;
|
6934 |
// }
|
6935 |
// }
|
6936 |
// }
|
6937 |
// }
|
6938 |
// }
|
6939 |
// else {
|
6940 |
// // If has to move the area
|
6941 |
// if (getJToggleButtonMove().isSelected()) {
|
6942 |
// // Move in X
|
6943 |
// if ((hasChanged_v1X) || (hasChanged_v2X)) {
|
6944 |
// double c1 = getDoubleValueOfJTextFieldV1X();
|
6945 |
// double c2 = getDoubleValueOfJTextFieldV2X();
|
6946 |
// double d1, d2;
|
6947 |
//
|
6948 |
// if (hasChanged_v1X)
|
6949 |
// d1 = c1 - getDoubleValueOfLastJTextFieldV1XValue();
|
6950 |
// else
|
6951 |
// d1 = 0.0;
|
6952 |
//
|
6953 |
// if (hasChanged_v2X)
|
6954 |
// d2 = c2 - getDoubleValueOfLastJTextFieldV2XValue();
|
6955 |
// else
|
6956 |
// d2 = 0.0;
|
6957 |
//
|
6958 |
// if (d1 == 0.0) {
|
6959 |
// // It's supposed that d2 != 0
|
6960 |
// c1 += d2;
|
6961 |
//
|
6962 |
// if (c1 < getDoubleValueOfJTextFieldV2X()) {
|
6963 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6964 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6965 |
// return;
|
6966 |
// }
|
6967 |
//
|
6968 |
// getJTextFieldVertex1X().setText(Double.toString(c1));
|
6969 |
// }
|
6970 |
// else {
|
6971 |
// if (d2 == 0.0) {
|
6972 |
// // It's supposed that d1 != 0
|
6973 |
// c2 += d1;
|
6974 |
//
|
6975 |
// if (c2 > getDoubleValueOfJTextFieldV1X()) {
|
6976 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6977 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6978 |
// return;
|
6979 |
// }
|
6980 |
//
|
6981 |
// getJTextFieldVertex2X().setText(Double.toString(c2));
|
6982 |
// }
|
6983 |
// else {
|
6984 |
// // If there has been an error -> can't move different distances in X the two vertexes
|
6985 |
// if (d1 != d2) {
|
6986 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_X"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
6987 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
6988 |
// return;
|
6989 |
// }
|
6990 |
// }
|
6991 |
// }
|
6992 |
// }
|
6993 |
//
|
6994 |
// // Move in Y
|
6995 |
// if ((hasChanged_v1Y) || (hasChanged_v2Y)) {
|
6996 |
// double c1 = getDoubleValueOfJTextFieldV1Y();
|
6997 |
// double c2 = getDoubleValueOfJTextFieldV2Y();
|
6998 |
// double d1, d2;
|
6999 |
//
|
7000 |
// if (hasChanged_v1Y)
|
7001 |
// d1 = c1 - getDoubleValueOfLastJTextFieldV1YValue();
|
7002 |
// else
|
7003 |
// d1 = 0.0;
|
7004 |
//
|
7005 |
// if (hasChanged_v2Y)
|
7006 |
// d2 = c2 - getDoubleValueOfLastJTextFieldV2YValue();
|
7007 |
// else
|
7008 |
// d2 = 0.0;
|
7009 |
//
|
7010 |
// if (d1 == 0.0) {
|
7011 |
// // It's supposed that d2 != 0
|
7012 |
// c1 += d2;
|
7013 |
//
|
7014 |
// if (c1 < getDoubleValueOfJTextFieldV2Y()) {
|
7015 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7016 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
7017 |
// return;
|
7018 |
// }
|
7019 |
//
|
7020 |
// getJTextFieldVertex1Y().setText(Double.toString(c1));
|
7021 |
// }
|
7022 |
// else {
|
7023 |
// if (d2 == 0.0) {
|
7024 |
// // It's supposed that d1 != 0
|
7025 |
// c2 += d1;
|
7026 |
//
|
7027 |
// if (c2 > getDoubleValueOfJTextFieldV1Y()) {
|
7028 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7029 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
7030 |
// return;
|
7031 |
// }
|
7032 |
//
|
7033 |
// getJTextFieldVertex2Y().setText(Double.toString(c2));
|
7034 |
// }
|
7035 |
// else {
|
7036 |
// // If there has been an error -> can't move different distances in Y the two vertexes
|
7037 |
// if (d1 != d2) {
|
7038 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "different_distances_in_Y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7039 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
7040 |
// return;
|
7041 |
// }
|
7042 |
// }
|
7043 |
// }
|
7044 |
// }
|
7045 |
// }
|
7046 |
// else {
|
7047 |
// boolean canSetExtent = true;
|
7048 |
//
|
7049 |
// // Check if there is a impossible coordinate
|
7050 |
// if (hasChanged_v1X) {
|
7051 |
// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
7052 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jButtonPreviewArea, "v2x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7053 |
// canSetExtent = false;
|
7054 |
// }
|
7055 |
// }
|
7056 |
//
|
7057 |
// if (hasChanged_v1Y) {
|
7058 |
// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
7059 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jButtonPreviewArea, "v2y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7060 |
// canSetExtent = false;
|
7061 |
// }
|
7062 |
// }
|
7063 |
//
|
7064 |
// if (hasChanged_v2X) {
|
7065 |
// if (getDoubleValueOfJTextFieldV2X() > getDoubleValueOfJTextFieldV1X()) {
|
7066 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jButtonPreviewArea, "v1x"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7067 |
// canSetExtent = false;
|
7068 |
// }
|
7069 |
// }
|
7070 |
//
|
7071 |
// if (hasChanged_v2Y) {
|
7072 |
// if (getDoubleValueOfJTextFieldV2Y() > getDoubleValueOfJTextFieldV1Y()) {
|
7073 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jButtonPreviewArea, "v1y"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7074 |
// canSetExtent = false;
|
7075 |
// }
|
7076 |
// }
|
7077 |
//
|
7078 |
// // If can set the new Extent -> finish
|
7079 |
// if (!canSetExtent) {
|
7080 |
// restoreAllModifiedCoordinates(); // restores the coordinates
|
7081 |
// return;
|
7082 |
// }
|
7083 |
// }
|
7084 |
// }
|
7085 |
//
|
7086 |
// //Rectangle2D r2d = vP.getExtent();
|
7087 |
// if (vP.getExtent() != null){
|
7088 |
// vP.setExtent(getNewRectangleByCoordinates());
|
7089 |
// vP.refreshExtent();
|
7090 |
// }
|
7091 |
// }
|
7092 |
// }
|
7093 |
// else {
|
7094 |
// JOptionPane.showMessageDialog(jButtonPreviewArea, PluginServices.getText(jButtonPreviewArea, "at_least_one_incorrect_coordinate"), PluginServices.getText(jButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
|
7095 |
// }
|
7096 |
// }
|
7097 |
// });
|
7098 |
// }
|
7099 |
// return jButtonPreviewArea;
|
7100 |
// }
|
7101 |
//
|
7102 |
// /**
|
7103 |
// * Calculates the new rectangle using the coordinates of the text fields
|
7104 |
// *
|
7105 |
// * @return java.awt.geom.Rectangle2D
|
7106 |
// */
|
7107 |
// private Rectangle2D getNewRectangleByCoordinates() {
|
7108 |
// return new Rectangle2D.Double(getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV2Y(), getDoubleValueOfJTextFieldV1X() - getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV1Y() - getDoubleValueOfJTextFieldV2Y());
|
7109 |
// }
|
7110 |
//
|
7111 |
// /**
|
7112 |
// * Restores the value of all text fields with coordinates modified to their last value
|
7113 |
// */
|
7114 |
// private void restoreAllModifiedCoordinates() {
|
7115 |
// if (hasChanged_v1X) {
|
7116 |
// getJTextFieldVertex1X().setText(last_Coordinates[0]);
|
7117 |
// hasChanged_v1X = false;
|
7118 |
// }
|
7119 |
//
|
7120 |
// if (hasChanged_v1Y) {
|
7121 |
// getJTextFieldVertex1Y().setText(last_Coordinates[1]);
|
7122 |
// hasChanged_v1Y = false;
|
7123 |
// }
|
7124 |
//
|
7125 |
// if (hasChanged_v2X) {
|
7126 |
// getJTextFieldVertex2X().setText(last_Coordinates[2]);
|
7127 |
// hasChanged_v2X = false;
|
7128 |
// }
|
7129 |
//
|
7130 |
// if (hasChanged_v2Y) {
|
7131 |
// getJTextFieldVertex2Y().setText(last_Coordinates[3]);
|
7132 |
// hasChanged_v2Y = false;
|
7133 |
// }
|
7134 |
// }
|
7135 |
//
|
7136 |
// /**
|
7137 |
// * Enables or disables all inner JTextField
|
7138 |
// *
|
7139 |
// * @param b A boolean value
|
7140 |
// */
|
7141 |
// public void setAllTextFieldsEnabled(boolean b) {
|
7142 |
// getJTextFieldVertex1X().setEnabled(b);
|
7143 |
// getJTextFieldVertex1Y().setEnabled(b);
|
7144 |
// getJTextFieldVertex2X().setEnabled(b);
|
7145 |
// getJTextFieldVertex2Y().setEnabled(b);
|
7146 |
// }
|
7147 |
//
|
7148 |
// /**
|
7149 |
// * Sets the extent into the text fields
|
7150 |
// *
|
7151 |
// * @param extent java.awt.geom.Rectangle2D
|
7152 |
// */
|
7153 |
// public void updateCoordinates(Rectangle2D extent){
|
7154 |
// getJTextFieldVertex1X().setText(String.valueOf(extent.getMaxX()));
|
7155 |
// last_Coordinates[0] = getJTextFieldVertex1X().getText();
|
7156 |
// previous_Coordinate_Value[0] = last_Coordinates[0];
|
7157 |
//
|
7158 |
// getJTextFieldVertex1Y().setText(String.valueOf(extent.getMaxY()));
|
7159 |
// last_Coordinates[1] = getJTextFieldVertex1Y().getText();
|
7160 |
// previous_Coordinate_Value[1] = last_Coordinates[1];
|
7161 |
//
|
7162 |
// getJTextFieldVertex2X().setText(String.valueOf(extent.getMinX()));
|
7163 |
// last_Coordinates[2] = getJTextFieldVertex2X().getText();
|
7164 |
// previous_Coordinate_Value[2] = last_Coordinates[2];
|
7165 |
//
|
7166 |
// getJTextFieldVertex2Y().setText(String.valueOf(extent.getMinY()));
|
7167 |
// last_Coordinates[3] = getJTextFieldVertex2Y().getText();
|
7168 |
// previous_Coordinate_Value[3] = last_Coordinates[3];
|
7169 |
//
|
7170 |
// resetCoordinatesFlags();
|
7171 |
//
|
7172 |
// // Enable the 'Applicate' button
|
7173 |
// setApplicable(true);
|
7174 |
// }
|
7175 |
//
|
7176 |
// /**
|
7177 |
// * Validates all coordinates of both vertexes separately
|
7178 |
// *
|
7179 |
// * @return A ValidationInfo object reference
|
7180 |
// */
|
7181 |
// private ValidationInfo validVertexesCoordinates() {
|
7182 |
// if (! validateCoordinate(getJTextFieldVertex1X())) {
|
7183 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
7184 |
// }
|
7185 |
//
|
7186 |
// if (! validateCoordinate(getJTextFieldVertex1Y())) {
|
7187 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
7188 |
// }
|
7189 |
//
|
7190 |
// if (! validateCoordinate(getJTextFieldVertex2X())) {
|
7191 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
7192 |
// }
|
7193 |
//
|
7194 |
// if (! validateCoordinate(getJTextFieldVertex2Y())) {
|
7195 |
// return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
7196 |
// }
|
7197 |
//
|
7198 |
// // If arrives here, all coordinates are valid
|
7199 |
// return new ValidationInfo(true, "");
|
7200 |
// }
|
7201 |
//
|
7202 |
// /**
|
7203 |
// * Validates that Vertex1 is in the right-up corner and the Vertex2 in the left-down corner of the area/rectangle <br>
|
7204 |
// * (It's supposed that coordinates of the vertexes are valid) <br>
|
7205 |
// * (It's supposed that going to right or up, the coordinate value increases)
|
7206 |
// *
|
7207 |
// * @return A ValidationInfo object reference
|
7208 |
// */
|
7209 |
// private ValidationInfo validVertexesPositions() {
|
7210 |
// // Check if no coordinate it's defined
|
7211 |
// if (getJTextFieldVertex1X().getText().compareTo("") == 0) {
|
7212 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1x"));
|
7213 |
// }
|
7214 |
//
|
7215 |
// if (getJTextFieldVertex2X().getText().compareTo("") == 0) {
|
7216 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2x"));
|
7217 |
// }
|
7218 |
//
|
7219 |
// if (getJTextFieldVertex1Y().getText().compareTo("") == 0) {
|
7220 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
|
7221 |
// }
|
7222 |
//
|
7223 |
// if (getJTextFieldVertex2Y().getText().compareTo("") == 0) {
|
7224 |
// return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
|
7225 |
// }
|
7226 |
//
|
7227 |
// // Check if the vertex V1 is in the right-up corner and the vertex V2 is in the left-down corner
|
7228 |
// if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
|
7229 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1x") + " < " + PluginServices.getText(this, "v2x"));
|
7230 |
// }
|
7231 |
//
|
7232 |
// if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
|
7233 |
// return new ValidationInfo(false, PluginServices.getText(this, "v1y") + " < " + PluginServices.getText(this, "v2y"));
|
7234 |
// }
|
7235 |
//
|
7236 |
// // If arrives here -> vertexes positions are valid
|
7237 |
// return new ValidationInfo(true, "");
|
7238 |
// }
|
7239 |
//
|
7240 |
// /**
|
7241 |
// * Validate each coordinate of each vertex and the position of the vertexes
|
7242 |
// *
|
7243 |
// * @return A boolean value
|
7244 |
// */
|
7245 |
// public boolean validVertexes() {
|
7246 |
// ValidationInfo v1 = validVertexesCoordinates();
|
7247 |
//
|
7248 |
// if (!v1.isValid()) {
|
7249 |
// // Notify to user that no filter area will be applied
|
7250 |
// JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v1.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE);
|
7251 |
//
|
7252 |
// return false;
|
7253 |
// }
|
7254 |
// else {
|
7255 |
// ValidationInfo v2 = validVertexesPositions();
|
7256 |
// if (!v2.isValid()) {
|
7257 |
// // Notify to user that no filter area will be applied
|
7258 |
// JOptionPane.showMessageDialog(null, PluginServices.getText(null, PluginServices.getText(this, "invalid_coordinates") + ": " + v2.getMessage()), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE);
|
7259 |
//
|
7260 |
// return false;
|
7261 |
// }
|
7262 |
// else {
|
7263 |
// return true;
|
7264 |
// }
|
7265 |
// }
|
7266 |
// }
|
7267 |
//
|
7268 |
// /**
|
7269 |
// * Gets the extent (rectangle) represented by the values of the coordinate text fields
|
7270 |
// *
|
7271 |
// * @return java.awt.geom.Rectangle2D
|
7272 |
// */
|
7273 |
// public Rectangle2D getExtent() {
|
7274 |
// double v1x = getDoubleValueOfJTextFieldV1X();
|
7275 |
// double v1y = getDoubleValueOfJTextFieldV1Y();
|
7276 |
// double v2x = getDoubleValueOfJTextFieldV2X();
|
7277 |
// double v2y = getDoubleValueOfJTextFieldV2Y();
|
7278 |
//
|
7279 |
// return new Rectangle2D.Double(v2x, v1y, (v1x - v2x), (v1y - v2y));
|
7280 |
// }
|
7281 |
//
|
7282 |
// /**
|
7283 |
// * Returns true if there is some coordinate text field with data; else returns false
|
7284 |
// *
|
7285 |
// * @return A boolean value
|
7286 |
// */
|
7287 |
// public boolean areThereSomeCoordinatesWritten() {
|
7288 |
// return ((getJTextFieldVertex1X().getText().compareTo("") != 0) | (getJTextFieldVertex1Y().getText().compareTo("") != 0) | (getJTextFieldVertex2X().getText().compareTo("") != 0) | (getJTextFieldVertex2Y().getText().compareTo("") != 0));
|
7289 |
// }
|
7290 |
//
|
7291 |
// /**
|
7292 |
// * Returns true if all coordinate text fields are undefined (without values)
|
7293 |
// *
|
7294 |
// * @return A boolean value
|
7295 |
// */
|
7296 |
// public boolean areAllCoordinatesUndefined() {
|
7297 |
// return ((getJTextFieldVertex1X().getText().compareTo("") == 0) & (getJTextFieldVertex1Y().getText().compareTo("") == 0) & (getJTextFieldVertex2X().getText().compareTo("") == 0) & (getJTextFieldVertex2Y().getText().compareTo("") == 0));
|
7298 |
// }
|
7299 |
//
|
7300 |
//
|
7301 |
// /**
|
7302 |
// * Returns true if there is some coordinate undefined (without values)
|
7303 |
// *
|
7304 |
// * @return A boolean value
|
7305 |
// */
|
7306 |
// public boolean isThereAnyCoordinateUndefined() {
|
7307 |
// return ((getJTextFieldVertex1X().getText().compareTo("") == 0) | (getJTextFieldVertex1Y().getText().compareTo("") == 0) | (getJTextFieldVertex2X().getText().compareTo("") == 0) | (getJTextFieldVertex2Y().getText().compareTo("") == 0));
|
7308 |
// }
|
7309 |
// }
|
7310 |
//
|
7311 |
// /**
|
7312 |
// * This class is a MapControl JComponent that has visual information and allows user interact with some tools and view the results
|
7313 |
// *
|
7314 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
7315 |
// */
|
7316 |
// private class SelectableMapControlAreaPanel extends MapControl {
|
7317 |
// private MouseListener[] mouseListeners;
|
7318 |
// private MouseWheelListener[] mouseWheelListeners;
|
7319 |
// private MouseMotionListener[] mouseMotionListeners;
|
7320 |
//
|
7321 |
// /**
|
7322 |
// * Default constructor
|
7323 |
// */
|
7324 |
// public SelectableMapControlAreaPanel() {
|
7325 |
// super();
|
7326 |
// initialize();
|
7327 |
// }
|
7328 |
//
|
7329 |
// /**
|
7330 |
// * This method initializes this component
|
7331 |
// */
|
7332 |
// public void initialize() {
|
7333 |
// /* Sets Bounds of this graphical component */
|
7334 |
// this.setBounds(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE);
|
7335 |
//
|
7336 |
// /* Sets border to this graphical component */
|
7337 |
// this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
|
7338 |
//
|
7339 |
// /* Sets a clone of the current active view map context to this MapControl */
|
7340 |
// try {
|
7341 |
// MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext();
|
7342 |
//
|
7343 |
// this.setMapContext(mp.cloneFMap());
|
7344 |
// ViewPort vP = this.getViewPort();
|
7345 |
//
|
7346 |
// Rectangle2D r2D = vP.getExtent();
|
7347 |
//
|
7348 |
// if (r2D != null) {
|
7349 |
// vP.refreshExtent();
|
7350 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
7351 |
// }
|
7352 |
// } catch (XMLException e) {
|
7353 |
// e.printStackTrace();
|
7354 |
// }
|
7355 |
//
|
7356 |
// /* Adds listeners to this MapControl */
|
7357 |
// this.addToolsListeners();
|
7358 |
//
|
7359 |
// /* Sets default tool */
|
7360 |
// this.setTool(PAN_TOOL);
|
7361 |
// }
|
7362 |
//
|
7363 |
// /**
|
7364 |
// * Refresh the active view
|
7365 |
// */
|
7366 |
// public void refreshWithTheActiveView() {
|
7367 |
// try {
|
7368 |
// MapContext mp = ((BaseView) PluginServices.getMDIManager().getActiveWindow()).getMapControl().getMapContext();
|
7369 |
// this.setMapContext(mp.cloneFMap());
|
7370 |
// ViewPort vP = this.getViewPort();
|
7371 |
//
|
7372 |
// Rectangle2D r2D = vP.getExtent();
|
7373 |
//
|
7374 |
// if (r2D != null) {
|
7375 |
// vP.refreshExtent();
|
7376 |
// getCoordinatesPanel().updateCoordinates(r2D);
|
7377 |
// }
|
7378 |
// } catch (XMLException e) {
|
7379 |
// e.printStackTrace();
|
7380 |
// }
|
7381 |
// }
|
7382 |
//
|
7383 |
// /**
|
7384 |
// * Adds listeners that allows user interact with it's mouse over this component and that represents different tools
|
7385 |
// */
|
7386 |
// private void addToolsListeners() {
|
7387 |
// // MOVEMENT EVENTS LISTENER: sets mouse coordinates to the status bar
|
7388 |
// StatusBarListener sbl = new StatusBarListener(this);
|
7389 |
//
|
7390 |
// // ZOOM OUT (Presses on the map and it will be centered showing a bigger area)
|
7391 |
// // Only pressing, not selecting a rectangle area
|
7392 |
// ZoomOutListener zol = new ZoomOutListener(this);
|
7393 |
// this.addMapTool(ZOOM_OUT_TOOL, new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)});
|
7394 |
//
|
7395 |
// // ZOOM IN (Using a Rectangle or a simple mouse click)
|
7396 |
// ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(this);
|
7397 |
// ZoomInListener zil = new ZoomInListener(this);
|
7398 |
// this.addMapTool(ZOOM_IN_TOOL, new Behavior[]{new RectangleBehavior(zil),
|
7399 |
// new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
|
7400 |
//
|
7401 |
// // PAN
|
7402 |
// PanListener pl = new PanListener(this);
|
7403 |
// this.addMapTool(PAN_TOOL, new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)});
|
7404 |
//
|
7405 |
// // MEASURE DISTANCES
|
7406 |
// MeasureListener mli = new MeasureListener(this);
|
7407 |
// this.addMapTool(MEASURE_DISTANCES_TOOL, new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)});
|
7408 |
//
|
7409 |
// // MEASURE AREA
|
7410 |
// AreaListener ali = new AreaListener(this);
|
7411 |
// this.addMapTool(MEASURE_AREA_TOOL, new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
|
7412 |
//
|
7413 |
// this.getViewPort().addViewPortListener(new ViewPortListener() {
|
7414 |
// /*
|
7415 |
// * (non-Javadoc)
|
7416 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
7417 |
// */
|
7418 |
// public void extentChanged(ExtentEvent e) {
|
7419 |
// if (getMapContext().getViewPort().getExtents().hasPrevious()) {
|
7420 |
// Rectangle2D r2d = getViewPort().getExtent();
|
7421 |
//
|
7422 |
// if (r2d != null) {
|
7423 |
// getCoordinatesPanel().updateCoordinates(r2d);
|
7424 |
//
|
7425 |
// if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
|
7426 |
// hasUserDefinedAnArea = true;
|
7427 |
// }
|
7428 |
// }
|
7429 |
//
|
7430 |
// getJButtonZoomPrevious().setEnabled(true);
|
7431 |
// getJButtonUndo().setEnabled(true);
|
7432 |
// }
|
7433 |
// else {
|
7434 |
// getJButtonZoomPrevious().setEnabled(false);
|
7435 |
// getJButtonUndo().setEnabled(false);
|
7436 |
// }
|
7437 |
// }
|
7438 |
//
|
7439 |
// /*
|
7440 |
// * (non-Javadoc)
|
7441 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
7442 |
// */
|
7443 |
// public void backColorChanged(ColorEvent e) {
|
7444 |
// }
|
7445 |
//
|
7446 |
// /*
|
7447 |
// * (non-Javadoc)
|
7448 |
// * @see com.iver.cit.gvsig.fmap.ViewPortListener#projectionChanged(com.iver.cit.gvsig.fmap.ProjectionEvent)
|
7449 |
// */
|
7450 |
// public void projectionChanged(ProjectionEvent e) {
|
7451 |
// }
|
7452 |
//
|
7453 |
// });
|
7454 |
// }
|
7455 |
//
|
7456 |
// /*
|
7457 |
// * (non-Javadoc)
|
7458 |
// * @see java.awt.Component#setEnabled(boolean)
|
7459 |
// */
|
7460 |
// public void setEnabled(boolean b) {
|
7461 |
// super.setEnabled(b);
|
7462 |
//
|
7463 |
// if (b)
|
7464 |
// enableAllMouseListeners();
|
7465 |
// else
|
7466 |
// disableAllMouseListeners();
|
7467 |
// }
|
7468 |
//
|
7469 |
// /**
|
7470 |
// * Disables all mouse listeners
|
7471 |
// */
|
7472 |
// public void disableAllMouseListeners() {
|
7473 |
// int i;
|
7474 |
//
|
7475 |
// // Only disable listeners if there are listeners to remove (it's supposed that there are always the same number of mouse listeners, and this listeners
|
7476 |
// // are referenciated by this component or by the private attribute 'mouseListeners')
|
7477 |
//
|
7478 |
// // Mouse Button Listeners
|
7479 |
// if (mouseListeners == null) {
|
7480 |
// mouseListeners = this.getMouseListeners();
|
7481 |
//
|
7482 |
// for (i = 0; i < mouseListeners.length; i++) {
|
7483 |
// removeMouseListener(mouseListeners[i]);
|
7484 |
// }
|
7485 |
// }
|
7486 |
//
|
7487 |
// // Mouse Wheel Listeners
|
7488 |
// if (mouseWheelListeners == null) {
|
7489 |
// mouseWheelListeners = this.getMouseWheelListeners();
|
7490 |
//
|
7491 |
// for (i = 0; i < mouseWheelListeners.length; i++) {
|
7492 |
// removeMouseWheelListener(mouseWheelListeners[i]);
|
7493 |
// }
|
7494 |
// }
|
7495 |
//
|
7496 |
// // Mouse motion listeners
|
7497 |
// if (mouseMotionListeners == null) {
|
7498 |
// mouseMotionListeners = this.getMouseMotionListeners();
|
7499 |
//
|
7500 |
// for (i = 0; i < mouseMotionListeners.length; i++) {
|
7501 |
// removeMouseMotionListener(mouseMotionListeners[i]);
|
7502 |
// }
|
7503 |
// }
|
7504 |
// }
|
7505 |
//
|
7506 |
// /**
|
7507 |
// * Enables all mouse listeners
|
7508 |
// */
|
7509 |
// public void enableAllMouseListeners() {
|
7510 |
// int i;
|
7511 |
//
|
7512 |
// // Mouse Button Listeners
|
7513 |
// for (i = 0; i < mouseListeners.length; i++) {
|
7514 |
// addMouseListener(mouseListeners[i]);
|
7515 |
// }
|
7516 |
//
|
7517 |
// mouseListeners = null;
|
7518 |
//
|
7519 |
// // Mouse Wheel Listeners
|
7520 |
// for (i = 0; i < mouseWheelListeners.length; i++) {
|
7521 |
// addMouseWheelListener(mouseWheelListeners[i]);
|
7522 |
// }
|
7523 |
//
|
7524 |
// mouseWheelListeners = null;
|
7525 |
//
|
7526 |
// // Mouse motion listeners
|
7527 |
// for (i = 0; i < mouseMotionListeners.length; i++) {
|
7528 |
// addMouseMotionListener(mouseMotionListeners[i]);
|
7529 |
// }
|
7530 |
//
|
7531 |
// mouseMotionListeners = null;
|
7532 |
// }
|
7533 |
// }
|
7534 |
//
|
7535 |
// /**
|
7536 |
// * This class has information about a validation: <br>
|
7537 |
// * - A boolean value -> if has been or not validated <br>
|
7538 |
// * - An String -> a message about the invalid
|
7539 |
// *
|
7540 |
// * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
|
7541 |
// */
|
7542 |
// private class ValidationInfo {
|
7543 |
// private boolean _valid;
|
7544 |
// private String _message;
|
7545 |
//
|
7546 |
// /**
|
7547 |
// * Default constructor with two parameters
|
7548 |
// *
|
7549 |
// * @param valid If was valid or not
|
7550 |
// * @param message A message associate to the validation (If has been valid, this attribute should be "", in the other case should have a message with
|
7551 |
// * an explanation about the invalidation)
|
7552 |
// */
|
7553 |
// public ValidationInfo(boolean valid, String message) {
|
7554 |
// _valid = valid;
|
7555 |
// _message = message;
|
7556 |
// }
|
7557 |
//
|
7558 |
// /**
|
7559 |
// * Returns the value of the inner attribute '_valid'
|
7560 |
// *
|
7561 |
// * @return A boolean value
|
7562 |
// */
|
7563 |
// public boolean isValid() {
|
7564 |
// return _valid;
|
7565 |
// }
|
7566 |
//
|
7567 |
// /**
|
7568 |
// * Returns the value of the inner attribute '_message'
|
7569 |
// *
|
7570 |
// * @return java.lang.String
|
7571 |
// */
|
7572 |
// public String getMessage() {
|
7573 |
// return _message;
|
7574 |
// }
|
7575 |
// }
|
7576 |
//}
|