1
14
15 package demo.layout;
16
17 import y.base.Edge;
18 import y.base.Node;
19 import y.base.NodeMap;
20 import y.layout.BufferedLayouter;
21 import y.layout.CopiedLayoutGraph;
22 import y.layout.DefaultLayoutGraph;
23 import y.layout.hierarchic.IncrementalHierarchicLayouter;
24 import y.layout.hierarchic.incremental.SwimLaneDescriptor;
25 import y.util.D;
26
27
38 public class SwimLaneLayoutWithoutAView
39 {
40
41
44 public static void main(String[] args)
45 {
46 SwimLaneLayoutWithoutAView lwv = new SwimLaneLayoutWithoutAView();
47 lwv.doit();
48 }
49
50
53 public void doit()
54 {
55 DefaultLayoutGraph graph = new DefaultLayoutGraph();
56
57 Node v1 = graph.createNode();
59 graph.setSize(v1,30,30);
60 Node v2 = graph.createNode();
61 graph.setSize(v2,30,30);
62 Node v3 = graph.createNode();
63 graph.setSize(v3,30,30);
64 Node v4 = graph.createNode();
65 graph.setSize(v4,30,30);
66
67 Edge e1 = graph.createEdge(v1,v2);
69 Edge e2 = graph.createEdge(v1,v3);
70 Edge e3 = graph.createEdge(v2,v4);
71
72 SwimLaneDescriptor sl1 = new SwimLaneDescriptor(new Integer(1));
75 SwimLaneDescriptor sl2 = new SwimLaneDescriptor(new Integer(2));
76
77 NodeMap slMap = graph.createNodeMap();
79
80 slMap.set(v1, sl1);
82 slMap.set(v2, sl2);
83 slMap.set(v3, sl2);
84 slMap.set(v4, sl1);
85
86 graph.addDataProvider(IncrementalHierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY, slMap);
88
89 IncrementalHierarchicLayouter layouter = new IncrementalHierarchicLayouter();
91
92 new BufferedLayouter(layouter).doLayout(graph);
94
95 LayoutPreviewPanel lpp1 = new LayoutPreviewPanel(new CopiedLayoutGraph(graph));
97 lpp1.createFrame("Swimlanes").setVisible(true);
98
99 D.bug("\n\nGRAPH LAID OUT HIERARCHICALLY IN SWIMLANES");
100 D.bug("v1 center position = " + graph.getCenter(v1));
101 D.bug("v2 center position = " + graph.getCenter(v2));
102 D.bug("v3 center position = " + graph.getCenter(v3));
103 D.bug("v4 center position = " + graph.getCenter(v4));
104 D.bug("e1 path = " + graph.getPath(e1));
105 D.bug("e2 path = " + graph.getPath(e2));
106 D.bug("e3 path = " + graph.getPath(e3));
107 D.bug("SwimLane 1 index = " + sl1.getComputedLaneIndex());
108 D.bug("SwimLane 1 position = " + sl1.getComputedLanePosition());
109 D.bug("SwimLane 1 width = " + sl1.getComputedLaneWidth());
110 D.bug("SwimLane 2 index = " + sl2.getComputedLaneIndex());
111 D.bug("SwimLane 2 position = " + sl2.getComputedLanePosition());
112 D.bug("SwimLane 2 width = " + sl2.getComputedLaneWidth());
113
114 }
115 }
116