Revision 6567 trunk/extensions/extGPS/src/org/gvsig/gps/panel/TestPanel.java
TestPanel.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.10 2006-07-17 10:27:44 jaume
|
|
46 |
* Revision 1.11 2006-07-31 06:46:02 jaume
|
|
47 | 47 |
* *** empty log message *** |
48 | 48 |
* |
49 | 49 |
* Revision 1.9 2006/04/12 10:03:32 jaume |
... | ... | |
79 | 79 |
* |
80 | 80 |
*/ |
81 | 81 |
/** |
82 |
*
|
|
82 |
* |
|
83 | 83 |
*/ |
84 | 84 |
package org.gvsig.gps.panel; |
85 | 85 |
|
... | ... | |
100 | 100 |
import org.cresques.cts.ICoordTrans; |
101 | 101 |
import org.cresques.cts.IProjection; |
102 | 102 |
import org.cresques.cts.ProjectionPool; |
103 |
import org.cresques.cts.gt2.CoordSys; |
|
103 |
import org.cresques.geo.Projection; |
|
104 |
import org.cresques.geo.ReProjection; |
|
104 | 105 |
import org.gvsig.gps.GPSDriver; |
105 | 106 |
import org.gvsig.gps.GPSExtension; |
106 | 107 |
import org.gvsig.gps.listeners.GPSEventListener; |
... | ... | |
126 | 127 |
private JLabel lblPos; |
127 | 128 |
private boolean alreadyStarted; |
128 | 129 |
/** |
129 |
*
|
|
130 |
* |
|
130 | 131 |
*/ |
131 | 132 |
public TestPanel() { |
132 | 133 |
super(); |
133 | 134 |
initialize(); |
134 | 135 |
} |
135 |
|
|
136 |
|
|
136 | 137 |
/** |
137 | 138 |
* This method initializes this |
138 |
*
|
|
139 |
* |
|
139 | 140 |
* @return void |
140 | 141 |
*/ |
141 | 142 |
private void initialize() { |
... | ... | |
169 | 170 |
while (portList.hasMoreElements()) { |
170 | 171 |
getCmbPorts().addItem(((CommPortIdentifier) portList.nextElement()).getName()); |
171 | 172 |
} |
172 |
|
|
173 |
|
|
173 |
|
|
174 |
|
|
174 | 175 |
} |
175 | 176 |
|
176 | 177 |
/** |
177 |
* This method initializes jTextField
|
|
178 |
*
|
|
179 |
* @return javax.swing.JTextField
|
|
180 |
*/
|
|
178 |
* This method initializes jTextField |
|
179 |
* |
|
180 |
* @return javax.swing.JTextField |
|
181 |
*/ |
|
181 | 182 |
private JTextField getTxtSampleRate() { |
182 | 183 |
if (txtSampleRate == null) { |
183 | 184 |
txtSampleRate = new JTextField(); |
184 | 185 |
txtSampleRate.setBounds(157, 52, 204, 20); |
185 |
txtSampleRate.addKeyListener(new java.awt.event.KeyAdapter() {
|
|
186 |
public void keyTyped(java.awt.event.KeyEvent e) {
|
|
186 |
txtSampleRate.addKeyListener(new java.awt.event.KeyAdapter() { |
|
187 |
public void keyTyped(java.awt.event.KeyEvent e) { |
|
187 | 188 |
try { |
188 | 189 |
float time = Float.parseFloat(txtSampleRate.getText()); |
189 | 190 |
gps.setSampleRate(Math.abs((int) (time * 1000))); |
190 |
|
|
191 |
|
|
191 | 192 |
} catch (Exception ex) { |
192 | 193 |
txtSampleRate.setText(""); |
193 | 194 |
}; |
... | ... | |
203 | 204 |
m_viewInfo.setTitle(PluginServices.getText(this, "gps_control_panel")); |
204 | 205 |
m_viewInfo.setWidth(this.getWidth()+8); |
205 | 206 |
m_viewInfo.setHeight(this.getHeight()+8); |
206 |
|
|
207 |
|
|
207 | 208 |
return m_viewInfo; |
208 | 209 |
} |
209 | 210 |
|
210 | 211 |
/** |
211 |
* This method initializes btnStart
|
|
212 |
*
|
|
213 |
* @return javax.swing.JButton
|
|
214 |
*/
|
|
212 |
* This method initializes btnStart |
|
213 |
* |
|
214 |
* @return javax.swing.JButton |
|
215 |
*/ |
|
215 | 216 |
private JButton getBtnStart() { |
216 | 217 |
if (btnStart == null) { |
217 | 218 |
btnStart = new JButton(); |
218 | 219 |
btnStart.setBounds(49, 140, 104, 41); |
219 |
btnStart.addActionListener(new java.awt.event.ActionListener() {
|
|
220 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
220 |
btnStart.addActionListener(new java.awt.event.ActionListener() { |
|
221 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
221 | 222 |
start(); |
222 | 223 |
} |
223 | 224 |
}); |
... | ... | |
226 | 227 |
return btnStart; |
227 | 228 |
} |
228 | 229 |
|
229 |
|
|
230 |
|
|
230 | 231 |
public void start() { |
231 | 232 |
if (!alreadyStarted) { |
232 | 233 |
Enumeration portList = CommPortIdentifier.getPortIdentifiers(); |
... | ... | |
236 | 237 |
try { |
237 | 238 |
gps.setPort(myPortId, 4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); |
238 | 239 |
gps.addEventListener(new GPSEventListener() { |
239 |
|
|
240 |
|
|
240 | 241 |
public void unhandledMessage(String message) { |
241 | 242 |
System.out.println("unhandledMessage"+": "+message+"\n"); |
242 | 243 |
lblPosValue.setText(message); |
243 | 244 |
} |
244 |
|
|
245 |
|
|
245 | 246 |
public void connectionLost() { |
246 | 247 |
System.out.println("connectionLost"); |
247 | 248 |
} |
248 |
|
|
249 |
|
|
249 | 250 |
public void connectionEstablished() { |
250 | 251 |
System.out.println("connectionEstablished"); |
251 | 252 |
} |
252 |
|
|
253 |
|
|
253 | 254 |
public void newLonLatPositionReceived(double lon, double lat) { |
254 | 255 |
IProjection reqProj = ProjectionPool.get("EPSG:23030"); |
255 |
IProjection latLonProj = ProjectionPool.get("EPSG:4326");
|
|
256 |
ICoordTrans ct = latLonProj.getCT((CoordSys) reqProj);
|
|
256 |
IProjection latLonProj = ProjectionPool.get("EPSG:4326"); |
|
257 |
ICoordTrans ct = latLonProj.getCT(reqProj); |
|
257 | 258 |
Point2D pDst = new Point2D.Double(); |
258 | 259 |
Point2D pSrc = new Point2D.Double(lon, lat); |
259 | 260 |
pDst = ct.convert(pSrc, pDst); |
260 | 261 |
lblPosValue.setText("("+pDst.getX()+", "+pDst.getY()+")"); |
261 |
|
|
262 |
|
|
262 | 263 |
GPSExtension ext = (GPSExtension) PluginServices.getExtension(GPSExtension.class); |
263 | 264 |
ext.drawSymbol(null, null, pDst, false); |
264 | 265 |
} |
265 |
|
|
266 |
|
|
266 | 267 |
public void signalQualityChanged(float level, int satellites, String qualityStatus) { |
267 | 268 |
} |
268 |
|
|
269 |
|
|
269 | 270 |
public void speedChanged(float speed, short course) { |
270 | 271 |
} |
271 |
|
|
272 |
|
|
272 | 273 |
public void estimatedPosErrorChanged(double f) { |
273 | 274 |
} |
274 | 275 |
|
... | ... | |
277 | 278 |
|
278 | 279 |
public void precisionChanged(float pDop, float hDop, float vDop) { |
279 | 280 |
} |
280 |
|
|
281 |
|
|
281 | 282 |
}); |
282 | 283 |
gps.connect(); |
283 | 284 |
alreadyStarted = true; |
... | ... | |
288 | 289 |
} |
289 | 290 |
} |
290 | 291 |
/** |
291 |
* This method initializes btnStop
|
|
292 |
*
|
|
293 |
* @return javax.swing.JButton
|
|
294 |
*/
|
|
292 |
* This method initializes btnStop |
|
293 |
* |
|
294 |
* @return javax.swing.JButton |
|
295 |
*/ |
|
295 | 296 |
private JButton getBtnPause() { |
296 | 297 |
if (btnPause == null) { |
297 | 298 |
btnPause = new JButton(); |
298 | 299 |
btnPause.setBounds(158, 140, 102, 40); |
299 |
btnPause.addActionListener(new java.awt.event.ActionListener() {
|
|
300 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
300 |
btnPause.addActionListener(new java.awt.event.ActionListener() { |
|
301 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
301 | 302 |
gps.silence(); |
302 | 303 |
} |
303 | 304 |
}); |
304 | 305 |
btnPause.setText("Pause"); |
305 |
|
|
306 |
|
|
306 | 307 |
} |
307 | 308 |
return btnPause; |
308 | 309 |
} |
309 | 310 |
|
310 | 311 |
/** |
311 |
* This method initializes btnStop
|
|
312 |
*
|
|
313 |
* @return javax.swing.JButton
|
|
314 |
*/
|
|
312 |
* This method initializes btnStop |
|
313 |
* |
|
314 |
* @return javax.swing.JButton |
|
315 |
*/ |
|
315 | 316 |
private JButton getBtnStop() { |
316 | 317 |
if (btnStop == null) { |
317 | 318 |
btnStop = new JButton(); |
318 | 319 |
btnStop.setBounds(450, 140, 102, 40); |
319 |
btnStop.addActionListener(new java.awt.event.ActionListener() {
|
|
320 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
320 |
btnStop.addActionListener(new java.awt.event.ActionListener() { |
|
321 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
321 | 322 |
gps.close(); |
322 | 323 |
} |
323 | 324 |
}); |
... | ... | |
327 | 328 |
} |
328 | 329 |
|
329 | 330 |
/** |
330 |
* This method initializes cmvPorts
|
|
331 |
*
|
|
332 |
* @return javax.swing.JComboBox
|
|
333 |
*/
|
|
331 |
* This method initializes cmvPorts |
|
332 |
* |
|
333 |
* @return javax.swing.JComboBox |
|
334 |
*/ |
|
334 | 335 |
private JComboBox getCmbPorts() { |
335 | 336 |
if (cmbPorts == null) { |
336 | 337 |
cmbPorts = new JComboBox(); |
Also available in: Unified diff