]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java
Take zoom level into account when picking connections
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / elementclass / RouteGraphConnectionClass.java
index a9015fcfb95c9918f7ebaea362d677c1517abea8..bf4577b51e1666378a10b3b6a46e4412b54dab99 100644 (file)
@@ -171,6 +171,10 @@ public class RouteGraphConnectionClass {
 
         @Override
         public boolean pickTest(IElement e, Shape s, PickPolicy policy) {
+            RouteGraphNode rgn = e.getHint(KEY_RG_NODE);
+            if (rgn == null) {
+                return false;
+            }
             RouteGraph rg = getRouteGraph(e);
             if (rg == null)
                 return false;
@@ -185,7 +189,7 @@ public class RouteGraphConnectionClass {
                        if (e.containsHint(KEY_USE_TOLERANCE_IN_SELECTION))
                                tolerance = getTolerance(e);
                        else
-                               tolerance = (bounds.getHeight()+bounds.getHeight()) * 0.25;
+                               tolerance = Math.max((bounds.getHeight()+bounds.getHeight()) * 0.25, rgn.getSelectionStrokeWidth() / 2);
                        Object node = rg.pickLine(bounds.getCenterX(), bounds.getCenterY(), tolerance);
                     return node != null;
             }