- if (size == null)
- size = new Rectangle2D.Double();
- size.setFrame(-0.5, -0.5, 1, 1);
+ DistrictNetworkVertexNode node = e.getHint(KEY_DN_VERTEX_NODE);
+ Rectangle2D boundsInLocal = node.getBoundsInLocal();
+ ICanvasContext ctx = DiagramNodeUtil.getCanvasContext(node);
+ AffineTransform canvasTransform = ctx.getHintStack().getHint(Hints.KEY_CANVAS_TRANSFORM);
+ // for some reason PickContextImpl expands the rectangle by 0.001 (too much) - let's counter it
+ double counterExpansion = 0.001;
+ double x = boundsInLocal.getX() + counterExpansion;
+ double y = boundsInLocal.getY() + counterExpansion;
+ double scaledWidth = boundsInLocal.getWidth() / canvasTransform.getScaleX() / 10000.0;
+ double scaledHeight = boundsInLocal.getHeight() / canvasTransform.getScaleY() / 10000.0;
+ double width = scaledWidth - 2*counterExpansion;
+ double height = scaledHeight - 2*counterExpansion;
+ size.setFrame(x, y, width, height);
+