package altosui;
import java.awt.*;
-import java.awt.image.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.event.MouseInputAdapter;
-import javax.imageio.ImageIO;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.lang.Math;
import java.awt.geom.Point2D;
-import java.awt.geom.Line2D;
+import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
// preferred vertical step in a tile in naut. miles
// based on google js
// http://maps.gstatic.com/intl/en_us/mapfiles/api-3/2/10/main.js
// search for fromLatLngToPoint and fromPointToLatLng
+ /*
private static Point2D.Double pt(LatLng latlng, int zoom) {
double scale_x = 256/360.0 * Math.pow(2, zoom);
double scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom);
return pt(latlng, scale_x, scale_y);
}
+ */
private static Point2D.Double pt(LatLng latlng,
double scale_x, double scale_y)
private LatLng latlng(double x, double y) {
return latlng(new Point2D.Double(x,y), scale_x, scale_y);
}
+ /*
private LatLng latlng(Point2D.Double pt) {
return latlng(pt, scale_x, scale_y);
}
+ */
- HashMap<Point,AltosSiteMapTile> mapTiles = new HashMap<Point,AltosSiteMapTile>();
+ ConcurrentHashMap<Point,AltosSiteMapTile> mapTiles = new ConcurrentHashMap<Point,AltosSiteMapTile>();
Point2D.Double centre;
private Point2D.Double tileCoordOffset(Point p) {
// nothing
}
+ public void set_font() {
+ // nothing
+ }
+
private void loadMap(final AltosSiteMapTile tile,
File pngfile, String pngurl)
{
AltosSiteMap asm = new AltosSiteMap(true);
asm.centre = asm.getBaseLocation(lat, lng);
- Point2D.Double p = new Point2D.Double();
- Point2D.Double p2;
+ //Point2D.Double p = new Point2D.Double();
+ //Point2D.Double p2;
int dx = -w/2, dy = -h/2;
for (int y = dy; y < h+dy; y++) {
for (int x = dx; x < w+dx; x++) {
char chlng = lng < 0 ? 'W' : 'E';
if (lat < 0) lat = -lat;
if (lng < 0) lng = -lng;
- return new File(AltosPreferences.mapdir(),
+ return new File(AltosUIPreferences.mapdir(),
String.format("map-%c%.6f,%c%.6f-%d.png",
chlat, lat, chlng, lng, zoom));
}
last_state = state.state;
}
+ public void draw_circle(double lat, double lon) {
+ final Point2D.Double pt = pt(lat, lon);
+
+ for (Point offset : mapTiles.keySet()) {
+ AltosSiteMapTile tile = mapTiles.get(offset);
+ Point2D.Double ref = translatePoint(pt, tileCoordOffset(offset));
+ tile.draw_circle(ref);
+ }
+ }
+
private AltosSiteMapTile createTile(Point offset) {
AltosSiteMapTile tile = new AltosSiteMapTile(px_size);
mapTiles.put(offset, tile);
public AltosSiteMap(int in_radius) {
radius = in_radius;
- GrabNDrag scroller = new GrabNDrag(comp);
+ //GrabNDrag scroller = new GrabNDrag(comp);
comp.setLayout(layout);