diff --git a/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java b/JHotDraw/src/CH/ifa/draw/contrib/MiniMapView.java index 13b37cf3b2294d36515d37f999f164d226041576..e320eff7c6b816802fa396c019d3d0ceaea4f9c1 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 13b37cf3b2294d36515d37f999f164d226041576..e320eff7c6b816802fa396c019d3d0ceaea4f9c1 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; }