diff options
author | Roman Kennke <roman@kennke.org> | 2006-09-21 10:04:26 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-09-21 10:04:26 +0000 |
commit | bd901e5f53c33ef007941390b563dc70a85c1df5 (patch) | |
tree | 6548aca548d2ed49ebb0496acfa0c715f9400f80 /javax/swing/plaf | |
parent | 614b826b0271811c6737131a5d292a92309a8d13 (diff) | |
download | classpath-bd901e5f53c33ef007941390b563dc70a85c1df5.tar.gz |
2006-09-21 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicScrollPaneUI.java
(syncScrollPaneWithViewport): Fixed typo (hsb vs. vsb).
Use more efficient getViewPosition() and getViewSize() methods
to avoid creating a rectangle.
(HSBChangeListener.stateChanged): Update the view position
unconditionally. Let the Viewport figure out if something
changed.
(VSBChangeListener.stateChanged): Update the view position
unconditionally. Let the Viewport figure out if something
changed.
* javax/swing/JViewport.java
(ViewListener.componentResized): Fire state change, because
the extentSize changes.
(extentSize): Removed unneeded field.
(viewSize): Removed unneeded field.
(getExtentSize): Return the viewport's size here.
(getViewRect): Reformatted.
(getViewSize): Reordered for only one return statement.
(paintImmediately2): Fixed up javadoc.
(paint): Removed unneeded statement.
(setExtentSize): Set viewport size and check for actual change
of value.
(setViewPosition): Simplified condition. Set scrollUnderway
true and don't set isViewSizeSet. Avoid creating one Point
object.
(setViewSize): Fixed != comparison with equals(). Set scrollUnderway
to false.
* javax/swing/JScrollBar.java
(ScrollBarListener): New class. Forwards change events from
the model as adjustment events.
(sbChangeListener): New field.
(JScrollBar): Install listener on new model.
(fireAdjustmentValueChanged(int,int,int)): Delegate to new helper
method.
(fireAdjustmentValueChanged(int,int,int,boolean)): New helper
method to allow custom isAdjusting value.
(setMaximum): Only forward to model.
(setMinimum): Only forward to model.
(setValue): Only forward to model.
(setVisibleAmount): Only forward to model.
(setValues): Only forward to model.
(setModel): Update the change listener.
Diffstat (limited to 'javax/swing/plaf')
-rw-r--r-- | javax/swing/plaf/basic/BasicScrollPaneUI.java | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java index 0b26ea6b9..236eac073 100644 --- a/javax/swing/plaf/basic/BasicScrollPaneUI.java +++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java @@ -101,13 +101,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI JScrollBar hsb = scrollpane.getHorizontalScrollBar(); JViewport vp = scrollpane.getViewport(); Point viewPosition = vp.getViewPosition(); - int xpos = hsb.getValue(); - - if (xpos != viewPosition.x) - { - viewPosition.x = xpos; - vp.setViewPosition(viewPosition); - } + viewPosition.x = hsb.getValue(); + vp.setViewPosition(viewPosition); } } @@ -132,12 +127,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI JScrollBar vsb = scrollpane.getVerticalScrollBar(); JViewport vp = scrollpane.getViewport(); Point viewPosition = vp.getViewPosition(); - int ypos = vsb.getValue(); - if (ypos != viewPosition.y) - { - viewPosition.y = ypos; - vp.setViewPosition(viewPosition); - } + viewPosition.y = vsb.getValue(); + vp.setViewPosition(viewPosition); } } @@ -819,16 +810,17 @@ public class BasicScrollPaneUI extends ScrollPaneUI if (vp != null) { Dimension extentSize = vp.getExtentSize(); - Rectangle viewBounds = vp.getViewRect(); + Point viewPos = vp.getViewPosition(); + Dimension viewSize = vp.getViewSize(); // Update the vertical scrollbar. JScrollBar vsb = scrollpane.getVerticalScrollBar(); if (vsb != null) { int extent = extentSize.height; - int max = viewBounds.height; - vsb.setValues(Math.max(0, Math.min(viewBounds.y, max - extent)), - extent, 0, max); + int max = viewSize.height; + int val = Math.max(0, Math.min(viewPos.y, max - extent)); + vsb.setValues(val, extent, 0, max); } // Update the horizontal scrollbar. @@ -836,16 +828,16 @@ public class BasicScrollPaneUI extends ScrollPaneUI if (hsb != null) { int extent = extentSize.width; - int max = viewBounds.width; - vsb.setValues(Math.max(0, Math.min(viewBounds.x, max - extent)), - extent, 0, max); + int max = viewSize.width; + int val = Math.max(0, Math.min(viewPos.x, max - extent)); + hsb.setValues(val, extent, 0, max); } // Update the row header. JViewport rowHeader = scrollpane.getRowHeader(); if (rowHeader != null) { - Point p = new Point(0, viewBounds.y); + Point p = new Point(0, viewPos.y); rowHeader.setViewPosition(p); } @@ -853,7 +845,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI JViewport colHeader = scrollpane.getColumnHeader(); if (colHeader != null) { - Point p = new Point(viewBounds.x, 0); + Point p = new Point(viewPos.x, 0); colHeader.setViewPosition(p); } } |