From 935dde422dc39fcccffc378354e4d1b1ca030fe8 Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 20 Apr 2003 01:06:12 +0000 Subject: [PATCH] possibly fix to work with negative values git-svn-id: https://samskivert.googlecode.com/svn/trunk@1101 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/swing/ScrollBox.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java b/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java index b6164e91..474fa7bb 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java +++ b/projects/samskivert/src/java/com/samskivert/swing/ScrollBox.java @@ -1,5 +1,5 @@ // -// $Id: ScrollBox.java,v 1.2 2003/03/26 20:38:18 ray Exp $ +// $Id: ScrollBox.java,v 1.3 2003/04/20 01:06:12 ray Exp $ package com.samskivert.swing; @@ -120,15 +120,17 @@ public class ScrollBox extends JPanel */ protected void updateBox () { - _hFactor = (_active.width) / - (float) (_horz.getMaximum() - _horz.getMinimum()); - _vFactor = (_active.height) / - (float) (_vert.getMaximum() - _vert.getMinimum()); + int hmin = _horz.getMinimum(); + int vmin = _vert.getMinimum(); + _hFactor = (_active.width) / (float) (_horz.getMaximum() - hmin); + _vFactor = (_active.height) / (float) (_vert.getMaximum() - vmin); - _box.x = _active.x + (int) Math.round(_horz.getValue() * _hFactor); + _box.x = _active.x + (int) Math.round((_horz.getValue() - hmin) * + _hFactor); _box.width = (int) Math.round(_horz.getExtent() * _hFactor); - _box.y = _active.y + (int) Math.round(_vert.getValue() * _vFactor); + _box.y = _active.y + (int) Math.round((_vert.getValue() - vmin) * + _vFactor); _box.height = (int) Math.round(_vert.getExtent() * _vFactor); }