aboutsummaryrefslogtreecommitdiff
path: root/src/RectangleDrawer.java
blob: 7ada78f6a45ea98bcf239dfd837ebaab1bc77488 (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
67
68
69
70
71
/*    */ import java.awt.Point;
/*    */ import java.awt.Rectangle;
/*    */ import java.awt.event.MouseEvent;
/*    */ import java.awt.event.MouseListener;
/*    */ import java.awt.event.MouseMotionListener;
/*    */ import java.util.ArrayList;
/*    */ 
/*    */ public class RectangleDrawer
/*    */   implements MouseMotionListener, MouseListener
/*    */ {
/*    */   private Graph2D graph;
/*    */   private Point lastClick;
/*    */   private Rectangle lastRect;
/*    */   private boolean toggle;
/*    */   private ArrayList<GraphBoxListener> listener;
/*    */ 
/*    */   public RectangleDrawer(Graph2D graph)
/*    */   {
/* 17 */     this.graph = graph;
/* 18 */     this.lastClick = new Point(0, 0);
/* 19 */     this.listener = new ArrayList();
/*    */   }
/*    */ 
/*    */   public void mouseDragged(MouseEvent arg0)
/*    */   {
/* 24 */     this.graph.setRectangleShow(new Point(arg0.getPoint().x, arg0.getPoint().y), new Point(this.lastClick.x, this.lastClick.y));
/* 25 */     this.graph.repaint();
/* 26 */     this.lastRect = new Rectangle(this.lastClick.x, this.lastClick.y, arg0.getPoint().x - this.lastClick.x, arg0.getPoint().y - this.lastClick.y);
/*    */   }
/*    */ 
/*    */   public void mouseMoved(MouseEvent arg0)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mouseClicked(MouseEvent arg0)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mouseEntered(MouseEvent arg0)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mouseExited(MouseEvent arg0)
/*    */   {
/*    */   }
/*    */ 
/*    */   public void mousePressed(MouseEvent arg0)
/*    */   {
/* 57 */     this.lastClick = arg0.getPoint();
/* 58 */     this.toggle = true;
/*    */   }
/*    */ 
/*    */   public void mouseReleased(MouseEvent arg0)
/*    */   {
/* 63 */     this.toggle = false;
/* 64 */     this.graph.setRectangleShow(null, null);
/* 65 */     this.graph.setRectangleMode(false);
/* 66 */     this.graph.repaint();
/* 67 */     for (int i = 0; i < this.listener.size(); i++)
/* 68 */       ((GraphBoxListener)this.listener.get(i)).graphBoxMade(arg0.getPoint().x, arg0.getPoint().y, this.lastClick.x, this.lastClick.y);
/*    */   }
/*    */ 
/*    */   public void addGraphBoxListener(GraphBoxListener l) {
/* 72 */     this.listener.add(l);
/*    */   }
/*    */ }

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