X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fevents%2FSGMouseEvent.java;fp=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fevents%2FSGMouseEvent.java;h=b7493f8f9c1ad80864ebf8d7a12fc1b067a5e869;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..b7493f8f9 --- /dev/null +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/SGMouseEvent.java @@ -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 _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(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(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(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(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(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(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(); + } +}