summaryrefslogtreecommitdiff
path: root/javax
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2007-02-08 22:15:17 +0000
committerRoman Kennke <roman@kennke.org>2007-02-08 22:15:17 +0000
commitd712668d689ebcebeeffb36045552c591ed3ff70 (patch)
tree9b1bc46d618565fb8450c47ee05e3c8ff182a2b1 /javax
parent02b306e75252bf9e0ab79e1d98ae87b6ef5602c1 (diff)
downloadclasspath-d712668d689ebcebeeffb36045552c591ed3ff70.tar.gz
2007-02-08 Roman Kennke <kennke@aicas.com>
PR 30347 * javax/swing/JViewport.java (scrollRectToVisible): Use correct X/Y offset for calculations. (paintBackingStore): Update backbuffer when we are not the paint root.
Diffstat (limited to 'javax')
-rw-r--r--javax/swing/JViewport.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index d90da1d15..023948032 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -574,8 +574,12 @@ public class JViewport extends JComponent implements Accessible
Component view = getView();
if (view == null)
return;
-
+
Point pos = getViewPosition();
+ // We get the contentRect in the viewport coordinates. But we want to
+ // calculate with view coordinates.
+ int contentX = contentRect.x + pos.x;
+ int contentY = contentRect.y + pos.y;
Rectangle viewBounds = getView().getBounds();
Rectangle portBounds = getBounds();
@@ -584,20 +588,20 @@ public class JViewport extends JComponent implements Accessible
// If the bottom boundary of contentRect is below the port
// boundaries, scroll up as necessary.
- if (contentRect.y + contentRect.height + viewBounds.y > portBounds.height)
- pos.y = contentRect.y + contentRect.height - portBounds.height;
- // If contentRect.y is above the port boundaries, scroll down to
- // contentRect.y.
- if (contentRect.y + viewBounds.y < 0)
- pos.y = contentRect.y;
+ if (contentY + contentRect.height + viewBounds.y > portBounds.height)
+ pos.y = contentY + contentRect.height - portBounds.height;
+ // If contentY is above the port boundaries, scroll down to
+ // contentY.
+ if (contentY + viewBounds.y < 0)
+ pos.y = contentY;
// If the right boundary of contentRect is right from the port
// boundaries, scroll left as necessary.
- if (contentRect.x + contentRect.width + viewBounds.x > portBounds.width)
- pos.x = contentRect.x + contentRect.width - portBounds.width;
- // If contentRect.x is left from the port boundaries, scroll right to
+ if (contentX + contentRect.width + viewBounds.x > portBounds.width)
+ pos.x = contentX + contentRect.width - portBounds.width;
+ // If contentX is left from the port boundaries, scroll right to
// contentRect.x.
- if (contentRect.x + viewBounds.x < 0)
- pos.x = contentRect.x;
+ if (contentX + viewBounds.x < 0)
+ pos.x = contentX;
setViewPosition(pos);
}
@@ -834,7 +838,7 @@ public class JViewport extends JComponent implements Accessible
int dy = viewPosition.y - lastPaintPosition.y;
boolean canBlit = computeBlit(dx, dy, cachedBlitFrom, cachedBlitTo,
cachedBlitSize, cachedBlitPaint);
- if (canBlit)
+ if (canBlit && isPaintRoot)
{
// Copy the part that remains visible during scrolling.
if (cachedBlitSize.width > 0 && cachedBlitSize.height > 0)