Point2D.Double coord_pt;
Point2D.Double last_pt;
- JLabel mapLabel;
+ AltosSiteMapLabel mapLabel;
JLabel draw;
Graphics2D g2d;
private void loadMap() {
Point2D.Double map_latlng = latlng(px_size/2, px_size/2);
- File pngfile = new File(AltosPreferences.logdir(),
- FileCoord(map_latlng, zoom));
- try {
- mapLabel.setIcon(new ImageIcon(ImageIO.read(pngfile)));
- } catch (Exception e) {
- // throw new RuntimeException(e);
- System.out.printf("# Failed to find file %s\n", pngfile);
- System.out.printf(" wget -O '%s' 'http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=hybrid&format=png32'\n", pngfile, map_latlng.x, map_latlng.y, zoom, px_size, px_size);
- }
+ mapLabel.loadMap(map_latlng.x, map_latlng.y, zoom, px_size);
}
private boolean setLocation(double lat, double lng) {
return v;
}
- private static String FileCoord(Point2D.Double latlng, int zoom) {
- double lat, lng;
- lat = latlng.x;
- lng = latlng.y;
- return FileCoord(lat, lng, zoom);
- }
- private static String FileCoord(double lat, double lng, int zoom) {
- char chlat = lat < 0 ? 'S' : 'N';
- char chlng = lng < 0 ? 'E' : 'W';
- if (lat < 0) lat = -lat;
- if (lng < 0) lng = -lng;
- return String.format("map-%c%.6f,%c%.6f-%d.png",
- chlat, lat, chlng, lng, zoom);
- }
-
-
// based on google js
// http://maps.gstatic.com/intl/en_us/mapfiles/api-3/2/10/main.js
// search for fromLatLngToPoint and fromPointToLatLng
};
boolean drawn_landed_circle = false;
+ boolean drawn_boost_circle = false;
public void show(AltosState state, int crc_errors) {
if (!state.gps_ready) {
if (state.pad_lat == 0 && state.pad_lon == 0)
if (last_pt == null) {
setLocation(state.pad_lat, state.pad_lon);
loadMap();
- last_pt = pt;
+ last_pt = pt(state.pad_lat, state.pad_lon);
}
Point2D.Double pt = pt(state.gps.lat, state.gps.lon);
}
}
+ if (state.state == 3 && !drawn_boost_circle) {
+ drawn_boost_circle = true;
+ g2d.setColor(Color.RED);
+ g2d.drawOval((int)last_pt.x-5, (int)last_pt.y-5, 10, 10);
+ g2d.drawOval((int)last_pt.x-20, (int)last_pt.y-20, 40, 40);
+ g2d.drawOval((int)last_pt.x-35, (int)last_pt.y-35, 70, 70);
+ }
if (state.state == 8 && !drawn_landed_circle) {
drawn_landed_circle = true;
- g2d.setColor(Color.RED);
+ g2d.setColor(Color.BLACK);
g2d.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10);
g2d.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40);
g2d.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70);
public AltosSiteMapTile(int x_tile_offset, int y_tile_offset) {
setPreferredSize(new Dimension(px_size, px_size));
- mapLabel = new JLabel();
+ mapLabel = new AltosSiteMapLabel();
fillLabel(mapLabel, Color.GRAY);
mapLabel.setOpaque(true);
mapLabel.setBounds(0, 0, px_size, px_size);