}
public static AbstractLayout layoutFactory(Class toInstantiate, Graph g) {
try {
Constructor graphConstructor = toInstantiate.getConstructor(Graph.class);
AbstractLayout ret = (AbstractLayout) graphConstructor.newInstance(g);
return ret;
} catch (NoSuchMethodException nse) {
Logger.getLogger(ClusterViewer.class.getName()).log(Level.WARNING, String.format("Couldn't instantiate %s, falling back on FRLayout", toInstantiate.getName()), nse);
} catch (InstantiationException iex) {
Logger.getLogger(ClusterViewer.class.getName()).log(Level.WARNING, String.format("Instantiating %s failed, will return FRLayout instead", toInstantiate.getName()), iex);