if (pe instanceof Shape) { Shape shape = (Shape) pe; removeAllConnections(shape); } else if (pe instanceof AdvancedAnchor) { removeAllConnections((AdvancedAnchor) pe); } ... protected void removeAllConnections(Shape shape) { List<Anchor> anchors = shape.getAnchors(); for (Anchor anchor : anchors) { removeAllConnections(anchor); } }
@Override protected void removeAllConnections(Shape shape) { // recursive! if(shape instanceof ContainerShape) { for (Shape innerShape : ((ContainerShape)shape).getChildren()) { removeAllConnections(innerShape); } } List<Anchor> anchors = shape.getAnchors(); for (Anchor anchor : anchors) { removeAllConnections(anchor); } }