newConnections = new LinkedList();
newTopLevelParts = new LinkedList();
Iterator i = parts.iterator();
LogicSubpart part = null;
while (i.hasNext()) {
part = (LogicSubpart)i.next();
if (bounds != null && bounds.containsKey(part)) {
clonePart(part, parent, (Rectangle)bounds.get(part),
newConnections, connectionPartMap, -1);
} else if (indices != null && indices.containsKey(part)) {
clonePart(part, parent, null, newConnections,
connectionPartMap, ((Integer)indices.get(part)).intValue());
} else {
clonePart(part, parent, null, newConnections, connectionPartMap, -1);
}
}
// go through and set the source of each connection to the proper source.
Iterator c = newConnections.iterator();
while (c.hasNext()) {
Wire conn = (Wire)c.next();
LogicSubpart source = conn.getSource();
if (connectionPartMap.containsKey(source)) {
conn.setSource((LogicSubpart)connectionPartMap.get(source));
conn.attachSource();
conn.attachTarget();
}