svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / tools / Behavior / GeoRedimBehavior.java @ 5217
History | View | Annotate | Download (17.7 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.georeferencing.tools.Behavior; |
42 |
|
43 |
import java.awt.Color; |
44 |
import java.awt.Component; |
45 |
import java.awt.Graphics; |
46 |
import java.awt.Image; |
47 |
import java.awt.Point; |
48 |
import java.awt.Rectangle; |
49 |
import java.awt.Toolkit; |
50 |
import java.awt.event.MouseEvent; |
51 |
import java.awt.geom.Point2D; |
52 |
import java.awt.geom.Rectangle2D; |
53 |
import java.awt.image.BufferedImage; |
54 |
|
55 |
import javax.swing.ImageIcon; |
56 |
import javax.swing.JOptionPane; |
57 |
|
58 |
import org.cresques.px.Extent; |
59 |
import org.gvsig.georeferencing.gui.dialogs.GeoreferencingDialog; |
60 |
import org.gvsig.georeferencing.layers.FLyrGeoRaster; |
61 |
import org.gvsig.georeferencing.layers.GeoPoint; |
62 |
|
63 |
import com.iver.andami.PluginServices; |
64 |
import com.iver.cit.gvsig.fmap.MapControl; |
65 |
import com.iver.cit.gvsig.fmap.ViewPort; |
66 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
67 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
68 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
69 |
import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener; |
70 |
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener; |
71 |
|
72 |
|
73 |
/**
|
74 |
* Behaviour que espera un listener de tipo RedimListener.
|
75 |
* Nacho Brodin (brodin_ign@gva.es)
|
76 |
*
|
77 |
*/
|
78 |
public class GeoRedimBehavior extends Behavior { |
79 |
//Params
|
80 |
private int WIDTH_BORDER = 25; |
81 |
private int LONG_CORNER = 35; |
82 |
private Color rectangleColor = Color.RED; |
83 |
|
84 |
private RectangleListener listener;
|
85 |
|
86 |
private final Image iconHoriz = new ImageIcon(getClass().getClassLoader().getResource( |
87 |
"images/FlechaHorizCursor.gif")).getImage();
|
88 |
private final Image iconVert = new ImageIcon(getClass().getClassLoader().getResource( |
89 |
"images/FlechaVertCursor.gif")).getImage();
|
90 |
private final Image iconInclDer = new ImageIcon(getClass().getClassLoader().getResource( |
91 |
"images/FlechaInclDerCursor.gif")).getImage();
|
92 |
private final Image iconInclIzq = new ImageIcon(getClass().getClassLoader().getResource( |
93 |
"images/FlechaInclIzqCursor.gif")).getImage();
|
94 |
private final Image defaultCursor = new ImageIcon(getClass().getClassLoader().getResource( |
95 |
"images/ZoomInCursor.gif")).getImage();
|
96 |
|
97 |
/**
|
98 |
* Cada elemento del vector corresponde a un tipo de icono que
|
99 |
* estar? a true si est? activo y a false si no lo est?.
|
100 |
* horizontal, vertical, inclinado derecha, inclinado izquierda
|
101 |
*/
|
102 |
private boolean[] iconActive = {false, false, false, false}; |
103 |
private Point2D ul = null; |
104 |
private Point2D lr = null; |
105 |
private Point2D tmpUl = null; |
106 |
private Point2D tmpLr = null; |
107 |
|
108 |
/**
|
109 |
* Variable que si est? a true permite que se pinte el marco de la imagen. Se activa al
|
110 |
* comenzar el redimensionado y se desactiva al terminar
|
111 |
*/
|
112 |
private boolean isResizable = false; |
113 |
|
114 |
/**
|
115 |
* Cada elemento corresponde a la acivaci?n de redimensionado en una
|
116 |
* direcci?n que estar? activa a true.
|
117 |
* vertical derecha, vertical izquierda, horizontal arriba, horizontal abajo,
|
118 |
* inclinado
|
119 |
*/
|
120 |
private boolean[] redimActive = new boolean[5]; |
121 |
private Point2D pointInit = null; |
122 |
private Rectangle2D rectInit = null; |
123 |
private FLyrGeoRaster lyrGeoRaster = null; |
124 |
private GeoreferencingDialog parent = null; |
125 |
private com.iver.cit.gvsig.gui.View theView = null; |
126 |
|
127 |
|
128 |
/**
|
129 |
* Crea un nuevo RectangleBehavior.
|
130 |
*
|
131 |
* @param zili listener.
|
132 |
*/
|
133 |
public GeoRedimBehavior(RectangleListener zili, GeoreferencingDialog p) {
|
134 |
listener = zili; |
135 |
parent = p; |
136 |
for(int i=0; i<redimActive.length;i++) |
137 |
redimActive[i] = false;
|
138 |
} |
139 |
|
140 |
/**
|
141 |
* Funci?n que carga la capa si todav?a no lo est?.
|
142 |
*/
|
143 |
private void loadLayer() throws InstantiationException, ClassCastException{ |
144 |
//Cargamos la capa
|
145 |
|
146 |
theView = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
147 |
for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){ |
148 |
FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i); |
149 |
if( lyr instanceof FLyrGeoRaster && |
150 |
lyr.getName().startsWith("*"))
|
151 |
this.lyrGeoRaster = (FLyrGeoRaster)lyr;
|
152 |
} |
153 |
if(lyrGeoRaster == null) |
154 |
throw new InstantiationException("No se ha podido cargar la capa de georreferenciaci?n"); |
155 |
} |
156 |
|
157 |
|
158 |
/**
|
159 |
* Cuando se produce un evento de pintado dibujamos el marco de la imagen para
|
160 |
* que el usuario pueda seleccionar y redimensionar.
|
161 |
*/
|
162 |
public void paintComponent(Graphics g) { |
163 |
BufferedImage img = getMapControl().getImage();
|
164 |
g.drawImage(img, 0, 0, null); |
165 |
g.setColor(rectangleColor); |
166 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
167 |
try{
|
168 |
loadLayer(); |
169 |
Rectangle r = new Rectangle(); |
170 |
|
171 |
if(tmpLr == null || tmpUl == null){ |
172 |
ul = vp.fromMapPoint(lyrGeoRaster.getAssignExtent().getMin().getX(), lyrGeoRaster.getAssignExtent().getMin().getY()); |
173 |
lr = vp.fromMapPoint(lyrGeoRaster.getAssignExtent().getMax().getX(), lyrGeoRaster.getAssignExtent().getMax().getY()); |
174 |
r.setFrameFromDiagonal(ul, lr); |
175 |
}else
|
176 |
r.setFrameFromDiagonal(tmpUl, tmpLr); |
177 |
if(isResizable)
|
178 |
g.drawRect(r.x, r.y, r.width, r.height); |
179 |
}catch(InstantiationException exc){ |
180 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
181 |
PluginServices.getText(this, "error_capa_puntos")); |
182 |
}catch(ClassCastException exc){ |
183 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
184 |
PluginServices.getText(this, "error_capa_puntos")); |
185 |
} |
186 |
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* Reimplementaci?n del m?todo mousePressed de Behavior. Cuando se pulsa
|
191 |
* estando sobre el marco de la imagen activamos la posibilidad de arrastrar
|
192 |
* para redimensionar la imagen.
|
193 |
*
|
194 |
* @param e MouseEvent
|
195 |
*/
|
196 |
public void mousePressed(MouseEvent e) { |
197 |
if (e.getButton() == MouseEvent.BUTTON1) { |
198 |
isResizable = true;
|
199 |
try{
|
200 |
loadLayer(); |
201 |
}catch(InstantiationException exc){ |
202 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
203 |
PluginServices.getText(this, "error_capa_puntos")); |
204 |
return;
|
205 |
}catch(ClassCastException exc){ |
206 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
207 |
PluginServices.getText(this, "error_capa_puntos")); |
208 |
return;
|
209 |
} |
210 |
|
211 |
tmpUl = ul; |
212 |
tmpLr = lr; |
213 |
|
214 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
215 |
double wcX = vp.toMapPoint(e.getX(), e.getY()).getX();
|
216 |
double wcY = vp.toMapPoint(e.getX(), e.getY()).getY();
|
217 |
|
218 |
double minX = lyrGeoRaster.getAssignExtent().getMin().getX();
|
219 |
double minY = lyrGeoRaster.getAssignExtent().getMin().getY();
|
220 |
double maxX = lyrGeoRaster.getAssignExtent().getMax().getX();
|
221 |
double maxY = lyrGeoRaster.getAssignExtent().getMax().getY();
|
222 |
|
223 |
|
224 |
if(iconActive[0]){//Estirar en horizontal activado |
225 |
if(wcX > (maxX - WIDTH_BORDER) && wcX < maxX)
|
226 |
redimActive[0] = true; |
227 |
if(wcX < (minX + WIDTH_BORDER) && wcX > minX)
|
228 |
redimActive[1] = true; |
229 |
} |
230 |
if(iconActive[1]){//Estirar en vertical activado |
231 |
if(wcY > (maxY - WIDTH_BORDER) && wcY < maxY)
|
232 |
redimActive[3] = true; |
233 |
if(wcY < (minY + WIDTH_BORDER) && wcY > minY)
|
234 |
redimActive[2] = true; |
235 |
} |
236 |
if(iconActive[2] || iconActive[3]){ //Estirar en oblicuo activado |
237 |
redimActive[4] = true; |
238 |
pointInit = e.getPoint(); |
239 |
rectInit = new Rectangle2D.Double(tmpUl.getX(), tmpUl.getY(), tmpLr.getX() - tmpUl.getX(), tmpLr.getY() - tmpUl.getY()); |
240 |
} |
241 |
|
242 |
} |
243 |
|
244 |
if (listener.cancelDrawing()) {
|
245 |
getMapControl().cancelDrawing(); |
246 |
} |
247 |
|
248 |
//getMapControl().repaint();
|
249 |
//getMapControl().drawMap(true);
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. Desactivamos
|
254 |
* los flags de redimensionado y a partir de la selecci?n del usuario
|
255 |
* creamos un nuevo extent para la imagen. Con este extent creamos una nueva
|
256 |
* capa que sustituir? a la anterior.
|
257 |
*
|
258 |
* @param e MouseEvent
|
259 |
*
|
260 |
* @throws BehaviorException Excepci?n lanzada cuando el Behavior.
|
261 |
*/
|
262 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
263 |
|
264 |
if (e.getButton() == MouseEvent.BUTTON1 && isResizable) { |
265 |
//Desactivamos los flags de redimensionado
|
266 |
for(int i=0;i<redimActive.length;i++) |
267 |
redimActive[i] = false;
|
268 |
//Asignamos el nuevo extent a la imagen
|
269 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
270 |
Extent ext = new Extent(vp.toMapPoint((int)tmpUl.getX(), (int)tmpUl.getY()).getX(), |
271 |
vp.toMapPoint((int)tmpUl.getX(), (int)tmpUl.getY()).getY(), |
272 |
vp.toMapPoint((int)tmpLr.getX(), (int)tmpLr.getY()).getX(), |
273 |
vp.toMapPoint((int)tmpLr.getX(), (int)tmpLr.getY()).getY()); |
274 |
|
275 |
|
276 |
if(this.lyrGeoRaster != null){ |
277 |
|
278 |
((FLyrGeoRaster)getMapControl().getMapContext().getLayers().getLayer(lyrGeoRaster.getName())).setAssignExtent(ext); |
279 |
|
280 |
//Si la capa tiene puntos de control hacemos un update de estos
|
281 |
//a su posici?n para que se actualicen los controles
|
282 |
for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++){ |
283 |
|
284 |
Point2D center = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint);
|
285 |
lyrGeoRaster.getFLyrPoints().setMiniExtent( i, |
286 |
center, |
287 |
lyrGeoRaster.getGeoDialog().getZoomControlLeft().getCanvas().initViewPort(vp, center, lyrGeoRaster.getFLyrPoints().getPoint(i).leftViewPort), |
288 |
false);
|
289 |
} |
290 |
|
291 |
//Repintamos la vista y las mini im?genes
|
292 |
int selection = lyrGeoRaster.getGeoDialog().getSelectedPoint();
|
293 |
GeoPoint gp = lyrGeoRaster.getFLyrPoints().getPoint(selection); |
294 |
Point2D px = null; |
295 |
Point2D map = null; |
296 |
if(gp != null){ |
297 |
px = gp.pixelPoint; |
298 |
map = gp.mapPoint; |
299 |
} |
300 |
|
301 |
lyrGeoRaster.getFLyrPoints().getPointManager().updateData(selection + 1, px, map, lyrGeoRaster.getGeoDialog(), theView);
|
302 |
if(px == null && map == null) |
303 |
theView.getMapControl().getMapContext().invalidate(); |
304 |
|
305 |
tmpUl = null;
|
306 |
tmpLr = null;
|
307 |
|
308 |
} |
309 |
isResizable = false;
|
310 |
} |
311 |
} |
312 |
|
313 |
/**
|
314 |
* Al arrastrar cuando se ha pulsado sobre el marco de la imagen recalculamos
|
315 |
* el marco de la imagen
|
316 |
*
|
317 |
* @param e MouseEvent
|
318 |
*/
|
319 |
public void mouseDragged(MouseEvent e) { |
320 |
double longLadoX = Math.abs(tmpLr.getX() - tmpUl.getX()); |
321 |
double longLadoY = Math.abs(tmpLr.getY() - tmpUl.getY()); |
322 |
double coordCentro = 0D; |
323 |
|
324 |
//Guardamos los puntos iniciales para poder reponerlos si excedemos el tama?o m?nimo
|
325 |
Point2D antUl = tmpUl;
|
326 |
Point2D antLr = tmpLr;
|
327 |
|
328 |
coordCentro = tmpLr.getY() + (Math.abs(tmpLr.getY() - tmpUl.getY()) / 2); |
329 |
if(redimActive[0]){//vertical derecha |
330 |
double newLadoX = (e.getX() - tmpUl.getX());
|
331 |
double newLadoY = (newLadoX * longLadoY) / longLadoX;
|
332 |
tmpUl = new Point2D.Double(tmpUl.getX(), coordCentro + (newLadoY/2)); |
333 |
tmpLr = new Point2D.Double(e.getX(), coordCentro - (newLadoY/2)); |
334 |
} |
335 |
if(redimActive[1]){//vertical izquierda |
336 |
double newLadoX = (e.getX() - tmpLr.getX());
|
337 |
double newLadoY = (newLadoX * longLadoY) / longLadoX;
|
338 |
tmpLr = new Point2D.Double(tmpLr.getX(), coordCentro + (newLadoY/2)); |
339 |
tmpUl = new Point2D.Double(e.getX(), coordCentro - (newLadoY/2)); |
340 |
} |
341 |
|
342 |
coordCentro = tmpLr.getX() - (Math.abs(tmpLr.getX() - tmpUl.getX()) / 2); |
343 |
if(redimActive[2]){//horizontal abajo |
344 |
double newLadoY = (e.getY() - tmpLr.getY());
|
345 |
double newLadoX = (newLadoY * longLadoX) / longLadoY;
|
346 |
tmpLr = new Point2D.Double(coordCentro + (newLadoX/2), tmpLr.getY()); |
347 |
tmpUl = new Point2D.Double(coordCentro - (newLadoX/2), e.getY()); |
348 |
} |
349 |
if(redimActive[3]){//horizontal arriba |
350 |
double newLadoY = (e.getY() - tmpUl.getY());
|
351 |
double newLadoX = (newLadoY * longLadoX) / longLadoY;
|
352 |
tmpUl = new Point2D.Double(coordCentro + (newLadoX/2), tmpUl.getY()); |
353 |
tmpLr = new Point2D.Double(coordCentro - (newLadoX/2), e.getY()); |
354 |
} |
355 |
if(redimActive[4]){//inclinado |
356 |
double distX = (e.getX() - pointInit.getX());
|
357 |
double distY = (e.getY() - pointInit.getY());
|
358 |
double incrLadoX = 0D, incrLadoY = 0D; |
359 |
|
360 |
if(longLadoY <= longLadoX){
|
361 |
incrLadoX = distX; |
362 |
incrLadoY = (incrLadoX * longLadoY) / longLadoX; |
363 |
}else{
|
364 |
incrLadoY = distY; |
365 |
incrLadoX = (incrLadoY * longLadoX) / longLadoY; |
366 |
} |
367 |
if(distX > 0 && e.getX() > lr.getX()){ |
368 |
tmpUl = new Point2D.Double(rectInit.getMinX() - Math.abs(incrLadoX), rectInit.getMinY() + Math.abs(incrLadoY)); |
369 |
tmpLr = new Point2D.Double(rectInit.getMaxX() + Math.abs(incrLadoX), rectInit.getMaxY() - Math.abs(incrLadoY)); |
370 |
}else if(distX < 0 && e.getX() < ul.getX()){ |
371 |
tmpUl = new Point2D.Double(rectInit.getMinX() - Math.abs(incrLadoX), rectInit.getMinY() + Math.abs(incrLadoY)); |
372 |
tmpLr = new Point2D.Double(rectInit.getMaxX() + Math.abs(incrLadoX), rectInit.getMaxY() - Math.abs(incrLadoY)); |
373 |
}else if(distX > 0 && e.getX() < lr.getX() && e.getX() > ul.getX()){ |
374 |
tmpUl = new Point2D.Double(rectInit.getMinX() + Math.abs(incrLadoX), rectInit.getMinY() - Math.abs(incrLadoY)); |
375 |
tmpLr = new Point2D.Double(rectInit.getMaxX() - Math.abs(incrLadoX), rectInit.getMaxY() + Math.abs(incrLadoY)); |
376 |
}else if(distX < 0 && e.getX() < lr.getX() && e.getX() > ul.getX()){ |
377 |
tmpUl = new Point2D.Double(rectInit.getMinX() + Math.abs(incrLadoX), rectInit.getMinY() - Math.abs(incrLadoY)); |
378 |
tmpLr = new Point2D.Double(rectInit.getMaxX() - Math.abs(incrLadoX), rectInit.getMaxY() + Math.abs(incrLadoY)); |
379 |
} |
380 |
} |
381 |
//A partir de un tama?o m?nimo no reducimos m?s
|
382 |
if((tmpLr.getX() - tmpUl.getX()) < 25 || (tmpUl.getY() - tmpLr.getY()) < 25){ |
383 |
tmpUl = antUl; |
384 |
tmpLr = antLr; |
385 |
} |
386 |
|
387 |
getMapControl().repaint(); |
388 |
} |
389 |
|
390 |
/**
|
391 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setListener(org.gvsig.georeferencing.fmap.tools.ToolListener)
|
392 |
*/
|
393 |
public void setListener(ToolListener listener) { |
394 |
this.listener = (RectangleListener) listener;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
|
399 |
*/
|
400 |
public ToolListener getListener() {
|
401 |
return listener;
|
402 |
} |
403 |
|
404 |
/**
|
405 |
* Cuando movemos el rat?n detecta si estamos en el marco de la
|
406 |
* imagen y pone el icono del cursor del rat?n adecuado.
|
407 |
*/
|
408 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
409 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
410 |
|
411 |
try{
|
412 |
loadLayer(); |
413 |
}catch(InstantiationException exc){ |
414 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
415 |
PluginServices.getText(this, "error_capa_puntos")); |
416 |
return;
|
417 |
}catch(ClassCastException exc){ |
418 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
419 |
PluginServices.getText(this, "error_capa_puntos")); |
420 |
return;
|
421 |
} |
422 |
|
423 |
double wcX = vp.toMapPoint(e.getX(), e.getY()).getX();
|
424 |
double wcY = vp.toMapPoint(e.getX(), e.getY()).getY();
|
425 |
|
426 |
double minX = lyrGeoRaster.getAssignExtent().getMin().getX();
|
427 |
double minY = lyrGeoRaster.getAssignExtent().getMin().getY();
|
428 |
double maxX = lyrGeoRaster.getAssignExtent().getMax().getX();
|
429 |
double maxY = lyrGeoRaster.getAssignExtent().getMax().getY();
|
430 |
|
431 |
//Calculamos el borde sobre el cual cambiar? el puntero del rat?n y la longitud de la esquina
|
432 |
|
433 |
WIDTH_BORDER = (int)Math.round((maxX - minX) * 0.02); |
434 |
LONG_CORNER = (int)Math.round((maxX - minX) * 0.03); |
435 |
if(WIDTH_BORDER < 15) |
436 |
WIDTH_BORDER = 15;
|
437 |
if(LONG_CORNER < 20) |
438 |
LONG_CORNER = 20;
|
439 |
|
440 |
int iconPosActive = -1; |
441 |
|
442 |
//Flecha horizontal
|
443 |
if( ((wcX > minX && wcX < minX + WIDTH_BORDER) ||
|
444 |
(wcX < maxX && wcX > maxX - WIDTH_BORDER )) && |
445 |
(wcY < (maxY - LONG_CORNER)) && |
446 |
(wcY > (minY + LONG_CORNER))){ |
447 |
getMapControl().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconHoriz, new Point(16, 16), "")); |
448 |
iconPosActive = 0;
|
449 |
|
450 |
}else{
|
451 |
//Flecha Vertical
|
452 |
if( ((wcY > minY && wcY < minY + WIDTH_BORDER) ||
|
453 |
(wcY < maxY && wcY > maxY - WIDTH_BORDER )) && |
454 |
(wcX < (maxX - LONG_CORNER)) && |
455 |
(wcX > (minX + LONG_CORNER))){ |
456 |
getMapControl().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconVert, new Point(16, 16), "")); |
457 |
iconPosActive = 1;
|
458 |
}else{
|
459 |
//Flecha oblicua derecha
|
460 |
if((wcX > (maxX - LONG_CORNER) && wcX < maxX &&
|
461 |
wcY < (minY + LONG_CORNER) && wcY > minY) || |
462 |
(wcX > minX && wcX < (minX + LONG_CORNER) && |
463 |
wcY < maxY && wcY > (maxY - LONG_CORNER))){ |
464 |
getMapControl().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconInclIzq, new Point(16, 16), "")); |
465 |
iconPosActive = 2;
|
466 |
}else{
|
467 |
//Flecha oblicua izquierda
|
468 |
if((wcX > minX && wcX < (minX + LONG_CORNER) &&
|
469 |
wcY < (minY + LONG_CORNER) && wcY > minY) || |
470 |
(wcX > (maxX - LONG_CORNER) && wcX < maxX && |
471 |
wcY > (maxY - LONG_CORNER) && wcY < maxY)){ |
472 |
getMapControl().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconInclDer, new Point(16, 16), "")); |
473 |
iconPosActive = 3;
|
474 |
}else{
|
475 |
getMapControl().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(defaultCursor, new Point(16, 16), "")); |
476 |
iconPosActive = -1;
|
477 |
} |
478 |
} |
479 |
} |
480 |
} |
481 |
|
482 |
//Ponemos a true el incono activado y a false el resto
|
483 |
for(int i=0;i<iconActive.length;i++){ |
484 |
if(i==iconPosActive)
|
485 |
iconActive[i] = true;
|
486 |
else
|
487 |
iconActive[i] = false;
|
488 |
} |
489 |
getMapControl().repaint(); |
490 |
} |
491 |
|
492 |
} |