aboutsummaryrefslogtreecommitdiff
path: root/src/GraphEventHandler.java
blob: ff56fb9d4ddf8138136ec98c322702bdca1edded (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*    */ import java.awt.Point;
/*    */ import java.awt.event.MouseEvent;
/*    */ import java.awt.event.MouseListener;
/*    */ import java.awt.event.MouseMotionListener;
/*    */ import java.awt.event.MouseWheelEvent;
/*    */ import java.awt.event.MouseWheelListener;
/*    */ 
/*    */ public class GraphEventHandler
/*    */   implements MouseListener, MouseMotionListener, MouseWheelListener
/*    */ {
/*    */   private Point lastClick;
/*    */   private Graph2D graph;
/*    */ 
/*    */   public GraphEventHandler(Graph2D target)
/*    */   {
/* 19 */     this.graph = target;
/*    */   }
/*    */ 
/*    */   public void mouseClicked(MouseEvent e) {
/* 23 */     this.lastClick = e.getPoint();
/*    */   }
/*    */ 
/*    */   public void mouseEntered(MouseEvent e)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mouseExited(MouseEvent e)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mousePressed(MouseEvent e)
/*    */   {
/* 38 */     this.lastClick = e.getPoint();
/*    */   }
/*    */ 
/*    */   public void mouseReleased(MouseEvent e)
/*    */   {
/* 44 */     this.lastClick = e.getPoint();
/*    */   }
/*    */ 
/*    */   public void mouseDragged(MouseEvent e)
/*    */   {
/* 50 */     Point move = e.getPoint();
/*    */ 
/* 52 */     double difx = (move.x - this.lastClick.x) * this.graph.getXRes();
/* 53 */     double dify = (move.y - this.lastClick.y) * this.graph.getYRes();
/* 54 */     this.graph.setWindowRange(this.graph.getWindowRange().getTranslatedInstance(difx, dify));
/* 55 */     this.graph.recreate();
/* 56 */     this.graph.repaint();
/* 57 */     this.lastClick = e.getPoint();
/*    */   }
/*    */ 
/*    */   public void mouseMoved(MouseEvent e)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mouseWheelMoved(MouseWheelEvent e)
/*    */   {
/* 67 */     this.graph.zoom(Math.min(Math.pow(1.2D, e.getWheelRotation()), 1.728D));
/*    */   }
/*    */ }

/* Location:           Modulus.jar
 * Qualified Name:     GraphEventHandler
 * JD-Core Version:    0.6.2
 */