Merge lp:~cezary-bartosiak/gephi/generator-plugin into lp:~gephi.team/gephi/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
Reviewer Review Type Date Requested Status
Mathieu Bastian Approve
Review via email: mp+43858@code.launchpad.net

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

Subscribers

People subscribed via source and target branches