]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Improvements to sg event handling implementation (a bit slower, but more robust)...
authorjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 13 Dec 2010 09:27:21 +0000 (09:27 +0000)
committerjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 13 Dec 2010 09:27:21 +0000 (09:27 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@19131 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java

index 1577b1bc54f9af417cf0fd730f87b8855d160d32..8a6f36251b4a5906f20edd4aa9eeb03a043204d3 100644 (file)
@@ -27,6 +27,7 @@ import java.beans.PropertyChangeListener;
 \r
 import org.simantics.scenegraph.ISelectionPainterNode;\r
 import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.g2d.events.ISGMouseEvent;\r
 import org.simantics.scenegraph.utils.NodeUtil;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
@@ -162,11 +163,10 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode, Mo
        boolean pressHit = false;\r
 \r
        private boolean hitTest(MouseEvent event, double tolerance) {\r
-       Point2D mp = NodeUtil.sgEventLocations.get(event);\r
-               if(mp != null) {\r
+       if(event instanceof ISGMouseEvent) {\r
                        if(beginBounds == null || endBounds == null) return false;\r
 \r
-                       return Arcs.hitTest(beginBounds, endBounds, angle, mp.getX(), mp.getY(), tolerance);\r
+                       return Arcs.hitTest(beginBounds, endBounds, angle, ((ISGMouseEvent)event).getDoubleX(), ((ISGMouseEvent)event).getDoubleY(), tolerance);\r
                } else {\r
                        return false;\r
                }\r
@@ -179,11 +179,10 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode, Mo
 \r
        @Override\r
        public void mouseDragged(MouseEvent e) {\r
-       Point2D mp = NodeUtil.sgEventLocations.get(e);\r
-               if(pressHit && mp != null) {\r
+               if(pressHit && e instanceof ISGMouseEvent) {\r
                setAngle(Arcs.angleOfArc(\r
                                beginBounds.getCenterX(), beginBounds.getCenterY(), \r
-                               mp.getX(), mp.getY(), \r
+                               ((ISGMouseEvent)e).getDoubleX(), ((ISGMouseEvent)e).getDoubleY(), \r
                                endBounds.getCenterX(), endBounds.getCenterY()));\r
                }\r
        }\r