svn-gvsig-desktop / trunk / extensions / extGPS / src / org / gvsig / gps / tools / PointCalibrate.java @ 6389
History | View | Annotate | Download (4.29 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 6389 2006-07-17 10:27:44Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.8 2006-07-17 10:27:44 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.7 2006/04/12 06:51:35 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.5 2006/04/11 13:27:30 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.4 2006/04/11 13:25:54 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.3 2006/04/11 13:19:51 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.2 2006/04/10 11:21:52 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.1 2006/04/07 12:45:55 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
package org.gvsig.gps.tools; |
70 |
|
71 |
import java.awt.Component; |
72 |
import java.awt.Cursor; |
73 |
import java.awt.geom.Point2D; |
74 |
|
75 |
import javax.swing.JOptionPane; |
76 |
|
77 |
import org.cresques.cts.ICoordTrans; |
78 |
import org.cresques.cts.IProjection; |
79 |
import org.cresques.cts.ProjectionPool; |
80 |
import org.cresques.cts.gt2.CoordSys; |
81 |
import org.gvsig.gps.GPSDriver; |
82 |
import org.gvsig.gps.panel.GPSConfigPanel; |
83 |
|
84 |
import com.iver.andami.PluginServices; |
85 |
import com.iver.andami.ui.mdiManager.SingletonView; |
86 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
87 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
88 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
89 |
import com.iver.cit.gvsig.gui.View; |
90 |
|
91 |
public class PointCalibrate implements PointListener { |
92 |
|
93 |
private View view; |
94 |
private Cursor cur = java.awt.Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); |
95 |
private String previousToolName; |
96 |
|
97 |
public PointCalibrate(View v, String previousToolName) { |
98 |
this.view = v;
|
99 |
this.previousToolName = previousToolName;
|
100 |
} |
101 |
|
102 |
public void point(PointEvent event) throws BehaviorException { |
103 |
Point2D pReal = view.getMapControl().getMapContext().getViewPort().toMapPoint(event.getPoint());
|
104 |
|
105 |
// the geodesic projection
|
106 |
IProjection latLonProj = ProjectionPool.get("EPSG:4326");
|
107 |
|
108 |
// create a translator from view's projection to geodesic to the current
|
109 |
ICoordTrans ct = latLonProj.getCT((CoordSys) view.getMapControl().getProjection()); |
110 |
//ICoordTrans ct = new CoordTrans((CoordSys) view.getMapControl().getProjection(), (CoordSys) latLonProj);
|
111 |
|
112 |
Point2D pGeo = new Point2D.Double(); |
113 |
pGeo = ct.convert(pReal, pGeo); |
114 |
GPSDriver gps = GPSDriver.getInstance(); |
115 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), "LON: "+ pGeo.getX() + "\nLAT: "+pGeo.getY()); |
116 |
Point2D currPos = gps.getCurrentPosition();
|
117 |
if (currPos!=null) |
118 |
gps.setPosOffset(currPos.getX() - pGeo.getX(), currPos.getY() - pGeo.getY()); |
119 |
else
|
120 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "gps_not_ready") ); |
121 |
|
122 |
view.getMapControl().setTool(previousToolName); |
123 |
com.iver.andami.ui.mdiManager.View views[] = PluginServices.getMDIManager().getAllViews();
|
124 |
for (int i = 0; i < views.length; i++) { |
125 |
if (views[i] instanceof SingletonView) { |
126 |
SingletonView s = (SingletonView) views[i]; |
127 |
if (s.getViewModel().equals(GPSConfigPanel.viewModel))
|
128 |
PluginServices.getMDIManager().addView(s); |
129 |
} |
130 |
} |
131 |
|
132 |
} |
133 |
|
134 |
public void pointDoubleClick(PointEvent event) throws BehaviorException {} |
135 |
|
136 |
public Cursor getCursor() { |
137 |
return cur;
|
138 |
} |
139 |
|
140 |
public boolean cancelDrawing() { |
141 |
return false; |
142 |
} |
143 |
|
144 |
} |