- Point2D calcPoint = calculatePoint2D(vertex, point);
- AffineTransform at = getTransform();
- return new Rectangle2D.Double(calcPoint.getX(), calcPoint.getY(), width / at.getScaleX(), height / at.getScaleY()).getBounds2D();
- }
-
- private static Point2D calculatePoint2D(DistrictNetworkVertex vertex, Point2D result) {
- Point2D point = vertex.getPoint();
- double x = ModelledCRS.longitudeToX(point.getX());
- double y = ModelledCRS.latitudeToY(-point.getY()); // Inverse because Simantics Diagram is inverted
- if (result == null)
- result = new Point2D.Double(x, y);
- else
- result.setLocation(x, y);
- return result;
+ Point2D calcPoint = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), point);
+ AffineTransform at = NodeUtil.getLocalToGlobalTransform(this);
+ at.concatenate(MapScalingTransform.INSTANCE);
+ double x = calcPoint.getX();
+ double y = calcPoint.getY();
+ double scaleRecip = DistrictNetworkNodeUtils.calculateScaleRecip(at);
+ double widthh = width * scaleRecip * nodeSize;
+ double heighth = height * scaleRecip * nodeSize;
+ if (rect == null)
+ rect = new Rectangle2D.Double();
+ rect.setRect(x - widthh/2, y - heighth/2, widthh, heighth);
+ return rect;