]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/pointertool/TerminalUtil.java
Performance and resource consumption optimization for G2D picking
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / participant / pointertool / TerminalUtil.java
index 677c97f0f4fa0062779d9688ea718e39218f4508..da98294284aba29e314ee056168004c91d92189b 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
+import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.DiagramUtils;
 import org.simantics.g2d.diagram.IDiagram;
 import org.simantics.g2d.diagram.handler.PickRequest;
@@ -118,7 +119,7 @@ public class TerminalUtil {
      * @param pickAreaTerminals pick terminals that have a shape
      * @return terminals in z-order (bottom to top)
      */
-    public static List<TerminalInfo> pickTerminals(IDiagram d, Shape pickShape, boolean pickPointTerminals, boolean pickAreaTerminals)
+    public static List<TerminalInfo> pickTerminals(ICanvasContext ctx, IDiagram d, Shape pickShape, boolean pickPointTerminals, boolean pickAreaTerminals)
     {
         boolean clearElements = false;
         List<IElement> elements = null;
@@ -127,7 +128,7 @@ public class TerminalUtil {
             elements = ELEMENTS.get();
             elements.clear();
             clearElements = true;
-            PickRequest req = new PickRequest(pickShape);
+            PickRequest req = new PickRequest(pickShape).context(ctx);
             DiagramUtils.pick(d, req, elements);
         } else {
             // Select all terminals
@@ -201,11 +202,11 @@ public class TerminalUtil {
      * @param pickShape pick area (in diagram coordinate system)
      * @return terminals in z-order (bottom to top)
      */
-    public static TerminalInfo pickTerminal(IDiagram diagram, Shape pickShape)
+    public static TerminalInfo pickTerminal(ICanvasContext ctx, IDiagram diagram, Shape pickShape)
     {
         ArrayList<IElement> elements = ELEMENTS.get();
         elements.clear();
-        PickRequest req = new PickRequest(pickShape);
+        PickRequest req = new PickRequest(pickShape).context(ctx);
         DiagramUtils.pick(diagram, req, elements);
         if (elements.isEmpty())
             return null;
@@ -363,7 +364,7 @@ public class TerminalUtil {
      * @param pickShape
      * @return bends or null
      */
-    public BendsInfo pickBends(IDiagram diagram, Shape pickShape)
+    public BendsInfo pickBends(ICanvasContext ctx, IDiagram diagram, Shape pickShape)
     {
         BendsInfo              result = null;
         double                         bestShortestDist = Double.MAX_VALUE;
@@ -372,7 +373,7 @@ public class TerminalUtil {
 
         ArrayList<IElement> elements = ELEMENTS.get();
         elements.clear();
-        PickRequest req = new PickRequest(pickShape);
+        PickRequest req = new PickRequest(pickShape).context(ctx);
         DiagramUtils.pick(diagram, req, elements);
 
         ArrayList<Bend> bends = new ArrayList<>();