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