]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/SGMouseEvent.java
Sync git svn branch with SVN repository r33269.
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / events / SGMouseEvent.java
1 package org.simantics.scenegraph.g2d.events;
2
3 import java.awt.Component;
4 import java.awt.event.MouseEvent;
5 import java.lang.ref.WeakReference;
6
7 public class SGMouseEvent extends MouseEvent implements ISGMouseEvent {
8         /**
9          * 
10          */
11         private static final long serialVersionUID = 1L;
12
13         private double _x;
14         private double _y;
15         private WeakReference<MouseEvent> _orig;
16         
17         public SGMouseEvent(Component source, int id, long when, int modifiers,
18                         int x, int y, int xAbs, int yAbs, int clickCount,
19                         boolean popupTrigger, int button, MouseEvent orig) {
20                 super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger,
21                                 button);
22                 this._x = x;
23                 this._y = y;
24                 this._orig = new WeakReference<MouseEvent>(orig);
25         }
26
27         public SGMouseEvent(Component source, int id, long when, int modifiers,
28                         int x, int y, int clickCount, boolean popupTrigger, int button, MouseEvent orig) {
29                 super(source, id, when, modifiers, x, y, clickCount, popupTrigger, button);
30                 this._x = x;
31                 this._y = y;
32                 this._orig = new WeakReference<MouseEvent>(orig);
33         }
34
35         public SGMouseEvent(Component source, int id, long when, int modifiers,
36                         int x, int y, int clickCount, boolean popupTrigger, MouseEvent orig) {
37                 super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
38                 this._x = x;
39                 this._y = y;
40                 this._orig = new WeakReference<MouseEvent>(orig);
41         }
42
43         public SGMouseEvent(Component source, int id, long when, int modifiers,
44                         double x, double y, int xAbs, int yAbs, int clickCount,
45                         boolean popupTrigger, int button, MouseEvent orig) {
46                 super(source, id, when, modifiers, (int)x, (int)y, xAbs, yAbs, clickCount, popupTrigger,
47                                 button);
48                 this._x = x;
49                 this._y = y;
50                 this._orig = new WeakReference<MouseEvent>(orig);
51         }
52
53         public SGMouseEvent(Component source, int id, long when, int modifiers,
54                         double x, double y, int clickCount, boolean popupTrigger, int button, MouseEvent orig) {
55                 super(source, id, when, modifiers, (int)x, (int)y, clickCount, popupTrigger, button);
56                 this._x = x;
57                 this._y = y;
58                 this._orig = new WeakReference<MouseEvent>(orig);
59         }
60
61         public SGMouseEvent(Component source, int id, long when, int modifiers,
62                         double x, double y, int clickCount, boolean popupTrigger, MouseEvent orig) {
63                 super(source, id, when, modifiers, (int)x, (int)y, clickCount, popupTrigger);
64                 this._x = x;
65                 this._y = y;
66                 this._orig = new WeakReference<MouseEvent>(orig);
67         }
68         
69         public double getDoubleX() {
70                 return _x;
71         }
72         
73         public double getDoubleY() {
74                 return _y;
75         }
76         
77         @Override
78         public void consume() {
79                 MouseEvent e =_orig.get();
80                 if(e != null)
81                         e.consume();
82                 super.consume();
83         }
84         
85         @Override
86         public boolean isConsumed() {
87                 MouseEvent e =_orig.get();
88                 if(e != null)
89                         return e.isConsumed();
90                 return super.isConsumed();
91         }
92 }