+ LatLng line_start, line_end;
+
+ private void set_line() {
+ if (line_start != null && line_end != null) {
+ Point2D.Double start = pt(line_start.lat, line_start.lng);
+ Point2D.Double end = pt(line_end.lat, line_end.lng);
+ AltosGreatCircle g = new AltosGreatCircle(line_start.lat, line_start.lng,
+ line_end.lat, line_end.lng);
+
+ for (Point offset : mapTiles.keySet()) {
+ AltosSiteMapTile tile = mapTiles.get(offset);
+ Point2D.Double s, e;
+ s = translatePoint(start, tileCoordOffset(offset));
+ e = translatePoint(end, tileCoordOffset(offset));
+ tile.set_line(new Line2D.Double(s.x, s.y, e.x, e.y), g.distance);
+ }
+ } else {
+ for (AltosSiteMapTile tile : mapTiles.values())
+ tile.set_line(null, 0);
+ }
+ }
+
+ LatLng latlng(MouseEvent e) {
+ if (!base_location_set)
+ return null;
+
+ Rectangle zerozero = mapTiles.get(new Point(0, 0)).getBounds();
+
+ return latlng(-centre.x + e.getPoint().x - zerozero.x, -centre.y + e.getPoint().y - zerozero.y);
+ }
+
+ /* MouseMotionListener methods */
+ public void mouseDragged(MouseEvent e) {
+ if (!GrabNDrag.grab_n_drag(e)) {
+ LatLng loc = latlng(e);
+ line_end = loc;
+ set_line();
+ }
+ }
+
+ public void mouseMoved(MouseEvent e) {
+ }
+
+ /* MouseListener methods */
+ public void mouseClicked(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ public void mouseExited(MouseEvent e) {
+ }
+
+ public void mousePressed(MouseEvent e) {
+ if (!GrabNDrag.grab_n_drag(e)) {
+ LatLng loc = latlng(e);
+ line_start = loc;
+ line_end = null;
+ set_line();
+ }
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+