summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/ViewportLayout.java
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-18 17:29:21 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-18 17:29:21 +0000
commit64089cc9f030d8ef7972adb5d117e0b23f47d62b (patch)
tree9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/javax/swing/ViewportLayout.java
parent96034e28360d660d7a7708807fcbc4b519574d8e (diff)
downloadppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.tar.gz
ppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.zip
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale. * sources.am: Regenerated. * gcj/javaprims.h: Regenerated. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * gnu/java/lang/VMInstrumentationImpl.java: New override. * gnu/java/net/local/LocalSocketImpl.java: Likewise. * gnu/classpath/jdwp/VMMethod.java: Likewise. * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest interface. * java/lang/Thread.java: Add UncaughtExceptionHandler. * java/lang/reflect/Method.java: Implements GenericDeclaration and isSynthetic(), * java/lang/reflect/Field.java: Likewise. * java/lang/reflect/Constructor.java * java/lang/Class.java: Implements Type, GenericDeclaration, getSimpleName() and getEnclosing*() methods. * java/lang/Class.h: Add new public methods. * java/lang/Math.java: Add signum(), ulp() and log10(). * java/lang/natMath.cc (log10): New function. * java/security/VMSecureRandom.java: New override. * java/util/logging/Logger.java: Updated to latest classpath version. * java/util/logging/LogManager.java: New override. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113887 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/swing/ViewportLayout.java')
-rw-r--r--libjava/classpath/javax/swing/ViewportLayout.java93
1 files changed, 48 insertions, 45 deletions
diff --git a/libjava/classpath/javax/swing/ViewportLayout.java b/libjava/classpath/javax/swing/ViewportLayout.java
index 674de959f6e..b61834e9e50 100644
--- a/libjava/classpath/javax/swing/ViewportLayout.java
+++ b/libjava/classpath/javax/swing/ViewportLayout.java
@@ -120,80 +120,83 @@ public class ViewportLayout implements LayoutManager, Serializable
}
/**
- * Layout the view and viewport to respect the following rules. These are
- * not precisely the rules described in sun's javadocs, but they are the
- * rules which sun's swing implementation follows, if you watch its
- * behavior:
- *
- * <ol>
- *
- * <li>If the port is smaller than the view, leave the view at its
- * current size. Also, do not move the port, <em>unless</em> the port
- * extends into space <em>past</em> the edge of the view. If so, move the
- * port up or to the left, in view space, by the amount of empty space
- * (keep the lower and right edges lined up)</li>
+ * Layout the view and viewport to respect the following rules. These are not
+ * precisely the rules described in sun's javadocs, but they are the rules
+ * which sun's swing implementation follows, if you watch its behavior:
+ * <ol>
+ * <li>If the port is smaller than the view, leave the view at its current
+ * size.</li>
+ * <li>If the view is smaller than the port, the view is top aligned.</li>
+ * <li>If the view tracks the port size, the view position is always zero and
+ * the size equal to the viewport size</li>
* <li>In {@link JViewport#setViewSize(Dimension)}, the view size is never
* set smaller that its minimum size.</li>
- *
* </ol>
- *
+ *
* @see JViewport#getViewSize
* @see JViewport#setViewSize
* @see JViewport#getViewPosition
* @see JViewport#setViewPosition
*/
- public void layoutContainer(Container parent)
+ public void layoutContainer(Container parent)
{
// The way to interpret this function is basically to ignore the names
// of methods it calls, and focus on the variable names here. getViewRect
// doesn't, for example, return the view; it returns the port bounds in
- // view space. Likwise setViewPosition doesn't reposition the view; it
+ // view space. Likwise setViewPosition doesn't reposition the view; it
// positions the port, in view coordinates.
- JViewport port = (JViewport) parent;
+ JViewport port = (JViewport) parent;
Component view = port.getView();
-
+
if (view == null)
return;
- // These dimensions and positions are in *view space*. Do not mix
+ // These dimensions and positions are in *view space*. Do not mix
// variables in here from port space (eg. parent.getBounds()). This
// function should be entirely in view space, because the methods on
// the viewport require inputs in view space.
Rectangle portBounds = port.getViewRect();
- Dimension viewPref = view.getPreferredSize();
- Dimension viewMinimum = view.getMinimumSize();
-
+ Dimension viewPref = new Dimension(view.getPreferredSize());
+
Point portLowerRight = new Point(portBounds.x + portBounds.width,
portBounds.y + portBounds.height);
- int overextension;
// vertical implementation of the above rules
- if ((! (view instanceof Scrollable) && viewPref.height < portBounds.height
- || (view instanceof Scrollable
- && ((Scrollable) view).getScrollableTracksViewportHeight())))
- viewPref.height = portBounds.height;
-
- // If the view is larger than the port, and port is partly outside
- // the view, it is moved fully into the view area.
- overextension = portLowerRight.y - viewPref.height;
- if (overextension > 0)
- portBounds.y -= overextension;
-
- // horizontal implementation of the above rules
- if ((! (view instanceof Scrollable) && viewPref.width < portBounds.width
- || (view instanceof Scrollable
- && ((Scrollable) view).getScrollableTracksViewportWidth())))
- viewPref.width = portBounds.width;
-
- // If the view is larger than the port, and port is partly outside
- // the view, it is moved fully into the view area.
- overextension = portLowerRight.x - viewPref.width;
- if (overextension > 0)
- portBounds.x -= overextension;
+ if (view instanceof Scrollable)
+ {
+ Scrollable sView = (Scrollable) view;
+
+ // If the view size matches viewport size, the port offset can
+ // only be zero.
+ if (sView.getScrollableTracksViewportWidth())
+ {
+ viewPref.width = portBounds.width;
+ portBounds.x = 0;
+ }
+ if (sView.getScrollableTracksViewportHeight())
+ {
+ viewPref.height = portBounds.height;
+ portBounds.y = 0;
+ }
+ }
+
+ if (viewPref.width < portBounds.width)
+ viewPref.width = portBounds.width;
+ if (viewPref.height < portBounds.height)
+ viewPref.height = portBounds.height;
+
+ // If the view is larger than the port, the port is top and right
+ // aligned.
+ if (portLowerRight.x > viewPref.width)
+ portBounds.x = 0;
+
+ if (portLowerRight.y > viewPref.height)
+ portBounds.y = 0;
port.setViewSize(viewPref);
port.setViewPosition(portBounds.getLocation());
}
+
}
OpenPOWER on IntegriCloud