root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / gui / Panels / ZoomControlPanel.java @ 3064
History | View | Annotate | Download (19.2 KB)
1 |
package com.iver.cit.gvsig.gui.Panels; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Canvas; |
5 |
import java.awt.Color; |
6 |
import java.awt.Component; |
7 |
import java.awt.Graphics; |
8 |
import java.awt.Graphics2D; |
9 |
import java.awt.GridBagConstraints; |
10 |
import java.awt.GridBagLayout; |
11 |
import java.awt.Image; |
12 |
import java.awt.event.ActionEvent; |
13 |
import java.awt.event.ActionListener; |
14 |
import java.awt.event.MouseEvent; |
15 |
import java.awt.event.MouseListener; |
16 |
import java.awt.event.MouseMotionListener; |
17 |
import java.awt.geom.Point2D; |
18 |
import java.awt.geom.Rectangle2D; |
19 |
import java.awt.image.BufferedImage; |
20 |
|
21 |
import javax.swing.ImageIcon; |
22 |
import javax.swing.JButton; |
23 |
import javax.swing.JOptionPane; |
24 |
import javax.swing.JPanel; |
25 |
|
26 |
import com.iver.andami.PluginServices; |
27 |
import com.iver.cit.gvsig.fmap.DriverException; |
28 |
import com.iver.cit.gvsig.fmap.ViewPort; |
29 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
30 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
31 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
32 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
33 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
34 |
import com.iver.cit.gvsig.gui.View; |
35 |
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog; |
36 |
|
37 |
/**
|
38 |
* Panel que contiene los controles de zoom de la vista para
|
39 |
* afinar en la georreferenciaci?n.
|
40 |
*
|
41 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
42 |
*
|
43 |
*/
|
44 |
public class ZoomControlPanel extends JPanel implements ActionListener{ |
45 |
private JPanel pImage = null; |
46 |
private JPanel pControls = null; |
47 |
private JButton bZoomMas = null; |
48 |
private JButton bZoomMenos = null; |
49 |
|
50 |
private int sX = 140, sY = 140; |
51 |
private CanvasZone canvas = null; |
52 |
private ViewPort viewPort = null; |
53 |
|
54 |
public FLyrPoints lyrPoints = null; |
55 |
public FLyrGeoRaster lyrGeoRaster = null; |
56 |
public GeoreferencingDialog dialog = null; |
57 |
private boolean rightControl = false; |
58 |
|
59 |
|
60 |
|
61 |
/**
|
62 |
* This is the default constructor
|
63 |
*/
|
64 |
public ZoomControlPanel(boolean rightControl) { |
65 |
super();
|
66 |
this.rightControl = rightControl;
|
67 |
initialize(rightControl); |
68 |
} |
69 |
|
70 |
/**
|
71 |
* This method initializes this
|
72 |
*
|
73 |
* @return void
|
74 |
*/
|
75 |
private void initialize(boolean rightControl) { |
76 |
|
77 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
78 |
if(rightControl)
|
79 |
gridBagConstraints1.gridx = 1;
|
80 |
else
|
81 |
gridBagConstraints1.gridx = 0;
|
82 |
gridBagConstraints1.gridy = 0;
|
83 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
84 |
if(rightControl)
|
85 |
gridBagConstraints.gridx = 0;
|
86 |
else
|
87 |
gridBagConstraints.gridx = 1;
|
88 |
gridBagConstraints.gridy = 0;
|
89 |
this.setLayout(new GridBagLayout()); |
90 |
this.setPreferredSize(new java.awt.Dimension(175,142)); |
91 |
this.setSize(new java.awt.Dimension(175,142)); |
92 |
this.setLocation(new java.awt.Point(0,0)); |
93 |
this.add(getPImage(), gridBagConstraints);
|
94 |
this.add(getPControls(), gridBagConstraints1);
|
95 |
} |
96 |
|
97 |
/**
|
98 |
* Carga las capas de puntos y de raster georreferenciado
|
99 |
*
|
100 |
*/
|
101 |
public void loadLayer() throws InstantiationException{ |
102 |
//Cargamos la capa
|
103 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
104 |
for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){ |
105 |
FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i); |
106 |
if( lyr instanceof FLyrGeoRaster && |
107 |
lyr.getName().startsWith("*") &&
|
108 |
lyr.isActive()){ |
109 |
lyrGeoRaster = (FLyrGeoRaster)lyr; |
110 |
lyrPoints = lyrGeoRaster.getFLyrPoints(); |
111 |
} |
112 |
} |
113 |
if(lyrGeoRaster == null || lyrPoints == null) |
114 |
throw new InstantiationException("No se ha podido instanciar la capa de puntos o georreferenciada"); |
115 |
|
116 |
dialog = lyrGeoRaster.getGeoDialog(); |
117 |
} |
118 |
|
119 |
/**
|
120 |
* This method initializes jPanel
|
121 |
*
|
122 |
* @return javax.swing.JPanel
|
123 |
*/
|
124 |
private JPanel getPImage() { |
125 |
if (pImage == null) { |
126 |
pImage = new JPanel(); |
127 |
BorderLayout borderLayout = new BorderLayout(); |
128 |
pImage.setLayout(borderLayout); |
129 |
pImage.setPreferredSize(new java.awt.Dimension(140,140)); |
130 |
pImage.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); |
131 |
if(canvas == null){ |
132 |
canvas = new CanvasZone(sX, sY, this); |
133 |
canvas.setVisible(false);
|
134 |
canvas.addMouseListener(canvas); |
135 |
canvas.addMouseMotionListener(canvas); |
136 |
} |
137 |
pImage.add(canvas, BorderLayout.CENTER);
|
138 |
|
139 |
} |
140 |
return pImage;
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* This method initializes jPanel1
|
145 |
*
|
146 |
* @return javax.swing.JPanel
|
147 |
*/
|
148 |
private JPanel getPControls() { |
149 |
if (pControls == null) { |
150 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
151 |
gridBagConstraints3.gridx = 0;
|
152 |
gridBagConstraints3.insets = new java.awt.Insets(5,0,0,0); |
153 |
gridBagConstraints3.gridy = 1;
|
154 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
155 |
gridBagConstraints2.gridx = 0;
|
156 |
gridBagConstraints2.gridy = 0;
|
157 |
pControls = new JPanel(); |
158 |
pControls.setLayout(new GridBagLayout()); |
159 |
pControls.setPreferredSize(new java.awt.Dimension(33,140)); |
160 |
pControls.add(getBZoomMas(), gridBagConstraints2); |
161 |
pControls.add(getBZoomMenos(), gridBagConstraints3); |
162 |
} |
163 |
return pControls;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* This method initializes jButton
|
168 |
*
|
169 |
* @return javax.swing.JButton
|
170 |
*/
|
171 |
private JButton getBZoomMas() { |
172 |
if (bZoomMas == null) { |
173 |
bZoomMas = new JButton(); |
174 |
bZoomMas.setPreferredSize(new java.awt.Dimension(25,25)); |
175 |
bZoomMas.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/aumentar.png"))); |
176 |
bZoomMas.addActionListener(this);
|
177 |
} |
178 |
return bZoomMas;
|
179 |
} |
180 |
|
181 |
/**
|
182 |
* This method initializes jButton
|
183 |
*
|
184 |
* @return javax.swing.JButton
|
185 |
*/
|
186 |
private JButton getBZoomMenos() { |
187 |
if (bZoomMenos == null) { |
188 |
bZoomMenos = new JButton(); |
189 |
bZoomMenos.setPreferredSize(new java.awt.Dimension(25,25)); |
190 |
bZoomMenos.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/disminuir.png"))); |
191 |
bZoomMenos.addActionListener(this);
|
192 |
} |
193 |
return bZoomMenos;
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* @param viewPort The viewPort to set.
|
198 |
*/
|
199 |
public void setViewPort(ViewPort viewPort) { |
200 |
this.viewPort = viewPort;
|
201 |
canvas.setViewPort(this.viewPort);
|
202 |
} |
203 |
|
204 |
/**
|
205 |
*Llama a la funci?n de pintado del canvas con los par?metros que tenga en ese momento
|
206 |
*/
|
207 |
public void draw(){ |
208 |
if(canvas != null){ |
209 |
canvas.repaint(); |
210 |
} |
211 |
} |
212 |
|
213 |
/**
|
214 |
* Asigna al canvas la propiedad de visibilidad a verdadero o falso.
|
215 |
* @param visible true para mostrar el canvas y false para ocultarlo
|
216 |
*/
|
217 |
public void setVisible(boolean visible){ |
218 |
canvas.setVisible(visible); |
219 |
if(!visible)
|
220 |
canvas.setSize(0,0); |
221 |
else{
|
222 |
canvas.setSize(sX, sY); |
223 |
} |
224 |
canvas.repaint(); |
225 |
} |
226 |
|
227 |
/**
|
228 |
* Asigna el punto sobre el que se centrar? el zoom de la minimagen
|
229 |
* @param pto
|
230 |
*/
|
231 |
public void setCenterPoint(Point2D pto){ |
232 |
canvas.setCenterPoint(pto); |
233 |
} |
234 |
|
235 |
/**
|
236 |
* Recupera el n?mero de punto que se est? tratando
|
237 |
* @param n
|
238 |
*/
|
239 |
public int getNumberPoint(){ |
240 |
try{
|
241 |
if(getDialog().getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 0) |
242 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
243 |
else
|
244 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
245 |
}catch(NullPointerException exc){ |
246 |
return -1; |
247 |
} |
248 |
} |
249 |
|
250 |
/**
|
251 |
* Manejo de los controles zoom m?s y zoom menos
|
252 |
*/
|
253 |
public void actionPerformed(ActionEvent e) { |
254 |
if(e.getSource() == bZoomMas){
|
255 |
canvas.calcZoom(0.6);
|
256 |
canvas.repaint(); |
257 |
} |
258 |
|
259 |
if(e.getSource() == bZoomMenos){
|
260 |
canvas.calcZoom(1.8);
|
261 |
canvas.repaint(); |
262 |
} |
263 |
|
264 |
} |
265 |
|
266 |
|
267 |
/**
|
268 |
* @return Returns the rightControl.
|
269 |
*/
|
270 |
public boolean isRightControl() { |
271 |
return rightControl;
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* @return Returns the lyrGeoRaster.
|
276 |
*/
|
277 |
public FLyrGeoRaster getLyrGeoRaster() {
|
278 |
return lyrGeoRaster;
|
279 |
} |
280 |
|
281 |
|
282 |
/**
|
283 |
* @return Returns the lyrPoints.
|
284 |
*/
|
285 |
public FLyrPoints getLyrPoints() {
|
286 |
try{
|
287 |
if(lyrPoints == null) |
288 |
this.loadLayer();
|
289 |
}catch(InstantiationException e){ |
290 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
291 |
PluginServices.getText(this, "error_capa_puntos")); |
292 |
} |
293 |
return lyrPoints;
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* @return Returns the dialog.
|
298 |
*/
|
299 |
public GeoreferencingDialog getDialog() {
|
300 |
try{
|
301 |
if(dialog == null) |
302 |
this.loadLayer();
|
303 |
}catch(InstantiationException e){ |
304 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
305 |
PluginServices.getText(this, "error_capa_puntos")); |
306 |
} |
307 |
return dialog;
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* Asigna el viewPort recalculado
|
312 |
* @param vp ViewPort
|
313 |
*/
|
314 |
public void setNewViewPort(ViewPort vp){ |
315 |
canvas.setNewViewPort(vp); |
316 |
} |
317 |
|
318 |
/**
|
319 |
*Limpia el canvas
|
320 |
*/
|
321 |
public void clear(){ |
322 |
canvas.setCleanCanvas(true);
|
323 |
canvas.repaint(); |
324 |
} |
325 |
|
326 |
/**
|
327 |
* Control que representa la zona de dibujado de la ventana. Este se encarga de
|
328 |
* repintar el contenido sobre el Graphics2D a partir del viewPort que se le pase
|
329 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
330 |
*/
|
331 |
class CanvasZone extends Canvas implements MouseListener, MouseMotionListener{ |
332 |
private ZoomControlPanel zoomControl = null; |
333 |
private int ancho; |
334 |
private int alto; |
335 |
private FLayers flayers = null; |
336 |
private ViewPort viewPort = null; |
337 |
private ViewPort newViewPort = null; |
338 |
private Point2D centerPoint = null; |
339 |
private int zoom = 20; |
340 |
private boolean dragged = false; |
341 |
private Image dobleBuffer = null; |
342 |
private BufferedImage imgTmp = null; |
343 |
private Graphics dbGraphics = null; |
344 |
private boolean cleanCanvas = false; |
345 |
|
346 |
/**
|
347 |
* Puntos inicial y final para el desplazamiento del punto de control
|
348 |
*/
|
349 |
private Point2D ptoIni = null, ptoFin = null; |
350 |
private Point2D movDragged = null, initCrux = null; |
351 |
|
352 |
|
353 |
public CanvasZone( int anc,int alt, ZoomControlPanel zc) { |
354 |
zoomControl = zc; |
355 |
ancho = anc; |
356 |
alto = alt; |
357 |
|
358 |
this.setSize(ancho, alto);
|
359 |
this.setBackground(Color.WHITE); |
360 |
|
361 |
imgTmp = new BufferedImage(this.ancho, this.alto, BufferedImage.TYPE_INT_ARGB); |
362 |
dobleBuffer = new BufferedImage(this.ancho, this.alto, BufferedImage.TYPE_INT_ARGB); |
363 |
dbGraphics = dobleBuffer.getGraphics(); |
364 |
} |
365 |
|
366 |
/**
|
367 |
* Asigna el viewPort
|
368 |
* @param vp ViewPort
|
369 |
*/
|
370 |
public void setViewPort(ViewPort vp){ |
371 |
this.viewPort = vp;
|
372 |
this.initViewPort();
|
373 |
} |
374 |
|
375 |
/**
|
376 |
* Asigna el viewPort recalculado
|
377 |
* @param vp ViewPort
|
378 |
*/
|
379 |
public void setNewViewPort(ViewPort vp){ |
380 |
this.newViewPort = vp;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* Calcula el zoom dependiendo del factor de escala pasado por
|
385 |
* par?metro.
|
386 |
*/
|
387 |
public void calcZoom(double factor){ |
388 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
389 |
double nuevoX = centerPoint.getX() -
|
390 |
((newViewPort.getExtent().getWidth() * factor) / 2.0);
|
391 |
double nuevoY = centerPoint.getY() -
|
392 |
((newViewPort.getExtent().getHeight() * factor) / 2.0);
|
393 |
r.x = nuevoX; |
394 |
r.y = nuevoY; |
395 |
r.width = newViewPort.getExtent().getWidth() * factor; |
396 |
r.height = newViewPort.getExtent().getHeight() * factor; |
397 |
newViewPort.setExtent(r); |
398 |
} |
399 |
|
400 |
/**
|
401 |
*Calculamos el viewPort para el zoom de la minimagen
|
402 |
*/
|
403 |
public void initViewPort(){ |
404 |
if(centerPoint != null){ |
405 |
newViewPort = this.viewPort.cloneViewPort();
|
406 |
//Hallamos la relaci?n entre el pixel y las WC a partir de la imagen de la capa
|
407 |
double relacionPixelWcWidth = ((viewPort.getExtent().getMaxX() - viewPort.getExtent().getMinX()) / zoom)/this.getWidth(); |
408 |
double relacionPixelWcHeight = ((viewPort.getExtent().getMaxY() - viewPort.getExtent().getMinY()) / zoom)/this.getHeight(); |
409 |
|
410 |
double wcOriginX = centerPoint.getX() - ((viewPort.getImageWidth()*relacionPixelWcWidth)/2); |
411 |
double wcOriginY = centerPoint.getY() - ((viewPort.getImageHeight()*relacionPixelWcHeight)/2); |
412 |
|
413 |
double wcDstMinX = wcOriginX;
|
414 |
double wcDstMinY = wcOriginY;
|
415 |
double wcDstMaxX = wcDstMinX + (viewPort.getImageWidth()*relacionPixelWcWidth);
|
416 |
double wcDstMaxY = wcDstMinY + (viewPort.getImageHeight()*relacionPixelWcHeight);
|
417 |
|
418 |
double wcDstWidth = wcDstMaxX - wcDstMinX;
|
419 |
double wcDstHeight = wcDstMaxY - wcDstMinY;
|
420 |
|
421 |
Rectangle2D ext = new Rectangle2D.Double(wcDstMinX, wcDstMinY, wcDstWidth, wcDstHeight); |
422 |
|
423 |
newViewPort.setExtent(ext); |
424 |
newViewPort.setImageSize(new java.awt.Dimension(this.getWidth(), this.getHeight())); |
425 |
newViewPort.setScale(); |
426 |
} |
427 |
} |
428 |
|
429 |
public void loadBuffer(){ |
430 |
|
431 |
Graphics2D gTmp = (Graphics2D)imgTmp.getGraphics(); |
432 |
|
433 |
if(!dragged){
|
434 |
dbGraphics.setColor( Color.WHITE );
|
435 |
dbGraphics.fillRect( 0,0,ancho,alto ); |
436 |
gTmp.setColor( Color.WHITE );
|
437 |
gTmp.fillRect( 0,0,ancho,alto ); |
438 |
|
439 |
try{
|
440 |
if(newViewPort != null){ |
441 |
if(zoomControl.getNumberPoint() != -1){//Salvamos el miniextent si hay puntos en la lista |
442 |
if(!zoomControl.isRightControl())
|
443 |
zoomControl.getLyrPoints().setMiniExtent(zoomControl.getNumberPoint(), |
444 |
centerPoint, |
445 |
newViewPort, |
446 |
true);
|
447 |
else
|
448 |
zoomControl.getLyrPoints().setMiniExtent(zoomControl.getNumberPoint(), |
449 |
centerPoint, |
450 |
newViewPort, |
451 |
false);
|
452 |
} |
453 |
//Si no tenemos las capas las cargamos
|
454 |
if(flayers == null){ |
455 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
456 |
flayers = theView.getMapControl().getMapContext().getLayers(); |
457 |
} |
458 |
//dibujamos
|
459 |
flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() { |
460 |
public boolean isCanceled() { |
461 |
return false; |
462 |
} |
463 |
},flayers.getFMap().getScaleView()); |
464 |
flayers.draw(null, gTmp, newViewPort,new Cancellable() { |
465 |
public boolean isCanceled() { |
466 |
return false; |
467 |
} |
468 |
},flayers.getFMap().getScaleView()); |
469 |
} |
470 |
}catch (DriverException e) {
|
471 |
e.printStackTrace(); |
472 |
} |
473 |
}else{
|
474 |
double x, y;
|
475 |
if(movDragged != null){ |
476 |
x = (movDragged.getX() - ptoIni.getX()) + initCrux.getX(); |
477 |
y = (movDragged.getY() - ptoIni.getY()) + initCrux.getY(); |
478 |
}else{
|
479 |
x = ptoIni.getX() + initCrux.getX(); |
480 |
y = ptoIni.getY() + initCrux.getY(); |
481 |
} |
482 |
|
483 |
dbGraphics.drawImage(imgTmp, 0, 0, null); |
484 |
dbGraphics.setColor( Color.RED );
|
485 |
dbGraphics.drawLine((int)(x - 5), (int)y, (int)(x + 5), (int)y); |
486 |
dbGraphics.drawLine((int)x, (int)(y - 5), (int)x, (int)(y + 5)); |
487 |
} |
488 |
} |
489 |
|
490 |
|
491 |
public void update(Graphics g){ |
492 |
this.paint(g);
|
493 |
} |
494 |
|
495 |
/**
|
496 |
* Dibuja sobre el Graphics2D pasado el viewPort solicitado a
|
497 |
* la lista de capas.
|
498 |
* @param g
|
499 |
*/
|
500 |
public void paint( Graphics g ) { |
501 |
loadBuffer(); |
502 |
if(!cleanCanvas)
|
503 |
g.drawImage(dobleBuffer, 0, 0, null); |
504 |
else{
|
505 |
g.setColor( Color.WHITE );
|
506 |
g.fillRect( 0,0,ancho,alto ); |
507 |
cleanCanvas = false;
|
508 |
} |
509 |
} |
510 |
|
511 |
/**
|
512 |
* Asigna el punto donde se centrar? la vista de la minimagen
|
513 |
* @param pto Punto central.
|
514 |
*/
|
515 |
public void setCenterPoint(Point2D pto){ |
516 |
this.centerPoint = pto;
|
517 |
} |
518 |
|
519 |
/* (non-Javadoc)
|
520 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
521 |
*/
|
522 |
public void mouseClicked(MouseEvent ev) { |
523 |
|
524 |
} |
525 |
|
526 |
/* (non-Javadoc)
|
527 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
528 |
*/
|
529 |
public void mouseEntered(MouseEvent arg0) { |
530 |
|
531 |
} |
532 |
|
533 |
/* (non-Javadoc)
|
534 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
535 |
*/
|
536 |
public void mouseExited(MouseEvent arg0) { |
537 |
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* Al pulsar el rat?n sobre la minimagen permitimos que se pueda desplazar la cruz
|
542 |
*
|
543 |
*/
|
544 |
public void mousePressed(MouseEvent ev) { |
545 |
this.movDragged = ptoIni = ev.getPoint();
|
546 |
try{
|
547 |
zoomControl.loadLayer(); |
548 |
initCrux = new Point2D.Double(); |
549 |
initCrux.setLocation(this.getWidth() / 2, this.getHeight() / 2); |
550 |
this.dragged = true; |
551 |
repaint(); |
552 |
}catch(InstantiationException e){ |
553 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
554 |
PluginServices.getText(this, "error_capa_puntos")); |
555 |
} |
556 |
} |
557 |
|
558 |
/* (non-Javadoc)
|
559 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
|
560 |
*/
|
561 |
public void mouseReleased(MouseEvent ev) { |
562 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
563 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
564 |
ptoFin = ev.getPoint(); |
565 |
this.dragged = false; |
566 |
|
567 |
double destX = newViewPort.getExtent().getMinX() + ((ptoFin.getX() * (centerPoint.getX() - newViewPort.getExtent().getMinX())) / ptoIni.getX());
|
568 |
double destY = newViewPort.getExtent().getMinY() + (((this.getHeight() - ptoFin.getY()) * (centerPoint.getY() - newViewPort.getExtent().getMinY())) / (this.getHeight() - ptoIni.getY())); |
569 |
|
570 |
if(flayers == null) |
571 |
flayers = theView.getMapControl().getMapContext().getLayers(); |
572 |
for(int i=0;i<flayers.getLayersCount();i++){ |
573 |
FLayer lyr = flayers.getLayer(i); |
574 |
if(lyr instanceof FLyrPoints){ |
575 |
FLyrPoints lp = (FLyrPoints)lyr; |
576 |
|
577 |
if(zoomControl.isRightControl()){ //Control de actualizaci?n de pixel de imagen |
578 |
Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(destX, destY);
|
579 |
|
580 |
if(pixelImg == null){ |
581 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
582 |
PluginServices.getText(this, "fuera_de_extent")); |
583 |
return;
|
584 |
} |
585 |
zoomControl.getLyrGeoRaster().updateData( Integer.valueOf(zoomControl.getDialog().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue(),
|
586 |
pixelImg, |
587 |
null,
|
588 |
zoomControl.getDialog(), |
589 |
theView, |
590 |
lp); |
591 |
|
592 |
}else{ //Control de actualizaci?n de coordenadas del mundo |
593 |
Point2D mapPoint = new Point2D.Double(); |
594 |
mapPoint.setLocation(destX, destY); |
595 |
zoomControl.getLyrGeoRaster().updateData( Integer.valueOf(zoomControl.getDialog().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue(),
|
596 |
null,
|
597 |
mapPoint, |
598 |
zoomControl.getDialog(), |
599 |
theView, |
600 |
lp); |
601 |
} |
602 |
} |
603 |
} |
604 |
|
605 |
|
606 |
repaint(); |
607 |
} |
608 |
|
609 |
/* (non-Javadoc)
|
610 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
611 |
*/
|
612 |
public void mouseDragged(MouseEvent ev) { |
613 |
this.movDragged = ev.getPoint();
|
614 |
repaint(); |
615 |
|
616 |
} |
617 |
|
618 |
/* (non-Javadoc)
|
619 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
|
620 |
*/
|
621 |
public void mouseMoved(MouseEvent arg0) { |
622 |
|
623 |
} |
624 |
|
625 |
/**
|
626 |
* @param cleanCanvas The cleanCanvas to set.
|
627 |
*/
|
628 |
public void setCleanCanvas(boolean cleanCanvas) { |
629 |
this.cleanCanvas = cleanCanvas;
|
630 |
} |
631 |
|
632 |
} |
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
} |