Hi all -
I just started using OpenMap and I'm trying a simple test of animating a
graphic on a map. I'm using a URLRasterLocation graphic since I'll be, at
some point, specifying a little plane graphic for what is being displayed.
For some reason, the call to repaint is not changing the location. I see the
location for the urlrloc object is changing on each call to paint though.
So, I'm confused.
I included the code for my very simple layer. The graphic shows up correctly
on first render but the Timer run interpolation fails miserably. Any
thoughts?
Thanks,
Chris
-------------------------------------------------
import com.bbn.openmap.Layer;
import com.bbn.openmap.event.*;
import com.bbn.openmap.proj.*;
import com.bbn.openmap.layer.location.URLRasterLocation;
import java.awt.event.*;
public class UCAVLayer extends Layer
{
javax.swing.Timer timer = null;
URLRasterLocation urlrloc = null;
int num_interpolations = 0;
final static int ONE_SECOND = 1000;
Projection cur_proj = null;
public UCAVLayer()
{
urlrloc = new URLRasterLocation(-6.0f, 141.0f, "UCAV1", "uav.gif");
System.out.println("Creating new timer...");
timer = new javax.swing.Timer(ONE_SECOND, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
interpolate();
}
});
timer.start();
}
float[] latlons = { -6.0f, 141.0f,
-6.996f, 144.006f,
-5.522f, 143.457f,
-4.017f, 141.988f,
-5.016f, 139.998f,
-6.0f, 141.0f
};
protected void interpolate() {
System.out.println("Here we are interpolating...");
if(num_interpolations >= latlons.length)
num_interpolations = 0;
float newlat = latlons[num_interpolations];
float newlon = latlons[num_interpolations + 1];
num_interpolations += 2;
urlrloc.setLocation(newlat, newlon);
repaint();
}
public void projectionChanged(ProjectionEvent e)
{
cur_proj = e.getProjection();
urlrloc.generate(cur_proj);
}
public void paint(java.awt.Graphics g)
{
System.out.println("\npainting...");
System.out.println("Location is " + urlrloc.lat + "," + urlrloc.lon);
if(cur_proj != null)
{
System.out.println("generating graphic...");
urlrloc.generate(cur_proj);
}
urlrloc.render(g);
}
}
-- [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 Tue Feb 26 12:30:14 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:32 EDT