Menu

[r49]: / GraphScript / trunk / ls / graph / ui / LayoutType.java  Maximize  Restore  History

Download this file

54 lines (44 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ls.graph.ui;
import java.lang.reflect.Constructor;
import ls.util.Utils;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.visualization.FRLayout;
import edu.uci.ics.jung.visualization.Layout;
import edu.uci.ics.jung.visualization.SpringLayout;
import edu.uci.ics.jung.visualization.contrib.CircleLayout;
import edu.uci.ics.jung.visualization.contrib.KKLayout;
public enum LayoutType
{
CIRCLE(CircleLayout.class, "Circle"),
SPRING(SpringLayout.class, "Spring"),
//TREE(TreeLayout.class,"Tree"),
FR(FRLayout.class,"FR Layout"),
KK(KKLayout.class,"KK Layout");
private Constructor<? extends Layout> constructor = null;
private String name = null;
LayoutType(Class<? extends Layout> layoutClass, String n)
{
try
{
constructor = layoutClass.getConstructor(new Class<?>[] {Graph.class});
}
catch (Exception exn) { Utils.exn(exn); constructor = null; }
name = n;
}
public String getName() { return this.name; }
public Layout createLayout(Graph g)
{
try
{
if (constructor != null)
return (Layout)(constructor.newInstance(new Object[] {g}));
else throw new Exception("Layout constructor is null");
}
catch (Exception exn)
{
Utils.exn(exn);
}
return null;
}
public String toString() { return this.getName(); }
}
MongoDB Logo MongoDB