import static org.simantics.g2d.canvas.Hints.KEY_CANVAS_TRANSFORM;
-import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
super.removedFromContext(ctx);
}
+ protected Class<? extends NavigationNode> getNavigationNodeClass() {
+ return NavigationNode.class;
+ }
+
@SGInit
public void initSG(G2DParentNode parent) {
// Replace old NAVIGATION_NODE with a new one
INode oldnav = NodeUtil.getRootNode(parent).getNode(SceneGraphConstants.NAVIGATION_NODE_NAME);
if(oldnav != null) {
- node = oldnav.appendParent(SceneGraphConstants.NAVIGATION_NODE_NAME, NavigationNode.class);
+ node = oldnav.appendParent(SceneGraphConstants.NAVIGATION_NODE_NAME, getNavigationNodeClass());
// FIXME : oldnav seems to be the same node as parent (most of the cases).
// Deleting it will cause plenty of code to fail, since they refer to the node directly.
// The bug was not shown, since deleting() a Node did not actually wipe its structures (until now).
// oldnav.delete();
} else {
- node = parent.addNode(SceneGraphConstants.NAVIGATION_NODE_NAME, NavigationNode.class);
+ node = parent.addNode(SceneGraphConstants.NAVIGATION_NODE_NAME, getNavigationNodeClass());
}
node.setLookupId(SceneGraphConstants.NAVIGATION_NODE_NAME);
node.setZIndex(0);
if (d==null) return false;
Set<IElement> selections = selection.getAllSelections();
- Shape bounds = ElementUtils.getElementBoundsOnDiagram(selections);
- if (bounds == null) return false;
- Rectangle2D diagramRect = bounds.getBounds2D();
+ Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(selections);
+ if (diagramRect == null) return false;
if (diagramRect.getWidth() <= 0 && diagramRect.getHeight() <= 0)
return false;