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