Update of /cvsroot/rcpilot/src/rcpilot/rcgs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8651/rcpilot/rcgs
Modified Files:
RcgsMap.java
Log Message:
Added trail of last 500 GPS positions behind plane.
Index: RcgsMap.java
===================================================================
RCS file: /cvsroot/rcpilot/src/rcpilot/rcgs/RcgsMap.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** RcgsMap.java 28 Jun 2004 08:35:57 -0000 1.11
--- RcgsMap.java 28 Jun 2004 10:33:45 -0000 1.12
***************
*** 43,46 ****
--- 43,48 ----
import javax.swing.*;
import java.io.*;
+ import java.util.Iterator;
+ import java.util.concurrent.*; // LinkedBlockingQueue
public class RcgsMap extends JComponent
***************
*** 65,68 ****
--- 67,74 ----
private static final int EARTH_MILE_CIRCUMF = 24988; // miles
private static final int EARTH_ASEC_CIRCUMF = 129600000; // asecs
+ private static final int GPS_HISTORY_LENGTH = 500;
+
+ private LinkedBlockingQueue gpsHistoryLat = null;
+ private LinkedBlockingQueue gpsHistoryLon = null;
private Image mapImg, displayImg;
***************
*** 170,173 ****
--- 176,182 ----
add(scrollDownButton);
add(scrollLeftButton);
+
+ gpsHistoryLat = new LinkedBlockingQueue(GPS_HISTORY_LENGTH);
+ gpsHistoryLon = new LinkedBlockingQueue(GPS_HISTORY_LENGTH);
}
***************
*** 374,380 ****
--- 383,395 ----
int course = (int)Rcgs.tdata.getCourse();
+
int planeLatSecs = Rcgs.tdata.getGPSLatitude();
int planeLonSecs = Rcgs.tdata.getGPSLongitude();
+ if(gpsHistoryLat.size()==GPS_HISTORY_LENGTH) {
+ gpsHistoryLat.poll(); // remove head of queue
+ gpsHistoryLon.poll(); // remove head of queue
+ }
+
// calculate plane position on current display
***************
*** 390,393 ****
--- 405,434 ----
}
+ private void drawGPSHistory(Graphics2D g) {
+
+ Iterator itLat = gpsHistoryLat.iterator();
+ Iterator itLon = gpsHistoryLon.iterator();
+
+ int lat[] = new int[gpsHistoryLat.size()];
+ int lon[] = new int[gpsHistoryLon.size()];
+
+ int i = 0;
+
+ while(itLat.hasNext() && itLon.hasNext()) {
+ int oneLat = ((Integer)itLat.next()).intValue();
+ int oneLon = ((Integer)itLon.next()).intValue();
+
+ int latPix = (int)((displayTopLatSecs-oneLat)/displayVscale);
+ int lonPix = (int)((oneLon-displayLeftLonSecs)/displayHscale);
+
+ lat[i] = latPix;
+ lon[i] = lonPix;
+ i++;
+ }
+
+ g.setColor(Color.blue);
+ g.drawPolyline(lon,lat,lat.length);
+ }
+
private void drawHome(Graphics2D g) {
***************
*** 491,498 ****
}
- // Passing 'this' as last arg results in imageUpdate() method
- // being called repeatedly until image is fully loaded. This
- // way we can guarantee paint is called after image is loaded.
-
g2.setColor(UserPreferences.getVidColor());
g2.fillRect(0,0,getWidth(),getHeight());
--- 532,535 ----
***************
*** 500,503 ****
--- 537,541 ----
g2.drawImage(displayImg, 0,0,null);
+ drawGPSHistory(g2);
drawPlane(g2);
drawHome(g2);
***************
*** 696,699 ****
--- 734,744 ----
public void telemetryDataChanged(TelemetryDataChangedEvent ev) {
+
+ int planeLatSecs = Rcgs.tdata.getGPSLatitude();
+ int planeLonSecs = Rcgs.tdata.getGPSLongitude();
+
+ gpsHistoryLat.offer(new Integer(planeLatSecs));
+ gpsHistoryLon.offer(new Integer(planeLonSecs));
+
repaint();
}
|