]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/SGMouseEvent.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / events / SGMouseEvent.java
diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/SGMouseEvent.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/SGMouseEvent.java
new file mode 100644 (file)
index 0000000..b7493f8
--- /dev/null
@@ -0,0 +1,92 @@
+package org.simantics.scenegraph.g2d.events;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.lang.ref.WeakReference;
+
+public class SGMouseEvent extends MouseEvent implements ISGMouseEvent {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+
+       private double _x;
+       private double _y;
+       private WeakReference<MouseEvent> _orig;
+       
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       int x, int y, int xAbs, int yAbs, int clickCount,
+                       boolean popupTrigger, int button, MouseEvent orig) {
+               super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger,
+                               button);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       int x, int y, int clickCount, boolean popupTrigger, int button, MouseEvent orig) {
+               super(source, id, when, modifiers, x, y, clickCount, popupTrigger, button);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       int x, int y, int clickCount, boolean popupTrigger, MouseEvent orig) {
+               super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       double x, double y, int xAbs, int yAbs, int clickCount,
+                       boolean popupTrigger, int button, MouseEvent orig) {
+               super(source, id, when, modifiers, (int)x, (int)y, xAbs, yAbs, clickCount, popupTrigger,
+                               button);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       double x, double y, int clickCount, boolean popupTrigger, int button, MouseEvent orig) {
+               super(source, id, when, modifiers, (int)x, (int)y, clickCount, popupTrigger, button);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+
+       public SGMouseEvent(Component source, int id, long when, int modifiers,
+                       double x, double y, int clickCount, boolean popupTrigger, MouseEvent orig) {
+               super(source, id, when, modifiers, (int)x, (int)y, clickCount, popupTrigger);
+               this._x = x;
+               this._y = y;
+               this._orig = new WeakReference<MouseEvent>(orig);
+       }
+       
+       public double getDoubleX() {
+               return _x;
+       }
+       
+       public double getDoubleY() {
+               return _y;
+       }
+       
+       @Override
+       public void consume() {
+               MouseEvent e =_orig.get();
+               if(e != null)
+                       e.consume();
+               super.consume();
+       }
+       
+       @Override
+       public boolean isConsumed() {
+               MouseEvent e =_orig.get();
+               if(e != null)
+                       return e.isConsumed();
+               return super.isConsumed();
+       }
+}