MapMouseListener patch

Julian RĂ¼th <[email protected]> Fri, 17 May 2002 18:02:49 +0200
Newsgroups gmane.games.freeciv.java
Message-ID <[email protected]>
Hello,

please apply this patch over my last patch. It adds keypad support for the 
UACTMove and a MapMouseListener which allows selecting units and opening city 
dialogs.

jule

-- 
Your mode of life will be changed for the better because of new developments.
diffs (text/x-diff, 23.8 KB)
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/Client.java org/freeciv/client/Client.java
--- org-orig/freeciv/client/Client.java	Wed Jan 23 16:08:27 2002
+++ org/freeciv/client/Client.java	Fri May 17 17:26:42 2002
@@ -67,7 +67,8 @@
  */
 public final class Client implements Constants
 {
-
+  // The only client object
+  private static Client m_client;
   // The tile spec holds all the images that the client uses
   private TileSpec m_tileSpec;
   // The actions are anything the user can do through the interface
@@ -98,7 +99,6 @@
   private boolean m_recycInit = false;
   private int m_lastContinentNumber = 0;
 
-
   // prob shouldn't instantiate this yet.
   private Game m_game = new Game();
   public final static String APP_NAME = "Freeciv4J";
@@ -122,8 +122,7 @@
   public Client()
   {
     super( );
-
-
+    m_client = this;
 
     // Take a hit right now and load the images etc.
     // BD: Need to do most of this in a different thread so connection
@@ -197,6 +196,16 @@
     return m_mainWindow;
   }
 
+
+  /**
+   * Static function to get the only client object
+   *
+   * @return the only client object
+   */
+  public static Client getClient()
+  {
+    return m_client;
+  }
 
 
   public String getCapabilities()
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/MainWindow.java org/freeciv/client/MainWindow.java
--- org-orig/freeciv/client/MainWindow.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/MainWindow.java	Fri May 17 17:57:13 2002
@@ -102,7 +102,7 @@
 
     // Set the listener for mouse event
     m_viewManager.getMainMapView().getComponent().addMouseListener(
-      new MapMouseListener(m_client, m_client.getGame().getMap()));
+					  new MapMouseListener());
 
     setDefaultCloseOperation( this.DO_NOTHING_ON_CLOSE );
     addWindowListener( new WindowCloseListener() );
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/AbstractClientAction.java org/freeciv/client/action/AbstractClientAction.java
--- org-orig/freeciv/client/action/AbstractClientAction.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/action/AbstractClientAction.java	Mon May 13 22:31:10 2002
@@ -60,7 +60,6 @@
   public final void addAccelerator( int vcode )
   {
     addAccelerator( vcode , 0 );
-    
   }
   
   /*
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveEast.java org/freeciv/client/action/UACTMoveEast.java
--- org-orig/freeciv/client/action/UACTMoveEast.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/action/UACTMoveEast.java	Mon May 13 22:35:12 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move East" ) );
     addAccelerator( KeyEvent.VK_KP_RIGHT );
+    addAccelerator( KeyEvent.VK_NUMPAD6 );
   }
 
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveNorth.java org/freeciv/client/action/UACTMoveNorth.java
--- org-orig/freeciv/client/action/UACTMoveNorth.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/action/UACTMoveNorth.java	Mon May 13 22:34:17 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move North" ) );
     addAccelerator( KeyEvent.VK_KP_UP );
+    addAccelerator( KeyEvent.VK_NUMPAD8 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveNorthEast.java org/freeciv/client/action/UACTMoveNorthEast.java
--- org-orig/freeciv/client/action/UACTMoveNorthEast.java	Thu May  9 21:44:06 2002
+++ org/freeciv/client/action/UACTMoveNorthEast.java	Mon May 13 22:36:05 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move NorthEast" ) );
     addAccelerator( KeyEvent.VK_PAGE_UP );
+    addAccelerator( KeyEvent.VK_NUMPAD9 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveNorthWest.java org/freeciv/client/action/UACTMoveNorthWest.java
--- org-orig/freeciv/client/action/UACTMoveNorthWest.java	Thu May  9 21:44:10 2002
+++ org/freeciv/client/action/UACTMoveNorthWest.java	Mon May 13 22:35:55 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move NorthWest" ) );
     addAccelerator( KeyEvent.VK_HOME );
+    addAccelerator( KeyEvent.VK_NUMPAD7 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveSouth.java org/freeciv/client/action/UACTMoveSouth.java
--- org-orig/freeciv/client/action/UACTMoveSouth.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/action/UACTMoveSouth.java	Mon May 13 22:34:27 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move South" ) );
     addAccelerator( KeyEvent.VK_KP_DOWN );
+    addAccelerator( KeyEvent.VK_NUMPAD2 );
     setEnabled( false );
   }
   
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveSouthEast.java org/freeciv/client/action/UACTMoveSouthEast.java
--- org-orig/freeciv/client/action/UACTMoveSouthEast.java	Thu May  9 21:44:20 2002
+++ org/freeciv/client/action/UACTMoveSouthEast.java	Mon May 13 22:35:38 2002
@@ -21,6 +21,7 @@
     super();
     setName( _( "Move SouthEast" ) );
     addAccelerator( KeyEvent.VK_PAGE_DOWN );
+    addAccelerator( KeyEvent.VK_NUMPAD3 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveSouthWest.java org/freeciv/client/action/UACTMoveSouthWest.java
--- org-orig/freeciv/client/action/UACTMoveSouthWest.java	Thu May  9 21:44:23 2002
+++ org/freeciv/client/action/UACTMoveSouthWest.java	Mon May 13 22:35:25 2002
@@ -21,6 +21,7 @@
     super();
     putValue( NAME, _( "Move SouthWest" ) );
     addAccelerator( KeyEvent.VK_END );
+    addAccelerator( KeyEvent.VK_NUMPAD1 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/action/UACTMoveWest.java org/freeciv/client/action/UACTMoveWest.java
--- org-orig/freeciv/client/action/UACTMoveWest.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/action/UACTMoveWest.java	Fri May 17 17:37:43 2002
@@ -21,7 +21,7 @@
     super();
     setName( _( "Move West" ) );
     addAccelerator( KeyEvent.VK_KP_LEFT );
-    setEnabled( false );
+    addAccelerator( KeyEvent.VK_NUMPAD4 );
   }
   
   /**
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/dialog/DialogManager.java org/freeciv/client/dialog/DialogManager.java
--- org-orig/freeciv/client/dialog/DialogManager.java	Mon Dec 24 20:32:08 2001
+++ org/freeciv/client/dialog/DialogManager.java	Fri May 17 17:38:01 2002
@@ -13,6 +13,8 @@
 public class DialogManager
 {
   private Client m_client;
+  // The only DialogManager object
+  private static DialogManager m_dialogManager;
   // We can hold on to any dialogs that are capable of resetting
   // themselves on each call.
   ImplLogin m_login;
@@ -33,10 +35,20 @@
   {
     m_client = c;
     m_alVisibleDialogs = new ArrayList();
+    m_dialogManager = this;
   }
   protected DialogManager()
   {
     this( null );
+  }
+
+  /**
+   * Static function to get the only dialog manager.
+   *
+   * @return the only DialogManager object
+   */
+  public static DialogManager getDialogManager(){
+    return m_dialogManager;
   }
   private class DialogInvoker implements Runnable
   {
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/AbstractMapView.java org/freeciv/client/map/AbstractMapView.java
--- org-orig/freeciv/client/map/AbstractMapView.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/map/AbstractMapView.java	Fri May 17 17:44:37 2002
@@ -97,7 +97,7 @@
     Assert.that( intro != null );
     m_scrollPane.setViewportView( new JLabel( intro ) );
   }
-  
+
   /**
    * Construct a city view.
    */
@@ -118,6 +118,16 @@
     return m_component;
   }
 
+  /**
+   * Get the MapViewInfo of this MapView.
+   *
+   * @return a MapViewInfo instance
+   */
+  public MapViewInfo getMapViewInfo()
+  {
+    return m_component.getMapViewInfo();
+  }
+
   public final void mapOverviewJumped( MapOverviewJumpEvent moje )
   {
     // TODO: some map views will optionally not be slaved to the overview
@@ -234,9 +244,16 @@
     return getClient().getGame().getMap();
   }
 
-  protected final Tile getTile(int x, int y)
+  /**
+   * Get information about a tile.
+   *
+   * @param mapx the map position to get tile information for
+   * @param mapy the map position to get tile information for
+   * @return a Tile object for the specified position
+   */
+  protected final Tile getTileAtMapPos(int mapx, int mapy)
   {
-    return getMap().getTile( x, y );
+    return getMap().getTile( mapx, mapy );
   }
 
   /**
@@ -471,7 +488,7 @@
      * @param mapPos the map position to get tile information for
      * @return a Tile object for the specified position
      */
-    public Tile getTile( Point mapPos )
+    public Tile getTileAtMapPos( Point mapPos )
     {
       return getClient().getGame().getMap().getTile( mapPos.x, mapPos.y );
     }
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/MapComponent.java org/freeciv/client/map/MapComponent.java
--- org-orig/freeciv/client/map/MapComponent.java	Sat May 11 23:23:44 2002
+++ org/freeciv/client/map/MapComponent.java	Fri May 17 17:35:03 2002
@@ -62,6 +62,15 @@
   }
 
   /**
+   * Get the MapViewInfo of the map in this component.
+   *
+   * @return a MapViewInfo instance
+   */
+  public MapViewInfo getMapViewInfo(){
+    return m_mvi;
+  }
+
+  /**
    * Request a repaint of the BufferLayer if existant
    */
   public void repaintLayers(int tilex, int tiley, int tilew, int tileh)
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/MapKeyListener.java org/freeciv/client/map/MapKeyListener.java
--- org-orig/freeciv/client/map/MapKeyListener.java	Thu Apr 11 17:41:34 2002
+++ org/freeciv/client/map/MapKeyListener.java	Thu Jan  1 01:00:00 1970
@@ -1,85 +0,0 @@
-// -------------------------------------------------------------- -*- Java -*- 
-//  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
-// --------------------------------------------------------------------------- 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2, or (at your option)
-// any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// --------------------------------------------------------------------------- 
-// FILE NAME        : MapKeyListener.java
-// DESCRIPTION      : The listener for the map
-// DATE             : 08/04/2002
-// AUTHORS          : Olivier Leprince
-// PROJECT          : Freeciv Java 
-// CATEGORY         : Map part
-// --------------------------------------------------------------------------- 
-
-package org.freeciv.client.map;
-
-import java.awt.event.*;
-
-import org.freeciv.net.PktMoveUnit;
-import org.freeciv.common.Map;
-import org.freeciv.common.Unit;
-import org.freeciv.client.Client;
-
-
-/**
- * Listener for Map Key events
- * @author Olivier Leprince
- */
-public class MapKeyListener extends KeyAdapter
-{
-
-  /** The client */
-  private Client m_client;
-
-  /** The map */
-  private Map m_map;;
-
-  public MapKeyListener(Client client, Map map)
-  {
-    m_client = client;
-    m_map = map;
-  }
-
-  public void keyPressed(KeyEvent e)
-  {
-    int dx=0, dy=0;
-
-    int code = e.getKeyCode();
-    if (code==KeyEvent.VK_UP || code==KeyEvent.VK_NUMPAD8)
-    { dy = -1; }
-    else if (code==KeyEvent.VK_DOWN || code==KeyEvent.VK_NUMPAD2)
-    { dy = 1; }
-    else if (code==KeyEvent.VK_LEFT || code==KeyEvent.VK_NUMPAD4)
-    { dx = -1; }
-    else if (code==KeyEvent.VK_RIGHT || code==KeyEvent.VK_NUMPAD6)
-    { dx = 1; }
-    else if (code==KeyEvent.VK_NUMPAD9)
-    { dx = 1; dy = -1; }
-    else if (code==KeyEvent.VK_NUMPAD7)
-    { dx = -1; dy = -1; }
-    else if (code==KeyEvent.VK_NUMPAD3)
-    { dx = 1; dy = 1; }
-    else if (code==KeyEvent.VK_NUMPAD1)
-    { dx = -1; dy = 1; }
-
-    // Take the focused unit
-    Unit u = m_client.getUnitInFocus();
-    if (u!=null)
-    {
-      PktMoveUnit pkt = new PktMoveUnit();
-      pkt.unitId = u.getId();
-      pkt.nx = m_map.adjustX(u.getX()+dx);
-      pkt.ny = m_map.adjustY(u.getY()+dy);
-      m_client.sendToServer(pkt);
-    }
-  }
-
-}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/MapMouseListener.java org/freeciv/client/map/MapMouseListener.java
--- org-orig/freeciv/client/map/MapMouseListener.java	Tue Apr  9 14:37:08 2002
+++ org/freeciv/client/map/MapMouseListener.java	Fri May 17 17:39:50 2002
@@ -1,54 +1,68 @@
-// -------------------------------------------------------------- -*- Java -*- 
-//  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
-// --------------------------------------------------------------------------- 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2, or (at your option)
-// any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// --------------------------------------------------------------------------- 
-// FILE NAME        : MapMouseListener.java
-// DESCRIPTION      : The listener for the map
-// DATE             : 08/04/2002
-// AUTHORS          : Olivier Leprince
-// PROJECT          : Freeciv Java 
-// CATEGORY         : Map part
-// --------------------------------------------------------------------------- 
-
-package org.freeciv.client.map;
-
-import java.awt.event.*;
-import org.freeciv.common.Map;
-import org.freeciv.client.Client;
-
-
-
-/**
- * Listener for Map Key events
- * @author Olivier Leprince
- */
-public class MapMouseListener extends MouseAdapter
-{
-
-  /** The client */
-  private Client m_client;
-
-  /** The map */
-  private Map m_map;;
-
-  public MapMouseListener(Client client, Map map)
-  {
-    m_client = client;
-    m_map = map;
-  }
-
-  public void mousePressed(MouseEvent e)
-  {
-    System.out.println("Click "+e.getX()+","+e.getY());
-  }
-
-}
+package org.freeciv.client.map;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseAdapter;
+import java.util.Iterator;
+
+import org.freeciv.common.Map;
+import org.freeciv.common.Tile;
+import org.freeciv.common.City;
+import org.freeciv.common.Unit;
+import org.freeciv.client.Client;
+import org.freeciv.client.dialog.DialogManager;
+
+/**
+ * This MouseListener handles all MouseEvents on the MapComponent.
+ *
+ * @author Julian Rueth
+ */
+public class MapMouseListener extends MouseAdapter
+{
+  /**
+   * Currently supported:
+   * - opening city dialogs
+   * - focusing units
+   *
+   * @param e a MouseEvent
+   */
+  public void mousePressed(MouseEvent e)
+  {
+    MapViewManager mvm = MapViewManager.getMapViewManager();
+    DialogManager dm = DialogManager.getDialogManager();
+    Tile tile = mvm.getMainMapView().getTileAtCanvasPos( e.getX(), e.getY() );
+    int playerId = Client.getClient().getGame().getCurrentPlayer().getNation().getId();
+
+    //check if there's a city on this tile
+    if( tile.hasCity() )
+    {
+      City city = tile.getCity();
+      //is this city owned by this player
+      if( city.getOwner().getNation().getId() == playerId )
+      {
+	//open city dialog
+	mvm.centerOnTile( city.getX() , city.getY() );
+	dm.getCityViewDialog().display( city );
+      }
+    }
+
+    //check if there are any units on this tile
+    Iterator it = tile.getUnits();
+    if( !it.hasNext() )
+    {
+      return;
+    }
+    Unit u = (Unit) it.next();
+    mvm.centerOnTile( u.getX() , u.getY() );
+    //if any unit on this tile is owned by the current player,
+    // focus it
+    do
+    {
+      if( u.getOwner().getNation().getId() == playerId )
+      {
+	Client.getClient().setUnitFocusAndSelect( u ); 
+	return;
+      }
+    }
+    while( it.hasNext() );
+  }
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/MapView.java org/freeciv/client/map/MapView.java
--- org-orig/freeciv/client/map/MapView.java	Tue Jan 22 20:49:00 2002
+++ org/freeciv/client/map/MapView.java	Fri May 17 17:46:41 2002
@@ -4,6 +4,7 @@
 
 import org.freeciv.client.panel.MapOverviewJumpListener;
 import org.freeciv.common.City;
+import org.freeciv.common.Tile;
 
 /**
  * The external interface to a single view on the map.
@@ -41,6 +42,16 @@
   void centerOnTile( int tilex, int tiley );
 
   /**
+   * Get the tile that currently covers a specified position in the 
+   * MapComponent's canvas.
+   *
+   * @param canvasx the x-coordinate in the currently visible part of the map
+   * @param canvasy the y-coordinate in the currently visible part of the map
+   * @return the Tile at this position
+   */
+  Tile getTileAtCanvasPos( int canvasx, int canvasy );
+
+  /**
    * Get the actual physical component for this map view
    */
   JComponent getComponent();
@@ -55,4 +66,4 @@
    */
   void setCity( City city );
   
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/MapViewInfo.java org/freeciv/client/map/MapViewInfo.java
--- org-orig/freeciv/client/map/MapViewInfo.java	Sun Dec  2 11:00:24 2001
+++ org/freeciv/client/map/MapViewInfo.java	Mon May 13 23:28:26 2002
@@ -64,7 +64,7 @@
    * @param mapPos the map position to get tile information for
    * @return a Tile object for the specified position
    */
-  Tile getTile( Point mapPos );
+  Tile getTileAtMapPos( Point mapPos );
 
   /**
    * Get the map
@@ -94,4 +94,4 @@
    */
   Player getCurrentPlayer();
 
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/grid/CityProductionLayer.java org/freeciv/client/map/grid/CityProductionLayer.java
--- org-orig/freeciv/client/map/grid/CityProductionLayer.java	Sat Jan 19 03:45:21 2002
+++ org/freeciv/client/map/grid/CityProductionLayer.java	Mon May 13 23:33:50 2002
@@ -38,7 +38,7 @@
 
   public void paintTile(Graphics g, Point mapPos, Point gPos, MapViewInfo info)
   {
-    Tile tile = info.getTile( mapPos );
+    Tile tile = info.getTileAtMapPos( mapPos );
     /*
     if ( tile.getWorkedBy() == getCity() )
     {
@@ -51,4 +51,4 @@
     }
     */
   }
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/grid/FogOfWarLayer.java org/freeciv/client/map/grid/FogOfWarLayer.java
--- org-orig/freeciv/client/map/grid/FogOfWarLayer.java	Sun Dec  2 11:00:24 2001
+++ org/freeciv/client/map/grid/FogOfWarLayer.java	Mon May 13 23:34:05 2002
@@ -39,7 +39,7 @@
 
   public void paintTile(Graphics g, Point mapPos, Point gPos, MapViewInfo info)
   {
-    if ( info.getTile( mapPos ).getKnown() == Constants.TILE_KNOWN_FOGGED )
+    if ( info.getTileAtMapPos( mapPos ).getKnown() == Constants.TILE_KNOWN_FOGGED )
     {
 
       Graphics2D g2d = (Graphics2D)g;
@@ -64,4 +64,4 @@
 
     
   }
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/grid/GridMapView.java org/freeciv/client/map/grid/GridMapView.java
--- org-orig/freeciv/client/map/grid/GridMapView.java	Sat May 11 22:02:57 2002
+++ org/freeciv/client/map/grid/GridMapView.java	Fri May 17 17:46:53 2002
@@ -2,6 +2,7 @@
 
 import java.awt.Graphics2D;
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -12,9 +13,11 @@
 import org.freeciv.client.map.AbstractMapView;
 import org.freeciv.client.map.BufferLayer;
 import org.freeciv.client.map.MapLayer;
+import org.freeciv.client.map.MapViewInfo;
 import org.freeciv.common.MapPosition;
 import org.freeciv.common.Player;
 import org.freeciv.common.City;
+import org.freeciv.common.Tile;
 
 /**
  * A map view that uses square grid tiles.
@@ -167,4 +170,23 @@
       && canvasPos.y >= 0
       && canvasPos.y < getBufferTileWidth() * getNormalTileHeight();
   }
+
+  /**
+   * Get the tile that currently covers a specified position in the 
+   * MapComponent's canvas.
+   *
+   * @param canvasx the x-coordinate in the currently visible part of the map
+   * @param canvasy the y-coordinate in the currently visible part of the map
+   * @return the Tile at this position
+   */
+  public Tile getTileAtCanvasPos(int canvasx, int canvasy)
+  {
+    Rectangle rect = getMapViewInfo().getVisibleRectangle();
+
+    int tilex = (((int)rect.getX()) + canvasx) / getNormalTileWidth();
+    int tiley = (((int)rect.getY()) + canvasy) / getNormalTileHeight();
+
+    return getTileAtMapPos( tilex , tiley );
+  }
+
 }
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/grid/TerrainLayer.java org/freeciv/client/map/grid/TerrainLayer.java
--- org-orig/freeciv/client/map/grid/TerrainLayer.java	Sun Dec  2 11:00:24 2001
+++ org/freeciv/client/map/grid/TerrainLayer.java	Mon May 13 23:34:41 2002
@@ -105,7 +105,7 @@
     int abs_x0 = mapPos.x;
     int abs_y0 = mapPos.y;
 
-    tile = info.getTile( mapPos );
+    tile = info.getTileAtMapPos( mapPos );
 
     if ( tile.getKnown() == TILE_UNKNOWN )
     {
@@ -559,4 +559,4 @@
     // java client.
   
   }
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/grid/UnitLayer.java org/freeciv/client/map/grid/UnitLayer.java
--- org-orig/freeciv/client/map/grid/UnitLayer.java	Wed Jan 23 16:08:28 2002
+++ org/freeciv/client/map/grid/UnitLayer.java	Mon May 13 23:36:30 2002
@@ -145,7 +145,7 @@
 
   public void paintTile(Graphics g, Point mapPos, Point gPos, MapViewInfo info)
   {
-    Tile tile = info.getTile( mapPos );
+    Tile tile = info.getTileAtMapPos( mapPos );
     Unit unit = findVisibleUnit( tile, info );
 
     if ( unit != null )
@@ -223,4 +223,4 @@
       }
     }
   }
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/map/iso/IsometricMapView.java org/freeciv/client/map/iso/IsometricMapView.java
--- org-orig/freeciv/client/map/iso/IsometricMapView.java	Sat Jan 19 00:06:22 2002
+++ org/freeciv/client/map/iso/IsometricMapView.java	Fri May 17 17:50:43 2002
@@ -8,6 +8,7 @@
 import org.freeciv.client.Client;
 import org.freeciv.client.map.AbstractMapView;
 import org.freeciv.common.City;
+import org.freeciv.common.Tile;
 
 /**
  * A map view that uses isometric tiles.
@@ -28,6 +29,10 @@
     super( c, city );
   }
 
+  public Tile getTileAtCanvasPos( int canvasx, int canvasy ){
+    return null;
+  }
+
   protected Collection getLayers()
   {
     return null;
@@ -94,4 +99,4 @@
       && ( canvasPos.y < height );
   }
 
-}
\ No newline at end of file
+}
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/client/panel/CivStatusPanel.java org/freeciv/client/panel/CivStatusPanel.java
--- org-orig/freeciv/client/panel/CivStatusPanel.java	Sun Nov  4 03:10:35 2001
+++ org/freeciv/client/panel/CivStatusPanel.java	Mon May 13 23:38:07 2002
@@ -2,6 +2,7 @@
 
 import org.freeciv.client.*;
 import org.freeciv.client.dialog.util.VerticalFlowPanel;
+import org.freeciv.util.Localize;
 import javax.swing.*;
 import java.awt.*;
 
@@ -20,6 +21,6 @@
   // game state)
   private static String _( String txt )
   {
-    return Localize.translation.translate( txt );
+    return Localize.translate( txt );
   }
 }
diff -N -u -r -x*~ -x*rej -x*orig -x*.fb -x*CVS org-orig/freeciv/common/Map.java org/freeciv/common/Map.java
--- org-orig/freeciv/common/Map.java	Wed Jan 23 16:08:28 2002
+++ org/freeciv/common/Map.java	Mon May 13 23:29:01 2002
@@ -1,7 +1,7 @@
 package org.freeciv.common;
 
 /**
- * Logical representation of information abou the map
+ * Logical representation of information about the map
  */
 public final class Map implements CommonConstants
 {
@@ -537,4 +537,4 @@
     return !m_cityTooNear;
   }
   
-}
\ No newline at end of file
+}