home *** CD-ROM | disk | FTP | other *** search
- package java.awt.dnd;
-
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.Timer;
-
- public class DropTarget$DropTargetAutoScroller implements ActionListener {
- private Component component;
- private Autoscroll autoScroll;
- private Timer timer;
- private Point locn;
- private Point prev;
- private Rectangle outer = new Rectangle();
- private Rectangle inner = new Rectangle();
- private int hysteresis = 10;
-
- protected DropTarget$DropTargetAutoScroller(Component var1, Point var2) {
- this.component = var1;
- this.autoScroll = (Autoscroll)this.component;
- Toolkit var3 = Toolkit.getDefaultToolkit();
- Integer var4 = new Integer(100);
- Integer var5 = new Integer(100);
-
- try {
- var4 = (Integer)var3.getDesktopProperty("DnD.Autoscroll.initialDelay");
- } catch (Exception var9) {
- }
-
- try {
- var5 = (Integer)var3.getDesktopProperty("DnD.Autoscroll.interval");
- } catch (Exception var8) {
- }
-
- this.timer = new Timer(var5, this);
- this.timer.setCoalesce(true);
- this.timer.setInitialDelay(var4);
- this.locn = var2;
- this.prev = var2;
-
- try {
- this.hysteresis = (Integer)var3.getDesktopProperty("DnD.Autoscroll.cursorHysteresis");
- } catch (Exception var7) {
- }
-
- this.timer.start();
- }
-
- private void updateRegion() {
- Insets var1 = this.autoScroll.getAutoscrollInsets();
- Dimension var2 = this.component.getSize();
- if (var2.width != this.outer.width || var2.height != this.outer.height) {
- this.outer.reshape(0, 0, var2.width, var2.height);
- }
-
- if (this.inner.x != var1.left || this.inner.y != var1.top) {
- this.inner.setLocation(var1.left, var1.top);
- }
-
- int var3 = var2.width - (var1.left + var1.right);
- int var4 = var2.height - (var1.top + var1.bottom);
- if (var3 != this.inner.width || var4 != this.inner.height) {
- this.inner.setSize(var3, var4);
- }
-
- }
-
- protected synchronized void updateLocation(Point var1) {
- this.prev = this.locn;
- this.locn = var1;
- if (Math.abs(this.locn.x - this.prev.x) <= this.hysteresis && Math.abs(this.locn.y - this.prev.y) <= this.hysteresis) {
- if (!this.timer.isRunning()) {
- this.timer.start();
- }
- } else if (this.timer.isRunning()) {
- this.timer.stop();
- }
-
- }
-
- protected void stop() {
- this.timer.stop();
- }
-
- public synchronized void actionPerformed(ActionEvent var1) {
- this.updateRegion();
- if (this.outer.contains(this.locn) && !this.inner.contains(this.locn)) {
- this.autoScroll.autoscroll(this.locn);
- }
-
- }
- }
-