+ private Point topleft = new Point(0,0);
+ private void scrollRocketToVisible(Point2D.Double pt) {
+ Rectangle r = comp.getVisibleRect();
+ Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft));
+ int dx = (int)copt.x - r.width/2 - r.x;
+ int dy = (int)copt.y - r.height/2 - r.y;
+ if (Math.abs(dx) > r.width/4 || Math.abs(dy) > r.height/4) {
+ r.x += dx;
+ r.y += dy;
+ comp.scrollRectToVisible(r);
+ }
+ }
+
+ private void addTileAt(AltosSiteMapTile tile, Point offset) {
+ if (Math.abs(offset.x) >= MAX_TILE_DELTA ||
+ Math.abs(offset.y) >= MAX_TILE_DELTA)
+ {
+ System.out.printf("Rocket too far away from pad (tile %d,%d)\n",
+ offset.x, offset.y);
+ return;
+ }
+
+ boolean review = false;
+ Rectangle r = comp.getVisibleRect();
+ if (offset.x < topleft.x) {
+ r.x += (topleft.x - offset.x) * px_size;
+ topleft.x = offset.x;
+ review = true;
+ }
+ if (offset.y < topleft.y) {
+ r.y += (topleft.y - offset.y) * px_size;
+ topleft.y = offset.y;
+ review = true;
+ }