bounds.put(part, newBounds);
}
protected void clonePart(BasicElement oldPart, MusicContainerForm newParent, Rectangle newBounds,
List<BasicElement> newConnections, Map<BasicElement, Serializable> connectionPartMap, int index) {
BasicElement newPart = null;
SimpleFactory simpleFactory = new SimpleFactory(
oldPart.getClass());
newPart = (BasicElement) simpleFactory.getNewObject();
if (oldPart instanceof MusicContainerForm) {
Iterator<?> i = ((MusicContainerForm)oldPart).getChildren().iterator();
while (i.hasNext()) {
// for children they will not need new bounds
clonePart((BasicElement)i.next(), (MusicContainerForm)newPart, null,
newConnections, connectionPartMap, -1);
}
}
if (index < 0) {
newParent.addChild(newPart);
} else {
newParent.addChild(newPart, index);
}
newPart.setSize(oldPart.getSize());
if (newBounds != null) {
newPart.setLocation(newBounds.getTopLeft());
} else {
newPart.setLocation(oldPart.getLocation());
}
// keep track of the new parts so we can delete them in undo
// keep track of the oldpart -> newpart map so that we can properly attach
// all connections.