3 |
3 |
import java.awt.BorderLayout;
|
4 |
4 |
import java.awt.Color;
|
5 |
5 |
import java.awt.Component;
|
|
6 |
import java.awt.Cursor;
|
6 |
7 |
import java.awt.Graphics;
|
7 |
8 |
import java.awt.Graphics2D;
|
8 |
9 |
import java.awt.GridBagConstraints;
|
9 |
10 |
import java.awt.GridBagLayout;
|
10 |
11 |
import java.awt.Image;
|
|
12 |
import java.awt.Point;
|
|
13 |
import java.awt.Toolkit;
|
11 |
14 |
import java.awt.event.ActionEvent;
|
12 |
15 |
import java.awt.event.ActionListener;
|
13 |
16 |
import java.awt.event.MouseEvent;
|
... | ... | |
24 |
27 |
|
25 |
28 |
import com.iver.andami.PluginServices;
|
26 |
29 |
import com.iver.cit.gvsig.fmap.DriverException;
|
|
30 |
import com.iver.cit.gvsig.fmap.MapControl;
|
27 |
31 |
import com.iver.cit.gvsig.fmap.ViewPort;
|
28 |
32 |
import com.iver.cit.gvsig.fmap.layers.FLayers;
|
29 |
33 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
|
... | ... | |
363 |
367 |
* aunque se pinche sobre el canvas no se capture el evento
|
364 |
368 |
*/
|
365 |
369 |
private boolean enableEvent = true;
|
|
370 |
/**
|
|
371 |
* Puntos inicial y final para el desplazamiento del punto de control
|
|
372 |
*/
|
|
373 |
private Point2D ptoIni = null, ptoFin = null;
|
|
374 |
private Point2D movDragged = null, initCrux = null;
|
|
375 |
private final Image redCursor = new ImageIcon(this.getClass().getResource(
|
|
376 |
"images/CircleCursor.png")).getImage();
|
|
377 |
private final Image blueCursor = new ImageIcon(this.getClass().getResource(
|
|
378 |
"images/RectangleCursor.png")).getImage();
|
366 |
379 |
//**********************End Vars******************************
|
367 |
380 |
|
368 |
381 |
//**********************Methods*******************************
|
... | ... | |
598 |
611 |
int ptoSelectY = (int)(this.getHeight() - arg0.getY());
|
599 |
612 |
double newWCPointY = this.newViewPort.getExtent().getMinY() + ((ptoSelectY * this.newViewPort.getExtent().getHeight()) / this.getHeight());
|
600 |
613 |
if(!zoomControl.rightControl){
|
|
614 |
System.out.println("--->"+newWCPointX+" "+newWCPointY);
|
601 |
615 |
zoomControl.getDialog().getPointManager().setTempWC(newWCPointX, newWCPointY);
|
602 |
616 |
}else{
|
603 |
617 |
Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(newWCPointX, newWCPointY);
|
... | ... | |
613 |
627 |
|
614 |
628 |
/**
|
615 |
629 |
* Al pulsar el rat?n sobre la minimagen permitimos que se pueda desplazar la cruz
|
|
630 |
*
|
616 |
631 |
*/
|
617 |
632 |
public void mousePressed(MouseEvent ev) {
|
618 |
|
|
|
633 |
this.movDragged = ptoIni = ev.getPoint();
|
|
634 |
try{
|
|
635 |
if(zoomControl.isRightControl())
|
|
636 |
setCursor(Toolkit.getDefaultToolkit().createCustomCursor(redCursor, new Point(16, 16), ""));
|
|
637 |
else
|
|
638 |
setCursor(Toolkit.getDefaultToolkit().createCustomCursor(blueCursor, new Point(16, 16), ""));
|
|
639 |
|
|
640 |
zoomControl.loadLayer();
|
|
641 |
initCrux = new Point2D.Double();
|
|
642 |
initCrux.setLocation(this.getWidth() / 2, this.getHeight() / 2);
|
|
643 |
repaint();
|
|
644 |
}catch(InstantiationException e){
|
|
645 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
|
|
646 |
PluginServices.getText(this, "error_capa_puntos"));
|
|
647 |
}
|
619 |
648 |
}
|
620 |
|
|
|
649 |
|
621 |
650 |
/* (non-Javadoc)
|
622 |
651 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
|
623 |
652 |
*/
|
624 |
653 |
public void mouseReleased(MouseEvent ev) {
|
|
654 |
View theView = null;
|
|
655 |
try{
|
|
656 |
theView = (View) PluginServices.getMDIManager().getActiveView();
|
|
657 |
}catch(ClassCastException exc){
|
|
658 |
return;
|
|
659 |
}
|
|
660 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort();
|
|
661 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
662 |
|
|
663 |
ptoFin = ev.getPoint();
|
|
664 |
|
|
665 |
double destX = newViewPort.getExtent().getMinX() + ((ptoFin.getX() * (centerPoint.getX() - newViewPort.getExtent().getMinX())) / ptoIni.getX());
|
|
666 |
double destY = newViewPort.getExtent().getMinY() + (((this.getHeight() - ptoFin.getY()) * (centerPoint.getY() - newViewPort.getExtent().getMinY())) / (this.getHeight() - ptoIni.getY()));
|
|
667 |
|
|
668 |
int nPoint = Integer.valueOf(zoomControl.getDialog().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue();
|
|
669 |
|
|
670 |
FLyrPoints lp = zoomControl.getLyrPoints();//(FLyrPoints)lyr;
|
|
671 |
|
|
672 |
if(zoomControl.isRightControl()){ //Control de actualizaci?n de pixel de imagen
|
|
673 |
Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(destX, destY);
|
|
674 |
|
|
675 |
if(pixelImg == null){
|
|
676 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
|
|
677 |
PluginServices.getText(this, "fuera_de_extent"));
|
|
678 |
return;
|
|
679 |
}
|
|
680 |
zoomControl.getDialog().getPointManager().updateData( nPoint,
|
|
681 |
pixelImg,
|
|
682 |
null,
|
|
683 |
zoomControl.getDialog(),
|
|
684 |
null);
|
|
685 |
|
|
686 |
//Actualizamos la otra miniimagen
|
|
687 |
shiftExtent(zoomControl.getLyrGeoRaster().img2World(pixelImg));
|
|
688 |
zoomControl.getDialog().getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw();
|
|
689 |
zoomControl.getDialog().getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw();
|
|
690 |
zoomControl.getDialog().getPointManager().setCurrentPixelCoord();
|
|
691 |
}else{ //Control de actualizaci?n de coordenadas del mundo
|
|
692 |
Point2D mapPoint = new Point2D.Double();
|
|
693 |
mapPoint.setLocation(destX, destY);
|
|
694 |
zoomControl.getDialog().getPointManager().updateData( nPoint,
|
|
695 |
null,
|
|
696 |
mapPoint,
|
|
697 |
zoomControl.getDialog(),
|
|
698 |
null);
|
|
699 |
|
|
700 |
//Actualizamos la otra miniimagen
|
|
701 |
shiftExtent(mapPoint);
|
|
702 |
zoomControl.getDialog().getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw();
|
|
703 |
zoomControl.getDialog().getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw();
|
|
704 |
zoomControl.getDialog().getPointManager().setCurrentWC();
|
|
705 |
}
|
|
706 |
repaint();
|
|
707 |
theView.getMapControl().getMapContext().invalidate();
|
|
708 |
}
|
|
709 |
|
|
710 |
/**
|
|
711 |
* Al pulsar el rat?n sobre la minimagen permitimos que se pueda desplazar la cruz
|
|
712 |
*/
|
|
713 |
/*public void mousePressed(MouseEvent ev) {
|
|
714 |
|
|
715 |
}
|
|
716 |
|
|
717 |
public void mouseReleased(MouseEvent ev) {
|
625 |
718 |
if(!isEnableEvent())
|
626 |
719 |
return ;
|
627 |
720 |
|
... | ... | |
674 |
767 |
}
|
675 |
768 |
repaint();
|
676 |
769 |
theView.getMapControl().getMapContext().invalidate();
|
677 |
|
}
|
|
770 |
}*/
|
678 |
771 |
|
679 |
772 |
/* (non-Javadoc)
|
680 |
773 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
681 |
774 |
*/
|
682 |
775 |
public void mouseDragged(MouseEvent ev) {
|
683 |
|
|
|
776 |
this.mouseMoved(ev);
|
684 |
777 |
}
|
685 |
778 |
//**********************End Methods***************************
|
686 |
779 |
|