Statistics
| Revision:

root / trunk / extensions / extGPS / src / org / gvsig / gps / tools / PointCalibrate.java @ 4806

History | View | Annotate | Download (3.09 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: PointCalibrate.java 4806 2006-04-11 13:25:54Z jaume $
45
* $Log$
46
* Revision 1.4  2006-04-11 13:25:54  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.3  2006/04/11 13:19:51  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.2  2006/04/10 11:21:52  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.1  2006/04/07 12:45:55  jaume
56
* *** empty log message ***
57
*
58
*
59
*/
60
package org.gvsig.gps.tools;
61

    
62
import java.awt.Component;
63
import java.awt.Cursor;
64
import java.awt.geom.Point2D;
65

    
66
import javax.swing.JOptionPane;
67

    
68
import org.gvsig.gps.GPSDriver;
69
import org.gvsig.gps.exceptions.GPSReceiverException;
70

    
71
import com.iver.andami.PluginServices;
72
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
73
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
74
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener;
75
import com.iver.cit.gvsig.gui.View;
76
import com.iver.utiles.XMLEntity;
77

    
78
public class PointCalibrate implements PointListener {
79
        
80
        private View view;
81
        private Cursor cur = java.awt.Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
82
        private String previousToolName;
83
        
84
        public PointCalibrate(View v, String previousToolName) {
85
                this.view = v;
86
                this.previousToolName = previousToolName;
87
        }
88

    
89
        public void point(PointEvent event) throws BehaviorException {
90
                Point2D pReal = view.getMapControl().getMapContext().getViewPort().toMapPoint(event.getPoint());
91
                Point2D pGeo = view.getMapControl().getProjection().toGeo(pReal);
92
                GPSDriver gps = GPSDriver.getInstance();
93
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),  "LON: "+ pGeo.getX() + "\nLAT: "+pGeo.getY());
94
                Point2D currPos = gps.getCurrentPosition();
95
                if (currPos!=null)
96
                        gps.setPosOffset(currPos.getX() - pGeo.getX(), currPos.getY() - pGeo.getY());
97
                
98
                view.getMapControl().setTool(previousToolName);
99
        }
100

    
101
        public void pointDoubleClick(PointEvent event) throws BehaviorException {}
102

    
103
        public Cursor getCursor() {
104
                return cur;
105
        }
106

    
107
        public boolean cancelDrawing() {
108
                return false;
109
        }
110

    
111
}