/Users/lyon/j4p/src/gui/mouse/MouseRotationController.java
|
1 /*
2 * Created by DocJava, Inc.
3 * User: lyon
4 * Date: Mar 30, 2003
5 * Time: 9:50:33 AM
6 */
7 package gui.mouse;
8
9 import java.awt.event.MouseEvent;
10 import java.awt.event.MouseListener;
11 import java.awt.event.MouseMotionListener;
12
13 public class MouseRotationController
14 implements MouseListener, MouseMotionListener {
15 //float xrot = 64;
16 //float yrot = 32;
17 //float zrot = 17;
18 private float dx = 0;
19 private float dy = 0;
20 private float dz = 0;
21 private float oldx,oldy;
22 private boolean autorot = true;
23 Rotatable r;
24
25 public void mouseMoved(MouseEvent evt) {
26 };
27 public void mouseClicked(MouseEvent evt) {
28 };
29 public void mouseEntered(MouseEvent evt) {
30 };
31 public void mouseExited(MouseEvent evt) {
32 }
33
34 public MouseRotationController(Rotatable _r) {
35 r = _r;
36 }
37
38
39 public void mousePressed(MouseEvent evt) {
40 autorot = false;
41 oldx = evt.getX();
42 oldy = evt.getY();
43 }
44
45 public void mouseReleased(MouseEvent evt) {
46 autorot = true;
47 oldx = evt.getX();
48 oldy = evt.getY();
49 }
50
51 public void mouseDragged(MouseEvent evt) {
52 int x = evt.getX();
53 int y = evt.getY();
54
55 r.rotateWorld((oldy - y), (oldx - x), 0);
56 dx = (dx + oldx - x + 360) % 360;
57 dy = (dy + oldy - y + 360) % 360;
58 //showStatus("dx="+dx+" dy="+dy);
59 oldx = x;
60 oldy = y;
61 }
62
63 public boolean isAutorot() {
64 return autorot;
65 }
66 }
67