00001 package org.hfbk.vis;
00002
00003 import java.lang.reflect.Constructor;
00004
00005 import org.dronus.graph.Node;
00006 import org.hfbk.vis.visnode.VisNode;
00007 import org.lwjgl.util.vector.Vector3f;
00008
00009
00024 public class VisNodeFactory {
00025
00029 final static Class<?>[] SIGNATURE={Node.class, Vector3f.class};
00030
00040 public static VisNode create(Node n, Vector3f position) {
00041
00042 String t=n.type;
00043
00044 Class<?> cl=null;
00045 try{
00046
00047 String classname="org.hfbk.vis.visnode.Vis"+Character.toUpperCase(t.charAt(0))+t.substring(1);
00048
00049 cl=Class.forName(classname);
00050
00051 Constructor cns=cl.getConstructor(SIGNATURE);
00052 return (VisNode)cns.newInstance(new Object[]{n, position});
00053
00054 } catch (ClassNotFoundException e) {
00055 return null;
00056 } catch (NoSuchMethodException e) {
00057 throw new RuntimeException("NodeFactory: No valid public constructor at class "+cl);
00058 } catch (Exception e){
00059 throw new RuntimeException(e);
00060 }
00061 }
00062 }