1
14 package demo.module;
15
16 import demo.view.DemoBase;
17 import y.module.YModule;
18 import y.option.OptionHandler;
19 import y.view.Arrow;
20 import y.view.hierarchy.HierarchyManager;
21
22 import javax.swing.AbstractAction;
23 import javax.swing.JToolBar;
24 import java.awt.event.ActionEvent;
25
26
34 public class LayoutModuleDemo extends DemoBase
35 {
36
37 public LayoutModuleDemo()
38 {
39 view.getGraph2D().getDefaultEdgeRealizer().setArrow(Arrow.DELTA);
41
42 HierarchyManager hierarchy = new HierarchyManager(view.getGraph2D());
44 loadGraph( "resource/sample.gml" );
45 }
46
47
50 protected JToolBar createToolBar()
51 {
52 JToolBar bar = super.createToolBar();
53
54 bar.addSeparator();
55
56 bar.add(new LaunchModule(new demo.module.OrganicLayoutModule(), "Organic"));
57 bar.add(new LaunchModule(new y.module.RandomLayoutModule(), "Random" ));
58 bar.add(new LaunchModule(new demo.module.CircularLayoutModule(), "Circular" ));
59 bar.add(new LaunchModule(new demo.module.HierarchicLayoutModule(), "Hierarchic" ));
60 bar.add(new LaunchModule(new demo.module.IncrementalHierarchicLayoutModule(), "Incremental H." ));
61 bar.add(new LaunchModule(new demo.module.OrthogonalLayoutModule(), "Orthogonal" ));
62 bar.add(new LaunchModule(new demo.module.TreeLayoutModule(), "Tree" ));
63 bar.add(new LaunchModule(new demo.module.DiagonalLayoutModule(), "Diagonal" ));
64 bar.add(new LaunchModule(new demo.module.FamilyTreeLayoutModule(), "Family" ));
65
66
67 return bar;
68 }
69
70
74 class LaunchModule extends AbstractAction
75 {
76 YModule module;
77
78 LaunchModule( YModule module, String title )
79 {
80 super(title);
81 this.module = module;
82 }
83
84 public void actionPerformed(ActionEvent e)
85 {
86 OptionHandler op = module.getOptionHandler();
87 if( op != null) {
88 if( !op.showEditor() )
89 return;
90 }
91 module.start(view.getGraph2D());
92 }
93 }
94
95 public static void main(String args[])
96 {
97 initLnF();
98 LayoutModuleDemo demo = new LayoutModuleDemo();
99 demo.start(demo.getClass().getName());
100 }
101 }
102
103
104
105