Merge lp:~cezary-bartosiak/gephi/generator-plugin into lp:~gephi.team/gephi/0.8
- generator-plugin
- Merge into 0.8
Proposed by
Cezary Bartosiak
Status: | Merged |
---|---|
Approved by: | Mathieu Bastian |
Approved revision: | 2038 |
Merged at revision: | 2048 |
Proposed branch: | lp:~cezary-bartosiak/gephi/generator-plugin |
Merge into: | lp:~gephi.team/gephi/0.8 |
Diff against target: |
6860 lines (+6008/-550) 58 files modified
GeneratorPlugin/manifest.mf (+1/-1) GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java (+136/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java (+177/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java (+277/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java (+152/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java (+151/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java (+129/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java (+123/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java (+200/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java (+0/-149) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java (+188/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java (+157/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java (+32/-0) GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java (+0/-30) GeneratorPluginUI/manifest.mf (+1/-1) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form (+110/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java (+180/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java (+62/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form (+182/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java (+238/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java (+68/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form (+129/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java (+200/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form (+129/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java (+200/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java (+64/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form (+110/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java (+161/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java (+62/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java (+64/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties (+70/-1) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form (+110/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java (+186/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java (+62/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form (+110/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java (+130/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpUIImpl.java (+62/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.form (+174/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.java (+279/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergUIImpl.java (+68/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.form (+134/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.java (+198/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaUIImpl.java (+64/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.form (+129/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.java (+197/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaUIImpl.java (+64/-0) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.form (+0/-124) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.java (+0/-174) GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzUIImpl.java (+0/-70) |
To merge this branch: | bzr merge lp:~cezary-bartosiak/gephi/generator-plugin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mathieu Bastian | Approve | ||
Review via email:
|
Commit message
Description of the change
Several generators implemented:
a) Erdős-Rényi model in two versions G(n, p) and G(n, m)
b) Alpha and Beta models of Watts and Strogatz
c) Kleinberg model
d) Barabási–Albert model in 4 versions: basic, generalized generator with probabilities of adding new edges and rewiring existing ones, simplified models: A (uniform attachment) and B (no growth)
e) Balanced Tree
To post a comment you must log in.
- 2038. By Cezary Bartosiak
-
* added torus based parameter for Kleinberg model
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mathieu Bastian (mathieu.bastian) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'GeneratorPlugin/manifest.mf' | |||
2 | --- GeneratorPlugin/manifest.mf 2010-08-19 09:38:57 +0000 | |||
3 | +++ GeneratorPlugin/manifest.mf 2010-12-17 03:47:30 +0000 | |||
4 | @@ -2,5 +2,5 @@ | |||
5 | 2 | AutoUpdate-Essential-Module: true | 2 | AutoUpdate-Essential-Module: true |
6 | 3 | OpenIDE-Module: org.gephi.io.generator.plugin | 3 | OpenIDE-Module: org.gephi.io.generator.plugin |
7 | 4 | OpenIDE-Module-Localizing-Bundle: org/gephi/io/generator/plugin/Bundle.properties | 4 | OpenIDE-Module-Localizing-Bundle: org/gephi/io/generator/plugin/Bundle.properties |
9 | 5 | OpenIDE-Module-Specification-Version: 0.7.1 | 5 | OpenIDE-Module-Specification-Version: 0.7.2 |
10 | 6 | 6 | ||
11 | 7 | 7 | ||
12 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java' | |||
13 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java 1970-01-01 00:00:00 +0000 | |||
14 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java 2010-12-17 03:47:30 +0000 | |||
15 | @@ -0,0 +1,136 @@ | |||
16 | 1 | /* | ||
17 | 2 | * Copyright 2008-2010 Gephi | ||
18 | 3 | * Authors : Cezary Bartosiak | ||
19 | 4 | * Website : http://www.gephi.org | ||
20 | 5 | * | ||
21 | 6 | * This file is part of Gephi. | ||
22 | 7 | * | ||
23 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
24 | 9 | * it under the terms of the GNU General Public License as published by | ||
25 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
26 | 11 | * (at your option) any later version. | ||
27 | 12 | * | ||
28 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
29 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | 16 | * GNU General Public License for more details. | ||
32 | 17 | * | ||
33 | 18 | * You should have received a copy of the GNU General Public License | ||
34 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
35 | 20 | */ | ||
36 | 21 | package org.gephi.io.generator.plugin; | ||
37 | 22 | |||
38 | 23 | import java.util.ArrayList; | ||
39 | 24 | import java.util.List; | ||
40 | 25 | import org.gephi.io.generator.spi.Generator; | ||
41 | 26 | import org.gephi.io.generator.spi.GeneratorUI; | ||
42 | 27 | import org.gephi.io.importer.api.ContainerLoader; | ||
43 | 28 | import org.gephi.io.importer.api.EdgeDefault; | ||
44 | 29 | import org.gephi.io.importer.api.EdgeDraft; | ||
45 | 30 | import org.gephi.io.importer.api.NodeDraft; | ||
46 | 31 | import org.gephi.utils.progress.Progress; | ||
47 | 32 | import org.gephi.utils.progress.ProgressTicket; | ||
48 | 33 | import org.openide.util.Lookup; | ||
49 | 34 | import org.openide.util.lookup.ServiceProvider; | ||
50 | 35 | |||
51 | 36 | /** | ||
52 | 37 | * Generates a perfectly balanced r-tree of height h (edges are undirected). | ||
53 | 38 | * | ||
54 | 39 | * r >= 2 | ||
55 | 40 | * h >= 1 | ||
56 | 41 | * | ||
57 | 42 | * O(r^h) | ||
58 | 43 | * | ||
59 | 44 | * @author Cezary Bartosiak | ||
60 | 45 | */ | ||
61 | 46 | @ServiceProvider(service = Generator.class) | ||
62 | 47 | public class BalancedTree implements Generator { | ||
63 | 48 | private boolean cancel = false; | ||
64 | 49 | private ProgressTicket progressTicket; | ||
65 | 50 | |||
66 | 51 | private int r = 2; | ||
67 | 52 | private int h = 4; | ||
68 | 53 | |||
69 | 54 | public void generate(ContainerLoader container) { | ||
70 | 55 | int n = ((int)Math.pow(r, h + 1) - 1) / (r - 1); | ||
71 | 56 | |||
72 | 57 | Progress.start(progressTicket, n - 1); | ||
73 | 58 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
74 | 59 | |||
75 | 60 | // Creating a root of degree r | ||
76 | 61 | NodeDraft root = container.factory().newNodeDraft(); | ||
77 | 62 | root.setLabel("Node 0"); | ||
78 | 63 | container.addNode(root); | ||
79 | 64 | List<NodeDraft> newLeaves = new ArrayList<NodeDraft>(); | ||
80 | 65 | int v = 1; | ||
81 | 66 | for (int i = 0; i < r && !cancel; ++i) { | ||
82 | 67 | NodeDraft node = container.factory().newNodeDraft(); | ||
83 | 68 | node.setLabel("Node " + v++); | ||
84 | 69 | newLeaves.add(node); | ||
85 | 70 | container.addNode(node); | ||
86 | 71 | |||
87 | 72 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
88 | 73 | edge.setSource(root); | ||
89 | 74 | edge.setTarget(node); | ||
90 | 75 | container.addEdge(edge); | ||
91 | 76 | |||
92 | 77 | Progress.progress(progressTicket); | ||
93 | 78 | } | ||
94 | 79 | |||
95 | 80 | // Creating internal nodes | ||
96 | 81 | for (int height = 1; height < h && !cancel; ++height) { | ||
97 | 82 | List<NodeDraft> leaves = newLeaves; | ||
98 | 83 | newLeaves = new ArrayList<NodeDraft>(); | ||
99 | 84 | for (NodeDraft leave : leaves) | ||
100 | 85 | for (int i = 0; i < r; ++i) { | ||
101 | 86 | NodeDraft node = container.factory().newNodeDraft(); | ||
102 | 87 | node.setLabel("Node " + v++); | ||
103 | 88 | newLeaves.add(node); | ||
104 | 89 | container.addNode(node); | ||
105 | 90 | |||
106 | 91 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
107 | 92 | edge.setSource(leave); | ||
108 | 93 | edge.setTarget(node); | ||
109 | 94 | container.addEdge(edge); | ||
110 | 95 | |||
111 | 96 | Progress.progress(progressTicket); | ||
112 | 97 | } | ||
113 | 98 | } | ||
114 | 99 | |||
115 | 100 | Progress.finish(progressTicket); | ||
116 | 101 | progressTicket = null; | ||
117 | 102 | } | ||
118 | 103 | |||
119 | 104 | public int getr() { | ||
120 | 105 | return r; | ||
121 | 106 | } | ||
122 | 107 | |||
123 | 108 | public int geth() { | ||
124 | 109 | return h; | ||
125 | 110 | } | ||
126 | 111 | |||
127 | 112 | public void setr(int r) { | ||
128 | 113 | this.r = r; | ||
129 | 114 | } | ||
130 | 115 | |||
131 | 116 | public void seth(int h) { | ||
132 | 117 | this.h = h; | ||
133 | 118 | } | ||
134 | 119 | |||
135 | 120 | public String getName() { | ||
136 | 121 | return "Balanced Tree"; | ||
137 | 122 | } | ||
138 | 123 | |||
139 | 124 | public GeneratorUI getUI() { | ||
140 | 125 | return Lookup.getDefault().lookup(BalancedTreeUI.class); | ||
141 | 126 | } | ||
142 | 127 | |||
143 | 128 | public boolean cancel() { | ||
144 | 129 | cancel = true; | ||
145 | 130 | return true; | ||
146 | 131 | } | ||
147 | 132 | |||
148 | 133 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
149 | 134 | this.progressTicket = progressTicket; | ||
150 | 135 | } | ||
151 | 136 | } | ||
152 | 0 | 137 | ||
153 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java' | |||
154 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java 1970-01-01 00:00:00 +0000 | |||
155 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java 2010-12-17 03:47:30 +0000 | |||
156 | @@ -0,0 +1,32 @@ | |||
157 | 1 | /* | ||
158 | 2 | * Copyright 2008-2010 Gephi | ||
159 | 3 | * Authors : Cezary Bartosiak | ||
160 | 4 | * Website : http://www.gephi.org | ||
161 | 5 | * | ||
162 | 6 | * This file is part of Gephi. | ||
163 | 7 | * | ||
164 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
165 | 9 | * it under the terms of the GNU General Public License as published by | ||
166 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
167 | 11 | * (at your option) any later version. | ||
168 | 12 | * | ||
169 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
170 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
171 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
172 | 16 | * GNU General Public License for more details. | ||
173 | 17 | * | ||
174 | 18 | * You should have received a copy of the GNU General Public License | ||
175 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
176 | 20 | */ | ||
177 | 21 | package org.gephi.io.generator.plugin; | ||
178 | 22 | |||
179 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
180 | 24 | |||
181 | 25 | /** | ||
182 | 26 | * | ||
183 | 27 | * | ||
184 | 28 | * @author Cezary Bartosiak | ||
185 | 29 | */ | ||
186 | 30 | public interface BalancedTreeUI extends GeneratorUI { | ||
187 | 31 | |||
188 | 32 | } | ||
189 | 0 | 33 | ||
190 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java' | |||
191 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java 1970-01-01 00:00:00 +0000 | |||
192 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java 2010-12-17 03:47:30 +0000 | |||
193 | @@ -0,0 +1,177 @@ | |||
194 | 1 | /* | ||
195 | 2 | * Copyright 2008-2010 Gephi | ||
196 | 3 | * Authors : Cezary Bartosiak | ||
197 | 4 | * Website : http://www.gephi.org | ||
198 | 5 | * | ||
199 | 6 | * This file is part of Gephi. | ||
200 | 7 | * | ||
201 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
202 | 9 | * it under the terms of the GNU General Public License as published by | ||
203 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
204 | 11 | * (at your option) any later version. | ||
205 | 12 | * | ||
206 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
207 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
208 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
209 | 16 | * GNU General Public License for more details. | ||
210 | 17 | * | ||
211 | 18 | * You should have received a copy of the GNU General Public License | ||
212 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
213 | 20 | */ | ||
214 | 21 | package org.gephi.io.generator.plugin; | ||
215 | 22 | |||
216 | 23 | import java.util.Random; | ||
217 | 24 | import org.gephi.io.generator.spi.Generator; | ||
218 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
219 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
220 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
221 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
222 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
223 | 30 | import org.gephi.utils.progress.Progress; | ||
224 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
225 | 32 | import org.openide.util.Lookup; | ||
226 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
227 | 34 | |||
228 | 35 | /** | ||
229 | 36 | * Generates an undirected connected graph. | ||
230 | 37 | * | ||
231 | 38 | * http://en.wikipedia.org/wiki/Barabási–Albert_model | ||
232 | 39 | * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf | ||
233 | 40 | * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf | ||
234 | 41 | * | ||
235 | 42 | * N > 0 | ||
236 | 43 | * m0 > 0 && m0 < N | ||
237 | 44 | * M > 0 && M <= m0 | ||
238 | 45 | * | ||
239 | 46 | * O(N^2 * M) | ||
240 | 47 | * | ||
241 | 48 | * @author Cezary Bartosiak | ||
242 | 49 | */ | ||
243 | 50 | @ServiceProvider(service = Generator.class) | ||
244 | 51 | public class BarabasiAlbert implements Generator { | ||
245 | 52 | private boolean cancel = false; | ||
246 | 53 | private ProgressTicket progressTicket; | ||
247 | 54 | |||
248 | 55 | private int N = 50; | ||
249 | 56 | private int m0 = 1; | ||
250 | 57 | private int M = 1; | ||
251 | 58 | |||
252 | 59 | public void generate(ContainerLoader container) { | ||
253 | 60 | Progress.start(progressTicket, N + M); | ||
254 | 61 | Random random = new Random(); | ||
255 | 62 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
256 | 63 | |||
257 | 64 | NodeDraft[] nodes = new NodeDraft[N]; | ||
258 | 65 | int[] degrees = new int[N]; | ||
259 | 66 | |||
260 | 67 | // Creating m0 nodes | ||
261 | 68 | for (int i = 0; i < m0 && !cancel; ++i) { | ||
262 | 69 | NodeDraft node = container.factory().newNodeDraft(); | ||
263 | 70 | node.setLabel("Node " + i); | ||
264 | 71 | nodes[i] = node; | ||
265 | 72 | degrees[i] = 0; | ||
266 | 73 | container.addNode(node); | ||
267 | 74 | Progress.progress(progressTicket); | ||
268 | 75 | } | ||
269 | 76 | |||
270 | 77 | // Linking every node with each other (no self-loops) | ||
271 | 78 | for (int i = 0; i < m0 && !cancel; ++i) | ||
272 | 79 | for (int j = i + 1; j < m0 && !cancel; ++j) { | ||
273 | 80 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
274 | 81 | edge.setSource(nodes[i]); | ||
275 | 82 | edge.setTarget(nodes[j]); | ||
276 | 83 | degrees[i]++; | ||
277 | 84 | degrees[j]++; | ||
278 | 85 | container.addEdge(edge); | ||
279 | 86 | Progress.progress(progressTicket); | ||
280 | 87 | } | ||
281 | 88 | |||
282 | 89 | // Adding N - m0 nodes, each with M edges | ||
283 | 90 | for (int i = m0; i < N && !cancel; ++i) { | ||
284 | 91 | // Adding new node | ||
285 | 92 | NodeDraft node = container.factory().newNodeDraft(); | ||
286 | 93 | node.setLabel("Node " + i); | ||
287 | 94 | nodes[i] = node; | ||
288 | 95 | degrees[i] = 0; | ||
289 | 96 | container.addNode(node); | ||
290 | 97 | |||
291 | 98 | // Adding M edges out of the new node | ||
292 | 99 | double sum = 0.0; // sum of all nodes degrees | ||
293 | 100 | for (int j = 0; j < i && !cancel; ++j) | ||
294 | 101 | sum += degrees[j]; | ||
295 | 102 | double s = 0.0; | ||
296 | 103 | for (int m = 0; m < M && !cancel; ++m) { | ||
297 | 104 | double r = random.nextDouble(); | ||
298 | 105 | double p = 0.0; | ||
299 | 106 | for (int j = 0; j < i && !cancel; ++j) { | ||
300 | 107 | if (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i])) | ||
301 | 108 | continue; | ||
302 | 109 | |||
303 | 110 | if (i == 1) | ||
304 | 111 | p = 1.0; | ||
305 | 112 | else p += degrees[j] / sum + s / (i - m); | ||
306 | 113 | |||
307 | 114 | if (r <= p) { | ||
308 | 115 | s += degrees[j] / sum; | ||
309 | 116 | |||
310 | 117 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
311 | 118 | edge.setSource(nodes[i]); | ||
312 | 119 | edge.setTarget(nodes[j]); | ||
313 | 120 | degrees[i]++; | ||
314 | 121 | degrees[j]++; | ||
315 | 122 | container.addEdge(edge); | ||
316 | 123 | Progress.progress(progressTicket); | ||
317 | 124 | |||
318 | 125 | break; | ||
319 | 126 | } | ||
320 | 127 | } | ||
321 | 128 | } | ||
322 | 129 | |||
323 | 130 | Progress.progress(progressTicket); | ||
324 | 131 | } | ||
325 | 132 | |||
326 | 133 | Progress.finish(progressTicket); | ||
327 | 134 | progressTicket = null; | ||
328 | 135 | } | ||
329 | 136 | |||
330 | 137 | public int getN() { | ||
331 | 138 | return N; | ||
332 | 139 | } | ||
333 | 140 | |||
334 | 141 | public int getm0() { | ||
335 | 142 | return m0; | ||
336 | 143 | } | ||
337 | 144 | |||
338 | 145 | public int getM() { | ||
339 | 146 | return M; | ||
340 | 147 | } | ||
341 | 148 | |||
342 | 149 | public void setN(int N) { | ||
343 | 150 | this.N = N; | ||
344 | 151 | } | ||
345 | 152 | |||
346 | 153 | public void setm0(int m0) { | ||
347 | 154 | this.m0 = m0; | ||
348 | 155 | } | ||
349 | 156 | |||
350 | 157 | public void setM(int M) { | ||
351 | 158 | this.M = M; | ||
352 | 159 | } | ||
353 | 160 | |||
354 | 161 | public String getName() { | ||
355 | 162 | return "Barabasi-Albert Scale Free model"; | ||
356 | 163 | } | ||
357 | 164 | |||
358 | 165 | public GeneratorUI getUI() { | ||
359 | 166 | return Lookup.getDefault().lookup(BarabasiAlbertUI.class); | ||
360 | 167 | } | ||
361 | 168 | |||
362 | 169 | public boolean cancel() { | ||
363 | 170 | cancel = true; | ||
364 | 171 | return true; | ||
365 | 172 | } | ||
366 | 173 | |||
367 | 174 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
368 | 175 | this.progressTicket = progressTicket; | ||
369 | 176 | } | ||
370 | 177 | } | ||
371 | 0 | 178 | ||
372 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java' | |||
373 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java 1970-01-01 00:00:00 +0000 | |||
374 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java 2010-12-17 03:47:30 +0000 | |||
375 | @@ -0,0 +1,277 @@ | |||
376 | 1 | /* | ||
377 | 2 | * Copyright 2008-2010 Gephi | ||
378 | 3 | * Authors : Cezary Bartosiak | ||
379 | 4 | * Website : http://www.gephi.org | ||
380 | 5 | * | ||
381 | 6 | * This file is part of Gephi. | ||
382 | 7 | * | ||
383 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
384 | 9 | * it under the terms of the GNU General Public License as published by | ||
385 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
386 | 11 | * (at your option) any later version. | ||
387 | 12 | * | ||
388 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
389 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
390 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
391 | 16 | * GNU General Public License for more details. | ||
392 | 17 | * | ||
393 | 18 | * You should have received a copy of the GNU General Public License | ||
394 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
395 | 20 | */ | ||
396 | 21 | package org.gephi.io.generator.plugin; | ||
397 | 22 | |||
398 | 23 | import java.util.Random; | ||
399 | 24 | import org.gephi.io.generator.spi.Generator; | ||
400 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
401 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
402 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
403 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
404 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
405 | 30 | import org.gephi.utils.progress.Progress; | ||
406 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
407 | 32 | import org.openide.util.Lookup; | ||
408 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
409 | 34 | |||
410 | 35 | /** | ||
411 | 36 | * Generates an undirected not necessarily connected graph. | ||
412 | 37 | * | ||
413 | 38 | * http://en.wikipedia.org/wiki/Barabási–Albert_model | ||
414 | 39 | * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf | ||
415 | 40 | * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf | ||
416 | 41 | * | ||
417 | 42 | * N > 0 | ||
418 | 43 | * m0 > 0 | ||
419 | 44 | * M > 0 && M <= m0 | ||
420 | 45 | * 0 <= p < 1 | ||
421 | 46 | * 0 <= q < 1 - p | ||
422 | 47 | * | ||
423 | 48 | * Ω(N^2 * M) | ||
424 | 49 | * | ||
425 | 50 | * @author Cezary Bartosiak | ||
426 | 51 | */ | ||
427 | 52 | @ServiceProvider(service = Generator.class) | ||
428 | 53 | public class BarabasiAlbertGeneralized implements Generator { | ||
429 | 54 | private boolean cancel = false; | ||
430 | 55 | private ProgressTicket progressTicket; | ||
431 | 56 | |||
432 | 57 | private int N = 50; | ||
433 | 58 | private int m0 = 1; | ||
434 | 59 | private int M = 1; | ||
435 | 60 | private double p = 0.25; | ||
436 | 61 | private double q = 0.25; | ||
437 | 62 | |||
438 | 63 | public void generate(ContainerLoader container) { | ||
439 | 64 | Progress.start(progressTicket, N); | ||
440 | 65 | Random random = new Random(); | ||
441 | 66 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
442 | 67 | |||
443 | 68 | NodeDraft[] nodes = new NodeDraft[N + 1]; | ||
444 | 69 | int[] degrees = new int[N + 1]; | ||
445 | 70 | |||
446 | 71 | // Creating m0 isolated nodes | ||
447 | 72 | for (int i = 0; i < m0 && !cancel; ++i) { | ||
448 | 73 | NodeDraft node = container.factory().newNodeDraft(); | ||
449 | 74 | node.setLabel("Node " + i); | ||
450 | 75 | nodes[i] = node; | ||
451 | 76 | degrees[i] = 0; | ||
452 | 77 | container.addNode(node); | ||
453 | 78 | } | ||
454 | 79 | |||
455 | 80 | // Performing N steps of the algorithm | ||
456 | 81 | int n = m0; // the number of existing nodes | ||
457 | 82 | int ec = 0; // the number of existing edges | ||
458 | 83 | for (int i = 0; i < N && !cancel; ++i) { | ||
459 | 84 | double r = random.nextDouble(); | ||
460 | 85 | |||
461 | 86 | if (r <= p) { // adding M edges | ||
462 | 87 | if (ec == n * (n - 1) / 2) | ||
463 | 88 | continue; | ||
464 | 89 | |||
465 | 90 | double sum = 0.0; | ||
466 | 91 | for (int j = 0; j < n && !cancel; ++j) | ||
467 | 92 | sum += degrees[j] + 1; | ||
468 | 93 | for (int m = 0; m < M && !cancel; ++m) { | ||
469 | 94 | int a = random.nextInt(n); | ||
470 | 95 | while (degrees[a] == n - 1 && !cancel) | ||
471 | 96 | a = random.nextInt(n); | ||
472 | 97 | double b = random.nextDouble(); | ||
473 | 98 | boolean e = false; | ||
474 | 99 | while (!e && !cancel) { | ||
475 | 100 | double pki = 0.0; | ||
476 | 101 | for (int j = 0; j < n && !e && !cancel; ++j) { | ||
477 | 102 | pki += (degrees[j] + 1) / sum; | ||
478 | 103 | |||
479 | 104 | if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) { | ||
480 | 105 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
481 | 106 | edge.setSource(nodes[a]); | ||
482 | 107 | edge.setTarget(nodes[j]); | ||
483 | 108 | degrees[a]++; | ||
484 | 109 | degrees[j]++; | ||
485 | 110 | sum += 2.0; | ||
486 | 111 | container.addEdge(edge); | ||
487 | 112 | ec++; | ||
488 | 113 | |||
489 | 114 | e = true; | ||
490 | 115 | } | ||
491 | 116 | else if (ec == n * (n - 1) / 2) | ||
492 | 117 | e = true; | ||
493 | 118 | } | ||
494 | 119 | b = random.nextDouble(); | ||
495 | 120 | } | ||
496 | 121 | } | ||
497 | 122 | } | ||
498 | 123 | else if (r <= p + q) { // rewiring M edges | ||
499 | 124 | if (ec == 0 || ec == n * (n - 1) / 2) | ||
500 | 125 | continue; | ||
501 | 126 | |||
502 | 127 | double sum = 0.0; | ||
503 | 128 | for (int j = 0; j < n && !cancel; ++j) | ||
504 | 129 | sum += degrees[j] + 1; | ||
505 | 130 | for (int m = 0; m < M && !cancel; ++m) { | ||
506 | 131 | int a = random.nextInt(n); | ||
507 | 132 | while ((degrees[a] == 0 || degrees[a] == n - 1) && !cancel) | ||
508 | 133 | a = random.nextInt(n); | ||
509 | 134 | int l = random.nextInt(n); | ||
510 | 135 | while (!edgeExists(container, nodes[l], nodes[a]) && !cancel) | ||
511 | 136 | l = random.nextInt(n); | ||
512 | 137 | double b = random.nextDouble(); | ||
513 | 138 | boolean e = false; | ||
514 | 139 | while (!e && !cancel) { | ||
515 | 140 | double pki = 0.0; | ||
516 | 141 | for (int j = 0; j < n && !e && !cancel; ++j) { | ||
517 | 142 | pki += (degrees[j] + 1) / sum; | ||
518 | 143 | |||
519 | 144 | if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) { | ||
520 | 145 | container.removeEdge(getEdge(container, nodes[a], nodes[l])); | ||
521 | 146 | degrees[l]--; | ||
522 | 147 | |||
523 | 148 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
524 | 149 | edge.setSource(nodes[a]); | ||
525 | 150 | edge.setTarget(nodes[j]); | ||
526 | 151 | degrees[j]++; | ||
527 | 152 | container.addEdge(edge); | ||
528 | 153 | |||
529 | 154 | e = true; | ||
530 | 155 | } | ||
531 | 156 | } | ||
532 | 157 | b = random.nextDouble(); | ||
533 | 158 | } | ||
534 | 159 | } | ||
535 | 160 | } | ||
536 | 161 | else { // adding a new node with M edges | ||
537 | 162 | NodeDraft node = container.factory().newNodeDraft(); | ||
538 | 163 | node.setLabel("Node " + n); | ||
539 | 164 | nodes[n] = node; | ||
540 | 165 | degrees[n] = 0; | ||
541 | 166 | container.addNode(node); | ||
542 | 167 | |||
543 | 168 | // Adding M edges out of the new node | ||
544 | 169 | double sum = 0.0; | ||
545 | 170 | for (int j = 0; j < n && !cancel; ++j) | ||
546 | 171 | sum += degrees[j]; | ||
547 | 172 | double s = 0.0; | ||
548 | 173 | for (int m = 0; m < M && !cancel; ++m) { | ||
549 | 174 | r = random.nextDouble(); | ||
550 | 175 | double p = 0.0; | ||
551 | 176 | for (int j = 0; j < n && !cancel; ++j) { | ||
552 | 177 | if (edgeExists(container, nodes[n], nodes[j])) | ||
553 | 178 | continue; | ||
554 | 179 | |||
555 | 180 | if (n == 1) | ||
556 | 181 | p = 1.0; | ||
557 | 182 | else p += degrees[j] / sum + s / (n - m); | ||
558 | 183 | |||
559 | 184 | if (r <= p) { | ||
560 | 185 | s += degrees[j] / sum; | ||
561 | 186 | |||
562 | 187 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
563 | 188 | edge.setSource(nodes[n]); | ||
564 | 189 | edge.setTarget(nodes[j]); | ||
565 | 190 | degrees[n]++; | ||
566 | 191 | degrees[j]++; | ||
567 | 192 | container.addEdge(edge); | ||
568 | 193 | ec++; | ||
569 | 194 | |||
570 | 195 | break; | ||
571 | 196 | } | ||
572 | 197 | } | ||
573 | 198 | } | ||
574 | 199 | |||
575 | 200 | n++; | ||
576 | 201 | } | ||
577 | 202 | |||
578 | 203 | Progress.progress(progressTicket); | ||
579 | 204 | } | ||
580 | 205 | |||
581 | 206 | Progress.finish(progressTicket); | ||
582 | 207 | progressTicket = null; | ||
583 | 208 | } | ||
584 | 209 | |||
585 | 210 | private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
586 | 211 | return container.edgeExists(node1, node2) || container.edgeExists(node2, node1); | ||
587 | 212 | } | ||
588 | 213 | |||
589 | 214 | private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
590 | 215 | EdgeDraft edge = container.getEdge(node1, node2); | ||
591 | 216 | if (edge == null) | ||
592 | 217 | edge = container.getEdge(node2, node1); | ||
593 | 218 | return edge; | ||
594 | 219 | } | ||
595 | 220 | |||
596 | 221 | public int getN() { | ||
597 | 222 | return N; | ||
598 | 223 | } | ||
599 | 224 | |||
600 | 225 | public int getm0() { | ||
601 | 226 | return m0; | ||
602 | 227 | } | ||
603 | 228 | |||
604 | 229 | public int getM() { | ||
605 | 230 | return M; | ||
606 | 231 | } | ||
607 | 232 | |||
608 | 233 | public double getp() { | ||
609 | 234 | return p; | ||
610 | 235 | } | ||
611 | 236 | |||
612 | 237 | public double getq() { | ||
613 | 238 | return q; | ||
614 | 239 | } | ||
615 | 240 | |||
616 | 241 | public void setN(int N) { | ||
617 | 242 | this.N = N; | ||
618 | 243 | } | ||
619 | 244 | |||
620 | 245 | public void setm0(int m0) { | ||
621 | 246 | this.m0 = m0; | ||
622 | 247 | } | ||
623 | 248 | |||
624 | 249 | public void setM(int M) { | ||
625 | 250 | this.M = M; | ||
626 | 251 | } | ||
627 | 252 | |||
628 | 253 | public void setp(double p) { | ||
629 | 254 | this.p = p; | ||
630 | 255 | } | ||
631 | 256 | |||
632 | 257 | public void setq(double q) { | ||
633 | 258 | this.q = q; | ||
634 | 259 | } | ||
635 | 260 | |||
636 | 261 | public String getName() { | ||
637 | 262 | return "Generalized Barabasi-Albert Scale Free model"; | ||
638 | 263 | } | ||
639 | 264 | |||
640 | 265 | public GeneratorUI getUI() { | ||
641 | 266 | return Lookup.getDefault().lookup(BarabasiAlbertGeneralizedUI.class); | ||
642 | 267 | } | ||
643 | 268 | |||
644 | 269 | public boolean cancel() { | ||
645 | 270 | cancel = true; | ||
646 | 271 | return true; | ||
647 | 272 | } | ||
648 | 273 | |||
649 | 274 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
650 | 275 | this.progressTicket = progressTicket; | ||
651 | 276 | } | ||
652 | 277 | } | ||
653 | 0 | 278 | ||
654 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java' | |||
655 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java 1970-01-01 00:00:00 +0000 | |||
656 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java 2010-12-17 03:47:30 +0000 | |||
657 | @@ -0,0 +1,32 @@ | |||
658 | 1 | /* | ||
659 | 2 | * Copyright 2008-2010 Gephi | ||
660 | 3 | * Authors : Cezary Bartosiak | ||
661 | 4 | * Website : http://www.gephi.org | ||
662 | 5 | * | ||
663 | 6 | * This file is part of Gephi. | ||
664 | 7 | * | ||
665 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
666 | 9 | * it under the terms of the GNU General Public License as published by | ||
667 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
668 | 11 | * (at your option) any later version. | ||
669 | 12 | * | ||
670 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
671 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
672 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
673 | 16 | * GNU General Public License for more details. | ||
674 | 17 | * | ||
675 | 18 | * You should have received a copy of the GNU General Public License | ||
676 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
677 | 20 | */ | ||
678 | 21 | package org.gephi.io.generator.plugin; | ||
679 | 22 | |||
680 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
681 | 24 | |||
682 | 25 | /** | ||
683 | 26 | * | ||
684 | 27 | * | ||
685 | 28 | * @author Cezary Bartosiak | ||
686 | 29 | */ | ||
687 | 30 | public interface BarabasiAlbertGeneralizedUI extends GeneratorUI { | ||
688 | 31 | |||
689 | 32 | } | ||
690 | 0 | 33 | ||
691 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java' | |||
692 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java 1970-01-01 00:00:00 +0000 | |||
693 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java 2010-12-17 03:47:30 +0000 | |||
694 | @@ -0,0 +1,152 @@ | |||
695 | 1 | /* | ||
696 | 2 | * Copyright 2008-2010 Gephi | ||
697 | 3 | * Authors : Cezary Bartosiak | ||
698 | 4 | * Website : http://www.gephi.org | ||
699 | 5 | * | ||
700 | 6 | * This file is part of Gephi. | ||
701 | 7 | * | ||
702 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
703 | 9 | * it under the terms of the GNU General Public License as published by | ||
704 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
705 | 11 | * (at your option) any later version. | ||
706 | 12 | * | ||
707 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
708 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
709 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
710 | 16 | * GNU General Public License for more details. | ||
711 | 17 | * | ||
712 | 18 | * You should have received a copy of the GNU General Public License | ||
713 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
714 | 20 | */ | ||
715 | 21 | package org.gephi.io.generator.plugin; | ||
716 | 22 | |||
717 | 23 | import java.util.Random; | ||
718 | 24 | import org.gephi.io.generator.spi.Generator; | ||
719 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
720 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
721 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
722 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
723 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
724 | 30 | import org.gephi.utils.progress.Progress; | ||
725 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
726 | 32 | import org.openide.util.Lookup; | ||
727 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
728 | 34 | |||
729 | 35 | /** | ||
730 | 36 | * Generates an undirected connected graph. | ||
731 | 37 | * | ||
732 | 38 | * http://en.wikipedia.org/wiki/Barabási–Albert_model | ||
733 | 39 | * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf | ||
734 | 40 | * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf | ||
735 | 41 | * | ||
736 | 42 | * N > 0 | ||
737 | 43 | * m0 > 0 && m0 < N | ||
738 | 44 | * M > 0 && M <= m0 | ||
739 | 45 | * | ||
740 | 46 | * Ω(N * M) | ||
741 | 47 | * | ||
742 | 48 | * @author Cezary Bartosiak | ||
743 | 49 | */ | ||
744 | 50 | @ServiceProvider(service = Generator.class) | ||
745 | 51 | public class BarabasiAlbertSimplifiedA implements Generator { | ||
746 | 52 | private boolean cancel = false; | ||
747 | 53 | private ProgressTicket progressTicket; | ||
748 | 54 | |||
749 | 55 | private int N = 50; | ||
750 | 56 | private int m0 = 1; | ||
751 | 57 | private int M = 1; | ||
752 | 58 | |||
753 | 59 | public void generate(ContainerLoader container) { | ||
754 | 60 | Progress.start(progressTicket, N + M); | ||
755 | 61 | Random random = new Random(); | ||
756 | 62 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
757 | 63 | |||
758 | 64 | NodeDraft[] nodes = new NodeDraft[N]; | ||
759 | 65 | |||
760 | 66 | // Creating m0 nodes | ||
761 | 67 | for (int i = 0; i < m0 && !cancel; ++i) { | ||
762 | 68 | NodeDraft node = container.factory().newNodeDraft(); | ||
763 | 69 | node.setLabel("Node " + i); | ||
764 | 70 | nodes[i] = node; | ||
765 | 71 | container.addNode(node); | ||
766 | 72 | Progress.progress(progressTicket); | ||
767 | 73 | } | ||
768 | 74 | |||
769 | 75 | // Linking every node with each other (no self-loops) | ||
770 | 76 | for (int i = 0; i < m0 && !cancel; ++i) | ||
771 | 77 | for (int j = i + 1; j < m0 && !cancel; ++j) { | ||
772 | 78 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
773 | 79 | edge.setSource(nodes[i]); | ||
774 | 80 | edge.setTarget(nodes[j]); | ||
775 | 81 | container.addEdge(edge); | ||
776 | 82 | Progress.progress(progressTicket); | ||
777 | 83 | } | ||
778 | 84 | |||
779 | 85 | // Adding N - m0 nodes, each with M edges | ||
780 | 86 | for (int i = m0; i < N && !cancel; ++i) { | ||
781 | 87 | // Adding new node | ||
782 | 88 | NodeDraft node = container.factory().newNodeDraft(); | ||
783 | 89 | node.setLabel("Node " + i); | ||
784 | 90 | nodes[i] = node; | ||
785 | 91 | container.addNode(node); | ||
786 | 92 | |||
787 | 93 | // Adding M edges out of the new node | ||
788 | 94 | for (int m = 0; m < M && !cancel; ++m) { | ||
789 | 95 | int j = random.nextInt(i); | ||
790 | 96 | while (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i])) | ||
791 | 97 | j = random.nextInt(i); | ||
792 | 98 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
793 | 99 | edge.setSource(nodes[i]); | ||
794 | 100 | edge.setTarget(nodes[j]); | ||
795 | 101 | container.addEdge(edge); | ||
796 | 102 | Progress.progress(progressTicket); | ||
797 | 103 | } | ||
798 | 104 | |||
799 | 105 | Progress.progress(progressTicket); | ||
800 | 106 | } | ||
801 | 107 | |||
802 | 108 | Progress.finish(progressTicket); | ||
803 | 109 | progressTicket = null; | ||
804 | 110 | } | ||
805 | 111 | |||
806 | 112 | public int getN() { | ||
807 | 113 | return N; | ||
808 | 114 | } | ||
809 | 115 | |||
810 | 116 | public int getm0() { | ||
811 | 117 | return m0; | ||
812 | 118 | } | ||
813 | 119 | |||
814 | 120 | public int getM() { | ||
815 | 121 | return M; | ||
816 | 122 | } | ||
817 | 123 | |||
818 | 124 | public void setN(int N) { | ||
819 | 125 | this.N = N; | ||
820 | 126 | } | ||
821 | 127 | |||
822 | 128 | public void setm0(int m0) { | ||
823 | 129 | this.m0 = m0; | ||
824 | 130 | } | ||
825 | 131 | |||
826 | 132 | public void setM(int M) { | ||
827 | 133 | this.M = M; | ||
828 | 134 | } | ||
829 | 135 | |||
830 | 136 | public String getName() { | ||
831 | 137 | return "Barabasi-Albert Scale Free model A (uniform attachment)"; | ||
832 | 138 | } | ||
833 | 139 | |||
834 | 140 | public GeneratorUI getUI() { | ||
835 | 141 | return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedAUI.class); | ||
836 | 142 | } | ||
837 | 143 | |||
838 | 144 | public boolean cancel() { | ||
839 | 145 | cancel = true; | ||
840 | 146 | return true; | ||
841 | 147 | } | ||
842 | 148 | |||
843 | 149 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
844 | 150 | this.progressTicket = progressTicket; | ||
845 | 151 | } | ||
846 | 152 | } | ||
847 | 0 | 153 | ||
848 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java' | |||
849 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java 1970-01-01 00:00:00 +0000 | |||
850 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java 2010-12-17 03:47:30 +0000 | |||
851 | @@ -0,0 +1,32 @@ | |||
852 | 1 | /* | ||
853 | 2 | * Copyright 2008-2010 Gephi | ||
854 | 3 | * Authors : Cezary Bartosiak | ||
855 | 4 | * Website : http://www.gephi.org | ||
856 | 5 | * | ||
857 | 6 | * This file is part of Gephi. | ||
858 | 7 | * | ||
859 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
860 | 9 | * it under the terms of the GNU General Public License as published by | ||
861 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
862 | 11 | * (at your option) any later version. | ||
863 | 12 | * | ||
864 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
865 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
866 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
867 | 16 | * GNU General Public License for more details. | ||
868 | 17 | * | ||
869 | 18 | * You should have received a copy of the GNU General Public License | ||
870 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
871 | 20 | */ | ||
872 | 21 | package org.gephi.io.generator.plugin; | ||
873 | 22 | |||
874 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
875 | 24 | |||
876 | 25 | /** | ||
877 | 26 | * | ||
878 | 27 | * | ||
879 | 28 | * @author Cezary Bartosiak | ||
880 | 29 | */ | ||
881 | 30 | public interface BarabasiAlbertSimplifiedAUI extends GeneratorUI { | ||
882 | 31 | |||
883 | 32 | } | ||
884 | 0 | 33 | ||
885 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java' | |||
886 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java 1970-01-01 00:00:00 +0000 | |||
887 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java 2010-12-17 03:47:30 +0000 | |||
888 | @@ -0,0 +1,151 @@ | |||
889 | 1 | /* | ||
890 | 2 | * Copyright 2008-2010 Gephi | ||
891 | 3 | * Authors : Cezary Bartosiak | ||
892 | 4 | * Website : http://www.gephi.org | ||
893 | 5 | * | ||
894 | 6 | * This file is part of Gephi. | ||
895 | 7 | * | ||
896 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
897 | 9 | * it under the terms of the GNU General Public License as published by | ||
898 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
899 | 11 | * (at your option) any later version. | ||
900 | 12 | * | ||
901 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
902 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
903 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
904 | 16 | * GNU General Public License for more details. | ||
905 | 17 | * | ||
906 | 18 | * You should have received a copy of the GNU General Public License | ||
907 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
908 | 20 | */ | ||
909 | 21 | package org.gephi.io.generator.plugin; | ||
910 | 22 | |||
911 | 23 | import java.util.Random; | ||
912 | 24 | import org.gephi.io.generator.spi.Generator; | ||
913 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
914 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
915 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
916 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
917 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
918 | 30 | import org.gephi.utils.progress.Progress; | ||
919 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
920 | 32 | import org.openide.util.Lookup; | ||
921 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
922 | 34 | |||
923 | 35 | /** | ||
924 | 36 | * Generates an undirected not necessarily connected graph. | ||
925 | 37 | * | ||
926 | 38 | * http://en.wikipedia.org/wiki/Barabási–Albert_model | ||
927 | 39 | * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf | ||
928 | 40 | * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf | ||
929 | 41 | * | ||
930 | 42 | * N > 0 | ||
931 | 43 | * M > 0 | ||
932 | 44 | * M <= N * (N - 1) / 2 | ||
933 | 45 | * | ||
934 | 46 | * Ω(N * M) | ||
935 | 47 | * | ||
936 | 48 | * @author Cezary Bartosiak | ||
937 | 49 | */ | ||
938 | 50 | @ServiceProvider(service = Generator.class) | ||
939 | 51 | public class BarabasiAlbertSimplifiedB implements Generator { | ||
940 | 52 | private boolean cancel = false; | ||
941 | 53 | private ProgressTicket progressTicket; | ||
942 | 54 | |||
943 | 55 | private int N = 50; | ||
944 | 56 | private int M = 50; | ||
945 | 57 | |||
946 | 58 | public void generate(ContainerLoader container) { | ||
947 | 59 | Progress.start(progressTicket, N + M); | ||
948 | 60 | Random random = new Random(); | ||
949 | 61 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
950 | 62 | |||
951 | 63 | NodeDraft[] nodes = new NodeDraft[N]; | ||
952 | 64 | int[] degrees = new int[N]; | ||
953 | 65 | |||
954 | 66 | // Creating N nodes | ||
955 | 67 | for (int i = 0; i < N && !cancel; ++i) { | ||
956 | 68 | NodeDraft node = container.factory().newNodeDraft(); | ||
957 | 69 | node.setLabel("Node " + i); | ||
958 | 70 | nodes[i] = node; | ||
959 | 71 | degrees[i] = 0; | ||
960 | 72 | container.addNode(node); | ||
961 | 73 | Progress.progress(progressTicket); | ||
962 | 74 | } | ||
963 | 75 | |||
964 | 76 | // Creating M edges | ||
965 | 77 | for (int m = 0; m < M && !cancel; ++m) { | ||
966 | 78 | double sum = 0.0; // sum of all nodes degrees | ||
967 | 79 | for (int j = 0; j < N && !cancel; ++j) | ||
968 | 80 | sum += degrees[j] + 1; | ||
969 | 81 | |||
970 | 82 | // Selecting a node randomly | ||
971 | 83 | int i = random.nextInt(N); | ||
972 | 84 | while (degrees[i] == N - 1 && !cancel) | ||
973 | 85 | i = random.nextInt(N); | ||
974 | 86 | |||
975 | 87 | double b = random.nextDouble(); | ||
976 | 88 | boolean e = false; | ||
977 | 89 | while (!e && !cancel) { | ||
978 | 90 | double pki = 0.0; | ||
979 | 91 | for (int j = 0; j < N && !e && !cancel; ++j) { | ||
980 | 92 | pki += (degrees[j] + 1) / sum; | ||
981 | 93 | |||
982 | 94 | if (b <= pki && i != j && !edgeExists(container, nodes[i], nodes[j])) { | ||
983 | 95 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
984 | 96 | edge.setSource(nodes[i]); | ||
985 | 97 | edge.setTarget(nodes[j]); | ||
986 | 98 | degrees[i]++; | ||
987 | 99 | degrees[j]++; | ||
988 | 100 | container.addEdge(edge); | ||
989 | 101 | |||
990 | 102 | e = true; | ||
991 | 103 | } | ||
992 | 104 | } | ||
993 | 105 | b = random.nextDouble(); | ||
994 | 106 | } | ||
995 | 107 | |||
996 | 108 | Progress.progress(progressTicket); | ||
997 | 109 | } | ||
998 | 110 | |||
999 | 111 | Progress.finish(progressTicket); | ||
1000 | 112 | progressTicket = null; | ||
1001 | 113 | } | ||
1002 | 114 | |||
1003 | 115 | private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
1004 | 116 | return container.edgeExists(node1, node2) || container.edgeExists(node2, node1); | ||
1005 | 117 | } | ||
1006 | 118 | |||
1007 | 119 | public int getN() { | ||
1008 | 120 | return N; | ||
1009 | 121 | } | ||
1010 | 122 | |||
1011 | 123 | public int getM() { | ||
1012 | 124 | return M; | ||
1013 | 125 | } | ||
1014 | 126 | |||
1015 | 127 | public void setN(int N) { | ||
1016 | 128 | this.N = N; | ||
1017 | 129 | } | ||
1018 | 130 | |||
1019 | 131 | public void setM(int M) { | ||
1020 | 132 | this.M = M; | ||
1021 | 133 | } | ||
1022 | 134 | |||
1023 | 135 | public String getName() { | ||
1024 | 136 | return "Barabasi-Albert Scale Free model B (no growth)"; | ||
1025 | 137 | } | ||
1026 | 138 | |||
1027 | 139 | public GeneratorUI getUI() { | ||
1028 | 140 | return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedBUI.class); | ||
1029 | 141 | } | ||
1030 | 142 | |||
1031 | 143 | public boolean cancel() { | ||
1032 | 144 | cancel = true; | ||
1033 | 145 | return true; | ||
1034 | 146 | } | ||
1035 | 147 | |||
1036 | 148 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
1037 | 149 | this.progressTicket = progressTicket; | ||
1038 | 150 | } | ||
1039 | 151 | } | ||
1040 | 0 | 152 | ||
1041 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java' | |||
1042 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java 1970-01-01 00:00:00 +0000 | |||
1043 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java 2010-12-17 03:47:30 +0000 | |||
1044 | @@ -0,0 +1,32 @@ | |||
1045 | 1 | /* | ||
1046 | 2 | * Copyright 2008-2010 Gephi | ||
1047 | 3 | * Authors : Cezary Bartosiak | ||
1048 | 4 | * Website : http://www.gephi.org | ||
1049 | 5 | * | ||
1050 | 6 | * This file is part of Gephi. | ||
1051 | 7 | * | ||
1052 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1053 | 9 | * it under the terms of the GNU General Public License as published by | ||
1054 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1055 | 11 | * (at your option) any later version. | ||
1056 | 12 | * | ||
1057 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1058 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1059 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1060 | 16 | * GNU General Public License for more details. | ||
1061 | 17 | * | ||
1062 | 18 | * You should have received a copy of the GNU General Public License | ||
1063 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1064 | 20 | */ | ||
1065 | 21 | package org.gephi.io.generator.plugin; | ||
1066 | 22 | |||
1067 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1068 | 24 | |||
1069 | 25 | /** | ||
1070 | 26 | * | ||
1071 | 27 | * | ||
1072 | 28 | * @author Cezary Bartosiak | ||
1073 | 29 | */ | ||
1074 | 30 | public interface BarabasiAlbertSimplifiedBUI extends GeneratorUI { | ||
1075 | 31 | |||
1076 | 32 | } | ||
1077 | 0 | 33 | ||
1078 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java' | |||
1079 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java 1970-01-01 00:00:00 +0000 | |||
1080 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java 2010-12-17 03:47:30 +0000 | |||
1081 | @@ -0,0 +1,32 @@ | |||
1082 | 1 | /* | ||
1083 | 2 | * Copyright 2008-2010 Gephi | ||
1084 | 3 | * Authors : Cezary Bartosiak | ||
1085 | 4 | * Website : http://www.gephi.org | ||
1086 | 5 | * | ||
1087 | 6 | * This file is part of Gephi. | ||
1088 | 7 | * | ||
1089 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1090 | 9 | * it under the terms of the GNU General Public License as published by | ||
1091 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1092 | 11 | * (at your option) any later version. | ||
1093 | 12 | * | ||
1094 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1095 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1096 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1097 | 16 | * GNU General Public License for more details. | ||
1098 | 17 | * | ||
1099 | 18 | * You should have received a copy of the GNU General Public License | ||
1100 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1101 | 20 | */ | ||
1102 | 21 | package org.gephi.io.generator.plugin; | ||
1103 | 22 | |||
1104 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1105 | 24 | |||
1106 | 25 | /** | ||
1107 | 26 | * | ||
1108 | 27 | * | ||
1109 | 28 | * @author Cezary Bartosiak | ||
1110 | 29 | */ | ||
1111 | 30 | public interface BarabasiAlbertUI extends GeneratorUI { | ||
1112 | 31 | |||
1113 | 32 | } | ||
1114 | 0 | 33 | ||
1115 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java' | |||
1116 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java 1970-01-01 00:00:00 +0000 | |||
1117 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java 2010-12-17 03:47:30 +0000 | |||
1118 | @@ -0,0 +1,129 @@ | |||
1119 | 1 | /* | ||
1120 | 2 | * Copyright 2008-2010 Gephi | ||
1121 | 3 | * Authors : Cezary Bartosiak | ||
1122 | 4 | * Website : http://www.gephi.org | ||
1123 | 5 | * | ||
1124 | 6 | * This file is part of Gephi. | ||
1125 | 7 | * | ||
1126 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1127 | 9 | * it under the terms of the GNU General Public License as published by | ||
1128 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1129 | 11 | * (at your option) any later version. | ||
1130 | 12 | * | ||
1131 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1132 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1133 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1134 | 16 | * GNU General Public License for more details. | ||
1135 | 17 | * | ||
1136 | 18 | * You should have received a copy of the GNU General Public License | ||
1137 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1138 | 20 | */ | ||
1139 | 21 | package org.gephi.io.generator.plugin; | ||
1140 | 22 | |||
1141 | 23 | import java.util.ArrayList; | ||
1142 | 24 | import java.util.List; | ||
1143 | 25 | import java.util.Random; | ||
1144 | 26 | import org.gephi.io.generator.spi.Generator; | ||
1145 | 27 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1146 | 28 | import org.gephi.io.importer.api.ContainerLoader; | ||
1147 | 29 | import org.gephi.io.importer.api.EdgeDefault; | ||
1148 | 30 | import org.gephi.io.importer.api.EdgeDraft; | ||
1149 | 31 | import org.gephi.io.importer.api.NodeDraft; | ||
1150 | 32 | import org.gephi.utils.progress.Progress; | ||
1151 | 33 | import org.gephi.utils.progress.ProgressTicket; | ||
1152 | 34 | import org.openide.util.Lookup; | ||
1153 | 35 | import org.openide.util.lookup.ServiceProvider; | ||
1154 | 36 | |||
1155 | 37 | /** | ||
1156 | 38 | * Generates an undirected not necessarily connected graph. | ||
1157 | 39 | * | ||
1158 | 40 | * http://www.math-inst.hu/~p_erdos/1960-10.pdf | ||
1159 | 41 | * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf | ||
1160 | 42 | * | ||
1161 | 43 | * n > 0 | ||
1162 | 44 | * m >= 0 | ||
1163 | 45 | * m <= n * (n - 1) / 2 | ||
1164 | 46 | * | ||
1165 | 47 | * O(n^2) | ||
1166 | 48 | * | ||
1167 | 49 | * @author Cezary Bartosiak | ||
1168 | 50 | */ | ||
1169 | 51 | @ServiceProvider(service = Generator.class) | ||
1170 | 52 | public class ErdosRenyiGnm implements Generator { | ||
1171 | 53 | private boolean cancel = false; | ||
1172 | 54 | private ProgressTicket progressTicket; | ||
1173 | 55 | |||
1174 | 56 | private int n = 50; | ||
1175 | 57 | private int m = 50; | ||
1176 | 58 | |||
1177 | 59 | public void generate(ContainerLoader container) { | ||
1178 | 60 | Progress.start(progressTicket, n + n * n + m); | ||
1179 | 61 | Random random = new Random(); | ||
1180 | 62 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
1181 | 63 | |||
1182 | 64 | NodeDraft[] nodes = new NodeDraft[n]; | ||
1183 | 65 | |||
1184 | 66 | // Creating n nodes | ||
1185 | 67 | for (int i = 0; i < n && !cancel; ++i) { | ||
1186 | 68 | NodeDraft node = container.factory().newNodeDraft(); | ||
1187 | 69 | node.setLabel("Node " + i); | ||
1188 | 70 | nodes[i] = node; | ||
1189 | 71 | container.addNode(node); | ||
1190 | 72 | Progress.progress(progressTicket); | ||
1191 | 73 | } | ||
1192 | 74 | |||
1193 | 75 | // Creating a list of n^2 edges | ||
1194 | 76 | List<EdgeDraft> edges = new ArrayList<EdgeDraft>(); | ||
1195 | 77 | for (int i = 0; i < n && !cancel; ++i) | ||
1196 | 78 | for (int j = i + 1; j < n && !cancel; ++j) { | ||
1197 | 79 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1198 | 80 | edge.setSource(nodes[i]); | ||
1199 | 81 | edge.setTarget(nodes[j]); | ||
1200 | 82 | edges.add(edge); | ||
1201 | 83 | Progress.progress(progressTicket); | ||
1202 | 84 | } | ||
1203 | 85 | |||
1204 | 86 | // Drawing m edges | ||
1205 | 87 | for (int i = 0; i < m; ++i) { | ||
1206 | 88 | EdgeDraft e = edges.get(random.nextInt(edges.size())); | ||
1207 | 89 | edges.remove(e); | ||
1208 | 90 | container.addEdge(e); | ||
1209 | 91 | } | ||
1210 | 92 | |||
1211 | 93 | Progress.finish(progressTicket); | ||
1212 | 94 | progressTicket = null; | ||
1213 | 95 | } | ||
1214 | 96 | |||
1215 | 97 | public int getn() { | ||
1216 | 98 | return n; | ||
1217 | 99 | } | ||
1218 | 100 | |||
1219 | 101 | public int getm() { | ||
1220 | 102 | return m; | ||
1221 | 103 | } | ||
1222 | 104 | |||
1223 | 105 | public void setn(int n) { | ||
1224 | 106 | this.n = n; | ||
1225 | 107 | } | ||
1226 | 108 | |||
1227 | 109 | public void setm(int m) { | ||
1228 | 110 | this.m = m; | ||
1229 | 111 | } | ||
1230 | 112 | |||
1231 | 113 | public String getName() { | ||
1232 | 114 | return "Erdos-Renyi G(n, m) model"; | ||
1233 | 115 | } | ||
1234 | 116 | |||
1235 | 117 | public GeneratorUI getUI() { | ||
1236 | 118 | return Lookup.getDefault().lookup(ErdosRenyiGnmUI.class); | ||
1237 | 119 | } | ||
1238 | 120 | |||
1239 | 121 | public boolean cancel() { | ||
1240 | 122 | cancel = true; | ||
1241 | 123 | return true; | ||
1242 | 124 | } | ||
1243 | 125 | |||
1244 | 126 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
1245 | 127 | this.progressTicket = progressTicket; | ||
1246 | 128 | } | ||
1247 | 129 | } | ||
1248 | 0 | 130 | ||
1249 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java' | |||
1250 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java 1970-01-01 00:00:00 +0000 | |||
1251 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java 2010-12-17 03:47:30 +0000 | |||
1252 | @@ -0,0 +1,32 @@ | |||
1253 | 1 | /* | ||
1254 | 2 | * Copyright 2008-2010 Gephi | ||
1255 | 3 | * Authors : Cezary Bartosiak | ||
1256 | 4 | * Website : http://www.gephi.org | ||
1257 | 5 | * | ||
1258 | 6 | * This file is part of Gephi. | ||
1259 | 7 | * | ||
1260 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1261 | 9 | * it under the terms of the GNU General Public License as published by | ||
1262 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1263 | 11 | * (at your option) any later version. | ||
1264 | 12 | * | ||
1265 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1266 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1267 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1268 | 16 | * GNU General Public License for more details. | ||
1269 | 17 | * | ||
1270 | 18 | * You should have received a copy of the GNU General Public License | ||
1271 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1272 | 20 | */ | ||
1273 | 21 | package org.gephi.io.generator.plugin; | ||
1274 | 22 | |||
1275 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1276 | 24 | |||
1277 | 25 | /** | ||
1278 | 26 | * | ||
1279 | 27 | * | ||
1280 | 28 | * @author Cezary Bartosiak | ||
1281 | 29 | */ | ||
1282 | 30 | public interface ErdosRenyiGnmUI extends GeneratorUI { | ||
1283 | 31 | |||
1284 | 32 | } | ||
1285 | 0 | 33 | ||
1286 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java' | |||
1287 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java 1970-01-01 00:00:00 +0000 | |||
1288 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java 2010-12-17 03:47:30 +0000 | |||
1289 | @@ -0,0 +1,123 @@ | |||
1290 | 1 | /* | ||
1291 | 2 | * Copyright 2008-2010 Gephi | ||
1292 | 3 | * Authors : Cezary Bartosiak | ||
1293 | 4 | * Website : http://www.gephi.org | ||
1294 | 5 | * | ||
1295 | 6 | * This file is part of Gephi. | ||
1296 | 7 | * | ||
1297 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1298 | 9 | * it under the terms of the GNU General Public License as published by | ||
1299 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1300 | 11 | * (at your option) any later version. | ||
1301 | 12 | * | ||
1302 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1303 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1304 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1305 | 16 | * GNU General Public License for more details. | ||
1306 | 17 | * | ||
1307 | 18 | * You should have received a copy of the GNU General Public License | ||
1308 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1309 | 20 | */ | ||
1310 | 21 | package org.gephi.io.generator.plugin; | ||
1311 | 22 | |||
1312 | 23 | import java.util.Random; | ||
1313 | 24 | import org.gephi.io.generator.spi.Generator; | ||
1314 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1315 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
1316 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
1317 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
1318 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
1319 | 30 | import org.gephi.utils.progress.Progress; | ||
1320 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
1321 | 32 | import org.openide.util.Lookup; | ||
1322 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
1323 | 34 | |||
1324 | 35 | /** | ||
1325 | 36 | * Generates an undirected not necessarily connected graph. | ||
1326 | 37 | * | ||
1327 | 38 | * http://www.math-inst.hu/~p_erdos/1960-10.pdf | ||
1328 | 39 | * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf | ||
1329 | 40 | * | ||
1330 | 41 | * n > 0 | ||
1331 | 42 | * 0 <= p <= 1 | ||
1332 | 43 | * | ||
1333 | 44 | * O(n^2) | ||
1334 | 45 | * | ||
1335 | 46 | * @author Cezary Bartosiak | ||
1336 | 47 | */ | ||
1337 | 48 | @ServiceProvider(service = Generator.class) | ||
1338 | 49 | public class ErdosRenyiGnp implements Generator { | ||
1339 | 50 | private boolean cancel = false; | ||
1340 | 51 | private ProgressTicket progressTicket; | ||
1341 | 52 | |||
1342 | 53 | private int n = 50; | ||
1343 | 54 | private double p = 0.05; | ||
1344 | 55 | |||
1345 | 56 | public void generate(ContainerLoader container) { | ||
1346 | 57 | Progress.start(progressTicket, n + n * n); | ||
1347 | 58 | Random random = new Random(); | ||
1348 | 59 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
1349 | 60 | |||
1350 | 61 | NodeDraft[] nodes = new NodeDraft[n]; | ||
1351 | 62 | |||
1352 | 63 | // Creating n nodes | ||
1353 | 64 | for (int i = 0; i < n && !cancel; ++i) { | ||
1354 | 65 | NodeDraft node = container.factory().newNodeDraft(); | ||
1355 | 66 | node.setLabel("Node " + i); | ||
1356 | 67 | nodes[i] = node; | ||
1357 | 68 | container.addNode(node); | ||
1358 | 69 | Progress.progress(progressTicket); | ||
1359 | 70 | } | ||
1360 | 71 | |||
1361 | 72 | // Linking every node with each other with probability p (no self-loops) | ||
1362 | 73 | for (int i = 0; i < n && !cancel; ++i) | ||
1363 | 74 | for (int j = 0; j < n && !cancel; ++j) | ||
1364 | 75 | if (i != j && !edgeExists(container, nodes[i], nodes[j]) && random.nextDouble() <= p) { | ||
1365 | 76 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1366 | 77 | edge.setSource(nodes[i]); | ||
1367 | 78 | edge.setTarget(nodes[j]); | ||
1368 | 79 | container.addEdge(edge); | ||
1369 | 80 | Progress.progress(progressTicket); | ||
1370 | 81 | } | ||
1371 | 82 | |||
1372 | 83 | Progress.finish(progressTicket); | ||
1373 | 84 | progressTicket = null; | ||
1374 | 85 | } | ||
1375 | 86 | |||
1376 | 87 | private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
1377 | 88 | return container.edgeExists(node1, node2) || container.edgeExists(node2, node1); | ||
1378 | 89 | } | ||
1379 | 90 | |||
1380 | 91 | public int getn() { | ||
1381 | 92 | return n; | ||
1382 | 93 | } | ||
1383 | 94 | |||
1384 | 95 | public double getp() { | ||
1385 | 96 | return p; | ||
1386 | 97 | } | ||
1387 | 98 | |||
1388 | 99 | public void setn(int n) { | ||
1389 | 100 | this.n = n; | ||
1390 | 101 | } | ||
1391 | 102 | |||
1392 | 103 | public void setp(double p) { | ||
1393 | 104 | this.p = p; | ||
1394 | 105 | } | ||
1395 | 106 | |||
1396 | 107 | public String getName() { | ||
1397 | 108 | return "Erdos-Renyi G(n, p) model"; | ||
1398 | 109 | } | ||
1399 | 110 | |||
1400 | 111 | public GeneratorUI getUI() { | ||
1401 | 112 | return Lookup.getDefault().lookup(ErdosRenyiGnpUI.class); | ||
1402 | 113 | } | ||
1403 | 114 | |||
1404 | 115 | public boolean cancel() { | ||
1405 | 116 | cancel = true; | ||
1406 | 117 | return true; | ||
1407 | 118 | } | ||
1408 | 119 | |||
1409 | 120 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
1410 | 121 | this.progressTicket = progressTicket; | ||
1411 | 122 | } | ||
1412 | 123 | } | ||
1413 | 0 | 124 | ||
1414 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java' | |||
1415 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java 1970-01-01 00:00:00 +0000 | |||
1416 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java 2010-12-17 03:47:30 +0000 | |||
1417 | @@ -0,0 +1,32 @@ | |||
1418 | 1 | /* | ||
1419 | 2 | * Copyright 2008-2010 Gephi | ||
1420 | 3 | * Authors : Cezary Bartosiak | ||
1421 | 4 | * Website : http://www.gephi.org | ||
1422 | 5 | * | ||
1423 | 6 | * This file is part of Gephi. | ||
1424 | 7 | * | ||
1425 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1426 | 9 | * it under the terms of the GNU General Public License as published by | ||
1427 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1428 | 11 | * (at your option) any later version. | ||
1429 | 12 | * | ||
1430 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1431 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1432 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1433 | 16 | * GNU General Public License for more details. | ||
1434 | 17 | * | ||
1435 | 18 | * You should have received a copy of the GNU General Public License | ||
1436 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1437 | 20 | */ | ||
1438 | 21 | package org.gephi.io.generator.plugin; | ||
1439 | 22 | |||
1440 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1441 | 24 | |||
1442 | 25 | /** | ||
1443 | 26 | * | ||
1444 | 27 | * | ||
1445 | 28 | * @author Cezary Bartosiak | ||
1446 | 29 | */ | ||
1447 | 30 | public interface ErdosRenyiGnpUI extends GeneratorUI { | ||
1448 | 31 | |||
1449 | 32 | } | ||
1450 | 0 | 33 | ||
1451 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java' | |||
1452 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java 1970-01-01 00:00:00 +0000 | |||
1453 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java 2010-12-17 03:47:30 +0000 | |||
1454 | @@ -0,0 +1,200 @@ | |||
1455 | 1 | /* | ||
1456 | 2 | * Copyright 2008-2010 Gephi | ||
1457 | 3 | * Authors : Cezary Bartosiak | ||
1458 | 4 | * Website : http://www.gephi.org | ||
1459 | 5 | * | ||
1460 | 6 | * This file is part of Gephi. | ||
1461 | 7 | * | ||
1462 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1463 | 9 | * it under the terms of the GNU General Public License as published by | ||
1464 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1465 | 11 | * (at your option) any later version. | ||
1466 | 12 | * | ||
1467 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1468 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1469 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1470 | 16 | * GNU General Public License for more details. | ||
1471 | 17 | * | ||
1472 | 18 | * You should have received a copy of the GNU General Public License | ||
1473 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1474 | 20 | */ | ||
1475 | 21 | package org.gephi.io.generator.plugin; | ||
1476 | 22 | |||
1477 | 23 | import java.util.Random; | ||
1478 | 24 | import org.gephi.io.generator.spi.Generator; | ||
1479 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1480 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
1481 | 27 | import org.gephi.io.importer.api.EdgeDraft; | ||
1482 | 28 | import org.gephi.io.importer.api.NodeDraft; | ||
1483 | 29 | import org.gephi.utils.progress.Progress; | ||
1484 | 30 | import org.gephi.utils.progress.ProgressTicket; | ||
1485 | 31 | import org.openide.util.Lookup; | ||
1486 | 32 | import org.openide.util.lookup.ServiceProvider; | ||
1487 | 33 | |||
1488 | 34 | /** | ||
1489 | 35 | * Generates a directed connected graph. | ||
1490 | 36 | * | ||
1491 | 37 | * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.117.7097&rep=rep1&type=pdf | ||
1492 | 38 | * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.83.381&rep=rep1&type=pdf | ||
1493 | 39 | * | ||
1494 | 40 | * n >= 2 | ||
1495 | 41 | * p >= 1 | ||
1496 | 42 | * p <= 2n - 2 | ||
1497 | 43 | * q >= 0 | ||
1498 | 44 | * q <= n^2 - p * (p + 3) / 2 - 1 for p < n | ||
1499 | 45 | * q <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n | ||
1500 | 46 | * r >= 0 | ||
1501 | 47 | * | ||
1502 | 48 | * Ω(n^4 * q) | ||
1503 | 49 | * | ||
1504 | 50 | * @author Cezary Bartosiak | ||
1505 | 51 | */ | ||
1506 | 52 | @ServiceProvider(service = Generator.class) | ||
1507 | 53 | public class Kleinberg implements Generator { | ||
1508 | 54 | private boolean cancel = false; | ||
1509 | 55 | private ProgressTicket progressTicket; | ||
1510 | 56 | |||
1511 | 57 | private int n = 10; | ||
1512 | 58 | private int p = 2; | ||
1513 | 59 | private int q = 2; | ||
1514 | 60 | private int r = 0; | ||
1515 | 61 | |||
1516 | 62 | private boolean torusBased = false; | ||
1517 | 63 | |||
1518 | 64 | public void generate(ContainerLoader container) { | ||
1519 | 65 | Progress.start(progressTicket, n * n + n * n * (2 * p + 1) * (2 * p + 1) + | ||
1520 | 66 | (int)Math.pow(n, 4) + n * n * q); | ||
1521 | 67 | Random random = new Random(); | ||
1522 | 68 | |||
1523 | 69 | // Creating lattice n x n | ||
1524 | 70 | NodeDraft[][] nodes = new NodeDraft[n][n]; | ||
1525 | 71 | for (int i = 0; i < n && !cancel; ++i) | ||
1526 | 72 | for (int j = 0; j < n && !cancel; ++j) { | ||
1527 | 73 | NodeDraft node = container.factory().newNodeDraft(); | ||
1528 | 74 | node.setLabel("Node " + i + " " + j); | ||
1529 | 75 | nodes[i][j] = node; | ||
1530 | 76 | container.addNode(node); | ||
1531 | 77 | Progress.progress(progressTicket); | ||
1532 | 78 | } | ||
1533 | 79 | |||
1534 | 80 | // Creating edges from each node to p local contacts | ||
1535 | 81 | for (int i = 0; i < n && !cancel; ++i) | ||
1536 | 82 | for (int j = 0; j < n && !cancel; ++j) | ||
1537 | 83 | for (int k = i - p; k <= i + p && !cancel; ++k) | ||
1538 | 84 | for (int l = j - p; l <= j + p && !cancel; ++l) { | ||
1539 | 85 | if ((torusBased || !torusBased && k >= 0 && k < n && l >= 0 && l < n) && | ||
1540 | 86 | d(i, j, k, l) <= p && nodes[i][j] != nodes[(k + n) % n][(l + n) % n]) { | ||
1541 | 87 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1542 | 88 | edge.setSource(nodes[i][j]); | ||
1543 | 89 | edge.setTarget(nodes[(k + n) % n][(l + n) % n]); | ||
1544 | 90 | container.addEdge(edge); | ||
1545 | 91 | } | ||
1546 | 92 | Progress.progress(progressTicket); | ||
1547 | 93 | } | ||
1548 | 94 | |||
1549 | 95 | // Creating edges from each node to q long-range contacts | ||
1550 | 96 | for (int i = 0; i < n && !cancel; ++i) | ||
1551 | 97 | for (int j = 0; j < n && !cancel; ++j) { | ||
1552 | 98 | double sum = 0.0; | ||
1553 | 99 | for (int k = 0; k < n && !cancel; ++k) | ||
1554 | 100 | for (int l = 0; l < n && !cancel; ++l) { | ||
1555 | 101 | if (!torusBased && d(i, j, k, l) > p) | ||
1556 | 102 | sum += Math.pow(d(i, j, k, l), -r); | ||
1557 | 103 | else if (torusBased && dtb(i, j, k, l) > p) | ||
1558 | 104 | sum += Math.pow(dtb(i, j, k, l), -r); | ||
1559 | 105 | Progress.progress(progressTicket); | ||
1560 | 106 | } | ||
1561 | 107 | for (int m = 0; m < q && !cancel; ++m) { | ||
1562 | 108 | double b = random.nextDouble(); | ||
1563 | 109 | boolean e = false; | ||
1564 | 110 | while (!e && !cancel) { | ||
1565 | 111 | double pki = 0.0; | ||
1566 | 112 | for (int k = 0; k < n && !e && !cancel; ++k) | ||
1567 | 113 | for (int l = 0; l < n && !e && !cancel; ++l) | ||
1568 | 114 | if (!torusBased && d(i, j, k, l) > p || torusBased && dtb(i, j, k, l) > p) { | ||
1569 | 115 | pki += Math.pow(!torusBased ? d(i, j, k, l) : dtb(i, j, k, l), -r) / sum; | ||
1570 | 116 | |||
1571 | 117 | if (b <= pki && !container.edgeExists(nodes[i][j], nodes[k][l])) { | ||
1572 | 118 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1573 | 119 | edge.setSource(nodes[i][j]); | ||
1574 | 120 | edge.setTarget(nodes[k][l]); | ||
1575 | 121 | container.addEdge(edge); | ||
1576 | 122 | |||
1577 | 123 | e = true; | ||
1578 | 124 | } | ||
1579 | 125 | } | ||
1580 | 126 | b = random.nextDouble(); | ||
1581 | 127 | } | ||
1582 | 128 | Progress.progress(progressTicket); | ||
1583 | 129 | } | ||
1584 | 130 | } | ||
1585 | 131 | |||
1586 | 132 | Progress.finish(progressTicket); | ||
1587 | 133 | progressTicket = null; | ||
1588 | 134 | } | ||
1589 | 135 | |||
1590 | 136 | private int d(int i, int j, int k, int l) { | ||
1591 | 137 | return Math.abs(k - i) + Math.abs(l - j); | ||
1592 | 138 | } | ||
1593 | 139 | |||
1594 | 140 | private int dtb(int i, int j, int k, int l) { | ||
1595 | 141 | return Math.min(Math.abs(k - i), n - Math.abs(k - i)) + Math.min(Math.abs(l - j), n - Math.abs(l - j)); | ||
1596 | 142 | } | ||
1597 | 143 | |||
1598 | 144 | public int getn() { | ||
1599 | 145 | return n; | ||
1600 | 146 | } | ||
1601 | 147 | |||
1602 | 148 | public int getp() { | ||
1603 | 149 | return p; | ||
1604 | 150 | } | ||
1605 | 151 | |||
1606 | 152 | public int getq() { | ||
1607 | 153 | return q; | ||
1608 | 154 | } | ||
1609 | 155 | |||
1610 | 156 | public int getr() { | ||
1611 | 157 | return r; | ||
1612 | 158 | } | ||
1613 | 159 | |||
1614 | 160 | public boolean isTorusBased() { | ||
1615 | 161 | return torusBased; | ||
1616 | 162 | } | ||
1617 | 163 | |||
1618 | 164 | public void setn(int n) { | ||
1619 | 165 | this.n = n; | ||
1620 | 166 | } | ||
1621 | 167 | |||
1622 | 168 | public void setp(int p) { | ||
1623 | 169 | this.p = p; | ||
1624 | 170 | } | ||
1625 | 171 | |||
1626 | 172 | public void setq(int q) { | ||
1627 | 173 | this.q = q; | ||
1628 | 174 | } | ||
1629 | 175 | |||
1630 | 176 | public void setr(int r) { | ||
1631 | 177 | this.r = r; | ||
1632 | 178 | } | ||
1633 | 179 | |||
1634 | 180 | public void setTorusBased(boolean torusBased) { | ||
1635 | 181 | this.torusBased = torusBased; | ||
1636 | 182 | } | ||
1637 | 183 | |||
1638 | 184 | public String getName() { | ||
1639 | 185 | return "Kleinberg Small World model"; | ||
1640 | 186 | } | ||
1641 | 187 | |||
1642 | 188 | public GeneratorUI getUI() { | ||
1643 | 189 | return Lookup.getDefault().lookup(KleinbergUI.class); | ||
1644 | 190 | } | ||
1645 | 191 | |||
1646 | 192 | public boolean cancel() { | ||
1647 | 193 | cancel = true; | ||
1648 | 194 | return true; | ||
1649 | 195 | } | ||
1650 | 196 | |||
1651 | 197 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
1652 | 198 | this.progressTicket = progressTicket; | ||
1653 | 199 | } | ||
1654 | 200 | } | ||
1655 | 0 | 201 | ||
1656 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java' | |||
1657 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java 1970-01-01 00:00:00 +0000 | |||
1658 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java 2010-12-17 03:47:30 +0000 | |||
1659 | @@ -0,0 +1,32 @@ | |||
1660 | 1 | /* | ||
1661 | 2 | * Copyright 2008-2010 Gephi | ||
1662 | 3 | * Authors : Cezary Bartosiak | ||
1663 | 4 | * Website : http://www.gephi.org | ||
1664 | 5 | * | ||
1665 | 6 | * This file is part of Gephi. | ||
1666 | 7 | * | ||
1667 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1668 | 9 | * it under the terms of the GNU General Public License as published by | ||
1669 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1670 | 11 | * (at your option) any later version. | ||
1671 | 12 | * | ||
1672 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1673 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1674 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1675 | 16 | * GNU General Public License for more details. | ||
1676 | 17 | * | ||
1677 | 18 | * You should have received a copy of the GNU General Public License | ||
1678 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1679 | 20 | */ | ||
1680 | 21 | package org.gephi.io.generator.plugin; | ||
1681 | 22 | |||
1682 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1683 | 24 | |||
1684 | 25 | /** | ||
1685 | 26 | * | ||
1686 | 27 | * | ||
1687 | 28 | * @author Cezary Bartosiak | ||
1688 | 29 | */ | ||
1689 | 30 | public interface KleinbergUI extends GeneratorUI { | ||
1690 | 31 | |||
1691 | 32 | } | ||
1692 | 0 | 33 | ||
1693 | === removed file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java' | |||
1694 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java 2010-09-27 08:43:21 +0000 | |||
1695 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java 1970-01-01 00:00:00 +0000 | |||
1696 | @@ -1,149 +0,0 @@ | |||
1697 | 1 | /* | ||
1698 | 2 | Copyright 2008-2010 Gephi | ||
1699 | 3 | Authors : Mathieu Bastian <mathieu.bastian@gephi.org> | ||
1700 | 4 | Website : http://www.gephi.org | ||
1701 | 5 | |||
1702 | 6 | This file is part of Gephi. | ||
1703 | 7 | |||
1704 | 8 | Gephi is free software: you can redistribute it and/or modify | ||
1705 | 9 | it under the terms of the GNU Affero General Public License as | ||
1706 | 10 | published by the Free Software Foundation, either version 3 of the | ||
1707 | 11 | License, or (at your option) any later version. | ||
1708 | 12 | |||
1709 | 13 | Gephi is distributed in the hope that it will be useful, | ||
1710 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1711 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1712 | 16 | GNU Affero General Public License for more details. | ||
1713 | 17 | |||
1714 | 18 | You should have received a copy of the GNU Affero General Public License | ||
1715 | 19 | along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1716 | 20 | */ | ||
1717 | 21 | package org.gephi.io.generator.plugin; | ||
1718 | 22 | |||
1719 | 23 | import java.util.Random; | ||
1720 | 24 | import org.gephi.io.generator.spi.Generator; | ||
1721 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1722 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
1723 | 27 | import org.gephi.io.importer.api.EdgeDraft; | ||
1724 | 28 | import org.gephi.io.importer.api.NodeDraft; | ||
1725 | 29 | import org.gephi.utils.progress.Progress; | ||
1726 | 30 | import org.gephi.utils.progress.ProgressTicket; | ||
1727 | 31 | import org.openide.util.Lookup; | ||
1728 | 32 | import org.openide.util.lookup.ServiceProvider; | ||
1729 | 33 | |||
1730 | 34 | /** | ||
1731 | 35 | * | ||
1732 | 36 | * @author Mathieu Bastian | ||
1733 | 37 | */ | ||
1734 | 38 | @ServiceProvider(service = Generator.class) | ||
1735 | 39 | public class WattsStrogatz implements Generator { | ||
1736 | 40 | |||
1737 | 41 | protected int numberOfNodes = 50; | ||
1738 | 42 | protected int numberOfNeighbors = 3; | ||
1739 | 43 | protected double rewiringProbability = 0.5; | ||
1740 | 44 | protected ProgressTicket progress; | ||
1741 | 45 | protected boolean cancel = false; | ||
1742 | 46 | |||
1743 | 47 | public void generate(ContainerLoader container) { | ||
1744 | 48 | Progress.start(progress, numberOfNodes); | ||
1745 | 49 | Random random = new Random(); | ||
1746 | 50 | |||
1747 | 51 | NodeDraft[] nodeArray = new NodeDraft[numberOfNodes]; | ||
1748 | 52 | |||
1749 | 53 | //Create ring lattice | ||
1750 | 54 | for (int i = 0; i < numberOfNodes && !cancel; i++) { | ||
1751 | 55 | NodeDraft node = container.factory().newNodeDraft(); | ||
1752 | 56 | node.setLabel("Node " + i); | ||
1753 | 57 | nodeArray[i] = node; | ||
1754 | 58 | container.addNode(node); | ||
1755 | 59 | } | ||
1756 | 60 | for (int i = 0; i < numberOfNodes && !cancel; i++) { | ||
1757 | 61 | for (int j = 0; j < numberOfNeighbors; j++) { | ||
1758 | 62 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1759 | 63 | edge.setSource(nodeArray[i]); | ||
1760 | 64 | edge.setTarget(nodeArray[(i + (numberOfNeighbors - j)) % numberOfNodes]); | ||
1761 | 65 | container.addEdge(edge); | ||
1762 | 66 | } | ||
1763 | 67 | } | ||
1764 | 68 | |||
1765 | 69 | //Rewire edges | ||
1766 | 70 | for (int i = 0; i < numberOfNodes && !cancel; i++) { | ||
1767 | 71 | for (int s = 1; s <= numberOfNeighbors && !cancel; s++) { | ||
1768 | 72 | while (true) { | ||
1769 | 73 | // randomly rewire a proportion, beta, of the edges in the graph. | ||
1770 | 74 | double r = random.nextDouble(); | ||
1771 | 75 | if (r < rewiringProbability) { | ||
1772 | 76 | int v = random.nextInt(numberOfNeighbors); | ||
1773 | 77 | |||
1774 | 78 | NodeDraft vthNode = nodeArray[v]; | ||
1775 | 79 | NodeDraft ithNode = nodeArray[i]; | ||
1776 | 80 | NodeDraft kthNode = nodeArray[((i + s) % numberOfNodes)];//upIndex(i, s)); | ||
1777 | 81 | EdgeDraft e = container.getEdge(ithNode, kthNode); | ||
1778 | 82 | |||
1779 | 83 | if (kthNode != vthNode && container.getEdge(kthNode, vthNode) == null) { | ||
1780 | 84 | container.removeEdge(e); | ||
1781 | 85 | EdgeDraft edgeDraft = container.factory().newEdgeDraft(); | ||
1782 | 86 | edgeDraft.setSource(kthNode); | ||
1783 | 87 | edgeDraft.setTarget(vthNode); | ||
1784 | 88 | container.addEdge(edgeDraft); | ||
1785 | 89 | break; | ||
1786 | 90 | } | ||
1787 | 91 | } else { | ||
1788 | 92 | break; | ||
1789 | 93 | } | ||
1790 | 94 | } | ||
1791 | 95 | } | ||
1792 | 96 | Progress.progress(progress); | ||
1793 | 97 | } | ||
1794 | 98 | |||
1795 | 99 | Progress.finish(progress); | ||
1796 | 100 | progress = null; | ||
1797 | 101 | } | ||
1798 | 102 | |||
1799 | 103 | public int getNumberOfNeighbors() { | ||
1800 | 104 | return numberOfNeighbors; | ||
1801 | 105 | } | ||
1802 | 106 | |||
1803 | 107 | public void setNumberOfNeighbors(int numberOfNeighbors) { | ||
1804 | 108 | if (numberOfNeighbors < 2 || numberOfNeighbors > numberOfNodes / 2) { | ||
1805 | 109 | throw new IllegalArgumentException("Neighbors must be between 2 and numberOfNodes / 2"); | ||
1806 | 110 | } | ||
1807 | 111 | this.numberOfNeighbors = numberOfNeighbors; | ||
1808 | 112 | } | ||
1809 | 113 | |||
1810 | 114 | public int getNumberOfNodes() { | ||
1811 | 115 | return numberOfNodes; | ||
1812 | 116 | } | ||
1813 | 117 | |||
1814 | 118 | public void setNumberOfNodes(int numberOfNodes) { | ||
1815 | 119 | this.numberOfNodes = numberOfNodes; | ||
1816 | 120 | } | ||
1817 | 121 | |||
1818 | 122 | public double getRewiringProbability() { | ||
1819 | 123 | return rewiringProbability; | ||
1820 | 124 | } | ||
1821 | 125 | |||
1822 | 126 | public void setRewiringProbability(double rewiringProbability) { | ||
1823 | 127 | if (rewiringProbability < 0 || rewiringProbability > 1) { | ||
1824 | 128 | throw new IllegalArgumentException("Probability must be between 0.0 and 1.0"); | ||
1825 | 129 | } | ||
1826 | 130 | this.rewiringProbability = rewiringProbability; | ||
1827 | 131 | } | ||
1828 | 132 | |||
1829 | 133 | public String getName() { | ||
1830 | 134 | return "Watts-Strogatz Small World"; | ||
1831 | 135 | } | ||
1832 | 136 | |||
1833 | 137 | public GeneratorUI getUI() { | ||
1834 | 138 | return Lookup.getDefault().lookup(WattsStrogatzUI.class); | ||
1835 | 139 | } | ||
1836 | 140 | |||
1837 | 141 | public boolean cancel() { | ||
1838 | 142 | cancel = true; | ||
1839 | 143 | return true; | ||
1840 | 144 | } | ||
1841 | 145 | |||
1842 | 146 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
1843 | 147 | this.progress = progressTicket; | ||
1844 | 148 | } | ||
1845 | 149 | } | ||
1846 | 150 | 0 | ||
1847 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java' | |||
1848 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java 1970-01-01 00:00:00 +0000 | |||
1849 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java 2010-12-17 03:47:30 +0000 | |||
1850 | @@ -0,0 +1,188 @@ | |||
1851 | 1 | /* | ||
1852 | 2 | * Copyright 2008-2010 Gephi | ||
1853 | 3 | * Authors : Cezary Bartosiak | ||
1854 | 4 | * Website : http://www.gephi.org | ||
1855 | 5 | * | ||
1856 | 6 | * This file is part of Gephi. | ||
1857 | 7 | * | ||
1858 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
1859 | 9 | * it under the terms of the GNU General Public License as published by | ||
1860 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
1861 | 11 | * (at your option) any later version. | ||
1862 | 12 | * | ||
1863 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
1864 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1865 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1866 | 16 | * GNU General Public License for more details. | ||
1867 | 17 | * | ||
1868 | 18 | * You should have received a copy of the GNU General Public License | ||
1869 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
1870 | 20 | */ | ||
1871 | 21 | package org.gephi.io.generator.plugin; | ||
1872 | 22 | |||
1873 | 23 | import java.util.ArrayList; | ||
1874 | 24 | import java.util.List; | ||
1875 | 25 | import java.util.Random; | ||
1876 | 26 | import org.gephi.io.generator.spi.Generator; | ||
1877 | 27 | import org.gephi.io.generator.spi.GeneratorUI; | ||
1878 | 28 | import org.gephi.io.importer.api.ContainerLoader; | ||
1879 | 29 | import org.gephi.io.importer.api.EdgeDefault; | ||
1880 | 30 | import org.gephi.io.importer.api.EdgeDraft; | ||
1881 | 31 | import org.gephi.io.importer.api.NodeDraft; | ||
1882 | 32 | import org.gephi.utils.progress.Progress; | ||
1883 | 33 | import org.gephi.utils.progress.ProgressTicket; | ||
1884 | 34 | import org.openide.util.Lookup; | ||
1885 | 35 | import org.openide.util.lookup.ServiceProvider; | ||
1886 | 36 | |||
1887 | 37 | /** | ||
1888 | 38 | * Generates an undirected connected graph. | ||
1889 | 39 | * | ||
1890 | 40 | * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model | ||
1891 | 41 | * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf | ||
1892 | 42 | * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf | ||
1893 | 43 | * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf | ||
1894 | 44 | * | ||
1895 | 45 | * n > k > 0 | ||
1896 | 46 | * 0 <= alpha | ||
1897 | 47 | * | ||
1898 | 48 | * O(n^3 * k) | ||
1899 | 49 | * | ||
1900 | 50 | * @author Cezary Bartosiak | ||
1901 | 51 | */ | ||
1902 | 52 | @ServiceProvider(service = Generator.class) | ||
1903 | 53 | public class WattsStrogatzAlpha implements Generator { | ||
1904 | 54 | private boolean cancel = false; | ||
1905 | 55 | private ProgressTicket progressTicket; | ||
1906 | 56 | |||
1907 | 57 | private int n = 20; | ||
1908 | 58 | private int k = 4; | ||
1909 | 59 | private double alpha = 3.5; | ||
1910 | 60 | private double p = Math.pow(10, -10); | ||
1911 | 61 | |||
1912 | 62 | public void generate(ContainerLoader container) { | ||
1913 | 63 | Progress.start(progressTicket, n + n + n * k / 2); | ||
1914 | 64 | Random random = new Random(); | ||
1915 | 65 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
1916 | 66 | |||
1917 | 67 | NodeDraft[] nodes = new NodeDraft[n]; | ||
1918 | 68 | |||
1919 | 69 | // Creating a regular ring lattice | ||
1920 | 70 | int ec = 0; | ||
1921 | 71 | for (int i = 0; i < n && !cancel; ++i) { | ||
1922 | 72 | NodeDraft node = container.factory().newNodeDraft(); | ||
1923 | 73 | node.setLabel("Node " + i); | ||
1924 | 74 | nodes[i] = node; | ||
1925 | 75 | container.addNode(node); | ||
1926 | 76 | Progress.progress(progressTicket); | ||
1927 | 77 | } | ||
1928 | 78 | for (int i = 0; i < n && !cancel; ++i) { | ||
1929 | 79 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1930 | 80 | edge.setSource(nodes[i]); | ||
1931 | 81 | edge.setTarget(nodes[(i + 1) % n]); | ||
1932 | 82 | container.addEdge(edge); | ||
1933 | 83 | ec++; | ||
1934 | 84 | Progress.progress(progressTicket); | ||
1935 | 85 | } | ||
1936 | 86 | |||
1937 | 87 | // Creating n * k / 2 edges | ||
1938 | 88 | List<Integer> ids = new ArrayList<Integer>(); | ||
1939 | 89 | while (ec < n * k / 2 && !cancel) { | ||
1940 | 90 | for (int i = 0; i < n && !cancel; ++i) | ||
1941 | 91 | ids.add(new Integer(i)); | ||
1942 | 92 | while (ec < n * k / 2 && ids.size() > 0 && !cancel) { | ||
1943 | 93 | Integer i = ids.remove(random.nextInt(ids.size())); | ||
1944 | 94 | double[] Rij = new double[n]; | ||
1945 | 95 | double sumRij = 0.0; | ||
1946 | 96 | for (int j = 0; j < n && !cancel; ++j) { | ||
1947 | 97 | Rij[j] = calculateRij(container, nodes, i, j); | ||
1948 | 98 | sumRij += Rij[j]; | ||
1949 | 99 | } | ||
1950 | 100 | double r = random.nextDouble(); | ||
1951 | 101 | double pij = 0.0; | ||
1952 | 102 | for (int j = 0; j < n && !cancel; ++j) | ||
1953 | 103 | if (i != j) { | ||
1954 | 104 | pij += Rij[j] / sumRij; | ||
1955 | 105 | if (r <= pij) { | ||
1956 | 106 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
1957 | 107 | edge.setSource(nodes[i]); | ||
1958 | 108 | edge.setTarget(nodes[j]); | ||
1959 | 109 | container.addEdge(edge); | ||
1960 | 110 | ec++; | ||
1961 | 111 | |||
1962 | 112 | Progress.progress(progressTicket); | ||
1963 | 113 | break; | ||
1964 | 114 | } | ||
1965 | 115 | } | ||
1966 | 116 | } | ||
1967 | 117 | } | ||
1968 | 118 | |||
1969 | 119 | Progress.finish(progressTicket); | ||
1970 | 120 | progressTicket = null; | ||
1971 | 121 | } | ||
1972 | 122 | |||
1973 | 123 | public double calculateRij(ContainerLoader container, NodeDraft[] nodes, int i, int j) { | ||
1974 | 124 | if (i == j || edgeExists(container, nodes[i], nodes[j])) | ||
1975 | 125 | return 0; | ||
1976 | 126 | int mij = calculatemij(container, nodes, i, j); | ||
1977 | 127 | if (mij >= k) | ||
1978 | 128 | return 1; | ||
1979 | 129 | if (mij == 0) | ||
1980 | 130 | return p; | ||
1981 | 131 | return Math.pow(mij / k, alpha) * (1 - p) + p; | ||
1982 | 132 | } | ||
1983 | 133 | |||
1984 | 134 | public int calculatemij(ContainerLoader container, NodeDraft[] nodes, int i, int j) { | ||
1985 | 135 | int mij = 0; | ||
1986 | 136 | for (int l = 0; l < n && !cancel; ++l) | ||
1987 | 137 | if (l != i && l != j && | ||
1988 | 138 | edgeExists(container, nodes[i], nodes[l]) && | ||
1989 | 139 | edgeExists(container, nodes[j], nodes[l])) | ||
1990 | 140 | mij++; | ||
1991 | 141 | return mij; | ||
1992 | 142 | } | ||
1993 | 143 | |||
1994 | 144 | private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
1995 | 145 | return container.edgeExists(node1, node2) || container.edgeExists(node2, node1); | ||
1996 | 146 | } | ||
1997 | 147 | |||
1998 | 148 | public int getn() { | ||
1999 | 149 | return n; | ||
2000 | 150 | } | ||
2001 | 151 | |||
2002 | 152 | public int getk() { | ||
2003 | 153 | return k; | ||
2004 | 154 | } | ||
2005 | 155 | |||
2006 | 156 | public double getalpha() { | ||
2007 | 157 | return alpha; | ||
2008 | 158 | } | ||
2009 | 159 | |||
2010 | 160 | public void setn(int n) { | ||
2011 | 161 | this.n = n; | ||
2012 | 162 | } | ||
2013 | 163 | |||
2014 | 164 | public void setk(int k) { | ||
2015 | 165 | this.k = k; | ||
2016 | 166 | } | ||
2017 | 167 | |||
2018 | 168 | public void setalpha(double alpha) { | ||
2019 | 169 | this.alpha = alpha; | ||
2020 | 170 | } | ||
2021 | 171 | |||
2022 | 172 | public String getName() { | ||
2023 | 173 | return "Watts-Strogatz Small World model Alpha"; | ||
2024 | 174 | } | ||
2025 | 175 | |||
2026 | 176 | public GeneratorUI getUI() { | ||
2027 | 177 | return Lookup.getDefault().lookup(WattsStrogatzAlphaUI.class); | ||
2028 | 178 | } | ||
2029 | 179 | |||
2030 | 180 | public boolean cancel() { | ||
2031 | 181 | cancel = true; | ||
2032 | 182 | return true; | ||
2033 | 183 | } | ||
2034 | 184 | |||
2035 | 185 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
2036 | 186 | this.progressTicket = progressTicket; | ||
2037 | 187 | } | ||
2038 | 188 | } | ||
2039 | 0 | 189 | ||
2040 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java' | |||
2041 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java 1970-01-01 00:00:00 +0000 | |||
2042 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java 2010-12-17 03:47:30 +0000 | |||
2043 | @@ -0,0 +1,32 @@ | |||
2044 | 1 | /* | ||
2045 | 2 | * Copyright 2008-2010 Gephi | ||
2046 | 3 | * Authors : Cezary Bartosiak | ||
2047 | 4 | * Website : http://www.gephi.org | ||
2048 | 5 | * | ||
2049 | 6 | * This file is part of Gephi. | ||
2050 | 7 | * | ||
2051 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2052 | 9 | * it under the terms of the GNU General Public License as published by | ||
2053 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2054 | 11 | * (at your option) any later version. | ||
2055 | 12 | * | ||
2056 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2057 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2058 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2059 | 16 | * GNU General Public License for more details. | ||
2060 | 17 | * | ||
2061 | 18 | * You should have received a copy of the GNU General Public License | ||
2062 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2063 | 20 | */ | ||
2064 | 21 | package org.gephi.io.generator.plugin; | ||
2065 | 22 | |||
2066 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
2067 | 24 | |||
2068 | 25 | /** | ||
2069 | 26 | * | ||
2070 | 27 | * | ||
2071 | 28 | * @author Cezary Bartosiak | ||
2072 | 29 | */ | ||
2073 | 30 | public interface WattsStrogatzAlphaUI extends GeneratorUI { | ||
2074 | 31 | |||
2075 | 32 | } | ||
2076 | 0 | 33 | ||
2077 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java' | |||
2078 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java 1970-01-01 00:00:00 +0000 | |||
2079 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java 2010-12-17 03:47:30 +0000 | |||
2080 | @@ -0,0 +1,157 @@ | |||
2081 | 1 | /* | ||
2082 | 2 | * Copyright 2008-2010 Gephi | ||
2083 | 3 | * Authors : Cezary Bartosiak | ||
2084 | 4 | * Website : http://www.gephi.org | ||
2085 | 5 | * | ||
2086 | 6 | * This file is part of Gephi. | ||
2087 | 7 | * | ||
2088 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2089 | 9 | * it under the terms of the GNU General Public License as published by | ||
2090 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2091 | 11 | * (at your option) any later version. | ||
2092 | 12 | * | ||
2093 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2094 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2095 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2096 | 16 | * GNU General Public License for more details. | ||
2097 | 17 | * | ||
2098 | 18 | * You should have received a copy of the GNU General Public License | ||
2099 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2100 | 20 | */ | ||
2101 | 21 | package org.gephi.io.generator.plugin; | ||
2102 | 22 | |||
2103 | 23 | import java.util.Random; | ||
2104 | 24 | import org.gephi.io.generator.spi.Generator; | ||
2105 | 25 | import org.gephi.io.generator.spi.GeneratorUI; | ||
2106 | 26 | import org.gephi.io.importer.api.ContainerLoader; | ||
2107 | 27 | import org.gephi.io.importer.api.EdgeDefault; | ||
2108 | 28 | import org.gephi.io.importer.api.EdgeDraft; | ||
2109 | 29 | import org.gephi.io.importer.api.NodeDraft; | ||
2110 | 30 | import org.gephi.utils.progress.Progress; | ||
2111 | 31 | import org.gephi.utils.progress.ProgressTicket; | ||
2112 | 32 | import org.openide.util.Lookup; | ||
2113 | 33 | import org.openide.util.lookup.ServiceProvider; | ||
2114 | 34 | |||
2115 | 35 | /** | ||
2116 | 36 | * Generates an undirected not necessarily connected graph. | ||
2117 | 37 | * | ||
2118 | 38 | * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model | ||
2119 | 39 | * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf | ||
2120 | 40 | * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf | ||
2121 | 41 | * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf | ||
2122 | 42 | * | ||
2123 | 43 | * N > K >= ln(N) >= 1 | ||
2124 | 44 | * K % 2 == 0 | ||
2125 | 45 | * 0 <= beta <= 1 | ||
2126 | 46 | * | ||
2127 | 47 | * Ω(N * K) | ||
2128 | 48 | * | ||
2129 | 49 | * @author Cezary Bartosiak | ||
2130 | 50 | */ | ||
2131 | 51 | @ServiceProvider(service = Generator.class) | ||
2132 | 52 | public class WattsStrogatzBeta implements Generator { | ||
2133 | 53 | private boolean cancel = false; | ||
2134 | 54 | private ProgressTicket progressTicket; | ||
2135 | 55 | |||
2136 | 56 | private int N = 20; | ||
2137 | 57 | private int K = 4; | ||
2138 | 58 | private double beta = 0.2; | ||
2139 | 59 | |||
2140 | 60 | public void generate(ContainerLoader container) { | ||
2141 | 61 | Progress.start(progressTicket, N + N * K); | ||
2142 | 62 | Random random = new Random(); | ||
2143 | 63 | container.setEdgeDefault(EdgeDefault.UNDIRECTED); | ||
2144 | 64 | |||
2145 | 65 | NodeDraft[] nodes = new NodeDraft[N]; | ||
2146 | 66 | |||
2147 | 67 | // Creating a regular ring lattice | ||
2148 | 68 | for (int i = 0; i < N && !cancel; ++i) { | ||
2149 | 69 | NodeDraft node = container.factory().newNodeDraft(); | ||
2150 | 70 | node.setLabel("Node " + i); | ||
2151 | 71 | nodes[i] = node; | ||
2152 | 72 | container.addNode(node); | ||
2153 | 73 | Progress.progress(progressTicket); | ||
2154 | 74 | } | ||
2155 | 75 | for (int i = 0; i < N && !cancel; ++i) | ||
2156 | 76 | for (int j = 1; j <= K / 2 && !cancel; ++j) { | ||
2157 | 77 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
2158 | 78 | edge.setSource(nodes[i]); | ||
2159 | 79 | edge.setTarget(nodes[(i + j) % N]); | ||
2160 | 80 | container.addEdge(edge); | ||
2161 | 81 | Progress.progress(progressTicket); | ||
2162 | 82 | } | ||
2163 | 83 | |||
2164 | 84 | // Rewiring edges | ||
2165 | 85 | for (int i = 0; i < N && !cancel; ++i) | ||
2166 | 86 | for (int j = 1; j <= K / 2 && !cancel; ++j) | ||
2167 | 87 | if (random.nextDouble() <= beta) { | ||
2168 | 88 | container.removeEdge(getEdge(container, nodes[i], nodes[(i + j) % N])); | ||
2169 | 89 | |||
2170 | 90 | int k = random.nextInt(N); | ||
2171 | 91 | while ((k == i || edgeExists(container, nodes[i], nodes[k])) && !cancel) | ||
2172 | 92 | k = random.nextInt(N); | ||
2173 | 93 | |||
2174 | 94 | EdgeDraft edge = container.factory().newEdgeDraft(); | ||
2175 | 95 | edge.setSource(nodes[i]); | ||
2176 | 96 | edge.setTarget(nodes[k]); | ||
2177 | 97 | container.addEdge(edge); | ||
2178 | 98 | |||
2179 | 99 | Progress.progress(progressTicket); | ||
2180 | 100 | } | ||
2181 | 101 | |||
2182 | 102 | Progress.finish(progressTicket); | ||
2183 | 103 | progressTicket = null; | ||
2184 | 104 | } | ||
2185 | 105 | |||
2186 | 106 | private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
2187 | 107 | return container.edgeExists(node1, node2) || container.edgeExists(node2, node1); | ||
2188 | 108 | } | ||
2189 | 109 | |||
2190 | 110 | private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) { | ||
2191 | 111 | EdgeDraft edge = container.getEdge(node1, node2); | ||
2192 | 112 | if (edge == null) | ||
2193 | 113 | edge = container.getEdge(node2, node1); | ||
2194 | 114 | return edge; | ||
2195 | 115 | } | ||
2196 | 116 | |||
2197 | 117 | public int getN() { | ||
2198 | 118 | return N; | ||
2199 | 119 | } | ||
2200 | 120 | |||
2201 | 121 | public int getK() { | ||
2202 | 122 | return K; | ||
2203 | 123 | } | ||
2204 | 124 | |||
2205 | 125 | public double getbeta() { | ||
2206 | 126 | return beta; | ||
2207 | 127 | } | ||
2208 | 128 | |||
2209 | 129 | public void setN(int N) { | ||
2210 | 130 | this.N = N; | ||
2211 | 131 | } | ||
2212 | 132 | |||
2213 | 133 | public void setK(int K) { | ||
2214 | 134 | this.K = K; | ||
2215 | 135 | } | ||
2216 | 136 | |||
2217 | 137 | public void setbeta(double beta) { | ||
2218 | 138 | this.beta = beta; | ||
2219 | 139 | } | ||
2220 | 140 | |||
2221 | 141 | public String getName() { | ||
2222 | 142 | return "Watts-Strogatz Small World model Beta"; | ||
2223 | 143 | } | ||
2224 | 144 | |||
2225 | 145 | public GeneratorUI getUI() { | ||
2226 | 146 | return Lookup.getDefault().lookup(WattsStrogatzBetaUI.class); | ||
2227 | 147 | } | ||
2228 | 148 | |||
2229 | 149 | public boolean cancel() { | ||
2230 | 150 | cancel = true; | ||
2231 | 151 | return true; | ||
2232 | 152 | } | ||
2233 | 153 | |||
2234 | 154 | public void setProgressTicket(ProgressTicket progressTicket) { | ||
2235 | 155 | this.progressTicket = progressTicket; | ||
2236 | 156 | } | ||
2237 | 157 | } | ||
2238 | 0 | 158 | ||
2239 | === added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java' | |||
2240 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java 1970-01-01 00:00:00 +0000 | |||
2241 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java 2010-12-17 03:47:30 +0000 | |||
2242 | @@ -0,0 +1,32 @@ | |||
2243 | 1 | /* | ||
2244 | 2 | * Copyright 2008-2010 Gephi | ||
2245 | 3 | * Authors : Cezary Bartosiak | ||
2246 | 4 | * Website : http://www.gephi.org | ||
2247 | 5 | * | ||
2248 | 6 | * This file is part of Gephi. | ||
2249 | 7 | * | ||
2250 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2251 | 9 | * it under the terms of the GNU General Public License as published by | ||
2252 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2253 | 11 | * (at your option) any later version. | ||
2254 | 12 | * | ||
2255 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2256 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2257 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2258 | 16 | * GNU General Public License for more details. | ||
2259 | 17 | * | ||
2260 | 18 | * You should have received a copy of the GNU General Public License | ||
2261 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2262 | 20 | */ | ||
2263 | 21 | package org.gephi.io.generator.plugin; | ||
2264 | 22 | |||
2265 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
2266 | 24 | |||
2267 | 25 | /** | ||
2268 | 26 | * | ||
2269 | 27 | * | ||
2270 | 28 | * @author Cezary Bartosiak | ||
2271 | 29 | */ | ||
2272 | 30 | public interface WattsStrogatzBetaUI extends GeneratorUI { | ||
2273 | 31 | |||
2274 | 32 | } | ||
2275 | 0 | 33 | ||
2276 | === removed file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java' | |||
2277 | --- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java 2010-07-15 14:48:14 +0000 | |||
2278 | +++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java 1970-01-01 00:00:00 +0000 | |||
2279 | @@ -1,30 +0,0 @@ | |||
2280 | 1 | /* | ||
2281 | 2 | Copyright 2008-2010 Gephi | ||
2282 | 3 | Authors : Mathieu Bastian <mathieu.bastian@gephi.org> | ||
2283 | 4 | Website : http://www.gephi.org | ||
2284 | 5 | |||
2285 | 6 | This file is part of Gephi. | ||
2286 | 7 | |||
2287 | 8 | Gephi is free software: you can redistribute it and/or modify | ||
2288 | 9 | it under the terms of the GNU Affero General Public License as | ||
2289 | 10 | published by the Free Software Foundation, either version 3 of the | ||
2290 | 11 | License, or (at your option) any later version. | ||
2291 | 12 | |||
2292 | 13 | Gephi is distributed in the hope that it will be useful, | ||
2293 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2294 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2295 | 16 | GNU Affero General Public License for more details. | ||
2296 | 17 | |||
2297 | 18 | You should have received a copy of the GNU Affero General Public License | ||
2298 | 19 | along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2299 | 20 | */ | ||
2300 | 21 | package org.gephi.io.generator.plugin; | ||
2301 | 22 | |||
2302 | 23 | import org.gephi.io.generator.spi.GeneratorUI; | ||
2303 | 24 | |||
2304 | 25 | /** | ||
2305 | 26 | * | ||
2306 | 27 | * @author Mathieu Bastian | ||
2307 | 28 | */ | ||
2308 | 29 | public interface WattsStrogatzUI extends GeneratorUI { | ||
2309 | 30 | } | ||
2310 | 31 | 0 | ||
2311 | === modified file 'GeneratorPluginUI/manifest.mf' | |||
2312 | --- GeneratorPluginUI/manifest.mf 2010-08-19 09:38:57 +0000 | |||
2313 | +++ GeneratorPluginUI/manifest.mf 2010-12-17 03:47:30 +0000 | |||
2314 | @@ -2,5 +2,5 @@ | |||
2315 | 2 | AutoUpdate-Essential-Module: true | 2 | AutoUpdate-Essential-Module: true |
2316 | 3 | OpenIDE-Module: org.gephi.ui.generator.plugin | 3 | OpenIDE-Module: org.gephi.ui.generator.plugin |
2317 | 4 | OpenIDE-Module-Localizing-Bundle: org/gephi/ui/generator/plugin/Bundle.properties | 4 | OpenIDE-Module-Localizing-Bundle: org/gephi/ui/generator/plugin/Bundle.properties |
2319 | 5 | OpenIDE-Module-Specification-Version: 0.7.1 | 5 | OpenIDE-Module-Specification-Version: 0.7.2 |
2320 | 6 | 6 | ||
2321 | 7 | 7 | ||
2322 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form' | |||
2323 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form 1970-01-01 00:00:00 +0000 | |||
2324 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form 2010-12-17 03:47:30 +0000 | |||
2325 | @@ -0,0 +1,110 @@ | |||
2326 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
2327 | 2 | |||
2328 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
2329 | 4 | <Properties> | ||
2330 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
2331 | 6 | <Dimension value="[330, 102]"/> | ||
2332 | 7 | </Property> | ||
2333 | 8 | </Properties> | ||
2334 | 9 | <AuxValues> | ||
2335 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
2336 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
2337 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
2338 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
2339 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
2340 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
2341 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
2342 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
2343 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
2344 | 19 | </AuxValues> | ||
2345 | 20 | |||
2346 | 21 | <Layout> | ||
2347 | 22 | <DimensionLayout dim="0"> | ||
2348 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2349 | 24 | <Group type="102" attributes="0"> | ||
2350 | 25 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2351 | 26 | <Group type="102" attributes="0"> | ||
2352 | 27 | <EmptySpace max="-2" attributes="0"/> | ||
2353 | 28 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2354 | 29 | <Component id="rLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2355 | 30 | <Component id="hLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2356 | 31 | </Group> | ||
2357 | 32 | <EmptySpace min="-2" pref="60" max="-2" attributes="0"/> | ||
2358 | 33 | <Group type="103" groupAlignment="1" attributes="0"> | ||
2359 | 34 | <Component id="hField" alignment="0" pref="134" max="32767" attributes="1"/> | ||
2360 | 35 | <Component id="rField" alignment="0" pref="134" max="32767" attributes="1"/> | ||
2361 | 36 | </Group> | ||
2362 | 37 | </Group> | ||
2363 | 38 | <Group type="102" alignment="0" attributes="0"> | ||
2364 | 39 | <EmptySpace min="-2" pref="136" max="-2" attributes="0"/> | ||
2365 | 40 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
2366 | 41 | </Group> | ||
2367 | 42 | </Group> | ||
2368 | 43 | <EmptySpace max="-2" attributes="0"/> | ||
2369 | 44 | </Group> | ||
2370 | 45 | </Group> | ||
2371 | 46 | </DimensionLayout> | ||
2372 | 47 | <DimensionLayout dim="1"> | ||
2373 | 48 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2374 | 49 | <Group type="102" alignment="0" attributes="0"> | ||
2375 | 50 | <EmptySpace max="-2" attributes="0"/> | ||
2376 | 51 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2377 | 52 | <Component id="rField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2378 | 53 | <Component id="rLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2379 | 54 | </Group> | ||
2380 | 55 | <EmptySpace max="-2" attributes="0"/> | ||
2381 | 56 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2382 | 57 | <Component id="hField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2383 | 58 | <Component id="hLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2384 | 59 | </Group> | ||
2385 | 60 | <EmptySpace max="-2" attributes="0"/> | ||
2386 | 61 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
2387 | 62 | <EmptySpace max="32767" attributes="0"/> | ||
2388 | 63 | </Group> | ||
2389 | 64 | </Group> | ||
2390 | 65 | </DimensionLayout> | ||
2391 | 66 | </Layout> | ||
2392 | 67 | <SubComponents> | ||
2393 | 68 | <Component class="javax.swing.JTextField" name="rField"> | ||
2394 | 69 | <Properties> | ||
2395 | 70 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2396 | 71 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2397 | 72 | </Property> | ||
2398 | 73 | </Properties> | ||
2399 | 74 | <AuxValues> | ||
2400 | 75 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2401 | 76 | </AuxValues> | ||
2402 | 77 | </Component> | ||
2403 | 78 | <Component class="javax.swing.JTextField" name="hField"> | ||
2404 | 79 | <Properties> | ||
2405 | 80 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2406 | 81 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2407 | 82 | </Property> | ||
2408 | 83 | </Properties> | ||
2409 | 84 | <AuxValues> | ||
2410 | 85 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2411 | 86 | </AuxValues> | ||
2412 | 87 | </Component> | ||
2413 | 88 | <Component class="javax.swing.JLabel" name="rLabel"> | ||
2414 | 89 | <Properties> | ||
2415 | 90 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2416 | 91 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2417 | 92 | </Property> | ||
2418 | 93 | </Properties> | ||
2419 | 94 | </Component> | ||
2420 | 95 | <Component class="javax.swing.JLabel" name="hLabel"> | ||
2421 | 96 | <Properties> | ||
2422 | 97 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2423 | 98 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2424 | 99 | </Property> | ||
2425 | 100 | </Properties> | ||
2426 | 101 | </Component> | ||
2427 | 102 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
2428 | 103 | <Properties> | ||
2429 | 104 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2430 | 105 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2431 | 106 | </Property> | ||
2432 | 107 | </Properties> | ||
2433 | 108 | </Component> | ||
2434 | 109 | </SubComponents> | ||
2435 | 110 | </Form> | ||
2436 | 0 | 111 | ||
2437 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java' | |||
2438 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java 1970-01-01 00:00:00 +0000 | |||
2439 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java 2010-12-17 03:47:30 +0000 | |||
2440 | @@ -0,0 +1,180 @@ | |||
2441 | 1 | /* | ||
2442 | 2 | * Copyright 2008-2010 Gephi | ||
2443 | 3 | * Authors : Cezary Bartosiak | ||
2444 | 4 | * Website : http://www.gephi.org | ||
2445 | 5 | * | ||
2446 | 6 | * This file is part of Gephi. | ||
2447 | 7 | * | ||
2448 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2449 | 9 | * it under the terms of the GNU General Public License as published by | ||
2450 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2451 | 11 | * (at your option) any later version. | ||
2452 | 12 | * | ||
2453 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2454 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2455 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2456 | 16 | * GNU General Public License for more details. | ||
2457 | 17 | * | ||
2458 | 18 | * You should have received a copy of the GNU General Public License | ||
2459 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2460 | 20 | */ | ||
2461 | 21 | package org.gephi.ui.generator.plugin; | ||
2462 | 22 | |||
2463 | 23 | import org.netbeans.validation.api.Problems; | ||
2464 | 24 | import org.netbeans.validation.api.Validator; | ||
2465 | 25 | import org.netbeans.validation.api.builtin.Validators; | ||
2466 | 26 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
2467 | 27 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
2468 | 28 | |||
2469 | 29 | /** | ||
2470 | 30 | * | ||
2471 | 31 | * | ||
2472 | 32 | * @author Cezary Bartosiak | ||
2473 | 33 | */ | ||
2474 | 34 | public class BalancedTreePanel extends javax.swing.JPanel { | ||
2475 | 35 | |||
2476 | 36 | /** Creates new form BarabasiAlbertPanel */ | ||
2477 | 37 | public BalancedTreePanel() { | ||
2478 | 38 | initComponents(); | ||
2479 | 39 | } | ||
2480 | 40 | |||
2481 | 41 | public static ValidationPanel createValidationPanel(BalancedTreePanel innerPanel) { | ||
2482 | 42 | ValidationPanel validationPanel = new ValidationPanel(); | ||
2483 | 43 | if (innerPanel == null) | ||
2484 | 44 | innerPanel = new BalancedTreePanel(); | ||
2485 | 45 | validationPanel.setInnerComponent(innerPanel); | ||
2486 | 46 | |||
2487 | 47 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
2488 | 48 | |||
2489 | 49 | group.add(innerPanel.rField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2490 | 50 | new rValidator(innerPanel)); | ||
2491 | 51 | group.add(innerPanel.hField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2492 | 52 | new hValidator(innerPanel)); | ||
2493 | 53 | |||
2494 | 54 | return validationPanel; | ||
2495 | 55 | } | ||
2496 | 56 | |||
2497 | 57 | private static class rValidator implements Validator<String> { | ||
2498 | 58 | private BalancedTreePanel innerPanel; | ||
2499 | 59 | |||
2500 | 60 | public rValidator(BalancedTreePanel innerPanel) { | ||
2501 | 61 | this.innerPanel = innerPanel; | ||
2502 | 62 | } | ||
2503 | 63 | |||
2504 | 64 | @Override | ||
2505 | 65 | public boolean validate(Problems problems, String compName, String model) { | ||
2506 | 66 | boolean result = false; | ||
2507 | 67 | |||
2508 | 68 | try { | ||
2509 | 69 | Integer r = Integer.parseInt(innerPanel.rField.getText()); | ||
2510 | 70 | result = r >= 2; | ||
2511 | 71 | } | ||
2512 | 72 | catch (Exception e) { } | ||
2513 | 73 | if (!result) { | ||
2514 | 74 | String message = "<html>r >= 2</html>"; | ||
2515 | 75 | problems.add(message); | ||
2516 | 76 | } | ||
2517 | 77 | |||
2518 | 78 | return result; | ||
2519 | 79 | } | ||
2520 | 80 | } | ||
2521 | 81 | |||
2522 | 82 | private static class hValidator implements Validator<String> { | ||
2523 | 83 | private BalancedTreePanel innerPanel; | ||
2524 | 84 | |||
2525 | 85 | public hValidator(BalancedTreePanel innerPanel) { | ||
2526 | 86 | this.innerPanel = innerPanel; | ||
2527 | 87 | } | ||
2528 | 88 | |||
2529 | 89 | @Override | ||
2530 | 90 | public boolean validate(Problems problems, String compName, String model) { | ||
2531 | 91 | boolean result = false; | ||
2532 | 92 | |||
2533 | 93 | try { | ||
2534 | 94 | Integer h = Integer.parseInt(innerPanel.hField.getText()); | ||
2535 | 95 | result = h >= 1; | ||
2536 | 96 | } | ||
2537 | 97 | catch (Exception e) { } | ||
2538 | 98 | if (!result) { | ||
2539 | 99 | String message = "<html>h >= 1</html>"; | ||
2540 | 100 | problems.add(message); | ||
2541 | 101 | } | ||
2542 | 102 | |||
2543 | 103 | return result; | ||
2544 | 104 | } | ||
2545 | 105 | } | ||
2546 | 106 | |||
2547 | 107 | /** This method is called from within the constructor to | ||
2548 | 108 | * initialize the form. | ||
2549 | 109 | * WARNING: Do NOT modify this code. The content of this method is | ||
2550 | 110 | * always regenerated by the Form Editor. | ||
2551 | 111 | */ | ||
2552 | 112 | @SuppressWarnings("unchecked") | ||
2553 | 113 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
2554 | 114 | private void initComponents() { | ||
2555 | 115 | |||
2556 | 116 | rField = new javax.swing.JTextField(); | ||
2557 | 117 | hField = new javax.swing.JTextField(); | ||
2558 | 118 | rLabel = new javax.swing.JLabel(); | ||
2559 | 119 | hLabel = new javax.swing.JLabel(); | ||
2560 | 120 | constraintsLabel = new javax.swing.JLabel(); | ||
2561 | 121 | |||
2562 | 122 | setPreferredSize(new java.awt.Dimension(330, 102)); | ||
2563 | 123 | |||
2564 | 124 | rField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rField.text")); // NOI18N | ||
2565 | 125 | |||
2566 | 126 | hField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hField.text")); // NOI18N | ||
2567 | 127 | |||
2568 | 128 | rLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rLabel.text")); // NOI18N | ||
2569 | 129 | |||
2570 | 130 | hLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hLabel.text")); // NOI18N | ||
2571 | 131 | |||
2572 | 132 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.constraintsLabel.text")); // NOI18N | ||
2573 | 133 | |||
2574 | 134 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
2575 | 135 | this.setLayout(layout); | ||
2576 | 136 | layout.setHorizontalGroup( | ||
2577 | 137 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
2578 | 138 | .addGroup(layout.createSequentialGroup() | ||
2579 | 139 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
2580 | 140 | .addGroup(layout.createSequentialGroup() | ||
2581 | 141 | .addContainerGap() | ||
2582 | 142 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
2583 | 143 | .addComponent(rLabel) | ||
2584 | 144 | .addComponent(hLabel)) | ||
2585 | 145 | .addGap(60, 60, 60) | ||
2586 | 146 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
2587 | 147 | .addComponent(hField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE) | ||
2588 | 148 | .addComponent(rField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))) | ||
2589 | 149 | .addGroup(layout.createSequentialGroup() | ||
2590 | 150 | .addGap(136, 136, 136) | ||
2591 | 151 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) | ||
2592 | 152 | .addContainerGap()) | ||
2593 | 153 | ); | ||
2594 | 154 | layout.setVerticalGroup( | ||
2595 | 155 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
2596 | 156 | .addGroup(layout.createSequentialGroup() | ||
2597 | 157 | .addContainerGap() | ||
2598 | 158 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
2599 | 159 | .addComponent(rField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
2600 | 160 | .addComponent(rLabel)) | ||
2601 | 161 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
2602 | 162 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
2603 | 163 | .addComponent(hField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
2604 | 164 | .addComponent(hLabel)) | ||
2605 | 165 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
2606 | 166 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
2607 | 167 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
2608 | 168 | ); | ||
2609 | 169 | }// </editor-fold>//GEN-END:initComponents | ||
2610 | 170 | |||
2611 | 171 | |||
2612 | 172 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
2613 | 173 | private javax.swing.JLabel constraintsLabel; | ||
2614 | 174 | protected javax.swing.JTextField hField; | ||
2615 | 175 | private javax.swing.JLabel hLabel; | ||
2616 | 176 | protected javax.swing.JTextField rField; | ||
2617 | 177 | private javax.swing.JLabel rLabel; | ||
2618 | 178 | // End of variables declaration//GEN-END:variables | ||
2619 | 179 | |||
2620 | 180 | } | ||
2621 | 0 | 181 | ||
2622 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java' | |||
2623 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java 1970-01-01 00:00:00 +0000 | |||
2624 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java 2010-12-17 03:47:30 +0000 | |||
2625 | @@ -0,0 +1,62 @@ | |||
2626 | 1 | /* | ||
2627 | 2 | * Copyright 2008-2010 Gephi | ||
2628 | 3 | * Authors : Cezary Bartosiak | ||
2629 | 4 | * Website : http://www.gephi.org | ||
2630 | 5 | * | ||
2631 | 6 | * This file is part of Gephi. | ||
2632 | 7 | * | ||
2633 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2634 | 9 | * it under the terms of the GNU General Public License as published by | ||
2635 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2636 | 11 | * (at your option) any later version. | ||
2637 | 12 | * | ||
2638 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2639 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2640 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2641 | 16 | * GNU General Public License for more details. | ||
2642 | 17 | * | ||
2643 | 18 | * You should have received a copy of the GNU General Public License | ||
2644 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2645 | 20 | */ | ||
2646 | 21 | package org.gephi.ui.generator.plugin; | ||
2647 | 22 | |||
2648 | 23 | import javax.swing.JPanel; | ||
2649 | 24 | import org.gephi.io.generator.plugin.BalancedTree; | ||
2650 | 25 | import org.gephi.io.generator.plugin.BalancedTreeUI; | ||
2651 | 26 | import org.gephi.io.generator.spi.Generator; | ||
2652 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
2653 | 28 | |||
2654 | 29 | /** | ||
2655 | 30 | * | ||
2656 | 31 | * | ||
2657 | 32 | * @author Cezary Bartosiak | ||
2658 | 33 | */ | ||
2659 | 34 | @ServiceProvider(service = BalancedTreeUI.class) | ||
2660 | 35 | public class BalancedTreeUIImpl implements BalancedTreeUI { | ||
2661 | 36 | private BalancedTreePanel panel; | ||
2662 | 37 | private BalancedTree balancedTree; | ||
2663 | 38 | |||
2664 | 39 | public BalancedTreeUIImpl() { } | ||
2665 | 40 | |||
2666 | 41 | public JPanel getPanel() { | ||
2667 | 42 | if (panel == null) | ||
2668 | 43 | panel = new BalancedTreePanel(); | ||
2669 | 44 | return BalancedTreePanel.createValidationPanel(panel); | ||
2670 | 45 | } | ||
2671 | 46 | |||
2672 | 47 | public void setup(Generator generator) { | ||
2673 | 48 | this.balancedTree = (BalancedTree)generator; | ||
2674 | 49 | |||
2675 | 50 | if (panel == null) | ||
2676 | 51 | panel = new BalancedTreePanel(); | ||
2677 | 52 | |||
2678 | 53 | panel.rField.setText(String.valueOf(balancedTree.getr())); | ||
2679 | 54 | panel.hField.setText(String.valueOf(balancedTree.geth())); | ||
2680 | 55 | } | ||
2681 | 56 | |||
2682 | 57 | public void unsetup() { | ||
2683 | 58 | balancedTree.setr(Integer.parseInt(panel.rField.getText())); | ||
2684 | 59 | balancedTree.seth(Integer.parseInt(panel.hField.getText())); | ||
2685 | 60 | panel = null; | ||
2686 | 61 | } | ||
2687 | 62 | } | ||
2688 | 0 | 63 | ||
2689 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form' | |||
2690 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form 1970-01-01 00:00:00 +0000 | |||
2691 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form 2010-12-17 03:47:30 +0000 | |||
2692 | @@ -0,0 +1,182 @@ | |||
2693 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
2694 | 2 | |||
2695 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
2696 | 4 | <Properties> | ||
2697 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
2698 | 6 | <Dimension value="[548, 236]"/> | ||
2699 | 7 | </Property> | ||
2700 | 8 | </Properties> | ||
2701 | 9 | <AuxValues> | ||
2702 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
2703 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
2704 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
2705 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
2706 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
2707 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
2708 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
2709 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
2710 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
2711 | 19 | </AuxValues> | ||
2712 | 20 | |||
2713 | 21 | <Layout> | ||
2714 | 22 | <DimensionLayout dim="0"> | ||
2715 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2716 | 24 | <Group type="102" attributes="0"> | ||
2717 | 25 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2718 | 26 | <Group type="102" attributes="0"> | ||
2719 | 27 | <EmptySpace max="-2" attributes="0"/> | ||
2720 | 28 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2721 | 29 | <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2722 | 30 | <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2723 | 31 | <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2724 | 32 | <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2725 | 33 | <Component id="qLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
2726 | 34 | </Group> | ||
2727 | 35 | <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> | ||
2728 | 36 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2729 | 37 | <Component id="qField" alignment="0" pref="153" max="32767" attributes="1"/> | ||
2730 | 38 | <Component id="pField" alignment="0" pref="153" max="32767" attributes="1"/> | ||
2731 | 39 | <Component id="m0Field" alignment="0" pref="153" max="32767" attributes="1"/> | ||
2732 | 40 | <Component id="MField" alignment="0" pref="153" max="32767" attributes="1"/> | ||
2733 | 41 | <Component id="NField" alignment="0" pref="153" max="32767" attributes="1"/> | ||
2734 | 42 | </Group> | ||
2735 | 43 | </Group> | ||
2736 | 44 | <Group type="102" alignment="0" attributes="0"> | ||
2737 | 45 | <EmptySpace min="-2" pref="233" max="-2" attributes="0"/> | ||
2738 | 46 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
2739 | 47 | </Group> | ||
2740 | 48 | </Group> | ||
2741 | 49 | <EmptySpace max="-2" attributes="0"/> | ||
2742 | 50 | </Group> | ||
2743 | 51 | </Group> | ||
2744 | 52 | </DimensionLayout> | ||
2745 | 53 | <DimensionLayout dim="1"> | ||
2746 | 54 | <Group type="103" groupAlignment="0" attributes="0"> | ||
2747 | 55 | <Group type="102" alignment="0" attributes="0"> | ||
2748 | 56 | <EmptySpace max="-2" attributes="0"/> | ||
2749 | 57 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2750 | 58 | <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2751 | 59 | <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2752 | 60 | </Group> | ||
2753 | 61 | <EmptySpace max="-2" attributes="0"/> | ||
2754 | 62 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2755 | 63 | <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2756 | 64 | <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2757 | 65 | </Group> | ||
2758 | 66 | <EmptySpace max="-2" attributes="0"/> | ||
2759 | 67 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2760 | 68 | <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2761 | 69 | <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2762 | 70 | </Group> | ||
2763 | 71 | <EmptySpace max="-2" attributes="0"/> | ||
2764 | 72 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2765 | 73 | <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2766 | 74 | <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2767 | 75 | </Group> | ||
2768 | 76 | <EmptySpace max="-2" attributes="0"/> | ||
2769 | 77 | <Group type="103" groupAlignment="3" attributes="0"> | ||
2770 | 78 | <Component id="qField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2771 | 79 | <Component id="qLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
2772 | 80 | </Group> | ||
2773 | 81 | <EmptySpace max="-2" attributes="0"/> | ||
2774 | 82 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
2775 | 83 | <EmptySpace max="32767" attributes="0"/> | ||
2776 | 84 | </Group> | ||
2777 | 85 | </Group> | ||
2778 | 86 | </DimensionLayout> | ||
2779 | 87 | </Layout> | ||
2780 | 88 | <SubComponents> | ||
2781 | 89 | <Component class="javax.swing.JLabel" name="MLabel"> | ||
2782 | 90 | <Properties> | ||
2783 | 91 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2784 | 92 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2785 | 93 | </Property> | ||
2786 | 94 | </Properties> | ||
2787 | 95 | </Component> | ||
2788 | 96 | <Component class="javax.swing.JTextField" name="MField"> | ||
2789 | 97 | <Properties> | ||
2790 | 98 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2791 | 99 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2792 | 100 | </Property> | ||
2793 | 101 | </Properties> | ||
2794 | 102 | <AuxValues> | ||
2795 | 103 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2796 | 104 | </AuxValues> | ||
2797 | 105 | </Component> | ||
2798 | 106 | <Component class="javax.swing.JTextField" name="NField"> | ||
2799 | 107 | <Properties> | ||
2800 | 108 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2801 | 109 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2802 | 110 | </Property> | ||
2803 | 111 | </Properties> | ||
2804 | 112 | <AuxValues> | ||
2805 | 113 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2806 | 114 | </AuxValues> | ||
2807 | 115 | </Component> | ||
2808 | 116 | <Component class="javax.swing.JTextField" name="m0Field"> | ||
2809 | 117 | <Properties> | ||
2810 | 118 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2811 | 119 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2812 | 120 | </Property> | ||
2813 | 121 | </Properties> | ||
2814 | 122 | <AuxValues> | ||
2815 | 123 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2816 | 124 | </AuxValues> | ||
2817 | 125 | </Component> | ||
2818 | 126 | <Component class="javax.swing.JLabel" name="NLabel"> | ||
2819 | 127 | <Properties> | ||
2820 | 128 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2821 | 129 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2822 | 130 | </Property> | ||
2823 | 131 | </Properties> | ||
2824 | 132 | </Component> | ||
2825 | 133 | <Component class="javax.swing.JLabel" name="m0Label"> | ||
2826 | 134 | <Properties> | ||
2827 | 135 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2828 | 136 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2829 | 137 | </Property> | ||
2830 | 138 | </Properties> | ||
2831 | 139 | </Component> | ||
2832 | 140 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
2833 | 141 | <Properties> | ||
2834 | 142 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2835 | 143 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2836 | 144 | </Property> | ||
2837 | 145 | </Properties> | ||
2838 | 146 | </Component> | ||
2839 | 147 | <Component class="javax.swing.JLabel" name="pLabel"> | ||
2840 | 148 | <Properties> | ||
2841 | 149 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2842 | 150 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2843 | 151 | </Property> | ||
2844 | 152 | </Properties> | ||
2845 | 153 | </Component> | ||
2846 | 154 | <Component class="javax.swing.JTextField" name="pField"> | ||
2847 | 155 | <Properties> | ||
2848 | 156 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2849 | 157 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2850 | 158 | </Property> | ||
2851 | 159 | </Properties> | ||
2852 | 160 | <AuxValues> | ||
2853 | 161 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2854 | 162 | </AuxValues> | ||
2855 | 163 | </Component> | ||
2856 | 164 | <Component class="javax.swing.JLabel" name="qLabel"> | ||
2857 | 165 | <Properties> | ||
2858 | 166 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2859 | 167 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2860 | 168 | </Property> | ||
2861 | 169 | </Properties> | ||
2862 | 170 | </Component> | ||
2863 | 171 | <Component class="javax.swing.JTextField" name="qField"> | ||
2864 | 172 | <Properties> | ||
2865 | 173 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
2866 | 174 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
2867 | 175 | </Property> | ||
2868 | 176 | </Properties> | ||
2869 | 177 | <AuxValues> | ||
2870 | 178 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
2871 | 179 | </AuxValues> | ||
2872 | 180 | </Component> | ||
2873 | 181 | </SubComponents> | ||
2874 | 182 | </Form> | ||
2875 | 0 | 183 | ||
2876 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java' | |||
2877 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java 1970-01-01 00:00:00 +0000 | |||
2878 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java 2010-12-17 03:47:30 +0000 | |||
2879 | @@ -0,0 +1,238 @@ | |||
2880 | 1 | /* | ||
2881 | 2 | * Copyright 2008-2010 Gephi | ||
2882 | 3 | * Authors : Cezary Bartosiak | ||
2883 | 4 | * Website : http://www.gephi.org | ||
2884 | 5 | * | ||
2885 | 6 | * This file is part of Gephi. | ||
2886 | 7 | * | ||
2887 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
2888 | 9 | * it under the terms of the GNU General Public License as published by | ||
2889 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
2890 | 11 | * (at your option) any later version. | ||
2891 | 12 | * | ||
2892 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
2893 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2894 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2895 | 16 | * GNU General Public License for more details. | ||
2896 | 17 | * | ||
2897 | 18 | * You should have received a copy of the GNU General Public License | ||
2898 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
2899 | 20 | */ | ||
2900 | 21 | package org.gephi.ui.generator.plugin; | ||
2901 | 22 | |||
2902 | 23 | import org.gephi.lib.validation.BetweenZeroAndOneValidator; | ||
2903 | 24 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
2904 | 25 | import org.netbeans.validation.api.Problems; | ||
2905 | 26 | import org.netbeans.validation.api.Validator; | ||
2906 | 27 | import org.netbeans.validation.api.builtin.Validators; | ||
2907 | 28 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
2908 | 29 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
2909 | 30 | |||
2910 | 31 | /** | ||
2911 | 32 | * | ||
2912 | 33 | * | ||
2913 | 34 | * @author Cezary Bartosiak | ||
2914 | 35 | */ | ||
2915 | 36 | public class BarabasiAlbertGeneralizedPanel extends javax.swing.JPanel { | ||
2916 | 37 | |||
2917 | 38 | /** Creates new form BarabasiAlbertPanel */ | ||
2918 | 39 | public BarabasiAlbertGeneralizedPanel() { | ||
2919 | 40 | initComponents(); | ||
2920 | 41 | } | ||
2921 | 42 | |||
2922 | 43 | public static ValidationPanel createValidationPanel(BarabasiAlbertGeneralizedPanel innerPanel) { | ||
2923 | 44 | ValidationPanel validationPanel = new ValidationPanel(); | ||
2924 | 45 | if (innerPanel == null) | ||
2925 | 46 | innerPanel = new BarabasiAlbertGeneralizedPanel(); | ||
2926 | 47 | validationPanel.setInnerComponent(innerPanel); | ||
2927 | 48 | |||
2928 | 49 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
2929 | 50 | |||
2930 | 51 | group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2931 | 52 | new PositiveNumberValidator()); | ||
2932 | 53 | group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2933 | 54 | new PositiveNumberValidator()); | ||
2934 | 55 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2935 | 56 | new PositiveNumberValidator()); | ||
2936 | 57 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2937 | 58 | new MValidator(innerPanel)); | ||
2938 | 59 | group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2939 | 60 | new BetweenZeroAndOneValidator()); | ||
2940 | 61 | group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2941 | 62 | new pqValidator(innerPanel)); | ||
2942 | 63 | group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2943 | 64 | new BetweenZeroAndOneValidator()); | ||
2944 | 65 | group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
2945 | 66 | new pqValidator(innerPanel)); | ||
2946 | 67 | |||
2947 | 68 | return validationPanel; | ||
2948 | 69 | } | ||
2949 | 70 | |||
2950 | 71 | private static class MValidator implements Validator<String> { | ||
2951 | 72 | private BarabasiAlbertGeneralizedPanel innerPanel; | ||
2952 | 73 | |||
2953 | 74 | public MValidator(BarabasiAlbertGeneralizedPanel innerPanel) { | ||
2954 | 75 | this.innerPanel = innerPanel; | ||
2955 | 76 | } | ||
2956 | 77 | |||
2957 | 78 | @Override | ||
2958 | 79 | public boolean validate(Problems problems, String compName, String model) { | ||
2959 | 80 | boolean result = false; | ||
2960 | 81 | |||
2961 | 82 | try { | ||
2962 | 83 | Integer m0 = Integer.parseInt(innerPanel.m0Field.getText()); | ||
2963 | 84 | Integer M = Integer.parseInt(innerPanel.MField.getText()); | ||
2964 | 85 | result = M <= m0; | ||
2965 | 86 | } | ||
2966 | 87 | catch (Exception e) { } | ||
2967 | 88 | if (!result) { | ||
2968 | 89 | String message = "<html>M <= m0</html>"; | ||
2969 | 90 | problems.add(message); | ||
2970 | 91 | } | ||
2971 | 92 | |||
2972 | 93 | return result; | ||
2973 | 94 | } | ||
2974 | 95 | } | ||
2975 | 96 | |||
2976 | 97 | private static class pqValidator implements Validator<String> { | ||
2977 | 98 | private BarabasiAlbertGeneralizedPanel innerPanel; | ||
2978 | 99 | |||
2979 | 100 | public pqValidator(BarabasiAlbertGeneralizedPanel innerPanel) { | ||
2980 | 101 | this.innerPanel = innerPanel; | ||
2981 | 102 | } | ||
2982 | 103 | |||
2983 | 104 | @Override | ||
2984 | 105 | public boolean validate(Problems problems, String compName, String model) { | ||
2985 | 106 | boolean result = false; | ||
2986 | 107 | |||
2987 | 108 | try { | ||
2988 | 109 | Double p = Double.parseDouble(innerPanel.pField.getText()); | ||
2989 | 110 | Double q = Double.parseDouble(innerPanel.qField.getText()); | ||
2990 | 111 | result = p + q < 1.0; | ||
2991 | 112 | } | ||
2992 | 113 | catch (Exception e) { } | ||
2993 | 114 | if (!result) { | ||
2994 | 115 | String message = "<html>p + q < 1.0</html>"; | ||
2995 | 116 | problems.add(message); | ||
2996 | 117 | } | ||
2997 | 118 | |||
2998 | 119 | return result; | ||
2999 | 120 | } | ||
3000 | 121 | } | ||
3001 | 122 | |||
3002 | 123 | /** This method is called from within the constructor to | ||
3003 | 124 | * initialize the form. | ||
3004 | 125 | * WARNING: Do NOT modify this code. The content of this method is | ||
3005 | 126 | * always regenerated by the Form Editor. | ||
3006 | 127 | */ | ||
3007 | 128 | @SuppressWarnings("unchecked") | ||
3008 | 129 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
3009 | 130 | private void initComponents() { | ||
3010 | 131 | |||
3011 | 132 | MLabel = new javax.swing.JLabel(); | ||
3012 | 133 | MField = new javax.swing.JTextField(); | ||
3013 | 134 | NField = new javax.swing.JTextField(); | ||
3014 | 135 | m0Field = new javax.swing.JTextField(); | ||
3015 | 136 | NLabel = new javax.swing.JLabel(); | ||
3016 | 137 | m0Label = new javax.swing.JLabel(); | ||
3017 | 138 | constraintsLabel = new javax.swing.JLabel(); | ||
3018 | 139 | pLabel = new javax.swing.JLabel(); | ||
3019 | 140 | pField = new javax.swing.JTextField(); | ||
3020 | 141 | qLabel = new javax.swing.JLabel(); | ||
3021 | 142 | qField = new javax.swing.JTextField(); | ||
3022 | 143 | |||
3023 | 144 | setPreferredSize(new java.awt.Dimension(548, 236)); | ||
3024 | 145 | |||
3025 | 146 | MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MLabel.text")); // NOI18N | ||
3026 | 147 | |||
3027 | 148 | MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MField.text")); // NOI18N | ||
3028 | 149 | |||
3029 | 150 | NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NField.text")); // NOI18N | ||
3030 | 151 | |||
3031 | 152 | m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Field.text")); // NOI18N | ||
3032 | 153 | |||
3033 | 154 | NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NLabel.text")); // NOI18N | ||
3034 | 155 | |||
3035 | 156 | m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Label.text")); // NOI18N | ||
3036 | 157 | |||
3037 | 158 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.constraintsLabel.text")); // NOI18N | ||
3038 | 159 | |||
3039 | 160 | pLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pLabel.text")); // NOI18N | ||
3040 | 161 | |||
3041 | 162 | pField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pField.text")); // NOI18N | ||
3042 | 163 | |||
3043 | 164 | qLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qLabel.text")); // NOI18N | ||
3044 | 165 | |||
3045 | 166 | qField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qField.text")); // NOI18N | ||
3046 | 167 | |||
3047 | 168 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
3048 | 169 | this.setLayout(layout); | ||
3049 | 170 | layout.setHorizontalGroup( | ||
3050 | 171 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3051 | 172 | .addGroup(layout.createSequentialGroup() | ||
3052 | 173 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3053 | 174 | .addGroup(layout.createSequentialGroup() | ||
3054 | 175 | .addContainerGap() | ||
3055 | 176 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3056 | 177 | .addComponent(NLabel) | ||
3057 | 178 | .addComponent(m0Label) | ||
3058 | 179 | .addComponent(MLabel) | ||
3059 | 180 | .addComponent(pLabel) | ||
3060 | 181 | .addComponent(qLabel)) | ||
3061 | 182 | .addGap(25, 25, 25) | ||
3062 | 183 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3063 | 184 | .addComponent(qField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) | ||
3064 | 185 | .addComponent(pField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) | ||
3065 | 186 | .addComponent(m0Field, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) | ||
3066 | 187 | .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) | ||
3067 | 188 | .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE))) | ||
3068 | 189 | .addGroup(layout.createSequentialGroup() | ||
3069 | 190 | .addGap(233, 233, 233) | ||
3070 | 191 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) | ||
3071 | 192 | .addContainerGap()) | ||
3072 | 193 | ); | ||
3073 | 194 | layout.setVerticalGroup( | ||
3074 | 195 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3075 | 196 | .addGroup(layout.createSequentialGroup() | ||
3076 | 197 | .addContainerGap() | ||
3077 | 198 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3078 | 199 | .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3079 | 200 | .addComponent(NLabel)) | ||
3080 | 201 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3081 | 202 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3082 | 203 | .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3083 | 204 | .addComponent(m0Label)) | ||
3084 | 205 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3085 | 206 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3086 | 207 | .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3087 | 208 | .addComponent(MLabel)) | ||
3088 | 209 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3089 | 210 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3090 | 211 | .addComponent(pField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3091 | 212 | .addComponent(pLabel)) | ||
3092 | 213 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3093 | 214 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3094 | 215 | .addComponent(qField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3095 | 216 | .addComponent(qLabel)) | ||
3096 | 217 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3097 | 218 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3098 | 219 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
3099 | 220 | ); | ||
3100 | 221 | }// </editor-fold>//GEN-END:initComponents | ||
3101 | 222 | |||
3102 | 223 | |||
3103 | 224 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
3104 | 225 | protected javax.swing.JTextField MField; | ||
3105 | 226 | private javax.swing.JLabel MLabel; | ||
3106 | 227 | protected javax.swing.JTextField NField; | ||
3107 | 228 | private javax.swing.JLabel NLabel; | ||
3108 | 229 | private javax.swing.JLabel constraintsLabel; | ||
3109 | 230 | protected javax.swing.JTextField m0Field; | ||
3110 | 231 | private javax.swing.JLabel m0Label; | ||
3111 | 232 | protected javax.swing.JTextField pField; | ||
3112 | 233 | private javax.swing.JLabel pLabel; | ||
3113 | 234 | protected javax.swing.JTextField qField; | ||
3114 | 235 | private javax.swing.JLabel qLabel; | ||
3115 | 236 | // End of variables declaration//GEN-END:variables | ||
3116 | 237 | |||
3117 | 238 | } | ||
3118 | 0 | 239 | ||
3119 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java' | |||
3120 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java 1970-01-01 00:00:00 +0000 | |||
3121 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java 2010-12-17 03:47:30 +0000 | |||
3122 | @@ -0,0 +1,68 @@ | |||
3123 | 1 | /* | ||
3124 | 2 | * Copyright 2008-2010 Gephi | ||
3125 | 3 | * Authors : Cezary Bartosiak | ||
3126 | 4 | * Website : http://www.gephi.org | ||
3127 | 5 | * | ||
3128 | 6 | * This file is part of Gephi. | ||
3129 | 7 | * | ||
3130 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
3131 | 9 | * it under the terms of the GNU General Public License as published by | ||
3132 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
3133 | 11 | * (at your option) any later version. | ||
3134 | 12 | * | ||
3135 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
3136 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3137 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3138 | 16 | * GNU General Public License for more details. | ||
3139 | 17 | * | ||
3140 | 18 | * You should have received a copy of the GNU General Public License | ||
3141 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
3142 | 20 | */ | ||
3143 | 21 | package org.gephi.ui.generator.plugin; | ||
3144 | 22 | |||
3145 | 23 | import javax.swing.JPanel; | ||
3146 | 24 | import org.gephi.io.generator.plugin.BarabasiAlbertGeneralized; | ||
3147 | 25 | import org.gephi.io.generator.plugin.BarabasiAlbertGeneralizedUI; | ||
3148 | 26 | import org.gephi.io.generator.spi.Generator; | ||
3149 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
3150 | 28 | |||
3151 | 29 | /** | ||
3152 | 30 | * | ||
3153 | 31 | * | ||
3154 | 32 | * @author Cezary Bartosiak | ||
3155 | 33 | */ | ||
3156 | 34 | @ServiceProvider(service = BarabasiAlbertGeneralizedUI.class) | ||
3157 | 35 | public class BarabasiAlbertGeneralizedUIImpl implements BarabasiAlbertGeneralizedUI { | ||
3158 | 36 | private BarabasiAlbertGeneralizedPanel panel; | ||
3159 | 37 | private BarabasiAlbertGeneralized barabasiAlbertGeneralized; | ||
3160 | 38 | |||
3161 | 39 | public BarabasiAlbertGeneralizedUIImpl() { } | ||
3162 | 40 | |||
3163 | 41 | public JPanel getPanel() { | ||
3164 | 42 | if (panel == null) | ||
3165 | 43 | panel = new BarabasiAlbertGeneralizedPanel(); | ||
3166 | 44 | return BarabasiAlbertGeneralizedPanel.createValidationPanel(panel); | ||
3167 | 45 | } | ||
3168 | 46 | |||
3169 | 47 | public void setup(Generator generator) { | ||
3170 | 48 | this.barabasiAlbertGeneralized = (BarabasiAlbertGeneralized)generator; | ||
3171 | 49 | |||
3172 | 50 | if (panel == null) | ||
3173 | 51 | panel = new BarabasiAlbertGeneralizedPanel(); | ||
3174 | 52 | |||
3175 | 53 | panel.NField.setText(String.valueOf(barabasiAlbertGeneralized.getN())); | ||
3176 | 54 | panel.m0Field.setText(String.valueOf(barabasiAlbertGeneralized.getm0())); | ||
3177 | 55 | panel.MField.setText(String.valueOf(barabasiAlbertGeneralized.getM())); | ||
3178 | 56 | panel.pField.setText(String.valueOf(barabasiAlbertGeneralized.getp())); | ||
3179 | 57 | panel.qField.setText(String.valueOf(barabasiAlbertGeneralized.getq())); | ||
3180 | 58 | } | ||
3181 | 59 | |||
3182 | 60 | public void unsetup() { | ||
3183 | 61 | barabasiAlbertGeneralized.setN(Integer.parseInt(panel.NField.getText())); | ||
3184 | 62 | barabasiAlbertGeneralized.setm0(Integer.parseInt(panel.m0Field.getText())); | ||
3185 | 63 | barabasiAlbertGeneralized.setM(Integer.parseInt(panel.MField.getText())); | ||
3186 | 64 | barabasiAlbertGeneralized.setp(Double.parseDouble(panel.pField.getText())); | ||
3187 | 65 | barabasiAlbertGeneralized.setq(Double.parseDouble(panel.qField.getText())); | ||
3188 | 66 | panel = null; | ||
3189 | 67 | } | ||
3190 | 68 | } | ||
3191 | 0 | 69 | ||
3192 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form' | |||
3193 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form 1970-01-01 00:00:00 +0000 | |||
3194 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form 2010-12-17 03:47:30 +0000 | |||
3195 | @@ -0,0 +1,129 @@ | |||
3196 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
3197 | 2 | |||
3198 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
3199 | 4 | <Properties> | ||
3200 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
3201 | 6 | <Dimension value="[451, 170]"/> | ||
3202 | 7 | </Property> | ||
3203 | 8 | </Properties> | ||
3204 | 9 | <AuxValues> | ||
3205 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
3206 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
3207 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
3208 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
3209 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
3210 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
3211 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
3212 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
3213 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
3214 | 19 | </AuxValues> | ||
3215 | 20 | |||
3216 | 21 | <Layout> | ||
3217 | 22 | <DimensionLayout dim="0"> | ||
3218 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3219 | 24 | <Group type="102" alignment="0" attributes="0"> | ||
3220 | 25 | <EmptySpace max="-2" attributes="0"/> | ||
3221 | 26 | <Group type="103" groupAlignment="1" attributes="0"> | ||
3222 | 27 | <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/> | ||
3223 | 28 | <Group type="103" alignment="1" groupAlignment="0" attributes="0"> | ||
3224 | 29 | <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3225 | 30 | <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3226 | 31 | <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3227 | 32 | </Group> | ||
3228 | 33 | </Group> | ||
3229 | 34 | <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> | ||
3230 | 35 | <Group type="103" groupAlignment="1" attributes="0"> | ||
3231 | 36 | <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3232 | 37 | <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3233 | 38 | <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3234 | 39 | </Group> | ||
3235 | 40 | <EmptySpace max="-2" attributes="0"/> | ||
3236 | 41 | </Group> | ||
3237 | 42 | </Group> | ||
3238 | 43 | </DimensionLayout> | ||
3239 | 44 | <DimensionLayout dim="1"> | ||
3240 | 45 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3241 | 46 | <Group type="102" alignment="0" attributes="0"> | ||
3242 | 47 | <EmptySpace max="-2" attributes="0"/> | ||
3243 | 48 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3244 | 49 | <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3245 | 50 | <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3246 | 51 | </Group> | ||
3247 | 52 | <EmptySpace max="-2" attributes="0"/> | ||
3248 | 53 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3249 | 54 | <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3250 | 55 | <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3251 | 56 | </Group> | ||
3252 | 57 | <EmptySpace max="-2" attributes="0"/> | ||
3253 | 58 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3254 | 59 | <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3255 | 60 | <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3256 | 61 | </Group> | ||
3257 | 62 | <EmptySpace max="-2" attributes="0"/> | ||
3258 | 63 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
3259 | 64 | <EmptySpace max="32767" attributes="0"/> | ||
3260 | 65 | </Group> | ||
3261 | 66 | </Group> | ||
3262 | 67 | </DimensionLayout> | ||
3263 | 68 | </Layout> | ||
3264 | 69 | <SubComponents> | ||
3265 | 70 | <Component class="javax.swing.JLabel" name="MLabel"> | ||
3266 | 71 | <Properties> | ||
3267 | 72 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3268 | 73 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3269 | 74 | </Property> | ||
3270 | 75 | </Properties> | ||
3271 | 76 | </Component> | ||
3272 | 77 | <Component class="javax.swing.JTextField" name="MField"> | ||
3273 | 78 | <Properties> | ||
3274 | 79 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3275 | 80 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3276 | 81 | </Property> | ||
3277 | 82 | </Properties> | ||
3278 | 83 | <AuxValues> | ||
3279 | 84 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3280 | 85 | </AuxValues> | ||
3281 | 86 | </Component> | ||
3282 | 87 | <Component class="javax.swing.JTextField" name="NField"> | ||
3283 | 88 | <Properties> | ||
3284 | 89 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3285 | 90 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3286 | 91 | </Property> | ||
3287 | 92 | </Properties> | ||
3288 | 93 | <AuxValues> | ||
3289 | 94 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3290 | 95 | </AuxValues> | ||
3291 | 96 | </Component> | ||
3292 | 97 | <Component class="javax.swing.JTextField" name="m0Field"> | ||
3293 | 98 | <Properties> | ||
3294 | 99 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3295 | 100 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3296 | 101 | </Property> | ||
3297 | 102 | </Properties> | ||
3298 | 103 | <AuxValues> | ||
3299 | 104 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3300 | 105 | </AuxValues> | ||
3301 | 106 | </Component> | ||
3302 | 107 | <Component class="javax.swing.JLabel" name="NLabel"> | ||
3303 | 108 | <Properties> | ||
3304 | 109 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3305 | 110 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3306 | 111 | </Property> | ||
3307 | 112 | </Properties> | ||
3308 | 113 | </Component> | ||
3309 | 114 | <Component class="javax.swing.JLabel" name="m0Label"> | ||
3310 | 115 | <Properties> | ||
3311 | 116 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3312 | 117 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3313 | 118 | </Property> | ||
3314 | 119 | </Properties> | ||
3315 | 120 | </Component> | ||
3316 | 121 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
3317 | 122 | <Properties> | ||
3318 | 123 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3319 | 124 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3320 | 125 | </Property> | ||
3321 | 126 | </Properties> | ||
3322 | 127 | </Component> | ||
3323 | 128 | </SubComponents> | ||
3324 | 129 | </Form> | ||
3325 | 0 | 130 | ||
3326 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java' | |||
3327 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java 1970-01-01 00:00:00 +0000 | |||
3328 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java 2010-12-17 03:47:30 +0000 | |||
3329 | @@ -0,0 +1,200 @@ | |||
3330 | 1 | /* | ||
3331 | 2 | * Copyright 2008-2010 Gephi | ||
3332 | 3 | * Authors : Cezary Bartosiak | ||
3333 | 4 | * Website : http://www.gephi.org | ||
3334 | 5 | * | ||
3335 | 6 | * This file is part of Gephi. | ||
3336 | 7 | * | ||
3337 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
3338 | 9 | * it under the terms of the GNU General Public License as published by | ||
3339 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
3340 | 11 | * (at your option) any later version. | ||
3341 | 12 | * | ||
3342 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
3343 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3344 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3345 | 16 | * GNU General Public License for more details. | ||
3346 | 17 | * | ||
3347 | 18 | * You should have received a copy of the GNU General Public License | ||
3348 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
3349 | 20 | */ | ||
3350 | 21 | package org.gephi.ui.generator.plugin; | ||
3351 | 22 | |||
3352 | 23 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
3353 | 24 | import org.netbeans.validation.api.Problems; | ||
3354 | 25 | import org.netbeans.validation.api.Validator; | ||
3355 | 26 | import org.netbeans.validation.api.builtin.Validators; | ||
3356 | 27 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
3357 | 28 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
3358 | 29 | |||
3359 | 30 | /** | ||
3360 | 31 | * | ||
3361 | 32 | * | ||
3362 | 33 | * @author Cezary Bartosiak | ||
3363 | 34 | */ | ||
3364 | 35 | public class BarabasiAlbertPanel extends javax.swing.JPanel { | ||
3365 | 36 | |||
3366 | 37 | /** Creates new form BarabasiAlbertPanel */ | ||
3367 | 38 | public BarabasiAlbertPanel() { | ||
3368 | 39 | initComponents(); | ||
3369 | 40 | } | ||
3370 | 41 | |||
3371 | 42 | public static ValidationPanel createValidationPanel(BarabasiAlbertPanel innerPanel) { | ||
3372 | 43 | ValidationPanel validationPanel = new ValidationPanel(); | ||
3373 | 44 | if (innerPanel == null) | ||
3374 | 45 | innerPanel = new BarabasiAlbertPanel(); | ||
3375 | 46 | validationPanel.setInnerComponent(innerPanel); | ||
3376 | 47 | |||
3377 | 48 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
3378 | 49 | |||
3379 | 50 | group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3380 | 51 | new PositiveNumberValidator()); | ||
3381 | 52 | group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3382 | 53 | new PositiveNumberValidator()); | ||
3383 | 54 | group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3384 | 55 | new m0Validator(innerPanel)); | ||
3385 | 56 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3386 | 57 | new PositiveNumberValidator()); | ||
3387 | 58 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3388 | 59 | new MValidator(innerPanel)); | ||
3389 | 60 | |||
3390 | 61 | return validationPanel; | ||
3391 | 62 | } | ||
3392 | 63 | |||
3393 | 64 | private static class m0Validator implements Validator<String> { | ||
3394 | 65 | private BarabasiAlbertPanel innerPanel; | ||
3395 | 66 | |||
3396 | 67 | public m0Validator(BarabasiAlbertPanel innerPanel) { | ||
3397 | 68 | this.innerPanel = innerPanel; | ||
3398 | 69 | } | ||
3399 | 70 | |||
3400 | 71 | @Override | ||
3401 | 72 | public boolean validate(Problems problems, String compName, String model) { | ||
3402 | 73 | boolean result = false; | ||
3403 | 74 | |||
3404 | 75 | try { | ||
3405 | 76 | Integer N = Integer.parseInt(innerPanel.NField.getText()); | ||
3406 | 77 | Integer m0 = Integer.parseInt(innerPanel.m0Field.getText()); | ||
3407 | 78 | result = m0 < N; | ||
3408 | 79 | } | ||
3409 | 80 | catch (Exception e) { } | ||
3410 | 81 | if (!result) { | ||
3411 | 82 | String message = "<html>m0 < N</html>"; | ||
3412 | 83 | problems.add(message); | ||
3413 | 84 | } | ||
3414 | 85 | |||
3415 | 86 | return result; | ||
3416 | 87 | } | ||
3417 | 88 | } | ||
3418 | 89 | |||
3419 | 90 | private static class MValidator implements Validator<String> { | ||
3420 | 91 | private BarabasiAlbertPanel innerPanel; | ||
3421 | 92 | |||
3422 | 93 | public MValidator(BarabasiAlbertPanel innerPanel) { | ||
3423 | 94 | this.innerPanel = innerPanel; | ||
3424 | 95 | } | ||
3425 | 96 | |||
3426 | 97 | @Override | ||
3427 | 98 | public boolean validate(Problems problems, String compName, String model) { | ||
3428 | 99 | boolean result = false; | ||
3429 | 100 | |||
3430 | 101 | try { | ||
3431 | 102 | Integer m0 = Integer.parseInt(innerPanel.m0Field.getText()); | ||
3432 | 103 | Integer M = Integer.parseInt(innerPanel.MField.getText()); | ||
3433 | 104 | result = M <= m0; | ||
3434 | 105 | } | ||
3435 | 106 | catch (Exception e) { } | ||
3436 | 107 | if (!result) { | ||
3437 | 108 | String message = "<html>M <= m0</html>"; | ||
3438 | 109 | problems.add(message); | ||
3439 | 110 | } | ||
3440 | 111 | |||
3441 | 112 | return result; | ||
3442 | 113 | } | ||
3443 | 114 | } | ||
3444 | 115 | |||
3445 | 116 | /** This method is called from within the constructor to | ||
3446 | 117 | * initialize the form. | ||
3447 | 118 | * WARNING: Do NOT modify this code. The content of this method is | ||
3448 | 119 | * always regenerated by the Form Editor. | ||
3449 | 120 | */ | ||
3450 | 121 | @SuppressWarnings("unchecked") | ||
3451 | 122 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
3452 | 123 | private void initComponents() { | ||
3453 | 124 | |||
3454 | 125 | MLabel = new javax.swing.JLabel(); | ||
3455 | 126 | MField = new javax.swing.JTextField(); | ||
3456 | 127 | NField = new javax.swing.JTextField(); | ||
3457 | 128 | m0Field = new javax.swing.JTextField(); | ||
3458 | 129 | NLabel = new javax.swing.JLabel(); | ||
3459 | 130 | m0Label = new javax.swing.JLabel(); | ||
3460 | 131 | constraintsLabel = new javax.swing.JLabel(); | ||
3461 | 132 | |||
3462 | 133 | setPreferredSize(new java.awt.Dimension(451, 170)); | ||
3463 | 134 | |||
3464 | 135 | MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MLabel.text")); // NOI18N | ||
3465 | 136 | |||
3466 | 137 | MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MField.text")); // NOI18N | ||
3467 | 138 | |||
3468 | 139 | NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NField.text")); // NOI18N | ||
3469 | 140 | |||
3470 | 141 | m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Field.text")); // NOI18N | ||
3471 | 142 | |||
3472 | 143 | NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NLabel.text")); // NOI18N | ||
3473 | 144 | |||
3474 | 145 | m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Label.text")); // NOI18N | ||
3475 | 146 | |||
3476 | 147 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.constraintsLabel.text")); // NOI18N | ||
3477 | 148 | |||
3478 | 149 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
3479 | 150 | this.setLayout(layout); | ||
3480 | 151 | layout.setHorizontalGroup( | ||
3481 | 152 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3482 | 153 | .addGroup(layout.createSequentialGroup() | ||
3483 | 154 | .addContainerGap() | ||
3484 | 155 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
3485 | 156 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3486 | 157 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3487 | 158 | .addComponent(NLabel) | ||
3488 | 159 | .addComponent(m0Label) | ||
3489 | 160 | .addComponent(MLabel))) | ||
3490 | 161 | .addGap(25, 25, 25) | ||
3491 | 162 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
3492 | 163 | .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE) | ||
3493 | 164 | .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE) | ||
3494 | 165 | .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)) | ||
3495 | 166 | .addContainerGap()) | ||
3496 | 167 | ); | ||
3497 | 168 | layout.setVerticalGroup( | ||
3498 | 169 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3499 | 170 | .addGroup(layout.createSequentialGroup() | ||
3500 | 171 | .addContainerGap() | ||
3501 | 172 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3502 | 173 | .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3503 | 174 | .addComponent(NLabel)) | ||
3504 | 175 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3505 | 176 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3506 | 177 | .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3507 | 178 | .addComponent(m0Label)) | ||
3508 | 179 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3509 | 180 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3510 | 181 | .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3511 | 182 | .addComponent(MLabel)) | ||
3512 | 183 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3513 | 184 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3514 | 185 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
3515 | 186 | ); | ||
3516 | 187 | }// </editor-fold>//GEN-END:initComponents | ||
3517 | 188 | |||
3518 | 189 | |||
3519 | 190 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
3520 | 191 | protected javax.swing.JTextField MField; | ||
3521 | 192 | private javax.swing.JLabel MLabel; | ||
3522 | 193 | protected javax.swing.JTextField NField; | ||
3523 | 194 | private javax.swing.JLabel NLabel; | ||
3524 | 195 | private javax.swing.JLabel constraintsLabel; | ||
3525 | 196 | protected javax.swing.JTextField m0Field; | ||
3526 | 197 | private javax.swing.JLabel m0Label; | ||
3527 | 198 | // End of variables declaration//GEN-END:variables | ||
3528 | 199 | |||
3529 | 200 | } | ||
3530 | 0 | 201 | ||
3531 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form' | |||
3532 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form 1970-01-01 00:00:00 +0000 | |||
3533 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form 2010-12-17 03:47:30 +0000 | |||
3534 | @@ -0,0 +1,129 @@ | |||
3535 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
3536 | 2 | |||
3537 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
3538 | 4 | <Properties> | ||
3539 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
3540 | 6 | <Dimension value="[451, 170]"/> | ||
3541 | 7 | </Property> | ||
3542 | 8 | </Properties> | ||
3543 | 9 | <AuxValues> | ||
3544 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
3545 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
3546 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
3547 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
3548 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
3549 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
3550 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
3551 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
3552 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
3553 | 19 | </AuxValues> | ||
3554 | 20 | |||
3555 | 21 | <Layout> | ||
3556 | 22 | <DimensionLayout dim="0"> | ||
3557 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3558 | 24 | <Group type="102" alignment="0" attributes="0"> | ||
3559 | 25 | <EmptySpace max="-2" attributes="0"/> | ||
3560 | 26 | <Group type="103" groupAlignment="1" attributes="0"> | ||
3561 | 27 | <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/> | ||
3562 | 28 | <Group type="103" alignment="1" groupAlignment="0" attributes="0"> | ||
3563 | 29 | <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3564 | 30 | <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3565 | 31 | <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3566 | 32 | </Group> | ||
3567 | 33 | </Group> | ||
3568 | 34 | <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> | ||
3569 | 35 | <Group type="103" groupAlignment="1" attributes="0"> | ||
3570 | 36 | <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3571 | 37 | <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3572 | 38 | <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3573 | 39 | </Group> | ||
3574 | 40 | <EmptySpace max="-2" attributes="0"/> | ||
3575 | 41 | </Group> | ||
3576 | 42 | </Group> | ||
3577 | 43 | </DimensionLayout> | ||
3578 | 44 | <DimensionLayout dim="1"> | ||
3579 | 45 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3580 | 46 | <Group type="102" alignment="0" attributes="0"> | ||
3581 | 47 | <EmptySpace max="-2" attributes="0"/> | ||
3582 | 48 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3583 | 49 | <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3584 | 50 | <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3585 | 51 | </Group> | ||
3586 | 52 | <EmptySpace max="-2" attributes="0"/> | ||
3587 | 53 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3588 | 54 | <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3589 | 55 | <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3590 | 56 | </Group> | ||
3591 | 57 | <EmptySpace max="-2" attributes="0"/> | ||
3592 | 58 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3593 | 59 | <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3594 | 60 | <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3595 | 61 | </Group> | ||
3596 | 62 | <EmptySpace max="-2" attributes="0"/> | ||
3597 | 63 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
3598 | 64 | <EmptySpace max="32767" attributes="0"/> | ||
3599 | 65 | </Group> | ||
3600 | 66 | </Group> | ||
3601 | 67 | </DimensionLayout> | ||
3602 | 68 | </Layout> | ||
3603 | 69 | <SubComponents> | ||
3604 | 70 | <Component class="javax.swing.JLabel" name="MLabel"> | ||
3605 | 71 | <Properties> | ||
3606 | 72 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3607 | 73 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3608 | 74 | </Property> | ||
3609 | 75 | </Properties> | ||
3610 | 76 | </Component> | ||
3611 | 77 | <Component class="javax.swing.JTextField" name="MField"> | ||
3612 | 78 | <Properties> | ||
3613 | 79 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3614 | 80 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3615 | 81 | </Property> | ||
3616 | 82 | </Properties> | ||
3617 | 83 | <AuxValues> | ||
3618 | 84 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3619 | 85 | </AuxValues> | ||
3620 | 86 | </Component> | ||
3621 | 87 | <Component class="javax.swing.JTextField" name="NField"> | ||
3622 | 88 | <Properties> | ||
3623 | 89 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3624 | 90 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3625 | 91 | </Property> | ||
3626 | 92 | </Properties> | ||
3627 | 93 | <AuxValues> | ||
3628 | 94 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3629 | 95 | </AuxValues> | ||
3630 | 96 | </Component> | ||
3631 | 97 | <Component class="javax.swing.JTextField" name="m0Field"> | ||
3632 | 98 | <Properties> | ||
3633 | 99 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3634 | 100 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3635 | 101 | </Property> | ||
3636 | 102 | </Properties> | ||
3637 | 103 | <AuxValues> | ||
3638 | 104 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
3639 | 105 | </AuxValues> | ||
3640 | 106 | </Component> | ||
3641 | 107 | <Component class="javax.swing.JLabel" name="NLabel"> | ||
3642 | 108 | <Properties> | ||
3643 | 109 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3644 | 110 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3645 | 111 | </Property> | ||
3646 | 112 | </Properties> | ||
3647 | 113 | </Component> | ||
3648 | 114 | <Component class="javax.swing.JLabel" name="m0Label"> | ||
3649 | 115 | <Properties> | ||
3650 | 116 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3651 | 117 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3652 | 118 | </Property> | ||
3653 | 119 | </Properties> | ||
3654 | 120 | </Component> | ||
3655 | 121 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
3656 | 122 | <Properties> | ||
3657 | 123 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
3658 | 124 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
3659 | 125 | </Property> | ||
3660 | 126 | </Properties> | ||
3661 | 127 | </Component> | ||
3662 | 128 | </SubComponents> | ||
3663 | 129 | </Form> | ||
3664 | 0 | 130 | ||
3665 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java' | |||
3666 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java 1970-01-01 00:00:00 +0000 | |||
3667 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java 2010-12-17 03:47:30 +0000 | |||
3668 | @@ -0,0 +1,200 @@ | |||
3669 | 1 | /* | ||
3670 | 2 | * Copyright 2008-2010 Gephi | ||
3671 | 3 | * Authors : Cezary Bartosiak | ||
3672 | 4 | * Website : http://www.gephi.org | ||
3673 | 5 | * | ||
3674 | 6 | * This file is part of Gephi. | ||
3675 | 7 | * | ||
3676 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
3677 | 9 | * it under the terms of the GNU General Public License as published by | ||
3678 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
3679 | 11 | * (at your option) any later version. | ||
3680 | 12 | * | ||
3681 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
3682 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3683 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3684 | 16 | * GNU General Public License for more details. | ||
3685 | 17 | * | ||
3686 | 18 | * You should have received a copy of the GNU General Public License | ||
3687 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
3688 | 20 | */ | ||
3689 | 21 | package org.gephi.ui.generator.plugin; | ||
3690 | 22 | |||
3691 | 23 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
3692 | 24 | import org.netbeans.validation.api.Problems; | ||
3693 | 25 | import org.netbeans.validation.api.Validator; | ||
3694 | 26 | import org.netbeans.validation.api.builtin.Validators; | ||
3695 | 27 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
3696 | 28 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
3697 | 29 | |||
3698 | 30 | /** | ||
3699 | 31 | * | ||
3700 | 32 | * | ||
3701 | 33 | * @author Cezary Bartosiak | ||
3702 | 34 | */ | ||
3703 | 35 | public class BarabasiAlbertSimplifiedAPanel extends javax.swing.JPanel { | ||
3704 | 36 | |||
3705 | 37 | /** Creates new form BarabasiAlbertPanel */ | ||
3706 | 38 | public BarabasiAlbertSimplifiedAPanel() { | ||
3707 | 39 | initComponents(); | ||
3708 | 40 | } | ||
3709 | 41 | |||
3710 | 42 | public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedAPanel innerPanel) { | ||
3711 | 43 | ValidationPanel validationPanel = new ValidationPanel(); | ||
3712 | 44 | if (innerPanel == null) | ||
3713 | 45 | innerPanel = new BarabasiAlbertSimplifiedAPanel(); | ||
3714 | 46 | validationPanel.setInnerComponent(innerPanel); | ||
3715 | 47 | |||
3716 | 48 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
3717 | 49 | |||
3718 | 50 | group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3719 | 51 | new PositiveNumberValidator()); | ||
3720 | 52 | group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3721 | 53 | new PositiveNumberValidator()); | ||
3722 | 54 | group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3723 | 55 | new m0Validator(innerPanel)); | ||
3724 | 56 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3725 | 57 | new PositiveNumberValidator()); | ||
3726 | 58 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
3727 | 59 | new MValidator(innerPanel)); | ||
3728 | 60 | |||
3729 | 61 | return validationPanel; | ||
3730 | 62 | } | ||
3731 | 63 | |||
3732 | 64 | private static class m0Validator implements Validator<String> { | ||
3733 | 65 | private BarabasiAlbertSimplifiedAPanel innerPanel; | ||
3734 | 66 | |||
3735 | 67 | public m0Validator(BarabasiAlbertSimplifiedAPanel innerPanel) { | ||
3736 | 68 | this.innerPanel = innerPanel; | ||
3737 | 69 | } | ||
3738 | 70 | |||
3739 | 71 | @Override | ||
3740 | 72 | public boolean validate(Problems problems, String compName, String model) { | ||
3741 | 73 | boolean result = false; | ||
3742 | 74 | |||
3743 | 75 | try { | ||
3744 | 76 | Integer N = Integer.parseInt(innerPanel.NField.getText()); | ||
3745 | 77 | Integer m0 = Integer.parseInt(innerPanel.m0Field.getText()); | ||
3746 | 78 | result = m0 < N; | ||
3747 | 79 | } | ||
3748 | 80 | catch (Exception e) { } | ||
3749 | 81 | if (!result) { | ||
3750 | 82 | String message = "<html>m0 < N</html>"; | ||
3751 | 83 | problems.add(message); | ||
3752 | 84 | } | ||
3753 | 85 | |||
3754 | 86 | return result; | ||
3755 | 87 | } | ||
3756 | 88 | } | ||
3757 | 89 | |||
3758 | 90 | private static class MValidator implements Validator<String> { | ||
3759 | 91 | private BarabasiAlbertSimplifiedAPanel innerPanel; | ||
3760 | 92 | |||
3761 | 93 | public MValidator(BarabasiAlbertSimplifiedAPanel innerPanel) { | ||
3762 | 94 | this.innerPanel = innerPanel; | ||
3763 | 95 | } | ||
3764 | 96 | |||
3765 | 97 | @Override | ||
3766 | 98 | public boolean validate(Problems problems, String compName, String model) { | ||
3767 | 99 | boolean result = false; | ||
3768 | 100 | |||
3769 | 101 | try { | ||
3770 | 102 | Integer m0 = Integer.parseInt(innerPanel.m0Field.getText()); | ||
3771 | 103 | Integer M = Integer.parseInt(innerPanel.MField.getText()); | ||
3772 | 104 | result = M <= m0; | ||
3773 | 105 | } | ||
3774 | 106 | catch (Exception e) { } | ||
3775 | 107 | if (!result) { | ||
3776 | 108 | String message = "<html>M <= m0</html>"; | ||
3777 | 109 | problems.add(message); | ||
3778 | 110 | } | ||
3779 | 111 | |||
3780 | 112 | return result; | ||
3781 | 113 | } | ||
3782 | 114 | } | ||
3783 | 115 | |||
3784 | 116 | /** This method is called from within the constructor to | ||
3785 | 117 | * initialize the form. | ||
3786 | 118 | * WARNING: Do NOT modify this code. The content of this method is | ||
3787 | 119 | * always regenerated by the Form Editor. | ||
3788 | 120 | */ | ||
3789 | 121 | @SuppressWarnings("unchecked") | ||
3790 | 122 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
3791 | 123 | private void initComponents() { | ||
3792 | 124 | |||
3793 | 125 | MLabel = new javax.swing.JLabel(); | ||
3794 | 126 | MField = new javax.swing.JTextField(); | ||
3795 | 127 | NField = new javax.swing.JTextField(); | ||
3796 | 128 | m0Field = new javax.swing.JTextField(); | ||
3797 | 129 | NLabel = new javax.swing.JLabel(); | ||
3798 | 130 | m0Label = new javax.swing.JLabel(); | ||
3799 | 131 | constraintsLabel = new javax.swing.JLabel(); | ||
3800 | 132 | |||
3801 | 133 | setPreferredSize(new java.awt.Dimension(451, 170)); | ||
3802 | 134 | |||
3803 | 135 | MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MLabel.text")); // NOI18N | ||
3804 | 136 | |||
3805 | 137 | MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MField.text")); // NOI18N | ||
3806 | 138 | |||
3807 | 139 | NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NField.text")); // NOI18N | ||
3808 | 140 | |||
3809 | 141 | m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Field.text")); // NOI18N | ||
3810 | 142 | |||
3811 | 143 | NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NLabel.text")); // NOI18N | ||
3812 | 144 | |||
3813 | 145 | m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Label.text")); // NOI18N | ||
3814 | 146 | |||
3815 | 147 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.constraintsLabel.text")); // NOI18N | ||
3816 | 148 | |||
3817 | 149 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
3818 | 150 | this.setLayout(layout); | ||
3819 | 151 | layout.setHorizontalGroup( | ||
3820 | 152 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3821 | 153 | .addGroup(layout.createSequentialGroup() | ||
3822 | 154 | .addContainerGap() | ||
3823 | 155 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
3824 | 156 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3825 | 157 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3826 | 158 | .addComponent(NLabel) | ||
3827 | 159 | .addComponent(m0Label) | ||
3828 | 160 | .addComponent(MLabel))) | ||
3829 | 161 | .addGap(25, 25, 25) | ||
3830 | 162 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
3831 | 163 | .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE) | ||
3832 | 164 | .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE) | ||
3833 | 165 | .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)) | ||
3834 | 166 | .addContainerGap()) | ||
3835 | 167 | ); | ||
3836 | 168 | layout.setVerticalGroup( | ||
3837 | 169 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
3838 | 170 | .addGroup(layout.createSequentialGroup() | ||
3839 | 171 | .addContainerGap() | ||
3840 | 172 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3841 | 173 | .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3842 | 174 | .addComponent(NLabel)) | ||
3843 | 175 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3844 | 176 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3845 | 177 | .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3846 | 178 | .addComponent(m0Label)) | ||
3847 | 179 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3848 | 180 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
3849 | 181 | .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3850 | 182 | .addComponent(MLabel)) | ||
3851 | 183 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
3852 | 184 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
3853 | 185 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
3854 | 186 | ); | ||
3855 | 187 | }// </editor-fold>//GEN-END:initComponents | ||
3856 | 188 | |||
3857 | 189 | |||
3858 | 190 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
3859 | 191 | protected javax.swing.JTextField MField; | ||
3860 | 192 | private javax.swing.JLabel MLabel; | ||
3861 | 193 | protected javax.swing.JTextField NField; | ||
3862 | 194 | private javax.swing.JLabel NLabel; | ||
3863 | 195 | private javax.swing.JLabel constraintsLabel; | ||
3864 | 196 | protected javax.swing.JTextField m0Field; | ||
3865 | 197 | private javax.swing.JLabel m0Label; | ||
3866 | 198 | // End of variables declaration//GEN-END:variables | ||
3867 | 199 | |||
3868 | 200 | } | ||
3869 | 0 | 201 | ||
3870 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java' | |||
3871 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java 1970-01-01 00:00:00 +0000 | |||
3872 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java 2010-12-17 03:47:30 +0000 | |||
3873 | @@ -0,0 +1,64 @@ | |||
3874 | 1 | /* | ||
3875 | 2 | * Copyright 2008-2010 Gephi | ||
3876 | 3 | * Authors : Cezary Bartosiak | ||
3877 | 4 | * Website : http://www.gephi.org | ||
3878 | 5 | * | ||
3879 | 6 | * This file is part of Gephi. | ||
3880 | 7 | * | ||
3881 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
3882 | 9 | * it under the terms of the GNU General Public License as published by | ||
3883 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
3884 | 11 | * (at your option) any later version. | ||
3885 | 12 | * | ||
3886 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
3887 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3888 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3889 | 16 | * GNU General Public License for more details. | ||
3890 | 17 | * | ||
3891 | 18 | * You should have received a copy of the GNU General Public License | ||
3892 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
3893 | 20 | */ | ||
3894 | 21 | package org.gephi.ui.generator.plugin; | ||
3895 | 22 | |||
3896 | 23 | import javax.swing.JPanel; | ||
3897 | 24 | import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedA; | ||
3898 | 25 | import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedAUI; | ||
3899 | 26 | import org.gephi.io.generator.spi.Generator; | ||
3900 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
3901 | 28 | |||
3902 | 29 | /** | ||
3903 | 30 | * | ||
3904 | 31 | * | ||
3905 | 32 | * @author Cezary Bartosiak | ||
3906 | 33 | */ | ||
3907 | 34 | @ServiceProvider(service = BarabasiAlbertSimplifiedAUI.class) | ||
3908 | 35 | public class BarabasiAlbertSimplifiedAUIImpl implements BarabasiAlbertSimplifiedAUI { | ||
3909 | 36 | private BarabasiAlbertSimplifiedAPanel panel; | ||
3910 | 37 | private BarabasiAlbertSimplifiedA barabasiAlbertSimplifiedA; | ||
3911 | 38 | |||
3912 | 39 | public BarabasiAlbertSimplifiedAUIImpl() { } | ||
3913 | 40 | |||
3914 | 41 | public JPanel getPanel() { | ||
3915 | 42 | if (panel == null) | ||
3916 | 43 | panel = new BarabasiAlbertSimplifiedAPanel(); | ||
3917 | 44 | return BarabasiAlbertSimplifiedAPanel.createValidationPanel(panel); | ||
3918 | 45 | } | ||
3919 | 46 | |||
3920 | 47 | public void setup(Generator generator) { | ||
3921 | 48 | this.barabasiAlbertSimplifiedA = (BarabasiAlbertSimplifiedA)generator; | ||
3922 | 49 | |||
3923 | 50 | if (panel == null) | ||
3924 | 51 | panel = new BarabasiAlbertSimplifiedAPanel(); | ||
3925 | 52 | |||
3926 | 53 | panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedA.getN())); | ||
3927 | 54 | panel.m0Field.setText(String.valueOf(barabasiAlbertSimplifiedA.getm0())); | ||
3928 | 55 | panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedA.getM())); | ||
3929 | 56 | } | ||
3930 | 57 | |||
3931 | 58 | public void unsetup() { | ||
3932 | 59 | barabasiAlbertSimplifiedA.setN(Integer.parseInt(panel.NField.getText())); | ||
3933 | 60 | barabasiAlbertSimplifiedA.setm0(Integer.parseInt(panel.m0Field.getText())); | ||
3934 | 61 | barabasiAlbertSimplifiedA.setM(Integer.parseInt(panel.MField.getText())); | ||
3935 | 62 | panel = null; | ||
3936 | 63 | } | ||
3937 | 64 | } | ||
3938 | 0 | 65 | ||
3939 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form' | |||
3940 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form 1970-01-01 00:00:00 +0000 | |||
3941 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form 2010-12-17 03:47:30 +0000 | |||
3942 | @@ -0,0 +1,110 @@ | |||
3943 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
3944 | 2 | |||
3945 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
3946 | 4 | <Properties> | ||
3947 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
3948 | 6 | <Dimension value="[451, 116]"/> | ||
3949 | 7 | </Property> | ||
3950 | 8 | </Properties> | ||
3951 | 9 | <AuxValues> | ||
3952 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
3953 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
3954 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
3955 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
3956 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
3957 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
3958 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
3959 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
3960 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
3961 | 19 | </AuxValues> | ||
3962 | 20 | |||
3963 | 21 | <Layout> | ||
3964 | 22 | <DimensionLayout dim="0"> | ||
3965 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3966 | 24 | <Group type="102" attributes="0"> | ||
3967 | 25 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3968 | 26 | <Group type="102" attributes="0"> | ||
3969 | 27 | <EmptySpace max="-2" attributes="0"/> | ||
3970 | 28 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3971 | 29 | <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3972 | 30 | <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
3973 | 31 | </Group> | ||
3974 | 32 | <EmptySpace min="-2" pref="59" max="-2" attributes="0"/> | ||
3975 | 33 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3976 | 34 | <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3977 | 35 | <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/> | ||
3978 | 36 | </Group> | ||
3979 | 37 | </Group> | ||
3980 | 38 | <Group type="102" alignment="0" attributes="0"> | ||
3981 | 39 | <EmptySpace min="-2" pref="167" max="-2" attributes="0"/> | ||
3982 | 40 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
3983 | 41 | </Group> | ||
3984 | 42 | </Group> | ||
3985 | 43 | <EmptySpace max="-2" attributes="0"/> | ||
3986 | 44 | </Group> | ||
3987 | 45 | </Group> | ||
3988 | 46 | </DimensionLayout> | ||
3989 | 47 | <DimensionLayout dim="1"> | ||
3990 | 48 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3991 | 49 | <Group type="102" alignment="0" attributes="0"> | ||
3992 | 50 | <EmptySpace max="-2" attributes="0"/> | ||
3993 | 51 | <Group type="103" groupAlignment="3" attributes="0"> | ||
3994 | 52 | <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3995 | 53 | <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
3996 | 54 | </Group> | ||
3997 | 55 | <EmptySpace max="-2" attributes="0"/> | ||
3998 | 56 | <Group type="103" groupAlignment="0" attributes="0"> | ||
3999 | 57 | <Component id="MLabel" min="-2" max="-2" attributes="0"/> | ||
4000 | 58 | <Component id="MField" min="-2" max="-2" attributes="0"/> | ||
4001 | 59 | </Group> | ||
4002 | 60 | <EmptySpace max="-2" attributes="0"/> | ||
4003 | 61 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
4004 | 62 | <EmptySpace max="32767" attributes="0"/> | ||
4005 | 63 | </Group> | ||
4006 | 64 | </Group> | ||
4007 | 65 | </DimensionLayout> | ||
4008 | 66 | </Layout> | ||
4009 | 67 | <SubComponents> | ||
4010 | 68 | <Component class="javax.swing.JLabel" name="MLabel"> | ||
4011 | 69 | <Properties> | ||
4012 | 70 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4013 | 71 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4014 | 72 | </Property> | ||
4015 | 73 | </Properties> | ||
4016 | 74 | </Component> | ||
4017 | 75 | <Component class="javax.swing.JTextField" name="MField"> | ||
4018 | 76 | <Properties> | ||
4019 | 77 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4020 | 78 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4021 | 79 | </Property> | ||
4022 | 80 | </Properties> | ||
4023 | 81 | <AuxValues> | ||
4024 | 82 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4025 | 83 | </AuxValues> | ||
4026 | 84 | </Component> | ||
4027 | 85 | <Component class="javax.swing.JTextField" name="NField"> | ||
4028 | 86 | <Properties> | ||
4029 | 87 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4030 | 88 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4031 | 89 | </Property> | ||
4032 | 90 | </Properties> | ||
4033 | 91 | <AuxValues> | ||
4034 | 92 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4035 | 93 | </AuxValues> | ||
4036 | 94 | </Component> | ||
4037 | 95 | <Component class="javax.swing.JLabel" name="NLabel"> | ||
4038 | 96 | <Properties> | ||
4039 | 97 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4040 | 98 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4041 | 99 | </Property> | ||
4042 | 100 | </Properties> | ||
4043 | 101 | </Component> | ||
4044 | 102 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
4045 | 103 | <Properties> | ||
4046 | 104 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4047 | 105 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4048 | 106 | </Property> | ||
4049 | 107 | </Properties> | ||
4050 | 108 | </Component> | ||
4051 | 109 | </SubComponents> | ||
4052 | 110 | </Form> | ||
4053 | 0 | 111 | ||
4054 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java' | |||
4055 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java 1970-01-01 00:00:00 +0000 | |||
4056 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java 2010-12-17 03:47:30 +0000 | |||
4057 | @@ -0,0 +1,161 @@ | |||
4058 | 1 | /* | ||
4059 | 2 | * Copyright 2008-2010 Gephi | ||
4060 | 3 | * Authors : Cezary Bartosiak | ||
4061 | 4 | * Website : http://www.gephi.org | ||
4062 | 5 | * | ||
4063 | 6 | * This file is part of Gephi. | ||
4064 | 7 | * | ||
4065 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4066 | 9 | * it under the terms of the GNU General Public License as published by | ||
4067 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4068 | 11 | * (at your option) any later version. | ||
4069 | 12 | * | ||
4070 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4071 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4072 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4073 | 16 | * GNU General Public License for more details. | ||
4074 | 17 | * | ||
4075 | 18 | * You should have received a copy of the GNU General Public License | ||
4076 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4077 | 20 | */ | ||
4078 | 21 | package org.gephi.ui.generator.plugin; | ||
4079 | 22 | |||
4080 | 23 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
4081 | 24 | import org.netbeans.validation.api.Problems; | ||
4082 | 25 | import org.netbeans.validation.api.Validator; | ||
4083 | 26 | import org.netbeans.validation.api.builtin.Validators; | ||
4084 | 27 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
4085 | 28 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
4086 | 29 | |||
4087 | 30 | /** | ||
4088 | 31 | * | ||
4089 | 32 | * | ||
4090 | 33 | * @author Cezary Bartosiak | ||
4091 | 34 | */ | ||
4092 | 35 | public class BarabasiAlbertSimplifiedBPanel extends javax.swing.JPanel { | ||
4093 | 36 | |||
4094 | 37 | /** Creates new form BarabasiAlbertPanel */ | ||
4095 | 38 | public BarabasiAlbertSimplifiedBPanel() { | ||
4096 | 39 | initComponents(); | ||
4097 | 40 | } | ||
4098 | 41 | |||
4099 | 42 | public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedBPanel innerPanel) { | ||
4100 | 43 | ValidationPanel validationPanel = new ValidationPanel(); | ||
4101 | 44 | if (innerPanel == null) | ||
4102 | 45 | innerPanel = new BarabasiAlbertSimplifiedBPanel(); | ||
4103 | 46 | validationPanel.setInnerComponent(innerPanel); | ||
4104 | 47 | |||
4105 | 48 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
4106 | 49 | |||
4107 | 50 | group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4108 | 51 | new PositiveNumberValidator()); | ||
4109 | 52 | group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4110 | 53 | new MNValidator(innerPanel)); | ||
4111 | 54 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4112 | 55 | new PositiveNumberValidator()); | ||
4113 | 56 | group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4114 | 57 | new MNValidator(innerPanel)); | ||
4115 | 58 | |||
4116 | 59 | return validationPanel; | ||
4117 | 60 | } | ||
4118 | 61 | |||
4119 | 62 | private static class MNValidator implements Validator<String> { | ||
4120 | 63 | private BarabasiAlbertSimplifiedBPanel innerPanel; | ||
4121 | 64 | |||
4122 | 65 | public MNValidator(BarabasiAlbertSimplifiedBPanel innerPanel) { | ||
4123 | 66 | this.innerPanel = innerPanel; | ||
4124 | 67 | } | ||
4125 | 68 | |||
4126 | 69 | @Override | ||
4127 | 70 | public boolean validate(Problems problems, String compName, String model) { | ||
4128 | 71 | boolean result = false; | ||
4129 | 72 | |||
4130 | 73 | try { | ||
4131 | 74 | Integer N = Integer.parseInt(innerPanel.NField.getText()); | ||
4132 | 75 | Integer M = Integer.parseInt(innerPanel.MField.getText()); | ||
4133 | 76 | result = M <= N * (N - 1) / 2; | ||
4134 | 77 | } | ||
4135 | 78 | catch (Exception e) { } | ||
4136 | 79 | if (!result) { | ||
4137 | 80 | String message = "<html>M <= N * (N - 1) / 2</html>"; | ||
4138 | 81 | problems.add(message); | ||
4139 | 82 | } | ||
4140 | 83 | |||
4141 | 84 | return result; | ||
4142 | 85 | } | ||
4143 | 86 | } | ||
4144 | 87 | |||
4145 | 88 | /** This method is called from within the constructor to | ||
4146 | 89 | * initialize the form. | ||
4147 | 90 | * WARNING: Do NOT modify this code. The content of this method is | ||
4148 | 91 | * always regenerated by the Form Editor. | ||
4149 | 92 | */ | ||
4150 | 93 | @SuppressWarnings("unchecked") | ||
4151 | 94 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
4152 | 95 | private void initComponents() { | ||
4153 | 96 | |||
4154 | 97 | MLabel = new javax.swing.JLabel(); | ||
4155 | 98 | MField = new javax.swing.JTextField(); | ||
4156 | 99 | NField = new javax.swing.JTextField(); | ||
4157 | 100 | NLabel = new javax.swing.JLabel(); | ||
4158 | 101 | constraintsLabel = new javax.swing.JLabel(); | ||
4159 | 102 | |||
4160 | 103 | setPreferredSize(new java.awt.Dimension(451, 116)); | ||
4161 | 104 | |||
4162 | 105 | MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MLabel.text")); // NOI18N | ||
4163 | 106 | |||
4164 | 107 | MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MField.text")); // NOI18N | ||
4165 | 108 | |||
4166 | 109 | NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NField.text")); // NOI18N | ||
4167 | 110 | |||
4168 | 111 | NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NLabel.text")); // NOI18N | ||
4169 | 112 | |||
4170 | 113 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.constraintsLabel.text")); // NOI18N | ||
4171 | 114 | |||
4172 | 115 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
4173 | 116 | this.setLayout(layout); | ||
4174 | 117 | layout.setHorizontalGroup( | ||
4175 | 118 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4176 | 119 | .addGroup(layout.createSequentialGroup() | ||
4177 | 120 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4178 | 121 | .addGroup(layout.createSequentialGroup() | ||
4179 | 122 | .addContainerGap() | ||
4180 | 123 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4181 | 124 | .addComponent(NLabel) | ||
4182 | 125 | .addComponent(MLabel)) | ||
4183 | 126 | .addGap(59, 59, 59) | ||
4184 | 127 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4185 | 128 | .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE) | ||
4186 | 129 | .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))) | ||
4187 | 130 | .addGroup(layout.createSequentialGroup() | ||
4188 | 131 | .addGap(167, 167, 167) | ||
4189 | 132 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) | ||
4190 | 133 | .addContainerGap()) | ||
4191 | 134 | ); | ||
4192 | 135 | layout.setVerticalGroup( | ||
4193 | 136 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4194 | 137 | .addGroup(layout.createSequentialGroup() | ||
4195 | 138 | .addContainerGap() | ||
4196 | 139 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
4197 | 140 | .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4198 | 141 | .addComponent(NLabel)) | ||
4199 | 142 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
4200 | 143 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4201 | 144 | .addComponent(MLabel) | ||
4202 | 145 | .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) | ||
4203 | 146 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
4204 | 147 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4205 | 148 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
4206 | 149 | ); | ||
4207 | 150 | }// </editor-fold>//GEN-END:initComponents | ||
4208 | 151 | |||
4209 | 152 | |||
4210 | 153 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
4211 | 154 | protected javax.swing.JTextField MField; | ||
4212 | 155 | private javax.swing.JLabel MLabel; | ||
4213 | 156 | protected javax.swing.JTextField NField; | ||
4214 | 157 | private javax.swing.JLabel NLabel; | ||
4215 | 158 | private javax.swing.JLabel constraintsLabel; | ||
4216 | 159 | // End of variables declaration//GEN-END:variables | ||
4217 | 160 | |||
4218 | 161 | } | ||
4219 | 0 | 162 | ||
4220 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java' | |||
4221 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java 1970-01-01 00:00:00 +0000 | |||
4222 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java 2010-12-17 03:47:30 +0000 | |||
4223 | @@ -0,0 +1,62 @@ | |||
4224 | 1 | /* | ||
4225 | 2 | * Copyright 2008-2010 Gephi | ||
4226 | 3 | * Authors : Cezary Bartosiak | ||
4227 | 4 | * Website : http://www.gephi.org | ||
4228 | 5 | * | ||
4229 | 6 | * This file is part of Gephi. | ||
4230 | 7 | * | ||
4231 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4232 | 9 | * it under the terms of the GNU General Public License as published by | ||
4233 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4234 | 11 | * (at your option) any later version. | ||
4235 | 12 | * | ||
4236 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4237 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4238 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4239 | 16 | * GNU General Public License for more details. | ||
4240 | 17 | * | ||
4241 | 18 | * You should have received a copy of the GNU General Public License | ||
4242 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4243 | 20 | */ | ||
4244 | 21 | package org.gephi.ui.generator.plugin; | ||
4245 | 22 | |||
4246 | 23 | import javax.swing.JPanel; | ||
4247 | 24 | import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedB; | ||
4248 | 25 | import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedBUI; | ||
4249 | 26 | import org.gephi.io.generator.spi.Generator; | ||
4250 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
4251 | 28 | |||
4252 | 29 | /** | ||
4253 | 30 | * | ||
4254 | 31 | * | ||
4255 | 32 | * @author Cezary Bartosiak | ||
4256 | 33 | */ | ||
4257 | 34 | @ServiceProvider(service = BarabasiAlbertSimplifiedBUI.class) | ||
4258 | 35 | public class BarabasiAlbertSimplifiedBUIImpl implements BarabasiAlbertSimplifiedBUI { | ||
4259 | 36 | private BarabasiAlbertSimplifiedBPanel panel; | ||
4260 | 37 | private BarabasiAlbertSimplifiedB barabasiAlbertSimplifiedB; | ||
4261 | 38 | |||
4262 | 39 | public BarabasiAlbertSimplifiedBUIImpl() { } | ||
4263 | 40 | |||
4264 | 41 | public JPanel getPanel() { | ||
4265 | 42 | if (panel == null) | ||
4266 | 43 | panel = new BarabasiAlbertSimplifiedBPanel(); | ||
4267 | 44 | return BarabasiAlbertSimplifiedBPanel.createValidationPanel(panel); | ||
4268 | 45 | } | ||
4269 | 46 | |||
4270 | 47 | public void setup(Generator generator) { | ||
4271 | 48 | this.barabasiAlbertSimplifiedB = (BarabasiAlbertSimplifiedB)generator; | ||
4272 | 49 | |||
4273 | 50 | if (panel == null) | ||
4274 | 51 | panel = new BarabasiAlbertSimplifiedBPanel(); | ||
4275 | 52 | |||
4276 | 53 | panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedB.getN())); | ||
4277 | 54 | panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedB.getM())); | ||
4278 | 55 | } | ||
4279 | 56 | |||
4280 | 57 | public void unsetup() { | ||
4281 | 58 | barabasiAlbertSimplifiedB.setN(Integer.parseInt(panel.NField.getText())); | ||
4282 | 59 | barabasiAlbertSimplifiedB.setM(Integer.parseInt(panel.MField.getText())); | ||
4283 | 60 | panel = null; | ||
4284 | 61 | } | ||
4285 | 62 | } | ||
4286 | 0 | 63 | ||
4287 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java' | |||
4288 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java 1970-01-01 00:00:00 +0000 | |||
4289 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java 2010-12-17 03:47:30 +0000 | |||
4290 | @@ -0,0 +1,64 @@ | |||
4291 | 1 | /* | ||
4292 | 2 | * Copyright 2008-2010 Gephi | ||
4293 | 3 | * Authors : Cezary Bartosiak | ||
4294 | 4 | * Website : http://www.gephi.org | ||
4295 | 5 | * | ||
4296 | 6 | * This file is part of Gephi. | ||
4297 | 7 | * | ||
4298 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4299 | 9 | * it under the terms of the GNU General Public License as published by | ||
4300 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4301 | 11 | * (at your option) any later version. | ||
4302 | 12 | * | ||
4303 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4304 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4305 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4306 | 16 | * GNU General Public License for more details. | ||
4307 | 17 | * | ||
4308 | 18 | * You should have received a copy of the GNU General Public License | ||
4309 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4310 | 20 | */ | ||
4311 | 21 | package org.gephi.ui.generator.plugin; | ||
4312 | 22 | |||
4313 | 23 | import javax.swing.JPanel; | ||
4314 | 24 | import org.gephi.io.generator.plugin.BarabasiAlbert; | ||
4315 | 25 | import org.gephi.io.generator.plugin.BarabasiAlbertUI; | ||
4316 | 26 | import org.gephi.io.generator.spi.Generator; | ||
4317 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
4318 | 28 | |||
4319 | 29 | /** | ||
4320 | 30 | * | ||
4321 | 31 | * | ||
4322 | 32 | * @author Cezary Bartosiak | ||
4323 | 33 | */ | ||
4324 | 34 | @ServiceProvider(service = BarabasiAlbertUI.class) | ||
4325 | 35 | public class BarabasiAlbertUIImpl implements BarabasiAlbertUI { | ||
4326 | 36 | private BarabasiAlbertPanel panel; | ||
4327 | 37 | private BarabasiAlbert barabasiAlbert; | ||
4328 | 38 | |||
4329 | 39 | public BarabasiAlbertUIImpl() { } | ||
4330 | 40 | |||
4331 | 41 | public JPanel getPanel() { | ||
4332 | 42 | if (panel == null) | ||
4333 | 43 | panel = new BarabasiAlbertPanel(); | ||
4334 | 44 | return BarabasiAlbertPanel.createValidationPanel(panel); | ||
4335 | 45 | } | ||
4336 | 46 | |||
4337 | 47 | public void setup(Generator generator) { | ||
4338 | 48 | this.barabasiAlbert = (BarabasiAlbert)generator; | ||
4339 | 49 | |||
4340 | 50 | if (panel == null) | ||
4341 | 51 | panel = new BarabasiAlbertPanel(); | ||
4342 | 52 | |||
4343 | 53 | panel.NField.setText(String.valueOf(barabasiAlbert.getN())); | ||
4344 | 54 | panel.m0Field.setText(String.valueOf(barabasiAlbert.getm0())); | ||
4345 | 55 | panel.MField.setText(String.valueOf(barabasiAlbert.getM())); | ||
4346 | 56 | } | ||
4347 | 57 | |||
4348 | 58 | public void unsetup() { | ||
4349 | 59 | barabasiAlbert.setN(Integer.parseInt(panel.NField.getText())); | ||
4350 | 60 | barabasiAlbert.setm0(Integer.parseInt(panel.m0Field.getText())); | ||
4351 | 61 | barabasiAlbert.setM(Integer.parseInt(panel.MField.getText())); | ||
4352 | 62 | panel = null; | ||
4353 | 63 | } | ||
4354 | 64 | } | ||
4355 | 0 | 65 | ||
4356 | === modified file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties' | |||
4357 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties 2010-04-12 12:48:22 +0000 | |||
4358 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties 2010-12-17 03:47:30 +0000 | |||
4359 | @@ -13,4 +13,73 @@ | |||
4360 | 13 | WattsStrogatzPanel.neighborField.text= | 13 | WattsStrogatzPanel.neighborField.text= |
4361 | 14 | WattsStrogatzPanel.probabilityField.text= | 14 | WattsStrogatzPanel.probabilityField.text= |
4362 | 15 | 15 | ||
4363 | 16 | WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1} | ||
4364 | 17 | \ No newline at end of file | 16 | \ No newline at end of file |
4365 | 17 | WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1} | ||
4366 | 18 | BarabasiAlbertPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nm0 < N<br>\nM > 0<br>\nM <= m0\n</html> | ||
4367 | 19 | BarabasiAlbertPanel.NLabel.text=N \u2013 number of nodes in generated network: | ||
4368 | 20 | BarabasiAlbertPanel.NField.text= | ||
4369 | 21 | BarabasiAlbertPanel.m0Label.text=m0 \u2013 number of nodes at the start time: | ||
4370 | 22 | BarabasiAlbertPanel.m0Field.text= | ||
4371 | 23 | BarabasiAlbertPanel.MLabel.text=M \u2013 number of edges coming with every new node: | ||
4372 | 24 | BarabasiAlbertPanel.MField.text= | ||
4373 | 25 | BarabasiAlbertGeneralizedPanel.MLabel.text=M \u2013 number of edges to add, rewire or coming with a node in every step: | ||
4374 | 26 | BarabasiAlbertGeneralizedPanel.NField.text= | ||
4375 | 27 | BarabasiAlbertGeneralizedPanel.MField.text= | ||
4376 | 28 | BarabasiAlbertGeneralizedPanel.NLabel.text=N \u2013 number of the algorithm's steps: | ||
4377 | 29 | BarabasiAlbertGeneralizedPanel.m0Field.text= | ||
4378 | 30 | BarabasiAlbertGeneralizedPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nM > 0<br>\nM <= m0<br>\n0 <= p < 1<br>\n0 <= q < 1 - p\n</html> | ||
4379 | 31 | BarabasiAlbertGeneralizedPanel.m0Label.text=m0 \u2013 number of isolated nodes at the start time: | ||
4380 | 32 | BarabasiAlbertGeneralizedPanel.pLabel.text=p \u2013 probability of adding new edges: | ||
4381 | 33 | BarabasiAlbertGeneralizedPanel.pField.text= | ||
4382 | 34 | BarabasiAlbertGeneralizedPanel.qLabel.text=q \u2013 probability of rewiring existing edges: | ||
4383 | 35 | BarabasiAlbertGeneralizedPanel.qField.text= | ||
4384 | 36 | BarabasiAlbertSimplifiedAPanel.MField.text= | ||
4385 | 37 | BarabasiAlbertSimplifiedAPanel.m0Field.text= | ||
4386 | 38 | BarabasiAlbertSimplifiedAPanel.NField.text= | ||
4387 | 39 | BarabasiAlbertSimplifiedAPanel.m0Label.text=m0 \u2013 number of nodes at the start time: | ||
4388 | 40 | BarabasiAlbertSimplifiedAPanel.NLabel.text=N \u2013 number of nodes in generated network: | ||
4389 | 41 | BarabasiAlbertSimplifiedAPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nm0 < N<br>\nM > 0<br>\nM <= m0\n</html> | ||
4390 | 42 | BarabasiAlbertSimplifiedAPanel.MLabel.text=M \u2013 number of edges coming with every new node: | ||
4391 | 43 | BarabasiAlbertSimplifiedBPanel.NField.text= | ||
4392 | 44 | BarabasiAlbertSimplifiedBPanel.MField.text= | ||
4393 | 45 | BarabasiAlbertSimplifiedBPanel.MLabel.text=M \u2013 number of edges in generated network: | ||
4394 | 46 | BarabasiAlbertSimplifiedBPanel.constraintsLabel.text=<html>\nN > 0<br>\nM > 0<br>\nM <= N * (N - 1) / 2<br>\n</html> | ||
4395 | 47 | BarabasiAlbertSimplifiedBPanel.NLabel.text=N \u2013 number of nodes in generated network: | ||
4396 | 48 | ErdosRenyiGnpPanel.constraintsLabel.text=<html>\nn > 0<br>\n0 <= p <= 1<br>\n</html> | ||
4397 | 49 | ErdosRenyiGnpPanel.nLabel.text=n \u2013 number of nodes in generated network: | ||
4398 | 50 | ErdosRenyiGnpPanel.nField.text= | ||
4399 | 51 | ErdosRenyiGnpPanel.pLabel.text=p \u2013 probability of edge existence between all pairs of nodes: | ||
4400 | 52 | ErdosRenyiGnpPanel.pField.text= | ||
4401 | 53 | ErdosRenyiGnmPanel.nField.text= | ||
4402 | 54 | ErdosRenyiGnmPanel.constraintsLabel.text=<html>\nn > 0<br>\nm >= 0<br>\nm <= n * (n - 1) / 2\n</html> | ||
4403 | 55 | ErdosRenyiGnmPanel.nLabel.text=n \u2013 number of nodes in generated network: | ||
4404 | 56 | ErdosRenyiGnmPanel.mLabel.text=m \u2013 number of edges in generated network: | ||
4405 | 57 | ErdosRenyiGnmPanel.mField.text= | ||
4406 | 58 | KleinbergPanel.constraintsLabel.text=<html>\nn >= 2<br>\np >= 1<br>\np <= 2n - 2<br>\nq >= 0<br>\nq <= n^2 - p * (p + 3) / 2 - 1 for p < n<br>\nq <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n<br>\nr >= 0\n</html> | ||
4407 | 59 | KleinbergPanel.nLabel.text=n \u2013 size of a lattice: | ||
4408 | 60 | KleinbergPanel.nField.text= | ||
4409 | 61 | KleinbergPanel.pLabel.text=p - lattice distance to local contacs: | ||
4410 | 62 | KleinbergPanel.pField.text= | ||
4411 | 63 | KleinbergPanel.qLabel.text=q - long-range contacs: | ||
4412 | 64 | KleinbergPanel.qField.text= | ||
4413 | 65 | KleinbergPanel.rLabel.text=r \u2013 clustering exponent: | ||
4414 | 66 | KleinbergPanel.rField.text= | ||
4415 | 67 | WattsStrogatzBetaPanel.constraintsLabel.text=<html>\nN > K >= ln(N) >= 1<br>\nK is even<br>\n0 <= beta <= 1\n</html> | ||
4416 | 68 | WattsStrogatzBetaPanel.NField.text= | ||
4417 | 69 | WattsStrogatzBetaPanel.NLabel.text=N \u2013 the desired number of nodes: | ||
4418 | 70 | WattsStrogatzBetaPanel.KLabel.text=K \u2013 the number of edges connected to each node: | ||
4419 | 71 | WattsStrogatzBetaPanel.KField.text= | ||
4420 | 72 | WattsStrogatzBetaPanel.betaLabel.text=beta - the probability of an edge being rewired randomly: | ||
4421 | 73 | WattsStrogatzBetaPanel.betaField.text= | ||
4422 | 74 | WattsStrogatzAlphaPanel.constraintsLabel.text=<html>\nn > k > 0<br>\n0 <= alpha\n</html> | ||
4423 | 75 | WattsStrogatzAlphaPanel.nLabel.text=n \u2013 the desired number of nodes: | ||
4424 | 76 | WattsStrogatzAlphaPanel.nField.text= | ||
4425 | 77 | WattsStrogatzAlphaPanel.kLabel.text=k \u2013 the average degree of the graph: | ||
4426 | 78 | WattsStrogatzAlphaPanel.kField.text= | ||
4427 | 79 | WattsStrogatzAlphaPanel.alphaLabel.text=alpha - a tunable parameter: | ||
4428 | 80 | WattsStrogatzAlphaPanel.alphaField.text= | ||
4429 | 81 | BalancedTreePanel.constraintsLabel.text=<html>\nr >= 2<br>\nh >= 1\n</html> | ||
4430 | 82 | BalancedTreePanel.rLabel.text=r - a degree of the root: | ||
4431 | 83 | BalancedTreePanel.rField.text= | ||
4432 | 84 | BalancedTreePanel.hLabel.text=h - a height of the tree: | ||
4433 | 85 | BalancedTreePanel.hField.text= | ||
4434 | 86 | KleinbergPanel.torusCheckBox.text=torus based | ||
4435 | 18 | 87 | ||
4436 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form' | |||
4437 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form 1970-01-01 00:00:00 +0000 | |||
4438 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form 2010-12-17 03:47:30 +0000 | |||
4439 | @@ -0,0 +1,110 @@ | |||
4440 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
4441 | 2 | |||
4442 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
4443 | 4 | <Properties> | ||
4444 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
4445 | 6 | <Dimension value="[431, 116]"/> | ||
4446 | 7 | </Property> | ||
4447 | 8 | </Properties> | ||
4448 | 9 | <AuxValues> | ||
4449 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
4450 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
4451 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
4452 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
4453 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
4454 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
4455 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
4456 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
4457 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
4458 | 19 | </AuxValues> | ||
4459 | 20 | |||
4460 | 21 | <Layout> | ||
4461 | 22 | <DimensionLayout dim="0"> | ||
4462 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4463 | 24 | <Group type="102" attributes="0"> | ||
4464 | 25 | <EmptySpace max="-2" attributes="0"/> | ||
4465 | 26 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4466 | 27 | <Group type="102" attributes="0"> | ||
4467 | 28 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4468 | 29 | <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
4469 | 30 | <Component id="mLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
4470 | 31 | </Group> | ||
4471 | 32 | <EmptySpace min="-2" pref="60" max="-2" attributes="0"/> | ||
4472 | 33 | <Group type="103" groupAlignment="1" attributes="0"> | ||
4473 | 34 | <Component id="mField" alignment="0" pref="140" max="32767" attributes="1"/> | ||
4474 | 35 | <Component id="nField" alignment="0" pref="140" max="32767" attributes="1"/> | ||
4475 | 36 | </Group> | ||
4476 | 37 | <EmptySpace max="-2" attributes="0"/> | ||
4477 | 38 | </Group> | ||
4478 | 39 | <Group type="102" alignment="1" attributes="0"> | ||
4479 | 40 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
4480 | 41 | <EmptySpace min="-2" pref="175" max="-2" attributes="0"/> | ||
4481 | 42 | </Group> | ||
4482 | 43 | </Group> | ||
4483 | 44 | </Group> | ||
4484 | 45 | </Group> | ||
4485 | 46 | </DimensionLayout> | ||
4486 | 47 | <DimensionLayout dim="1"> | ||
4487 | 48 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4488 | 49 | <Group type="102" alignment="0" attributes="0"> | ||
4489 | 50 | <EmptySpace max="-2" attributes="0"/> | ||
4490 | 51 | <Group type="103" groupAlignment="3" attributes="0"> | ||
4491 | 52 | <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4492 | 53 | <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4493 | 54 | </Group> | ||
4494 | 55 | <EmptySpace max="-2" attributes="0"/> | ||
4495 | 56 | <Group type="103" groupAlignment="3" attributes="0"> | ||
4496 | 57 | <Component id="mField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4497 | 58 | <Component id="mLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4498 | 59 | </Group> | ||
4499 | 60 | <EmptySpace max="-2" attributes="0"/> | ||
4500 | 61 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
4501 | 62 | <EmptySpace max="32767" attributes="0"/> | ||
4502 | 63 | </Group> | ||
4503 | 64 | </Group> | ||
4504 | 65 | </DimensionLayout> | ||
4505 | 66 | </Layout> | ||
4506 | 67 | <SubComponents> | ||
4507 | 68 | <Component class="javax.swing.JTextField" name="nField"> | ||
4508 | 69 | <Properties> | ||
4509 | 70 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4510 | 71 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4511 | 72 | </Property> | ||
4512 | 73 | </Properties> | ||
4513 | 74 | <AuxValues> | ||
4514 | 75 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4515 | 76 | </AuxValues> | ||
4516 | 77 | </Component> | ||
4517 | 78 | <Component class="javax.swing.JTextField" name="mField"> | ||
4518 | 79 | <Properties> | ||
4519 | 80 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4520 | 81 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4521 | 82 | </Property> | ||
4522 | 83 | </Properties> | ||
4523 | 84 | <AuxValues> | ||
4524 | 85 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4525 | 86 | </AuxValues> | ||
4526 | 87 | </Component> | ||
4527 | 88 | <Component class="javax.swing.JLabel" name="nLabel"> | ||
4528 | 89 | <Properties> | ||
4529 | 90 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4530 | 91 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4531 | 92 | </Property> | ||
4532 | 93 | </Properties> | ||
4533 | 94 | </Component> | ||
4534 | 95 | <Component class="javax.swing.JLabel" name="mLabel"> | ||
4535 | 96 | <Properties> | ||
4536 | 97 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4537 | 98 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4538 | 99 | </Property> | ||
4539 | 100 | </Properties> | ||
4540 | 101 | </Component> | ||
4541 | 102 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
4542 | 103 | <Properties> | ||
4543 | 104 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4544 | 105 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4545 | 106 | </Property> | ||
4546 | 107 | </Properties> | ||
4547 | 108 | </Component> | ||
4548 | 109 | </SubComponents> | ||
4549 | 110 | </Form> | ||
4550 | 0 | 111 | ||
4551 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java' | |||
4552 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java 1970-01-01 00:00:00 +0000 | |||
4553 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java 2010-12-17 03:47:30 +0000 | |||
4554 | @@ -0,0 +1,186 @@ | |||
4555 | 1 | /* | ||
4556 | 2 | * Copyright 2008-2010 Gephi | ||
4557 | 3 | * Authors : Cezary Bartosiak | ||
4558 | 4 | * Website : http://www.gephi.org | ||
4559 | 5 | * | ||
4560 | 6 | * This file is part of Gephi. | ||
4561 | 7 | * | ||
4562 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4563 | 9 | * it under the terms of the GNU General Public License as published by | ||
4564 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4565 | 11 | * (at your option) any later version. | ||
4566 | 12 | * | ||
4567 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4568 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4569 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4570 | 16 | * GNU General Public License for more details. | ||
4571 | 17 | * | ||
4572 | 18 | * You should have received a copy of the GNU General Public License | ||
4573 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4574 | 20 | */ | ||
4575 | 21 | package org.gephi.ui.generator.plugin; | ||
4576 | 22 | |||
4577 | 23 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
4578 | 24 | import org.netbeans.validation.api.Problems; | ||
4579 | 25 | import org.netbeans.validation.api.Validator; | ||
4580 | 26 | import org.netbeans.validation.api.builtin.Validators; | ||
4581 | 27 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
4582 | 28 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
4583 | 29 | |||
4584 | 30 | /** | ||
4585 | 31 | * | ||
4586 | 32 | * | ||
4587 | 33 | * @author Cezary Bartosiak | ||
4588 | 34 | */ | ||
4589 | 35 | public class ErdosRenyiGnmPanel extends javax.swing.JPanel { | ||
4590 | 36 | |||
4591 | 37 | /** Creates new form BarabasiAlbertPanel */ | ||
4592 | 38 | public ErdosRenyiGnmPanel() { | ||
4593 | 39 | initComponents(); | ||
4594 | 40 | } | ||
4595 | 41 | |||
4596 | 42 | public static ValidationPanel createValidationPanel(ErdosRenyiGnmPanel innerPanel) { | ||
4597 | 43 | ValidationPanel validationPanel = new ValidationPanel(); | ||
4598 | 44 | if (innerPanel == null) | ||
4599 | 45 | innerPanel = new ErdosRenyiGnmPanel(); | ||
4600 | 46 | validationPanel.setInnerComponent(innerPanel); | ||
4601 | 47 | |||
4602 | 48 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
4603 | 49 | |||
4604 | 50 | group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4605 | 51 | new PositiveNumberValidator()); | ||
4606 | 52 | group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4607 | 53 | new mnValidator(innerPanel)); | ||
4608 | 54 | group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4609 | 55 | new mValidator(innerPanel)); | ||
4610 | 56 | group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4611 | 57 | new mnValidator(innerPanel)); | ||
4612 | 58 | |||
4613 | 59 | return validationPanel; | ||
4614 | 60 | } | ||
4615 | 61 | |||
4616 | 62 | private static class mValidator implements Validator<String> { | ||
4617 | 63 | private ErdosRenyiGnmPanel innerPanel; | ||
4618 | 64 | |||
4619 | 65 | public mValidator(ErdosRenyiGnmPanel innerPanel) { | ||
4620 | 66 | this.innerPanel = innerPanel; | ||
4621 | 67 | } | ||
4622 | 68 | |||
4623 | 69 | @Override | ||
4624 | 70 | public boolean validate(Problems problems, String compName, String model) { | ||
4625 | 71 | boolean result = false; | ||
4626 | 72 | |||
4627 | 73 | try { | ||
4628 | 74 | Integer m = Integer.parseInt(innerPanel.mField.getText()); | ||
4629 | 75 | result = m >= 0; | ||
4630 | 76 | } | ||
4631 | 77 | catch (Exception e) { } | ||
4632 | 78 | if (!result) { | ||
4633 | 79 | String message = "<html>m >= 0</html>"; | ||
4634 | 80 | problems.add(message); | ||
4635 | 81 | } | ||
4636 | 82 | |||
4637 | 83 | return result; | ||
4638 | 84 | } | ||
4639 | 85 | } | ||
4640 | 86 | |||
4641 | 87 | private static class mnValidator implements Validator<String> { | ||
4642 | 88 | private ErdosRenyiGnmPanel innerPanel; | ||
4643 | 89 | |||
4644 | 90 | public mnValidator(ErdosRenyiGnmPanel innerPanel) { | ||
4645 | 91 | this.innerPanel = innerPanel; | ||
4646 | 92 | } | ||
4647 | 93 | |||
4648 | 94 | @Override | ||
4649 | 95 | public boolean validate(Problems problems, String compName, String model) { | ||
4650 | 96 | boolean result = false; | ||
4651 | 97 | |||
4652 | 98 | try { | ||
4653 | 99 | Integer m = Integer.parseInt(innerPanel.mField.getText()); | ||
4654 | 100 | Integer n = Integer.parseInt(innerPanel.nField.getText()); | ||
4655 | 101 | result = m <= n * (n - 1) / 2; | ||
4656 | 102 | } | ||
4657 | 103 | catch (Exception e) { } | ||
4658 | 104 | if (!result) { | ||
4659 | 105 | String message = "<html>m <= n * (n - 1) / 2</html>"; | ||
4660 | 106 | problems.add(message); | ||
4661 | 107 | } | ||
4662 | 108 | |||
4663 | 109 | return result; | ||
4664 | 110 | } | ||
4665 | 111 | } | ||
4666 | 112 | |||
4667 | 113 | /** This method is called from within the constructor to | ||
4668 | 114 | * initialize the form. | ||
4669 | 115 | * WARNING: Do NOT modify this code. The content of this method is | ||
4670 | 116 | * always regenerated by the Form Editor. | ||
4671 | 117 | */ | ||
4672 | 118 | @SuppressWarnings("unchecked") | ||
4673 | 119 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
4674 | 120 | private void initComponents() { | ||
4675 | 121 | |||
4676 | 122 | nField = new javax.swing.JTextField(); | ||
4677 | 123 | mField = new javax.swing.JTextField(); | ||
4678 | 124 | nLabel = new javax.swing.JLabel(); | ||
4679 | 125 | mLabel = new javax.swing.JLabel(); | ||
4680 | 126 | constraintsLabel = new javax.swing.JLabel(); | ||
4681 | 127 | |||
4682 | 128 | setPreferredSize(new java.awt.Dimension(431, 116)); | ||
4683 | 129 | |||
4684 | 130 | nField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nField.text")); // NOI18N | ||
4685 | 131 | |||
4686 | 132 | mField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mField.text")); // NOI18N | ||
4687 | 133 | |||
4688 | 134 | nLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nLabel.text")); // NOI18N | ||
4689 | 135 | |||
4690 | 136 | mLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mLabel.text")); // NOI18N | ||
4691 | 137 | |||
4692 | 138 | constraintsLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.constraintsLabel.text")); // NOI18N | ||
4693 | 139 | |||
4694 | 140 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
4695 | 141 | this.setLayout(layout); | ||
4696 | 142 | layout.setHorizontalGroup( | ||
4697 | 143 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4698 | 144 | .addGroup(layout.createSequentialGroup() | ||
4699 | 145 | .addContainerGap() | ||
4700 | 146 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4701 | 147 | .addGroup(layout.createSequentialGroup() | ||
4702 | 148 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4703 | 149 | .addComponent(nLabel) | ||
4704 | 150 | .addComponent(mLabel)) | ||
4705 | 151 | .addGap(60, 60, 60) | ||
4706 | 152 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | ||
4707 | 153 | .addComponent(mField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) | ||
4708 | 154 | .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)) | ||
4709 | 155 | .addContainerGap()) | ||
4710 | 156 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | ||
4711 | 157 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4712 | 158 | .addGap(175, 175, 175)))) | ||
4713 | 159 | ); | ||
4714 | 160 | layout.setVerticalGroup( | ||
4715 | 161 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
4716 | 162 | .addGroup(layout.createSequentialGroup() | ||
4717 | 163 | .addContainerGap() | ||
4718 | 164 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
4719 | 165 | .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4720 | 166 | .addComponent(nLabel)) | ||
4721 | 167 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
4722 | 168 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | ||
4723 | 169 | .addComponent(mField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4724 | 170 | .addComponent(mLabel)) | ||
4725 | 171 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | ||
4726 | 172 | .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | ||
4727 | 173 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | ||
4728 | 174 | ); | ||
4729 | 175 | }// </editor-fold>//GEN-END:initComponents | ||
4730 | 176 | |||
4731 | 177 | |||
4732 | 178 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
4733 | 179 | private javax.swing.JLabel constraintsLabel; | ||
4734 | 180 | protected javax.swing.JTextField mField; | ||
4735 | 181 | private javax.swing.JLabel mLabel; | ||
4736 | 182 | protected javax.swing.JTextField nField; | ||
4737 | 183 | private javax.swing.JLabel nLabel; | ||
4738 | 184 | // End of variables declaration//GEN-END:variables | ||
4739 | 185 | |||
4740 | 186 | } | ||
4741 | 0 | 187 | ||
4742 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java' | |||
4743 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java 1970-01-01 00:00:00 +0000 | |||
4744 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java 2010-12-17 03:47:30 +0000 | |||
4745 | @@ -0,0 +1,62 @@ | |||
4746 | 1 | /* | ||
4747 | 2 | * Copyright 2008-2010 Gephi | ||
4748 | 3 | * Authors : Cezary Bartosiak | ||
4749 | 4 | * Website : http://www.gephi.org | ||
4750 | 5 | * | ||
4751 | 6 | * This file is part of Gephi. | ||
4752 | 7 | * | ||
4753 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4754 | 9 | * it under the terms of the GNU General Public License as published by | ||
4755 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4756 | 11 | * (at your option) any later version. | ||
4757 | 12 | * | ||
4758 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4759 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4760 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4761 | 16 | * GNU General Public License for more details. | ||
4762 | 17 | * | ||
4763 | 18 | * You should have received a copy of the GNU General Public License | ||
4764 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4765 | 20 | */ | ||
4766 | 21 | package org.gephi.ui.generator.plugin; | ||
4767 | 22 | |||
4768 | 23 | import javax.swing.JPanel; | ||
4769 | 24 | import org.gephi.io.generator.plugin.ErdosRenyiGnm; | ||
4770 | 25 | import org.gephi.io.generator.plugin.ErdosRenyiGnmUI; | ||
4771 | 26 | import org.gephi.io.generator.spi.Generator; | ||
4772 | 27 | import org.openide.util.lookup.ServiceProvider; | ||
4773 | 28 | |||
4774 | 29 | /** | ||
4775 | 30 | * | ||
4776 | 31 | * | ||
4777 | 32 | * @author Cezary Bartosiak | ||
4778 | 33 | */ | ||
4779 | 34 | @ServiceProvider(service = ErdosRenyiGnmUI.class) | ||
4780 | 35 | public class ErdosRenyiGnmUIImpl implements ErdosRenyiGnmUI { | ||
4781 | 36 | private ErdosRenyiGnmPanel panel; | ||
4782 | 37 | private ErdosRenyiGnm erdosRenyiGnm; | ||
4783 | 38 | |||
4784 | 39 | public ErdosRenyiGnmUIImpl() { } | ||
4785 | 40 | |||
4786 | 41 | public JPanel getPanel() { | ||
4787 | 42 | if (panel == null) | ||
4788 | 43 | panel = new ErdosRenyiGnmPanel(); | ||
4789 | 44 | return ErdosRenyiGnmPanel.createValidationPanel(panel); | ||
4790 | 45 | } | ||
4791 | 46 | |||
4792 | 47 | public void setup(Generator generator) { | ||
4793 | 48 | this.erdosRenyiGnm = (ErdosRenyiGnm)generator; | ||
4794 | 49 | |||
4795 | 50 | if (panel == null) | ||
4796 | 51 | panel = new ErdosRenyiGnmPanel(); | ||
4797 | 52 | |||
4798 | 53 | panel.nField.setText(String.valueOf(erdosRenyiGnm.getn())); | ||
4799 | 54 | panel.mField.setText(String.valueOf(erdosRenyiGnm.getm())); | ||
4800 | 55 | } | ||
4801 | 56 | |||
4802 | 57 | public void unsetup() { | ||
4803 | 58 | erdosRenyiGnm.setn(Integer.parseInt(panel.nField.getText())); | ||
4804 | 59 | erdosRenyiGnm.setm(Integer.parseInt(panel.mField.getText())); | ||
4805 | 60 | panel = null; | ||
4806 | 61 | } | ||
4807 | 62 | } | ||
4808 | 0 | 63 | ||
4809 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form' | |||
4810 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form 1970-01-01 00:00:00 +0000 | |||
4811 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form 2010-12-17 03:47:30 +0000 | |||
4812 | @@ -0,0 +1,110 @@ | |||
4813 | 1 | <?xml version="1.1" encoding="UTF-8" ?> | ||
4814 | 2 | |||
4815 | 3 | <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
4816 | 4 | <Properties> | ||
4817 | 5 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
4818 | 6 | <Dimension value="[498, 102]"/> | ||
4819 | 7 | </Property> | ||
4820 | 8 | </Properties> | ||
4821 | 9 | <AuxValues> | ||
4822 | 10 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> | ||
4823 | 11 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
4824 | 12 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
4825 | 13 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
4826 | 14 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> | ||
4827 | 15 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
4828 | 16 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
4829 | 17 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
4830 | 18 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
4831 | 19 | </AuxValues> | ||
4832 | 20 | |||
4833 | 21 | <Layout> | ||
4834 | 22 | <DimensionLayout dim="0"> | ||
4835 | 23 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4836 | 24 | <Group type="102" attributes="0"> | ||
4837 | 25 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4838 | 26 | <Group type="102" attributes="0"> | ||
4839 | 27 | <EmptySpace max="-2" attributes="0"/> | ||
4840 | 28 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4841 | 29 | <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
4842 | 30 | <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/> | ||
4843 | 31 | </Group> | ||
4844 | 32 | <EmptySpace min="-2" pref="60" max="-2" attributes="0"/> | ||
4845 | 33 | <Group type="103" groupAlignment="1" attributes="0"> | ||
4846 | 34 | <Component id="pField" alignment="0" pref="128" max="32767" attributes="1"/> | ||
4847 | 35 | <Component id="nField" alignment="0" pref="128" max="32767" attributes="1"/> | ||
4848 | 36 | </Group> | ||
4849 | 37 | </Group> | ||
4850 | 38 | <Group type="102" alignment="0" attributes="0"> | ||
4851 | 39 | <EmptySpace min="-2" pref="227" max="-2" attributes="0"/> | ||
4852 | 40 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
4853 | 41 | </Group> | ||
4854 | 42 | </Group> | ||
4855 | 43 | <EmptySpace max="-2" attributes="0"/> | ||
4856 | 44 | </Group> | ||
4857 | 45 | </Group> | ||
4858 | 46 | </DimensionLayout> | ||
4859 | 47 | <DimensionLayout dim="1"> | ||
4860 | 48 | <Group type="103" groupAlignment="0" attributes="0"> | ||
4861 | 49 | <Group type="102" alignment="0" attributes="0"> | ||
4862 | 50 | <EmptySpace max="-2" attributes="0"/> | ||
4863 | 51 | <Group type="103" groupAlignment="3" attributes="0"> | ||
4864 | 52 | <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4865 | 53 | <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4866 | 54 | </Group> | ||
4867 | 55 | <EmptySpace max="-2" attributes="0"/> | ||
4868 | 56 | <Group type="103" groupAlignment="3" attributes="0"> | ||
4869 | 57 | <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4870 | 58 | <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/> | ||
4871 | 59 | </Group> | ||
4872 | 60 | <EmptySpace max="-2" attributes="0"/> | ||
4873 | 61 | <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/> | ||
4874 | 62 | <EmptySpace max="32767" attributes="0"/> | ||
4875 | 63 | </Group> | ||
4876 | 64 | </Group> | ||
4877 | 65 | </DimensionLayout> | ||
4878 | 66 | </Layout> | ||
4879 | 67 | <SubComponents> | ||
4880 | 68 | <Component class="javax.swing.JTextField" name="nField"> | ||
4881 | 69 | <Properties> | ||
4882 | 70 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4883 | 71 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4884 | 72 | </Property> | ||
4885 | 73 | </Properties> | ||
4886 | 74 | <AuxValues> | ||
4887 | 75 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4888 | 76 | </AuxValues> | ||
4889 | 77 | </Component> | ||
4890 | 78 | <Component class="javax.swing.JTextField" name="pField"> | ||
4891 | 79 | <Properties> | ||
4892 | 80 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4893 | 81 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4894 | 82 | </Property> | ||
4895 | 83 | </Properties> | ||
4896 | 84 | <AuxValues> | ||
4897 | 85 | <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> | ||
4898 | 86 | </AuxValues> | ||
4899 | 87 | </Component> | ||
4900 | 88 | <Component class="javax.swing.JLabel" name="nLabel"> | ||
4901 | 89 | <Properties> | ||
4902 | 90 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4903 | 91 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4904 | 92 | </Property> | ||
4905 | 93 | </Properties> | ||
4906 | 94 | </Component> | ||
4907 | 95 | <Component class="javax.swing.JLabel" name="pLabel"> | ||
4908 | 96 | <Properties> | ||
4909 | 97 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4910 | 98 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4911 | 99 | </Property> | ||
4912 | 100 | </Properties> | ||
4913 | 101 | </Component> | ||
4914 | 102 | <Component class="javax.swing.JLabel" name="constraintsLabel"> | ||
4915 | 103 | <Properties> | ||
4916 | 104 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> | ||
4917 | 105 | <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
4918 | 106 | </Property> | ||
4919 | 107 | </Properties> | ||
4920 | 108 | </Component> | ||
4921 | 109 | </SubComponents> | ||
4922 | 110 | </Form> | ||
4923 | 0 | 111 | ||
4924 | === added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java' | |||
4925 | --- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java 1970-01-01 00:00:00 +0000 | |||
4926 | +++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java 2010-12-17 03:47:30 +0000 | |||
4927 | @@ -0,0 +1,130 @@ | |||
4928 | 1 | /* | ||
4929 | 2 | * Copyright 2008-2010 Gephi | ||
4930 | 3 | * Authors : Cezary Bartosiak | ||
4931 | 4 | * Website : http://www.gephi.org | ||
4932 | 5 | * | ||
4933 | 6 | * This file is part of Gephi. | ||
4934 | 7 | * | ||
4935 | 8 | * Gephi is free software: you can redistribute it and/or modify | ||
4936 | 9 | * it under the terms of the GNU General Public License as published by | ||
4937 | 10 | * the Free Software Foundation, either version 3 of the License, or | ||
4938 | 11 | * (at your option) any later version. | ||
4939 | 12 | * | ||
4940 | 13 | * Gephi is distributed in the hope that it will be useful, | ||
4941 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4942 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4943 | 16 | * GNU General Public License for more details. | ||
4944 | 17 | * | ||
4945 | 18 | * You should have received a copy of the GNU General Public License | ||
4946 | 19 | * along with Gephi. If not, see <http://www.gnu.org/licenses/>. | ||
4947 | 20 | */ | ||
4948 | 21 | package org.gephi.ui.generator.plugin; | ||
4949 | 22 | |||
4950 | 23 | import org.gephi.lib.validation.BetweenZeroAndOneValidator; | ||
4951 | 24 | import org.gephi.lib.validation.PositiveNumberValidator; | ||
4952 | 25 | import org.netbeans.validation.api.builtin.Validators; | ||
4953 | 26 | import org.netbeans.validation.api.ui.ValidationGroup; | ||
4954 | 27 | import org.netbeans.validation.api.ui.ValidationPanel; | ||
4955 | 28 | |||
4956 | 29 | /** | ||
4957 | 30 | * | ||
4958 | 31 | * | ||
4959 | 32 | * @author Cezary Bartosiak | ||
4960 | 33 | */ | ||
4961 | 34 | public class ErdosRenyiGnpPanel extends javax.swing.JPanel { | ||
4962 | 35 | |||
4963 | 36 | /** Creates new form BarabasiAlbertPanel */ | ||
4964 | 37 | public ErdosRenyiGnpPanel() { | ||
4965 | 38 | initComponents(); | ||
4966 | 39 | } | ||
4967 | 40 | |||
4968 | 41 | public static ValidationPanel createValidationPanel(ErdosRenyiGnpPanel innerPanel) { | ||
4969 | 42 | ValidationPanel validationPanel = new ValidationPanel(); | ||
4970 | 43 | if (innerPanel == null) | ||
4971 | 44 | innerPanel = new ErdosRenyiGnpPanel(); | ||
4972 | 45 | validationPanel.setInnerComponent(innerPanel); | ||
4973 | 46 | |||
4974 | 47 | ValidationGroup group = validationPanel.getValidationGroup(); | ||
4975 | 48 | |||
4976 | 49 | group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4977 | 50 | new PositiveNumberValidator()); | ||
4978 | 51 | group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING, | ||
4979 | 52 | new BetweenZeroAndOneValidator()); | ||
4980 | 53 | |||
4981 | 54 | return validationPanel; | ||
4982 | 55 | } | ||
4983 | 56 | |||
4984 | 57 | /** This method is called from within the constructor to | ||
4985 | 58 | * initialize the form. | ||
4986 | 59 | * WARNING: Do NOT modify this code. The content of this method is | ||
4987 | 60 | * always regenerated by the Form Editor. | ||
4988 | 61 | */ | ||
4989 | 62 | @SuppressWarnings("unchecked") | ||
4990 | 63 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
4991 | 64 | private void initComponents() { | ||
4992 | 65 | |||
4993 | 66 | nField = new javax.swing.JTextField(); | ||
4994 | 67 | pField = new javax.swing.JTextField(); | ||
4995 | 68 | nLabel = new javax.swing.JLabel(); | ||
4996 | 69 | pLabel = new javax.swing.JLabel(); | ||
4997 | 70 | constraintsLabel = new javax.swing.JLabel(); | ||
4998 | 71 | |||
4999 | 72 | setPreferredSize(new java.awt.Dimension(498, 102)); | ||
5000 | 73 |
The diff has been truncated for viewing.