X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fdiagram%2Fparticipant%2FElementPainter.java;h=d35bfadb04ba2fd7e92eefaaa4b5f7feda40440d;hb=9c4f7c59dc673c6af8d3ac1d92566ff132d43826;hp=d69ef69c69fadec257a3e07e2fc31a600cd5ed15;hpb=c26409b1caf2f1e560d37c5befd11b442399c3fe;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java index d69ef69c6..d35bfadb0 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java @@ -91,6 +91,7 @@ import org.simantics.scenegraph.g2d.nodes.SingleElementNode; import org.simantics.scenegraph.g2d.nodes.UnboundedNode; import org.simantics.scenegraph.g2d.nodes.spatial.RTreeNode; import org.simantics.scenegraph.utils.ColorUtil; +import org.simantics.scenegraph.utils.GeometryUtils; import org.simantics.scenegraph.utils.NodeUtil; import org.simantics.utils.datastructures.collections.CollectionUtils; import org.simantics.utils.datastructures.hints.HintListenerAdapter; @@ -558,6 +559,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos if (holder == null) { holder = parentNode.addNode(ElementUtils.generateNodeId(e), ConnectionNode.class); holder.setKey(e.getHint(ElementHints.KEY_OBJECT)); + holder.setTypeClass(e.getHint(ElementHints.KEY_TYPE_CLASS)); holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e)); e.setHint(sgKey, holder); holder.setZIndex(parentNode.getNodeCount() + 1); @@ -569,6 +571,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos if (holder == null) { holder = parentNode.addNode(ElementUtils.generateNodeId(e), SingleElementNode.class); holder.setKey(e.getHint(ElementHints.KEY_OBJECT)); + holder.setTypeClass(e.getHint(ElementHints.KEY_TYPE_CLASS)); holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e)); e.setHint(sgKey, holder); holder.setZIndex(parentNode.getNodeCount() + 1); @@ -1012,8 +1015,12 @@ 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); + + Point2D scale = GeometryUtils.getScale2D(selectionTransform); + final double marginX = Math.abs(scale.getX()) > 1e-10 ? 1 / scale.getX() : 1; + final double marginY = Math.abs(scale.getY()) > 1e-10 ? 1 / scale.getY() : 1; + + bounds.setFrame(bounds.getMinX() - marginX, bounds.getMinY() - marginY, bounds.getWidth() + 2*marginX, bounds.getHeight() + 2*marginY); List ss = e.getElementClass().getItemsByClass(SelectionSpecification.class); if (!ss.isEmpty()) {