|
@@ -3,14 +3,12 @@ |
3 |
3 |
|
|
4 |
4 |
|
import org.litesoft.GWT.client.widgets.nonpublic.external.*; |
5 |
5 |
|
|
6 |
|
- |
public abstract class AbstractDragger implements DragGesture |
7 |
|
- |
{ |
|
6 |
+ |
public abstract class AbstractDragger implements DragGesture { |
8 |
7 |
|
private XY mMouseStartDrag; |
9 |
8 |
|
private boolean mCancelled; |
10 |
9 |
|
|
11 |
10 |
|
@Override |
12 |
|
- |
public void start( MouseEvent e ) |
13 |
|
- |
{ |
|
11 |
+ |
public void start( MouseEvent e ) { |
14 |
12 |
|
mCancelled = false; |
15 |
13 |
|
mMouseStartDrag = new XY( e.getWidgetX(), e.getWidgetY() ); |
16 |
14 |
|
// StatusBar.set( "dragStart" + mMouseStartDrag ); |
|
@@ -20,15 +18,12 @@ |
20 |
18 |
|
} |
21 |
19 |
|
|
22 |
20 |
|
@Override |
23 |
|
- |
public void step( DragEvent e ) |
24 |
|
- |
{ |
25 |
|
- |
if ( !mCancelled ) |
26 |
|
- |
{ |
|
21 |
+ |
public void step( DragEvent e ) { |
|
22 |
+ |
if ( !mCancelled ) { |
27 |
23 |
|
XY xy = new XY( e.getWidgetX(), e.getWidgetY() ); |
28 |
24 |
|
XY delta = xy.minus( mMouseStartDrag ); |
29 |
25 |
|
// StatusBar.set( "MouseMove" + xy + "-" + mMouseStartDrag + "=" + delta ); |
30 |
|
- |
if ( !dragBy( delta.getX(), delta.getY() ) ) |
31 |
|
- |
{ |
|
26 |
+ |
if ( !dragBy( delta.getX(), delta.getY() ) ) { |
32 |
27 |
|
finish(); |
33 |
28 |
|
mCancelled = true; |
34 |
29 |
|
} |
|
@@ -36,11 +31,9 @@ |
36 |
31 |
|
} |
37 |
32 |
|
|
38 |
33 |
|
@Override |
39 |
|
- |
public void finish() |
40 |
|
- |
{ |
|
34 |
+ |
public void finish() { |
41 |
35 |
|
// StatusBar.set( "dragStop" ); |
42 |
|
- |
if ( !mCancelled ) |
43 |
|
- |
{ |
|
36 |
+ |
if ( !mCancelled ) { |
44 |
37 |
|
mMouseStartDrag = null; |
45 |
38 |
|
|
46 |
39 |
|
// matg: disabled due to poor performance w/ complex windows |
|
@@ -53,59 +46,48 @@ |
53 |
46 |
|
*/ |
54 |
47 |
|
protected abstract boolean dragBy( int pDeltaX, int pDeltaY ); |
55 |
48 |
|
|
56 |
|
- |
private static class XY |
57 |
|
- |
{ |
|
49 |
+ |
private static class XY { |
58 |
50 |
|
private int mX, mY; |
59 |
51 |
|
|
60 |
|
- |
public XY( int pX, int pY ) |
61 |
|
- |
{ |
|
52 |
+ |
public XY( int pX, int pY ) { |
62 |
53 |
|
mX = pX; |
63 |
54 |
|
mY = pY; |
64 |
55 |
|
} |
65 |
56 |
|
|
66 |
|
- |
public int getX() |
67 |
|
- |
{ |
|
57 |
+ |
public int getX() { |
68 |
58 |
|
return mX; |
69 |
59 |
|
} |
70 |
60 |
|
|
71 |
|
- |
public int getY() |
72 |
|
- |
{ |
|
61 |
+ |
public int getY() { |
73 |
62 |
|
return mY; |
74 |
63 |
|
} |
75 |
64 |
|
|
76 |
65 |
|
@Override |
77 |
|
- |
public String toString() |
78 |
|
- |
{ |
|
66 |
+ |
public String toString() { |
79 |
67 |
|
return "(" + mX + ", " + mY + ")"; |
80 |
68 |
|
} |
81 |
69 |
|
|
82 |
|
- |
public XY add( XY them ) |
83 |
|
- |
{ |
|
70 |
+ |
public XY add( XY them ) { |
84 |
71 |
|
return new XY( this.mX + them.mX, this.mY + them.mY ); |
85 |
72 |
|
} |
86 |
73 |
|
|
87 |
|
- |
public XY minus( XY them ) |
88 |
|
- |
{ |
|
74 |
+ |
public XY minus( XY them ) { |
89 |
75 |
|
return new XY( this.mX - them.mX, this.mY - them.mY ); |
90 |
76 |
|
} |
91 |
77 |
|
|
92 |
|
- |
public XY addX( int pX ) |
93 |
|
- |
{ |
|
78 |
+ |
public XY addX( int pX ) { |
94 |
79 |
|
return new XY( this.mX + pX, this.mY ); |
95 |
80 |
|
} |
96 |
81 |
|
|
97 |
|
- |
public XY minusX( int pX ) |
98 |
|
- |
{ |
|
82 |
+ |
public XY minusX( int pX ) { |
99 |
83 |
|
return new XY( this.mX - pX, this.mY ); |
100 |
84 |
|
} |
101 |
85 |
|
|
102 |
|
- |
public XY addY( int pY ) |
103 |
|
- |
{ |
|
86 |
+ |
public XY addY( int pY ) { |
104 |
87 |
|
return new XY( this.mX, this.mY + pY ); |
105 |
88 |
|
} |
106 |
89 |
|
|
107 |
|
- |
public XY minusY( int pY ) |
108 |
|
- |
{ |
|
90 |
+ |
public XY minusY( int pY ) { |
109 |
91 |
|
return new XY( this.mX, this.mY - pY ); |
110 |
92 |
|
} |
111 |
93 |
|
} |