Jaya,
My response yesterday kept the gps device centered on the screen at all
times.
If you only want the projection to recenter when the gps device goes off the
screen (given the current projection) you could do something like the
following:
public actionPerformed(ActionEvent e)
{
gps_lat++;
gps_lon++;
gpsDevice.setLat(gps_lat);
gpsDevice.setLon(gps_lon);
Projection projection = getProjection();
Point p = projection.forward(gps_lat, gps_lon);
if(p.x <= 0 || // Off the screen, left
p.y <= 0 || // Off the screen, up
p.x >= projection.getWidth() || // Off the screen, right
p.y >= projection.getHeight()) // Off the screen, down
{
// Since in some way shape or form, we are off the screen
// We will now center the projection on the gpsDevice
Proj proj = (Proj)projection.makeClone();
proj.setCenter(gps_lat, gps_lon);
_map.setProjection(proj);
}
// Just to be sure the graphic is generated
gpsDevice.generate(_map.getProjection());
// Just to be sure we repaint
repaint();
}
-----Original Message-----
From: P Jaya Sunderam [mailto:jspothar@cs.uccs.edu]
Sent: Wednesday, February 18, 2004 2:29 PM
To: dietrick@bbn.com
Cc: openmap-users@bbn.com
Subject: [OpenMap Users] follow icon
hi Don,
i am trying to follow the icon as it moves out of the viewwing
window.following is the code for icon moving.any suggestion how to follow
it. gpsDevice.setLat(gps_lat++);
gpsDevice.setLon(gps_lon++);
//setCenter(gps_lat,gps_lon);
gpsDevice.regenerate(getProjection());
repaint();
thanks
jay
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"] -- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Wed Feb 18 15:21:27 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:37 EDT