}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void setLayout(Class<Layout<Device, Connection>> layout) {
if (currentTab == null) return;
final Map map = currentTab.map;
final VisualizationViewer<Device, Connection> vv = currentTab.vv;
final Layout<Device, Connection> oldLayout = map.getGraphLayout();
try {
Class<? extends Layout<Device, Connection>> layoutC = (Class<? extends Layout<Device, Connection>>) layout;
Constructor constructor = layoutC.getConstructor(new Class[] {Graph.class});
Object o = constructor.newInstance(map);
final Layout<Device, Connection> newLayout = (Layout<Device, Connection>) o;
newLayout.setInitializer(vv.getGraphLayout());
newLayout.setSize(vv.getSize());
map.getHistory().execute(new Command() {
@Override
public Object undo() {
map.setLayout(oldLayout);
new Animator(new LayoutTransition<Device, Connection>(vv, newLayout, oldLayout)).start();
vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
vv.repaint();
return null;
}
@Override
public Object redo() {
map.setLayout(newLayout);
new Animator(new LayoutTransition<Device, Connection>(vv, oldLayout, newLayout)).start();
vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
vv.repaint();
return null;
}