From 34c0bb46ce0623f4e0aecd06552e51dd989f44e2 Mon Sep 17 00:00:00 2001
From: pleumann <pleumann@fc158eef-6c16-0410-b9c5-873085b46621>
Date: Sun, 25 May 2003 11:46:24 +0000
Subject: [PATCH] Avoid positioning of the minimap rectangle outside the
 available area. Resulted in very strange artifacts on the screen.

---
 JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java   | 13 +++++++++++++
 jhotdraw6/src/org/jhotdraw/contrib/MiniMapView.java | 13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java b/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java
index 13b37cf3b..e320eff7c 100644
--- a/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java
+++ b/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java
@@ -186,6 +186,19 @@ public class MiniMapView extends JComponent {
 		Rectangle oldRectangle = getViewRectangle();
 		upperLeft[0] = centerX - oldRectangle.width/2;
 		upperLeft[1] = centerY - oldRectangle.height/2;
+
+        /*
+         * JP, 25-May-03: Avoid positioning of the rectangle outside the
+         * available area. Resulted in very strange artifacts on the screen.
+         */
+        if (upperLeft[0] + oldRectangle.width >= getX() + getWidth()) {
+            upperLeft[0] = getX() + getWidth() - oldRectangle.width - 1;
+        }
+
+        if (upperLeft[1] + oldRectangle.height >= getY() + getHeight()) {
+            upperLeft[1] = getY() + getHeight() - oldRectangle.height - 1;
+        }
+        
 		return upperLeft;
 	}
 
diff --git a/jhotdraw6/src/org/jhotdraw/contrib/MiniMapView.java b/jhotdraw6/src/org/jhotdraw/contrib/MiniMapView.java
index 13b37cf3b..e320eff7c 100644
--- a/jhotdraw6/src/org/jhotdraw/contrib/MiniMapView.java
+++ b/jhotdraw6/src/org/jhotdraw/contrib/MiniMapView.java
@@ -186,6 +186,19 @@ public class MiniMapView extends JComponent {
 		Rectangle oldRectangle = getViewRectangle();
 		upperLeft[0] = centerX - oldRectangle.width/2;
 		upperLeft[1] = centerY - oldRectangle.height/2;
+
+        /*
+         * JP, 25-May-03: Avoid positioning of the rectangle outside the
+         * available area. Resulted in very strange artifacts on the screen.
+         */
+        if (upperLeft[0] + oldRectangle.width >= getX() + getWidth()) {
+            upperLeft[0] = getX() + getWidth() - oldRectangle.width - 1;
+        }
+
+        if (upperLeft[1] + oldRectangle.height >= getY() + getHeight()) {
+            upperLeft[1] = getY() + getHeight() - oldRectangle.height - 1;
+        }
+        
 		return upperLeft;
 	}
 
-- 
GitLab