1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
package net.sourceforge.combean.test.adapters.jgraph; |
23 | |
|
24 | |
import org.jgraph.JGraph; |
25 | |
import org.jgraph.graph.DefaultCellViewFactory; |
26 | |
import org.jgraph.graph.DefaultGraphCell; |
27 | |
import org.jgraph.graph.DefaultGraphModel; |
28 | |
import org.jgraph.graph.GraphCell; |
29 | |
import org.jgraph.graph.GraphLayoutCache; |
30 | |
|
31 | |
import net.sourceforge.combean.adapters.jgraph.JGraphModelAsGraph; |
32 | |
import net.sourceforge.combean.adapters.jgraph.JGraphUtils; |
33 | |
import net.sourceforge.combean.interfaces.graph.Graph; |
34 | |
import net.sourceforge.combean.test.graph.generic.AbstractTestClique; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 3 | public class TestJGraphClique extends AbstractTestClique { |
41 | |
|
42 | |
private static final int CLIQUESIZE = 4; |
43 | |
|
44 | 6 | private DefaultGraphModel jgModel = null; |
45 | 6 | private GraphLayoutCache jgLayout = null; |
46 | 6 | private JGraph jg = null; |
47 | |
|
48 | 6 | private JGraphModelAsGraph g = null; |
49 | |
|
50 | |
public static void main(String[] args) { |
51 | 0 | junit.textui.TestRunner.run(TestJGraphClique.class); |
52 | 0 | } |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
protected void setUp() throws Exception { |
58 | |
|
59 | 6 | this.jgModel = new DefaultGraphModel(); |
60 | 6 | this.jgLayout = new GraphLayoutCache(this.jgModel, new DefaultCellViewFactory()); |
61 | 6 | this.jg = new JGraph(this.jgModel, this.jgLayout); |
62 | |
|
63 | 6 | DefaultGraphCell[] cells = JGraphUtils.createGraphCells(CLIQUESIZE); |
64 | 6 | this.jgLayout.insert(cells); |
65 | |
|
66 | 6 | GraphCell[] edges = new GraphCell[CLIQUESIZE * (CLIQUESIZE-1) / 2]; |
67 | 6 | int pos = 0; |
68 | 30 | for (int from = 0; from < cells.length; from ++) { |
69 | 60 | for (int to = from+1; to < cells.length; to++) { |
70 | 36 | edges[pos++] = JGraphUtils.createEdge(cells, from, to); |
71 | |
} |
72 | |
} |
73 | 6 | this.jgLayout.insert(edges); |
74 | |
|
75 | 6 | this.g = new JGraphModelAsGraph(this.jgModel); |
76 | |
|
77 | |
|
78 | 6 | assert this.g != null; |
79 | 6 | assert this.jg != null; |
80 | |
|
81 | 6 | super.setUp(); |
82 | 6 | } |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
protected void tearDown() throws Exception { |
88 | 6 | super.tearDown(); |
89 | 6 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public TestJGraphClique(String name) |
96 | |
throws Exception { |
97 | 6 | super(name); |
98 | 6 | } |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
protected Graph getGraph() { |
104 | 18 | return this.g; |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
protected int getNumNodes() { |
111 | 3 | return CLIQUESIZE; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public final void testGetNeighborsOfAllNodes() { |
121 | 3 | super.testGetNeighborsOfAllNodes(); |
122 | 3 | } |
123 | |
} |