summaryrefslogtreecommitdiff
path: root/javax/swing/JViewport.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/JViewport.java')
-rw-r--r--javax/swing/JViewport.java98
1 files changed, 38 insertions, 60 deletions
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index babffb7ce..9fd14e80a 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -157,6 +157,9 @@ public class JViewport extends JComponent implements Accessible
*/
public void componentResized(ComponentEvent ev)
{
+ // Fire state change, because resizing the view means changing the
+ // extentSize.
+ fireStateChanged();
revalidate();
}
}
@@ -198,22 +201,6 @@ public class JViewport extends JComponent implements Accessible
int scrollMode;
- /**
- * The width and height of the Viewport's area in terms of view
- * coordinates. Typically this will be the same as the width and height
- * of the viewport's bounds, unless the viewport transforms units of
- * width and height, which it may do, for example if it magnifies or
- * rotates its view.
- *
- * @see #toViewCoordinates(Dimension)
- */
- Dimension extentSize;
-
- /**
- * The width and height of the view in its own coordinate space.
- */
- Dimension viewSize;
-
/**
* The ViewListener instance.
*/
@@ -265,8 +252,7 @@ public class JViewport extends JComponent implements Accessible
static
{
String scrollModeProp =
- SystemProperties.getProperty("gnu.javax.swing.JViewport.scrollMode",
- "BLIT");
+ SystemProperties.getProperty("gnu.swing.scrollmode", "BACKINGSTORE");
if (scrollModeProp.equalsIgnoreCase("simple"))
defaultScrollMode = SIMPLE_SCROLL_MODE;
else if (scrollModeProp.equalsIgnoreCase("backingstore"))
@@ -290,10 +276,7 @@ public class JViewport extends JComponent implements Accessible
public Dimension getExtentSize()
{
- if (extentSize == null)
- return toViewCoordinates(getSize());
- else
- return extentSize;
+ return getSize();
}
public Dimension toViewCoordinates(Dimension size)
@@ -310,8 +293,12 @@ public class JViewport extends JComponent implements Accessible
public void setExtentSize(Dimension newSize)
{
- extentSize = newSize;
- fireStateChanged();
+ Dimension oldExtent = getExtentSize();
+ if (! newSize.equals(oldExtent))
+ {
+ setSize(newSize);
+ fireStateChanged();
+ }
}
/**
@@ -321,32 +308,34 @@ public class JViewport extends JComponent implements Accessible
*/
public Dimension getViewSize()
{
- if (isViewSizeSet)
- return viewSize;
- else
+ Dimension size;
+ Component view = getView();
+ if (view != null)
{
- Component view = getView();
- if (view != null)
- return view.getPreferredSize();
- else
- return new Dimension();
+ if (isViewSizeSet)
+ size = view.getSize();
+ else
+ size = view.getPreferredSize();
}
+ else
+ size = new Dimension(0, 0);
+ return size;
}
public void setViewSize(Dimension newSize)
{
- viewSize = newSize;
Component view = getView();
if (view != null)
{
- if (newSize != view.getSize())
+ if (! newSize.equals(view.getSize()))
{
- view.setSize(viewSize);
+ scrollUnderway = false;
+ view.setSize(newSize);
+ isViewSizeSet = true;
fireStateChanged();
}
}
- isViewSizeSet = true;
}
/**
@@ -371,23 +360,18 @@ public class JViewport extends JComponent implements Accessible
public void setViewPosition(Point p)
{
- if (getViewPosition().equals(p))
- return;
Component view = getView();
- if (view != null)
+ if (view != null && ! p.equals(getViewPosition()))
{
- Point q = new Point(-p.x, -p.y);
- view.setLocation(q);
- isViewSizeSet = false;
+ scrollUnderway = true;
+ view.setLocation(-p.x, -p.y);
fireStateChanged();
}
- repaint();
}
public Rectangle getViewRect()
{
- return new Rectangle(getViewPosition(),
- getExtentSize());
+ return new Rectangle(getViewPosition(), getExtentSize());
}
/**
@@ -495,7 +479,6 @@ public class JViewport extends JComponent implements Accessible
if (view == null)
return;
- Point pos = getViewPosition();
Rectangle viewBounds = view.getBounds();
Rectangle portBounds = getBounds();
@@ -643,19 +626,11 @@ public class JViewport extends JComponent implements Accessible
*/
public void repaint(long tm, int x, int y, int w, int h)
{
-// Component parent = getParent();
-// if (parent != null)
-// parent.repaint(tm, x + getX(), y + getY(), w, h);
-// else
-// super.repaint(tm, x, y, w, h);
-
- // The specs suggest to implement something like the above. This however
- // breaks blit painting, because the parent (most likely a JScrollPane)
- // clears the background of the offscreen area of the JViewport, thus
- // destroying the pieces that we want to clip. So we simply call super here
- // instead.
- super.repaint(tm, x, y, w, h);
-
+ Component parent = getParent();
+ if (parent != null)
+ parent.repaint(tm, x + getX(), y + getY(), w, h);
+ else
+ super.repaint(tm, x, y, w, h);
}
protected void addImpl(Component comp, Object constraints, int index)
@@ -940,7 +915,10 @@ public class JViewport extends JComponent implements Accessible
/**
* Overridden from JComponent to set the {@link #isPaintRoot} flag.
*
- * @param r the rectangle to paint
+ * @param x the rectangle to paint, X coordinate
+ * @param y the rectangle to paint, Y coordinate
+ * @param w the rectangle to paint, width
+ * @param h the rectangle to paint, height
*/
void paintImmediately2(int x, int y, int w, int h)
{