]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java
Merge "JsonNode support with Data/Json"
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / participant / ElementPainter.java
index 1eb15f61c2132ece167643ee6af6638ef4cb6e9b..eb9e33607d5500197cc7c4fd8d0c061036d835c3 100644 (file)
@@ -557,6 +557,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
             ConnectionNode holder = e.getHint(sgKey);
             if (holder == null) {
                 holder = parentNode.addNode(ElementUtils.generateNodeId(e), ConnectionNode.class);
+                holder.setKey(e.getHint(ElementHints.KEY_OBJECT));
                 holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e));
                 e.setHint(sgKey, holder);
                 holder.setZIndex(parentNode.getNodeCount() + 1);
@@ -567,6 +568,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
             SingleElementNode holder = e.getHint(sgKey);
             if (holder == null) {
                 holder = parentNode.addNode(ElementUtils.generateNodeId(e), SingleElementNode.class);
+                holder.setKey(e.getHint(ElementHints.KEY_OBJECT));
                 holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e));
                 e.setHint(sgKey, holder);
                 holder.setZIndex(parentNode.getNodeCount() + 1);
@@ -1010,8 +1012,9 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
         Shape shape = ElementUtils.getElementShapeOrBounds(e);
         Rectangle2D bounds = shape.getBounds2D();
         //System.out.println("selection bounds: "+bounds);
-        final double margin = 1;
-        bounds.setFrame(bounds.getMinX() - margin, bounds.getMinY() - margin, bounds.getWidth() + 2*margin, bounds.getHeight() + 2*margin);
+        final double marginX = 1 / selectionTransform.getScaleX();
+        final double marginY = 1 / selectionTransform.getScaleY();
+        bounds.setFrame(bounds.getMinX() - marginX, bounds.getMinY() - marginY, bounds.getWidth() + 2*marginX, bounds.getHeight() + 2*marginY);
 
         List<SelectionSpecification> ss = e.getElementClass().getItemsByClass(SelectionSpecification.class);
         if (!ss.isEmpty()) {