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;
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;
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;
}