home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / java / awt / dnd / DropTarget$DropTargetAutoScroller.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.5 KB  |  98 lines

  1. package java.awt.dnd;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Insets;
  6. import java.awt.Point;
  7. import java.awt.Rectangle;
  8. import java.awt.Toolkit;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import javax.swing.Timer;
  12.  
  13. public class DropTarget$DropTargetAutoScroller implements ActionListener {
  14.    private Component component;
  15.    private Autoscroll autoScroll;
  16.    private Timer timer;
  17.    private Point locn;
  18.    private Point prev;
  19.    private Rectangle outer = new Rectangle();
  20.    private Rectangle inner = new Rectangle();
  21.    private int hysteresis = 10;
  22.  
  23.    protected DropTarget$DropTargetAutoScroller(Component var1, Point var2) {
  24.       this.component = var1;
  25.       this.autoScroll = (Autoscroll)this.component;
  26.       Toolkit var3 = Toolkit.getDefaultToolkit();
  27.       Integer var4 = new Integer(100);
  28.       Integer var5 = new Integer(100);
  29.  
  30.       try {
  31.          var4 = (Integer)var3.getDesktopProperty("DnD.Autoscroll.initialDelay");
  32.       } catch (Exception var9) {
  33.       }
  34.  
  35.       try {
  36.          var5 = (Integer)var3.getDesktopProperty("DnD.Autoscroll.interval");
  37.       } catch (Exception var8) {
  38.       }
  39.  
  40.       this.timer = new Timer(var5, this);
  41.       this.timer.setCoalesce(true);
  42.       this.timer.setInitialDelay(var4);
  43.       this.locn = var2;
  44.       this.prev = var2;
  45.  
  46.       try {
  47.          this.hysteresis = (Integer)var3.getDesktopProperty("DnD.Autoscroll.cursorHysteresis");
  48.       } catch (Exception var7) {
  49.       }
  50.  
  51.       this.timer.start();
  52.    }
  53.  
  54.    private void updateRegion() {
  55.       Insets var1 = this.autoScroll.getAutoscrollInsets();
  56.       Dimension var2 = this.component.getSize();
  57.       if (var2.width != this.outer.width || var2.height != this.outer.height) {
  58.          this.outer.reshape(0, 0, var2.width, var2.height);
  59.       }
  60.  
  61.       if (this.inner.x != var1.left || this.inner.y != var1.top) {
  62.          this.inner.setLocation(var1.left, var1.top);
  63.       }
  64.  
  65.       int var3 = var2.width - (var1.left + var1.right);
  66.       int var4 = var2.height - (var1.top + var1.bottom);
  67.       if (var3 != this.inner.width || var4 != this.inner.height) {
  68.          this.inner.setSize(var3, var4);
  69.       }
  70.  
  71.    }
  72.  
  73.    protected synchronized void updateLocation(Point var1) {
  74.       this.prev = this.locn;
  75.       this.locn = var1;
  76.       if (Math.abs(this.locn.x - this.prev.x) <= this.hysteresis && Math.abs(this.locn.y - this.prev.y) <= this.hysteresis) {
  77.          if (!this.timer.isRunning()) {
  78.             this.timer.start();
  79.          }
  80.       } else if (this.timer.isRunning()) {
  81.          this.timer.stop();
  82.       }
  83.  
  84.    }
  85.  
  86.    protected void stop() {
  87.       this.timer.stop();
  88.    }
  89.  
  90.    public synchronized void actionPerformed(ActionEvent var1) {
  91.       this.updateRegion();
  92.       if (this.outer.contains(this.locn) && !this.inner.contains(this.locn)) {
  93.          this.autoScroll.autoscroll(this.locn);
  94.       }
  95.  
  96.    }
  97. }
  98.