home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- class DragView extends InternalWindow {
- int animationCount;
- int animationDeltaX;
- int animationDeltaY;
- boolean _animatingBack;
- boolean _wasAccepted;
- Timer timer;
- DragSession session;
-
- public DragView() {
- }
-
- public DragView(DragSession var1) {
- ((InternalWindow)this).setBounds(var1.initialX, var1.initialY, var1.image.width(), var1.image.height());
- this.session = var1;
- super._lastX = var1.mouseDownX;
- super._lastY = var1.mouseDownY;
- ((InternalWindow)this).setType(0);
- ((InternalWindow)this).setTransparent(var1.image.isTransparent());
- ((InternalWindow)this).contentView().setTransparent(true);
- ((InternalWindow)this).setLayer(400);
- super._dragStart = true;
- ((InternalWindow)this).setRootView(var1.rootView);
- ((InternalWindow)this).show();
- ((View)this).rootView().setMouseView(this);
- ((View)this).draw();
- }
-
- public void performCommand(String var1, Object var2) {
- if ("animateRejectedDrag".equals(var1)) {
- this.animateRejectedDrag();
- } else {
- super.performCommand(var1, var2);
- }
- }
-
- private void animateRejectedDrag() {
- if (this.animationCount <= 0) {
- this.timer.stop();
- this.timer = null;
- this._animatingBack = false;
- this.animationCount = 0;
- this.animationDeltaX = 0;
- this.animationDeltaY = 0;
- this.stopDragging();
- } else {
- --this.animationCount;
- int var1 = super._lastX - (this.animationDeltaX + super.bounds.x);
- int var2 = super._lastY - (this.animationDeltaY + super.bounds.y);
- MouseEvent var3 = new MouseEvent(0L, -2, var1, var2, 0);
- this.mouseDragged(var3);
- }
- }
-
- void startAnimatingRejectedDrag() {
- this._animatingBack = true;
- if (super._lastX - this.session.mouseDownX != 0 && super._lastY - this.session.mouseDownY != 0) {
- float var1 = (float)(super._lastX - this.session.mouseDownX);
- float var2 = (float)(super._lastY - this.session.mouseDownY);
- int var3;
- int var4;
- if (var1 > var2) {
- var3 = 1 + (int)(Math.abs(var2) / 5.0F);
- var4 = (int)(Math.abs(var2) / (float)var3);
- var1 /= Math.abs(var2);
- if (var2 < 0.0F) {
- var2 = -1.0F;
- } else {
- var2 = 1.0F;
- }
- } else if (var2 > var1) {
- var3 = 1 + (int)(Math.abs(var1) / 5.0F);
- var4 = (int)(Math.abs(var1) / (float)var3);
- var2 /= Math.abs(var1);
- if (var1 < 0.0F) {
- var1 = -1.0F;
- } else {
- var1 = 1.0F;
- }
- } else {
- var4 = 0;
- var3 = 0;
- }
-
- if (var4 > 0) {
- this.animationCount = var4;
- this.animationDeltaX = (int)((float)var3 * var1);
- this.animationDeltaY = (int)((float)var3 * var2);
- this.timer = new Timer(this, "animateRejectedDrag", 25);
- this.timer.start();
- } else {
- this._animatingBack = false;
- this.stopDragging();
- }
- } else {
- this._animatingBack = false;
- this.stopDragging();
- }
- }
-
- public boolean canBecomeMain() {
- return false;
- }
-
- public boolean canBecomeDocument() {
- return false;
- }
-
- public void mouseDragged(MouseEvent var1) {
- super.mouseDragged(var1);
- if (!this._animatingBack) {
- this.session.mouseDragged(var1);
- }
-
- }
-
- void stopDragging() {
- if (((InternalWindow)this).isVisible()) {
- ((InternalWindow)this).hide();
- ((View)this).setBuffered(false);
- super.rootView.redraw(super.bounds);
- }
- }
-
- public void mouseUp(MouseEvent var1) {
- super.mouseUp(var1);
- this.session.mouseUp(var1);
- }
-
- public void drawView(Graphics var1) {
- this.session.image.drawAt(var1, 0, 0);
- }
-
- public View viewForMouse(int var1, int var2) {
- return null;
- }
- }
-