From 298d789df267bdaafee3030004d48f636467a7d5 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sun, 21 Jul 2013 15:34:41 +0000 Subject: [PATCH] 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 --- src/micropolisj/gui/OverlayMapView.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/micropolisj/gui/OverlayMapView.java b/src/micropolisj/gui/OverlayMapView.java index e3da4af..921fae1 100644 --- a/src/micropolisj/gui/OverlayMapView.java +++ b/src/micropolisj/gui/OverlayMapView.java @@ -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); }