if (o instanceof Connection){
selectedConnectors.add(o);
} else {
Element as= null;
if (o instanceof TestGatedRectangle){
as = ((TestGatedRectangle)o).cloneTestGatedRectangle();
} else if (o instanceof TestConnection){
as = ((TestConnection)o).cloneTestConnection();
}
if (o instanceof GatedComponent){
selectedGatedComponent.add(o);
// Kept the relation between the existing and the new gate
List oldGates = new ArrayList(((GatedComponent)o).getGates());
List newGates = new ArrayList(((GatedComponent)as).getGates());
for(int j=0;j<oldGates.size(); j++){
clonedGates.put(oldGates.get(j), newGates.get(j));
}
}
as.translate(x,y);
TestShapesContainer.this.add(as);
}
}
// Now Copy the connectors