- private AltosMapView map_view;
-
- private double mapAccuracy = -1;
-
- int stroke_width = 20;
-
-
- void draw_text(AltosLatLon lat_lon, String text, int off_x, int off_y) {
- if (lat_lon != null && map != null && map.transform != null) {
- AltosPointInt pt = new AltosPointInt(map.transform.screen(lat_lon));
-
- Rect bounds = new Rect();
- paint.getTextBounds(text, 0, text.length(), bounds);
-
- int width = bounds.right - bounds.left;
- int height = bounds.bottom - bounds.top;
-
- float x = pt.x;
- float y = pt.y;
- x = x - width / 2.0f - off_x;
- y = y + height / 2.0f - off_y;
- paint.setColor(0xff000000);
- canvas.drawText(text, 0, text.length(), x, y, paint);
- }
- }
-
- void draw_bitmap(AltosLatLon lat_lon, Bitmap bitmap, int off_x, int off_y) {
- if (lat_lon != null && map != null && map.transform != null) {
- AltosPointInt pt = new AltosPointInt(map.transform.screen(lat_lon));
-
- canvas.drawBitmap(bitmap, pt.x - off_x, pt.y - off_y, paint);
- }
- }
-
- HashMap<Integer,Rocket> rockets = new HashMap<Integer,Rocket>();
-
- /* AltosMapInterface */
-
- static final int WHITE = 0xffffffff;
- static final int RED = 0xffff0000;
- static final int PINK = 0xffff8080;
- static final int YELLOW= 0xffffff00;
- static final int CYAN = 0xff00ffff;
- static final int BLUE = 0xff0000ff;
- static final int BLACK = 0xff000000;
-
- public static final int stateColors[] = {
- WHITE, // startup
- WHITE, // idle
- WHITE, // pad
- RED, // boost
- PINK, // fast
- YELLOW, // coast
- CYAN, // drogue
- BLUE, // main
- BLACK, // landed
- BLACK, // invalid
- CYAN, // stateless
- };
-
- public AltosMapPath new_path() {
- return null;
- }
-
- public AltosMapLine new_line() {
- return null;
- }
-
- class MapImage implements AltosImage {
- public Bitmap bitmap;
-
- public void flush() {
- if (bitmap != null) {
- bitmap.recycle();
- bitmap = null;
- }
- }
-
- public MapImage(File file) {
- bitmap = BitmapFactory.decodeFile(file.getPath());
- }
- }
-
- public AltosImage load_image(File file) throws Exception {
- return new MapImage(file);
- }
-
- class MapMark extends AltosMapMark {
- public void paint(AltosMapTransform t) {
- }
-
- MapMark(double lat, double lon, int state) {
- super(lat, lon, state);
- }
- }
-
- public AltosMapMark new_mark(double lat, double lon, int state) {
- return new MapMark(lat, lon, state);
- }
-
- class MapTile extends AltosMapTile {
- public void paint(AltosMapTransform t) {
- AltosPointInt pt = new AltosPointInt(t.screen(upper_left));
-
- if (canvas.quickReject(pt.x, pt.y, pt.x + px_size, pt.y + px_size, Canvas.EdgeType.AA))
- return;
-
- AltosImage altos_image = cache.get(this, store, px_size, px_size);
-
- MapImage map_image = (MapImage) altos_image;
-
- Bitmap bitmap = null;
-
- if (map_image != null)
- bitmap = map_image.bitmap;
-
- if (bitmap != null) {
- canvas.drawBitmap(bitmap, pt.x, pt.y, paint);
- } else {
- paint.setColor(0xff808080);
- canvas.drawRect(pt.x, pt.y, pt.x + px_size, pt.y + px_size, paint);
- if (t.has_location()) {
- String message = null;
- switch (status) {
- case AltosMapTile.loading:
- message = "Loading...";
- break;
- case AltosMapTile.bad_request:
- message = "Internal error";
- break;
- case AltosMapTile.failed:
- message = "Network error, check connection";
- break;
- case AltosMapTile.forbidden:
- message = "Too many requests, try later";
- break;
- }
- if (message != null) {
- Rect bounds = new Rect();
- paint.getTextBounds(message, 0, message.length(), bounds);
-
- int width = bounds.right - bounds.left;
- int height = bounds.bottom - bounds.top;
-
- float x = pt.x + px_size / 2.0f;
- float y = pt.y + px_size / 2.0f;
- x = x - width / 2.0f;
- y = y + height / 2.0f;
- paint.setColor(0xff000000);
- canvas.drawText(message, 0, message.length(), x, y, paint);
- }
- }
- }
- }
-
- public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) {
- super(listener, upper_left, center, zoom, maptype, px_size, 2);
- }
-
- }
-
- public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) {
- return new MapTile(listener, upper_left, center, zoom, maptype, px_size);
- }
-
- public int width() {
- if (map_view != null)
- return map_view.getWidth();
- return 500;
- }
-
- public int height() {
- if (map_view != null)
- return map_view.getHeight();
- return 500;
- }
-
- public void repaint() {
- if (map_view != null)
- map_view.postInvalidate();
- }
-
- public void repaint(AltosRectangle damage) {
- if (map_view != null)
- map_view.postInvalidate(damage.x, damage.y, damage.x + damage.width, damage.y + damage.height);
- }
-
- public void set_zoom_label(String label) {
- }
-
- public void debug(String format, Object ... arguments) {
- AltosDebug.debug(format, arguments);
- }