home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / awt / dnd / DragGestureRecognizer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  123 lines

  1. package java.awt.dnd;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Point;
  5. import java.awt.event.InputEvent;
  6. import java.util.ArrayList;
  7. import java.util.TooManyListenersException;
  8.  
  9. public abstract class DragGestureRecognizer {
  10.    protected DragSource dragSource;
  11.    protected Component component;
  12.    protected DragGestureListener dragGestureListener;
  13.    protected int sourceActions;
  14.    protected ArrayList events;
  15.  
  16.    protected DragGestureRecognizer(DragSource var1, Component var2, int var3, DragGestureListener var4) {
  17.       this.events = new ArrayList(1);
  18.       if (var1 == null) {
  19.          throw new IllegalArgumentException("null DragSource");
  20.       } else {
  21.          this.dragSource = var1;
  22.          this.component = var2;
  23.          this.sourceActions = var3 & 1073741827;
  24.  
  25.          try {
  26.             if (var4 != null) {
  27.                this.addDragGestureListener(var4);
  28.             }
  29.          } catch (TooManyListenersException var6) {
  30.          }
  31.  
  32.       }
  33.    }
  34.  
  35.    protected DragGestureRecognizer(DragSource var1, Component var2, int var3) {
  36.       this(var1, var2, var3, (DragGestureListener)null);
  37.    }
  38.  
  39.    protected DragGestureRecognizer(DragSource var1, Component var2) {
  40.       this(var1, var2, 0);
  41.    }
  42.  
  43.    protected DragGestureRecognizer(DragSource var1) {
  44.       this(var1, (Component)null);
  45.    }
  46.  
  47.    protected abstract void registerListeners();
  48.  
  49.    protected abstract void unregisterListeners();
  50.  
  51.    public DragSource getDragSource() {
  52.       return this.dragSource;
  53.    }
  54.  
  55.    public synchronized Component getComponent() {
  56.       return this.component;
  57.    }
  58.  
  59.    public synchronized void setComponent(Component var1) {
  60.       if (this.component != null && this.dragGestureListener != null) {
  61.          this.unregisterListeners();
  62.       }
  63.  
  64.       this.component = var1;
  65.       if (this.component != null && this.dragGestureListener != null) {
  66.          this.registerListeners();
  67.       }
  68.  
  69.    }
  70.  
  71.    public synchronized int getSourceActions() {
  72.       return this.sourceActions;
  73.    }
  74.  
  75.    public synchronized void setSourceActions(int var1) {
  76.       this.sourceActions = var1 & 1073741827;
  77.    }
  78.  
  79.    public InputEvent getTriggerEvent() {
  80.       return this.events.isEmpty() ? null : (InputEvent)this.events.get(0);
  81.    }
  82.  
  83.    public void resetRecognizer() {
  84.       this.events.clear();
  85.    }
  86.  
  87.    public synchronized void addDragGestureListener(DragGestureListener var1) throws TooManyListenersException {
  88.       if (this.dragGestureListener != null) {
  89.          throw new TooManyListenersException();
  90.       } else {
  91.          this.dragGestureListener = var1;
  92.          if (this.component != null) {
  93.             this.registerListeners();
  94.          }
  95.  
  96.       }
  97.    }
  98.  
  99.    public synchronized void removeDragGestureListener(DragGestureListener var1) {
  100.       if (this.dragGestureListener != null && this.dragGestureListener.equals(var1)) {
  101.          this.dragGestureListener = null;
  102.          if (this.component != null) {
  103.             this.unregisterListeners();
  104.          }
  105.  
  106.       } else {
  107.          throw new IllegalArgumentException();
  108.       }
  109.    }
  110.  
  111.    protected synchronized void fireDragGestureRecognized(int var1, Point var2) {
  112.       if (this.dragGestureListener != null) {
  113.          this.dragGestureListener.dragGestureRecognized(new DragGestureEvent(this, var1, var2, this.events));
  114.       }
  115.  
  116.       this.events.clear();
  117.    }
  118.  
  119.    protected synchronized void appendEvent(InputEvent var1) {
  120.       this.events.add(var1);
  121.    }
  122. }
  123.