]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fixed vertex hover after previous commit 51/3651/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 29 Nov 2019 19:17:55 +0000 (21:17 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 29 Nov 2019 19:17:55 +0000 (21:17 +0200)
Amendment to 86d471d96d6bc11bf7629113e57c6d9a9916e608

gitlab #44

Change-Id: Id8412c69303721b619262fe7977f2805ae22dfbb

org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/DynamicVisualisationContributionsParticipant.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkHoverInfoStyle.java

index 1639d5712b8abaaf3fc8e542d74d9d9110444a4b..76151a83fd879b41b1fc8ce7e528f7f6d59d60f8 100644 (file)
@@ -179,6 +179,10 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
         updateBounds();
     }
 
+    public DistrictNetworkVertex getVertex() {
+        return vertex;
+    }
+
     @Override
     public boolean hover(boolean hover, boolean isConnectionTool) {
         // Only react to hover when the connection tool is active
index 9fbb8a29d008f8d24e9c7971b384b04199875ef6..d1a810889319be51612529e0743cd27dc1ffa75c 100644 (file)
@@ -173,7 +173,7 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
 
                     StyleResult results = DistrictNetworkHoverInfoStyle.doCalculateStyleResult(graph, runtimeDiagram, mapElement);
                     if (results != null) {
-                        Point2D location = DistrictNetworkHoverInfoStyle.calculatePoint(hoveredNode, zoomLevel);
+                        Point2D location = DistrictNetworkHoverInfoStyle.calculatePoint(hoveredNode, zoomLevel, null);
                         thread.asyncExec(() -> {
                             if (isRemoved())
                                 return;
index bdb0b731350e4a2b526445a738704cd88d9825a0..31332ec6b5a2a66b21fb0b23a7e7712ccc2b7aa1 100644 (file)
@@ -1,7 +1,6 @@
 package org.simantics.district.network.ui.styles;
 
 import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
 import java.util.Collections;
 import java.util.List;
 
@@ -124,14 +123,17 @@ public class DistrictNetworkHoverInfoStyle {
         return point;
     }
 
-    public static Point2D calculatePoint(INode node, int zoomLevel) {
+    public static Point2D calculatePoint(INode node, int zoomLevel, Point2D result) {
         if (node instanceof DistrictNetworkVertexNode) {
             DistrictNetworkVertexNode vertex = (DistrictNetworkVertexNode) node;
-            Rectangle2D b = vertex.getBounds();
-            return new Point2D.Double(b.getCenterX(), b.getCenterY());
+            return DistrictNetworkNodeUtils.calculatePoint2D(vertex.getVertex().getPoint(), result);
         } else if (node instanceof DistrictNetworkEdgeNode) {
             DistrictNetworkEdgeNode edge = (DistrictNetworkEdgeNode) node;
-            return (Point2D) edge.getCenterPoint(zoomLevel).clone();
+            Point2D cp = edge.getCenterPoint(zoomLevel);
+            if (result == null)
+                result = new Point2D.Double();
+            result.setLocation(cp);
+            return result;
         }
         return null;
     }