overlay-map: fix selection rectangle for non-default zoom levels

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@763 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-07-21 15:34:41 +00:00
parent 1e21066cf2
commit 298d789df2

View file

@ -386,10 +386,10 @@ public class OverlayMapView extends JComponent
{
Rectangle rawRect = cv.scrollPane.getViewport().getViewRect();
return new Rectangle(
rawRect.x * 3 / 16,
rawRect.y * 3 / 16,
rawRect.width * 3 / 16,
rawRect.height * 3 / 16
rawRect.x * 3 / cv.view.getTileSize(),
rawRect.y * 3 / cv.view.getTileSize(),
rawRect.width * 3 / cv.view.getTileSize(),
rawRect.height * 3 / cv.view.getTileSize()
);
}
@ -403,8 +403,8 @@ public class OverlayMapView extends JComponent
Dimension mapSize = cv.scrollPane.getViewport().getViewSize();
Point np = new Point(
p.x * 16 / 3 - d.width / 2,
p.y * 16 / 3 - d.height / 2
p.x * cv.view.getTileSize() / 3 - d.width / 2,
p.y * cv.view.getTileSize() / 3 - d.height / 2
);
np.x = Math.max(0, Math.min(np.x, mapSize.width - d.width));
np.y = Math.max(0, Math.min(np.y, mapSize.height - d.height));
@ -482,10 +482,12 @@ public class OverlayMapView extends JComponent
class ConnectedView implements ChangeListener
{
MicropolisDrawingArea view;
JScrollPane scrollPane;
ConnectedView(MicropolisDrawingArea view, JScrollPane scrollPane)
{
this.view = view;
this.scrollPane = scrollPane;
scrollPane.getViewport().addChangeListener(this);
}