X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Fadapters%2FDistrictNetworkVertexElement.java;h=1ff5eefa407c7c75a3e978b9531232a23c067bdd;hb=3782d433abb145ad96572af30ee9968bb91ca7de;hp=b3e7fda3b822401b2d525d51ef7f0c1c0bb70e38;hpb=59a2dd367b6cb9d02f22e473386d63ab59a857b3;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkVertexElement.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkVertexElement.java index b3e7fda3..1ff5eefa 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkVertexElement.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkVertexElement.java @@ -22,7 +22,6 @@ import org.simantics.g2d.element.handler.impl.SimpleElementLayers; import org.simantics.scenegraph.INode; import org.simantics.scenegraph.g2d.G2DParentNode; import org.simantics.scenegraph.g2d.nodes.SVGNode; -import org.simantics.scenegraph.utils.GeometryUtils; import org.simantics.utils.datastructures.hints.IHintContext.Key; import org.simantics.utils.datastructures.hints.IHintContext.KeyOf; @@ -97,13 +96,16 @@ public class DistrictNetworkVertexElement { 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; + double x = boundsInLocal.getX(); + double y = boundsInLocal.getY(); + double scaledWidth = boundsInLocal.getWidth(); + double scaledHeight = boundsInLocal.getHeight(); + if (canvasTransform != null) { + scaledWidth = boundsInLocal.getWidth() / canvasTransform.getScaleX(); + scaledHeight= boundsInLocal.getHeight() / canvasTransform.getScaleY(); + } + double width = scaledWidth; + double height = scaledHeight; size.setFrame(x, y, width, height); return size; @@ -113,9 +115,6 @@ public class DistrictNetworkVertexElement { public boolean pickTest(IElement e, Shape s, PickPolicy policy) { DistrictNetworkVertexNode node = e.getHint(KEY_DN_VERTEX_NODE); Rectangle2D boundsInLocal = node.getBounds(); - ICanvasContext ctx = DiagramNodeUtil.getCanvasContext(node); - AffineTransform canvasTransform = ctx.getHintStack().getHint(Hints.KEY_CANVAS_TRANSFORM); - Rectangle2D scaledBounds = new Rectangle2D.Double(boundsInLocal.getX(), boundsInLocal.getY(), boundsInLocal.getWidth() / canvasTransform.getScaleX() * 2, boundsInLocal.getHeight() / canvasTransform.getScaleY() * 2); Rectangle2D bounds = getBounds(s); switch (policy) { case PICK_CONTAINED_OBJECTS: