//
void replaceAll(Map<Tool,Tool> toolMap) {
boolean changed = false;
for (Map.Entry<Integer,Tool> entry : map.entrySet()) {
Integer key = entry.getKey();
Tool tool = entry.getValue();
if (tool instanceof AddTool) {
ComponentFactory factory = ((AddTool) tool).getFactory();
if (toolMap.containsKey(factory)) {
changed = true;
Tool newTool = toolMap.get(factory);
if (newTool == null) {
map.remove(key);
} else {
Tool clone = newTool.cloneTool();
LoadedLibrary.copyAttributes(clone.getAttributeSet(),
tool.getAttributeSet());
map.put(key, clone);
}
}
} else {
if (toolMap.containsKey(tool)) {
changed = true;
Tool newTool = toolMap.get(tool);
if (newTool == null) {
map.remove(key);
} else {
Tool clone = newTool.cloneTool();
LoadedLibrary.copyAttributes(clone.getAttributeSet(),
tool.getAttributeSet());
map.put(key, clone);
}
}
}