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
=== modified file 'GeneratorPlugin/manifest.mf'
--- GeneratorPlugin/manifest.mf 2010-08-19 09:38:57 +0000
+++ GeneratorPlugin/manifest.mf 2010-12-17 03:47:30 +0000
@@ -2,5 +2,5 @@
2AutoUpdate-Essential-Module: true2AutoUpdate-Essential-Module: true
3OpenIDE-Module: org.gephi.io.generator.plugin3OpenIDE-Module: org.gephi.io.generator.plugin
4OpenIDE-Module-Localizing-Bundle: org/gephi/io/generator/plugin/Bundle.properties4OpenIDE-Module-Localizing-Bundle: org/gephi/io/generator/plugin/Bundle.properties
5OpenIDE-Module-Specification-Version: 0.7.15OpenIDE-Module-Specification-Version: 0.7.2
66
77
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTree.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,136 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.ArrayList;
24import java.util.List;
25import org.gephi.io.generator.spi.Generator;
26import org.gephi.io.generator.spi.GeneratorUI;
27import org.gephi.io.importer.api.ContainerLoader;
28import org.gephi.io.importer.api.EdgeDefault;
29import org.gephi.io.importer.api.EdgeDraft;
30import org.gephi.io.importer.api.NodeDraft;
31import org.gephi.utils.progress.Progress;
32import org.gephi.utils.progress.ProgressTicket;
33import org.openide.util.Lookup;
34import org.openide.util.lookup.ServiceProvider;
35
36/**
37 * Generates a perfectly balanced r-tree of height h (edges are undirected).
38 *
39 * r >= 2
40 * h >= 1
41 *
42 * O(r^h)
43 *
44 * @author Cezary Bartosiak
45 */
46@ServiceProvider(service = Generator.class)
47public class BalancedTree implements Generator {
48 private boolean cancel = false;
49 private ProgressTicket progressTicket;
50
51 private int r = 2;
52 private int h = 4;
53
54 public void generate(ContainerLoader container) {
55 int n = ((int)Math.pow(r, h + 1) - 1) / (r - 1);
56
57 Progress.start(progressTicket, n - 1);
58 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
59
60 // Creating a root of degree r
61 NodeDraft root = container.factory().newNodeDraft();
62 root.setLabel("Node 0");
63 container.addNode(root);
64 List<NodeDraft> newLeaves = new ArrayList<NodeDraft>();
65 int v = 1;
66 for (int i = 0; i < r && !cancel; ++i) {
67 NodeDraft node = container.factory().newNodeDraft();
68 node.setLabel("Node " + v++);
69 newLeaves.add(node);
70 container.addNode(node);
71
72 EdgeDraft edge = container.factory().newEdgeDraft();
73 edge.setSource(root);
74 edge.setTarget(node);
75 container.addEdge(edge);
76
77 Progress.progress(progressTicket);
78 }
79
80 // Creating internal nodes
81 for (int height = 1; height < h && !cancel; ++height) {
82 List<NodeDraft> leaves = newLeaves;
83 newLeaves = new ArrayList<NodeDraft>();
84 for (NodeDraft leave : leaves)
85 for (int i = 0; i < r; ++i) {
86 NodeDraft node = container.factory().newNodeDraft();
87 node.setLabel("Node " + v++);
88 newLeaves.add(node);
89 container.addNode(node);
90
91 EdgeDraft edge = container.factory().newEdgeDraft();
92 edge.setSource(leave);
93 edge.setTarget(node);
94 container.addEdge(edge);
95
96 Progress.progress(progressTicket);
97 }
98 }
99
100 Progress.finish(progressTicket);
101 progressTicket = null;
102 }
103
104 public int getr() {
105 return r;
106 }
107
108 public int geth() {
109 return h;
110 }
111
112 public void setr(int r) {
113 this.r = r;
114 }
115
116 public void seth(int h) {
117 this.h = h;
118 }
119
120 public String getName() {
121 return "Balanced Tree";
122 }
123
124 public GeneratorUI getUI() {
125 return Lookup.getDefault().lookup(BalancedTreeUI.class);
126 }
127
128 public boolean cancel() {
129 cancel = true;
130 return true;
131 }
132
133 public void setProgressTicket(ProgressTicket progressTicket) {
134 this.progressTicket = progressTicket;
135 }
136}
0137
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BalancedTreeUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface BalancedTreeUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbert.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,177 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected connected graph.
37 *
38 * http://en.wikipedia.org/wiki/Barabási–Albert_model
39 * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
40 * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
41 *
42 * N > 0
43 * m0 > 0 && m0 < N
44 * M > 0 && M <= m0
45 *
46 * O(N^2 * M)
47 *
48 * @author Cezary Bartosiak
49 */
50@ServiceProvider(service = Generator.class)
51public class BarabasiAlbert implements Generator {
52 private boolean cancel = false;
53 private ProgressTicket progressTicket;
54
55 private int N = 50;
56 private int m0 = 1;
57 private int M = 1;
58
59 public void generate(ContainerLoader container) {
60 Progress.start(progressTicket, N + M);
61 Random random = new Random();
62 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
63
64 NodeDraft[] nodes = new NodeDraft[N];
65 int[] degrees = new int[N];
66
67 // Creating m0 nodes
68 for (int i = 0; i < m0 && !cancel; ++i) {
69 NodeDraft node = container.factory().newNodeDraft();
70 node.setLabel("Node " + i);
71 nodes[i] = node;
72 degrees[i] = 0;
73 container.addNode(node);
74 Progress.progress(progressTicket);
75 }
76
77 // Linking every node with each other (no self-loops)
78 for (int i = 0; i < m0 && !cancel; ++i)
79 for (int j = i + 1; j < m0 && !cancel; ++j) {
80 EdgeDraft edge = container.factory().newEdgeDraft();
81 edge.setSource(nodes[i]);
82 edge.setTarget(nodes[j]);
83 degrees[i]++;
84 degrees[j]++;
85 container.addEdge(edge);
86 Progress.progress(progressTicket);
87 }
88
89 // Adding N - m0 nodes, each with M edges
90 for (int i = m0; i < N && !cancel; ++i) {
91 // Adding new node
92 NodeDraft node = container.factory().newNodeDraft();
93 node.setLabel("Node " + i);
94 nodes[i] = node;
95 degrees[i] = 0;
96 container.addNode(node);
97
98 // Adding M edges out of the new node
99 double sum = 0.0; // sum of all nodes degrees
100 for (int j = 0; j < i && !cancel; ++j)
101 sum += degrees[j];
102 double s = 0.0;
103 for (int m = 0; m < M && !cancel; ++m) {
104 double r = random.nextDouble();
105 double p = 0.0;
106 for (int j = 0; j < i && !cancel; ++j) {
107 if (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i]))
108 continue;
109
110 if (i == 1)
111 p = 1.0;
112 else p += degrees[j] / sum + s / (i - m);
113
114 if (r <= p) {
115 s += degrees[j] / sum;
116
117 EdgeDraft edge = container.factory().newEdgeDraft();
118 edge.setSource(nodes[i]);
119 edge.setTarget(nodes[j]);
120 degrees[i]++;
121 degrees[j]++;
122 container.addEdge(edge);
123 Progress.progress(progressTicket);
124
125 break;
126 }
127 }
128 }
129
130 Progress.progress(progressTicket);
131 }
132
133 Progress.finish(progressTicket);
134 progressTicket = null;
135 }
136
137 public int getN() {
138 return N;
139 }
140
141 public int getm0() {
142 return m0;
143 }
144
145 public int getM() {
146 return M;
147 }
148
149 public void setN(int N) {
150 this.N = N;
151 }
152
153 public void setm0(int m0) {
154 this.m0 = m0;
155 }
156
157 public void setM(int M) {
158 this.M = M;
159 }
160
161 public String getName() {
162 return "Barabasi-Albert Scale Free model";
163 }
164
165 public GeneratorUI getUI() {
166 return Lookup.getDefault().lookup(BarabasiAlbertUI.class);
167 }
168
169 public boolean cancel() {
170 cancel = true;
171 return true;
172 }
173
174 public void setProgressTicket(ProgressTicket progressTicket) {
175 this.progressTicket = progressTicket;
176 }
177}
0178
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralized.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,277 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected not necessarily connected graph.
37 *
38 * http://en.wikipedia.org/wiki/Barabási–Albert_model
39 * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
40 * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
41 *
42 * N > 0
43 * m0 > 0
44 * M > 0 && M <= m0
45 * 0 <= p < 1
46 * 0 <= q < 1 - p
47 *
48 * Ω(N^2 * M)
49 *
50 * @author Cezary Bartosiak
51 */
52@ServiceProvider(service = Generator.class)
53public class BarabasiAlbertGeneralized implements Generator {
54 private boolean cancel = false;
55 private ProgressTicket progressTicket;
56
57 private int N = 50;
58 private int m0 = 1;
59 private int M = 1;
60 private double p = 0.25;
61 private double q = 0.25;
62
63 public void generate(ContainerLoader container) {
64 Progress.start(progressTicket, N);
65 Random random = new Random();
66 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
67
68 NodeDraft[] nodes = new NodeDraft[N + 1];
69 int[] degrees = new int[N + 1];
70
71 // Creating m0 isolated nodes
72 for (int i = 0; i < m0 && !cancel; ++i) {
73 NodeDraft node = container.factory().newNodeDraft();
74 node.setLabel("Node " + i);
75 nodes[i] = node;
76 degrees[i] = 0;
77 container.addNode(node);
78 }
79
80 // Performing N steps of the algorithm
81 int n = m0; // the number of existing nodes
82 int ec = 0; // the number of existing edges
83 for (int i = 0; i < N && !cancel; ++i) {
84 double r = random.nextDouble();
85
86 if (r <= p) { // adding M edges
87 if (ec == n * (n - 1) / 2)
88 continue;
89
90 double sum = 0.0;
91 for (int j = 0; j < n && !cancel; ++j)
92 sum += degrees[j] + 1;
93 for (int m = 0; m < M && !cancel; ++m) {
94 int a = random.nextInt(n);
95 while (degrees[a] == n - 1 && !cancel)
96 a = random.nextInt(n);
97 double b = random.nextDouble();
98 boolean e = false;
99 while (!e && !cancel) {
100 double pki = 0.0;
101 for (int j = 0; j < n && !e && !cancel; ++j) {
102 pki += (degrees[j] + 1) / sum;
103
104 if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) {
105 EdgeDraft edge = container.factory().newEdgeDraft();
106 edge.setSource(nodes[a]);
107 edge.setTarget(nodes[j]);
108 degrees[a]++;
109 degrees[j]++;
110 sum += 2.0;
111 container.addEdge(edge);
112 ec++;
113
114 e = true;
115 }
116 else if (ec == n * (n - 1) / 2)
117 e = true;
118 }
119 b = random.nextDouble();
120 }
121 }
122 }
123 else if (r <= p + q) { // rewiring M edges
124 if (ec == 0 || ec == n * (n - 1) / 2)
125 continue;
126
127 double sum = 0.0;
128 for (int j = 0; j < n && !cancel; ++j)
129 sum += degrees[j] + 1;
130 for (int m = 0; m < M && !cancel; ++m) {
131 int a = random.nextInt(n);
132 while ((degrees[a] == 0 || degrees[a] == n - 1) && !cancel)
133 a = random.nextInt(n);
134 int l = random.nextInt(n);
135 while (!edgeExists(container, nodes[l], nodes[a]) && !cancel)
136 l = random.nextInt(n);
137 double b = random.nextDouble();
138 boolean e = false;
139 while (!e && !cancel) {
140 double pki = 0.0;
141 for (int j = 0; j < n && !e && !cancel; ++j) {
142 pki += (degrees[j] + 1) / sum;
143
144 if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) {
145 container.removeEdge(getEdge(container, nodes[a], nodes[l]));
146 degrees[l]--;
147
148 EdgeDraft edge = container.factory().newEdgeDraft();
149 edge.setSource(nodes[a]);
150 edge.setTarget(nodes[j]);
151 degrees[j]++;
152 container.addEdge(edge);
153
154 e = true;
155 }
156 }
157 b = random.nextDouble();
158 }
159 }
160 }
161 else { // adding a new node with M edges
162 NodeDraft node = container.factory().newNodeDraft();
163 node.setLabel("Node " + n);
164 nodes[n] = node;
165 degrees[n] = 0;
166 container.addNode(node);
167
168 // Adding M edges out of the new node
169 double sum = 0.0;
170 for (int j = 0; j < n && !cancel; ++j)
171 sum += degrees[j];
172 double s = 0.0;
173 for (int m = 0; m < M && !cancel; ++m) {
174 r = random.nextDouble();
175 double p = 0.0;
176 for (int j = 0; j < n && !cancel; ++j) {
177 if (edgeExists(container, nodes[n], nodes[j]))
178 continue;
179
180 if (n == 1)
181 p = 1.0;
182 else p += degrees[j] / sum + s / (n - m);
183
184 if (r <= p) {
185 s += degrees[j] / sum;
186
187 EdgeDraft edge = container.factory().newEdgeDraft();
188 edge.setSource(nodes[n]);
189 edge.setTarget(nodes[j]);
190 degrees[n]++;
191 degrees[j]++;
192 container.addEdge(edge);
193 ec++;
194
195 break;
196 }
197 }
198 }
199
200 n++;
201 }
202
203 Progress.progress(progressTicket);
204 }
205
206 Progress.finish(progressTicket);
207 progressTicket = null;
208 }
209
210 private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
211 return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
212 }
213
214 private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
215 EdgeDraft edge = container.getEdge(node1, node2);
216 if (edge == null)
217 edge = container.getEdge(node2, node1);
218 return edge;
219 }
220
221 public int getN() {
222 return N;
223 }
224
225 public int getm0() {
226 return m0;
227 }
228
229 public int getM() {
230 return M;
231 }
232
233 public double getp() {
234 return p;
235 }
236
237 public double getq() {
238 return q;
239 }
240
241 public void setN(int N) {
242 this.N = N;
243 }
244
245 public void setm0(int m0) {
246 this.m0 = m0;
247 }
248
249 public void setM(int M) {
250 this.M = M;
251 }
252
253 public void setp(double p) {
254 this.p = p;
255 }
256
257 public void setq(double q) {
258 this.q = q;
259 }
260
261 public String getName() {
262 return "Generalized Barabasi-Albert Scale Free model";
263 }
264
265 public GeneratorUI getUI() {
266 return Lookup.getDefault().lookup(BarabasiAlbertGeneralizedUI.class);
267 }
268
269 public boolean cancel() {
270 cancel = true;
271 return true;
272 }
273
274 public void setProgressTicket(ProgressTicket progressTicket) {
275 this.progressTicket = progressTicket;
276 }
277}
0278
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertGeneralizedUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface BarabasiAlbertGeneralizedUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedA.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,152 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected connected graph.
37 *
38 * http://en.wikipedia.org/wiki/Barabási–Albert_model
39 * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
40 * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
41 *
42 * N > 0
43 * m0 > 0 && m0 < N
44 * M > 0 && M <= m0
45 *
46 * Ω(N * M)
47 *
48 * @author Cezary Bartosiak
49 */
50@ServiceProvider(service = Generator.class)
51public class BarabasiAlbertSimplifiedA implements Generator {
52 private boolean cancel = false;
53 private ProgressTicket progressTicket;
54
55 private int N = 50;
56 private int m0 = 1;
57 private int M = 1;
58
59 public void generate(ContainerLoader container) {
60 Progress.start(progressTicket, N + M);
61 Random random = new Random();
62 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
63
64 NodeDraft[] nodes = new NodeDraft[N];
65
66 // Creating m0 nodes
67 for (int i = 0; i < m0 && !cancel; ++i) {
68 NodeDraft node = container.factory().newNodeDraft();
69 node.setLabel("Node " + i);
70 nodes[i] = node;
71 container.addNode(node);
72 Progress.progress(progressTicket);
73 }
74
75 // Linking every node with each other (no self-loops)
76 for (int i = 0; i < m0 && !cancel; ++i)
77 for (int j = i + 1; j < m0 && !cancel; ++j) {
78 EdgeDraft edge = container.factory().newEdgeDraft();
79 edge.setSource(nodes[i]);
80 edge.setTarget(nodes[j]);
81 container.addEdge(edge);
82 Progress.progress(progressTicket);
83 }
84
85 // Adding N - m0 nodes, each with M edges
86 for (int i = m0; i < N && !cancel; ++i) {
87 // Adding new node
88 NodeDraft node = container.factory().newNodeDraft();
89 node.setLabel("Node " + i);
90 nodes[i] = node;
91 container.addNode(node);
92
93 // Adding M edges out of the new node
94 for (int m = 0; m < M && !cancel; ++m) {
95 int j = random.nextInt(i);
96 while (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i]))
97 j = random.nextInt(i);
98 EdgeDraft edge = container.factory().newEdgeDraft();
99 edge.setSource(nodes[i]);
100 edge.setTarget(nodes[j]);
101 container.addEdge(edge);
102 Progress.progress(progressTicket);
103 }
104
105 Progress.progress(progressTicket);
106 }
107
108 Progress.finish(progressTicket);
109 progressTicket = null;
110 }
111
112 public int getN() {
113 return N;
114 }
115
116 public int getm0() {
117 return m0;
118 }
119
120 public int getM() {
121 return M;
122 }
123
124 public void setN(int N) {
125 this.N = N;
126 }
127
128 public void setm0(int m0) {
129 this.m0 = m0;
130 }
131
132 public void setM(int M) {
133 this.M = M;
134 }
135
136 public String getName() {
137 return "Barabasi-Albert Scale Free model A (uniform attachment)";
138 }
139
140 public GeneratorUI getUI() {
141 return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedAUI.class);
142 }
143
144 public boolean cancel() {
145 cancel = true;
146 return true;
147 }
148
149 public void setProgressTicket(ProgressTicket progressTicket) {
150 this.progressTicket = progressTicket;
151 }
152}
0153
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedAUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface BarabasiAlbertSimplifiedAUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedB.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,151 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected not necessarily connected graph.
37 *
38 * http://en.wikipedia.org/wiki/Barabási–Albert_model
39 * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
40 * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
41 *
42 * N > 0
43 * M > 0
44 * M <= N * (N - 1) / 2
45 *
46 * Ω(N * M)
47 *
48 * @author Cezary Bartosiak
49 */
50@ServiceProvider(service = Generator.class)
51public class BarabasiAlbertSimplifiedB implements Generator {
52 private boolean cancel = false;
53 private ProgressTicket progressTicket;
54
55 private int N = 50;
56 private int M = 50;
57
58 public void generate(ContainerLoader container) {
59 Progress.start(progressTicket, N + M);
60 Random random = new Random();
61 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
62
63 NodeDraft[] nodes = new NodeDraft[N];
64 int[] degrees = new int[N];
65
66 // Creating N nodes
67 for (int i = 0; i < N && !cancel; ++i) {
68 NodeDraft node = container.factory().newNodeDraft();
69 node.setLabel("Node " + i);
70 nodes[i] = node;
71 degrees[i] = 0;
72 container.addNode(node);
73 Progress.progress(progressTicket);
74 }
75
76 // Creating M edges
77 for (int m = 0; m < M && !cancel; ++m) {
78 double sum = 0.0; // sum of all nodes degrees
79 for (int j = 0; j < N && !cancel; ++j)
80 sum += degrees[j] + 1;
81
82 // Selecting a node randomly
83 int i = random.nextInt(N);
84 while (degrees[i] == N - 1 && !cancel)
85 i = random.nextInt(N);
86
87 double b = random.nextDouble();
88 boolean e = false;
89 while (!e && !cancel) {
90 double pki = 0.0;
91 for (int j = 0; j < N && !e && !cancel; ++j) {
92 pki += (degrees[j] + 1) / sum;
93
94 if (b <= pki && i != j && !edgeExists(container, nodes[i], nodes[j])) {
95 EdgeDraft edge = container.factory().newEdgeDraft();
96 edge.setSource(nodes[i]);
97 edge.setTarget(nodes[j]);
98 degrees[i]++;
99 degrees[j]++;
100 container.addEdge(edge);
101
102 e = true;
103 }
104 }
105 b = random.nextDouble();
106 }
107
108 Progress.progress(progressTicket);
109 }
110
111 Progress.finish(progressTicket);
112 progressTicket = null;
113 }
114
115 private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
116 return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
117 }
118
119 public int getN() {
120 return N;
121 }
122
123 public int getM() {
124 return M;
125 }
126
127 public void setN(int N) {
128 this.N = N;
129 }
130
131 public void setM(int M) {
132 this.M = M;
133 }
134
135 public String getName() {
136 return "Barabasi-Albert Scale Free model B (no growth)";
137 }
138
139 public GeneratorUI getUI() {
140 return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedBUI.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}
0152
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertSimplifiedBUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface BarabasiAlbertSimplifiedBUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/BarabasiAlbertUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface BarabasiAlbertUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnm.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,129 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.ArrayList;
24import java.util.List;
25import java.util.Random;
26import org.gephi.io.generator.spi.Generator;
27import org.gephi.io.generator.spi.GeneratorUI;
28import org.gephi.io.importer.api.ContainerLoader;
29import org.gephi.io.importer.api.EdgeDefault;
30import org.gephi.io.importer.api.EdgeDraft;
31import org.gephi.io.importer.api.NodeDraft;
32import org.gephi.utils.progress.Progress;
33import org.gephi.utils.progress.ProgressTicket;
34import org.openide.util.Lookup;
35import org.openide.util.lookup.ServiceProvider;
36
37/**
38 * Generates an undirected not necessarily connected graph.
39 *
40 * http://www.math-inst.hu/~p_erdos/1960-10.pdf
41 * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf
42 *
43 * n > 0
44 * m >= 0
45 * m <= n * (n - 1) / 2
46 *
47 * O(n^2)
48 *
49 * @author Cezary Bartosiak
50 */
51@ServiceProvider(service = Generator.class)
52public class ErdosRenyiGnm implements Generator {
53 private boolean cancel = false;
54 private ProgressTicket progressTicket;
55
56 private int n = 50;
57 private int m = 50;
58
59 public void generate(ContainerLoader container) {
60 Progress.start(progressTicket, n + n * n + m);
61 Random random = new Random();
62 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
63
64 NodeDraft[] nodes = new NodeDraft[n];
65
66 // Creating n nodes
67 for (int i = 0; i < n && !cancel; ++i) {
68 NodeDraft node = container.factory().newNodeDraft();
69 node.setLabel("Node " + i);
70 nodes[i] = node;
71 container.addNode(node);
72 Progress.progress(progressTicket);
73 }
74
75 // Creating a list of n^2 edges
76 List<EdgeDraft> edges = new ArrayList<EdgeDraft>();
77 for (int i = 0; i < n && !cancel; ++i)
78 for (int j = i + 1; j < n && !cancel; ++j) {
79 EdgeDraft edge = container.factory().newEdgeDraft();
80 edge.setSource(nodes[i]);
81 edge.setTarget(nodes[j]);
82 edges.add(edge);
83 Progress.progress(progressTicket);
84 }
85
86 // Drawing m edges
87 for (int i = 0; i < m; ++i) {
88 EdgeDraft e = edges.get(random.nextInt(edges.size()));
89 edges.remove(e);
90 container.addEdge(e);
91 }
92
93 Progress.finish(progressTicket);
94 progressTicket = null;
95 }
96
97 public int getn() {
98 return n;
99 }
100
101 public int getm() {
102 return m;
103 }
104
105 public void setn(int n) {
106 this.n = n;
107 }
108
109 public void setm(int m) {
110 this.m = m;
111 }
112
113 public String getName() {
114 return "Erdos-Renyi G(n, m) model";
115 }
116
117 public GeneratorUI getUI() {
118 return Lookup.getDefault().lookup(ErdosRenyiGnmUI.class);
119 }
120
121 public boolean cancel() {
122 cancel = true;
123 return true;
124 }
125
126 public void setProgressTicket(ProgressTicket progressTicket) {
127 this.progressTicket = progressTicket;
128 }
129}
0130
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnmUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface ErdosRenyiGnmUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnp.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,123 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected not necessarily connected graph.
37 *
38 * http://www.math-inst.hu/~p_erdos/1960-10.pdf
39 * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf
40 *
41 * n > 0
42 * 0 <= p <= 1
43 *
44 * O(n^2)
45 *
46 * @author Cezary Bartosiak
47 */
48@ServiceProvider(service = Generator.class)
49public class ErdosRenyiGnp implements Generator {
50 private boolean cancel = false;
51 private ProgressTicket progressTicket;
52
53 private int n = 50;
54 private double p = 0.05;
55
56 public void generate(ContainerLoader container) {
57 Progress.start(progressTicket, n + n * n);
58 Random random = new Random();
59 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
60
61 NodeDraft[] nodes = new NodeDraft[n];
62
63 // Creating n nodes
64 for (int i = 0; i < n && !cancel; ++i) {
65 NodeDraft node = container.factory().newNodeDraft();
66 node.setLabel("Node " + i);
67 nodes[i] = node;
68 container.addNode(node);
69 Progress.progress(progressTicket);
70 }
71
72 // Linking every node with each other with probability p (no self-loops)
73 for (int i = 0; i < n && !cancel; ++i)
74 for (int j = 0; j < n && !cancel; ++j)
75 if (i != j && !edgeExists(container, nodes[i], nodes[j]) && random.nextDouble() <= p) {
76 EdgeDraft edge = container.factory().newEdgeDraft();
77 edge.setSource(nodes[i]);
78 edge.setTarget(nodes[j]);
79 container.addEdge(edge);
80 Progress.progress(progressTicket);
81 }
82
83 Progress.finish(progressTicket);
84 progressTicket = null;
85 }
86
87 private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
88 return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
89 }
90
91 public int getn() {
92 return n;
93 }
94
95 public double getp() {
96 return p;
97 }
98
99 public void setn(int n) {
100 this.n = n;
101 }
102
103 public void setp(double p) {
104 this.p = p;
105 }
106
107 public String getName() {
108 return "Erdos-Renyi G(n, p) model";
109 }
110
111 public GeneratorUI getUI() {
112 return Lookup.getDefault().lookup(ErdosRenyiGnpUI.class);
113 }
114
115 public boolean cancel() {
116 cancel = true;
117 return true;
118 }
119
120 public void setProgressTicket(ProgressTicket progressTicket) {
121 this.progressTicket = progressTicket;
122 }
123}
0124
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/ErdosRenyiGnpUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface ErdosRenyiGnpUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/Kleinberg.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,200 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDraft;
28import org.gephi.io.importer.api.NodeDraft;
29import org.gephi.utils.progress.Progress;
30import org.gephi.utils.progress.ProgressTicket;
31import org.openide.util.Lookup;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 * Generates a directed connected graph.
36 *
37 * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.117.7097&rep=rep1&type=pdf
38 * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.83.381&rep=rep1&type=pdf
39 *
40 * n >= 2
41 * p >= 1
42 * p <= 2n - 2
43 * q >= 0
44 * q <= n^2 - p * (p + 3) / 2 - 1 for p < n
45 * q <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n
46 * r >= 0
47 *
48 * Ω(n^4 * q)
49 *
50 * @author Cezary Bartosiak
51 */
52@ServiceProvider(service = Generator.class)
53public class Kleinberg implements Generator {
54 private boolean cancel = false;
55 private ProgressTicket progressTicket;
56
57 private int n = 10;
58 private int p = 2;
59 private int q = 2;
60 private int r = 0;
61
62 private boolean torusBased = false;
63
64 public void generate(ContainerLoader container) {
65 Progress.start(progressTicket, n * n + n * n * (2 * p + 1) * (2 * p + 1) +
66 (int)Math.pow(n, 4) + n * n * q);
67 Random random = new Random();
68
69 // Creating lattice n x n
70 NodeDraft[][] nodes = new NodeDraft[n][n];
71 for (int i = 0; i < n && !cancel; ++i)
72 for (int j = 0; j < n && !cancel; ++j) {
73 NodeDraft node = container.factory().newNodeDraft();
74 node.setLabel("Node " + i + " " + j);
75 nodes[i][j] = node;
76 container.addNode(node);
77 Progress.progress(progressTicket);
78 }
79
80 // Creating edges from each node to p local contacts
81 for (int i = 0; i < n && !cancel; ++i)
82 for (int j = 0; j < n && !cancel; ++j)
83 for (int k = i - p; k <= i + p && !cancel; ++k)
84 for (int l = j - p; l <= j + p && !cancel; ++l) {
85 if ((torusBased || !torusBased && k >= 0 && k < n && l >= 0 && l < n) &&
86 d(i, j, k, l) <= p && nodes[i][j] != nodes[(k + n) % n][(l + n) % n]) {
87 EdgeDraft edge = container.factory().newEdgeDraft();
88 edge.setSource(nodes[i][j]);
89 edge.setTarget(nodes[(k + n) % n][(l + n) % n]);
90 container.addEdge(edge);
91 }
92 Progress.progress(progressTicket);
93 }
94
95 // Creating edges from each node to q long-range contacts
96 for (int i = 0; i < n && !cancel; ++i)
97 for (int j = 0; j < n && !cancel; ++j) {
98 double sum = 0.0;
99 for (int k = 0; k < n && !cancel; ++k)
100 for (int l = 0; l < n && !cancel; ++l) {
101 if (!torusBased && d(i, j, k, l) > p)
102 sum += Math.pow(d(i, j, k, l), -r);
103 else if (torusBased && dtb(i, j, k, l) > p)
104 sum += Math.pow(dtb(i, j, k, l), -r);
105 Progress.progress(progressTicket);
106 }
107 for (int m = 0; m < q && !cancel; ++m) {
108 double b = random.nextDouble();
109 boolean e = false;
110 while (!e && !cancel) {
111 double pki = 0.0;
112 for (int k = 0; k < n && !e && !cancel; ++k)
113 for (int l = 0; l < n && !e && !cancel; ++l)
114 if (!torusBased && d(i, j, k, l) > p || torusBased && dtb(i, j, k, l) > p) {
115 pki += Math.pow(!torusBased ? d(i, j, k, l) : dtb(i, j, k, l), -r) / sum;
116
117 if (b <= pki && !container.edgeExists(nodes[i][j], nodes[k][l])) {
118 EdgeDraft edge = container.factory().newEdgeDraft();
119 edge.setSource(nodes[i][j]);
120 edge.setTarget(nodes[k][l]);
121 container.addEdge(edge);
122
123 e = true;
124 }
125 }
126 b = random.nextDouble();
127 }
128 Progress.progress(progressTicket);
129 }
130 }
131
132 Progress.finish(progressTicket);
133 progressTicket = null;
134 }
135
136 private int d(int i, int j, int k, int l) {
137 return Math.abs(k - i) + Math.abs(l - j);
138 }
139
140 private int dtb(int i, int j, int k, int l) {
141 return Math.min(Math.abs(k - i), n - Math.abs(k - i)) + Math.min(Math.abs(l - j), n - Math.abs(l - j));
142 }
143
144 public int getn() {
145 return n;
146 }
147
148 public int getp() {
149 return p;
150 }
151
152 public int getq() {
153 return q;
154 }
155
156 public int getr() {
157 return r;
158 }
159
160 public boolean isTorusBased() {
161 return torusBased;
162 }
163
164 public void setn(int n) {
165 this.n = n;
166 }
167
168 public void setp(int p) {
169 this.p = p;
170 }
171
172 public void setq(int q) {
173 this.q = q;
174 }
175
176 public void setr(int r) {
177 this.r = r;
178 }
179
180 public void setTorusBased(boolean torusBased) {
181 this.torusBased = torusBased;
182 }
183
184 public String getName() {
185 return "Kleinberg Small World model";
186 }
187
188 public GeneratorUI getUI() {
189 return Lookup.getDefault().lookup(KleinbergUI.class);
190 }
191
192 public boolean cancel() {
193 cancel = true;
194 return true;
195 }
196
197 public void setProgressTicket(ProgressTicket progressTicket) {
198 this.progressTicket = progressTicket;
199 }
200}
0201
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/KleinbergUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface KleinbergUI extends GeneratorUI {
31
32}
033
=== removed file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java 2010-09-27 08:43:21 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatz.java 1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20*/
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDraft;
28import org.gephi.io.importer.api.NodeDraft;
29import org.gephi.utils.progress.Progress;
30import org.gephi.utils.progress.ProgressTicket;
31import org.openide.util.Lookup;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 * @author Mathieu Bastian
37 */
38@ServiceProvider(service = Generator.class)
39public class WattsStrogatz implements Generator {
40
41 protected int numberOfNodes = 50;
42 protected int numberOfNeighbors = 3;
43 protected double rewiringProbability = 0.5;
44 protected ProgressTicket progress;
45 protected boolean cancel = false;
46
47 public void generate(ContainerLoader container) {
48 Progress.start(progress, numberOfNodes);
49 Random random = new Random();
50
51 NodeDraft[] nodeArray = new NodeDraft[numberOfNodes];
52
53 //Create ring lattice
54 for (int i = 0; i < numberOfNodes && !cancel; i++) {
55 NodeDraft node = container.factory().newNodeDraft();
56 node.setLabel("Node " + i);
57 nodeArray[i] = node;
58 container.addNode(node);
59 }
60 for (int i = 0; i < numberOfNodes && !cancel; i++) {
61 for (int j = 0; j < numberOfNeighbors; j++) {
62 EdgeDraft edge = container.factory().newEdgeDraft();
63 edge.setSource(nodeArray[i]);
64 edge.setTarget(nodeArray[(i + (numberOfNeighbors - j)) % numberOfNodes]);
65 container.addEdge(edge);
66 }
67 }
68
69 //Rewire edges
70 for (int i = 0; i < numberOfNodes && !cancel; i++) {
71 for (int s = 1; s <= numberOfNeighbors && !cancel; s++) {
72 while (true) {
73 // randomly rewire a proportion, beta, of the edges in the graph.
74 double r = random.nextDouble();
75 if (r < rewiringProbability) {
76 int v = random.nextInt(numberOfNeighbors);
77
78 NodeDraft vthNode = nodeArray[v];
79 NodeDraft ithNode = nodeArray[i];
80 NodeDraft kthNode = nodeArray[((i + s) % numberOfNodes)];//upIndex(i, s));
81 EdgeDraft e = container.getEdge(ithNode, kthNode);
82
83 if (kthNode != vthNode && container.getEdge(kthNode, vthNode) == null) {
84 container.removeEdge(e);
85 EdgeDraft edgeDraft = container.factory().newEdgeDraft();
86 edgeDraft.setSource(kthNode);
87 edgeDraft.setTarget(vthNode);
88 container.addEdge(edgeDraft);
89 break;
90 }
91 } else {
92 break;
93 }
94 }
95 }
96 Progress.progress(progress);
97 }
98
99 Progress.finish(progress);
100 progress = null;
101 }
102
103 public int getNumberOfNeighbors() {
104 return numberOfNeighbors;
105 }
106
107 public void setNumberOfNeighbors(int numberOfNeighbors) {
108 if (numberOfNeighbors < 2 || numberOfNeighbors > numberOfNodes / 2) {
109 throw new IllegalArgumentException("Neighbors must be between 2 and numberOfNodes / 2");
110 }
111 this.numberOfNeighbors = numberOfNeighbors;
112 }
113
114 public int getNumberOfNodes() {
115 return numberOfNodes;
116 }
117
118 public void setNumberOfNodes(int numberOfNodes) {
119 this.numberOfNodes = numberOfNodes;
120 }
121
122 public double getRewiringProbability() {
123 return rewiringProbability;
124 }
125
126 public void setRewiringProbability(double rewiringProbability) {
127 if (rewiringProbability < 0 || rewiringProbability > 1) {
128 throw new IllegalArgumentException("Probability must be between 0.0 and 1.0");
129 }
130 this.rewiringProbability = rewiringProbability;
131 }
132
133 public String getName() {
134 return "Watts-Strogatz Small World";
135 }
136
137 public GeneratorUI getUI() {
138 return Lookup.getDefault().lookup(WattsStrogatzUI.class);
139 }
140
141 public boolean cancel() {
142 cancel = true;
143 return true;
144 }
145
146 public void setProgressTicket(ProgressTicket progressTicket) {
147 this.progress = progressTicket;
148 }
149}
1500
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlpha.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,188 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.ArrayList;
24import java.util.List;
25import java.util.Random;
26import org.gephi.io.generator.spi.Generator;
27import org.gephi.io.generator.spi.GeneratorUI;
28import org.gephi.io.importer.api.ContainerLoader;
29import org.gephi.io.importer.api.EdgeDefault;
30import org.gephi.io.importer.api.EdgeDraft;
31import org.gephi.io.importer.api.NodeDraft;
32import org.gephi.utils.progress.Progress;
33import org.gephi.utils.progress.ProgressTicket;
34import org.openide.util.Lookup;
35import org.openide.util.lookup.ServiceProvider;
36
37/**
38 * Generates an undirected connected graph.
39 *
40 * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model
41 * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf
42 * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf
43 * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf
44 *
45 * n > k > 0
46 * 0 <= alpha
47 *
48 * O(n^3 * k)
49 *
50 * @author Cezary Bartosiak
51 */
52@ServiceProvider(service = Generator.class)
53public class WattsStrogatzAlpha implements Generator {
54 private boolean cancel = false;
55 private ProgressTicket progressTicket;
56
57 private int n = 20;
58 private int k = 4;
59 private double alpha = 3.5;
60 private double p = Math.pow(10, -10);
61
62 public void generate(ContainerLoader container) {
63 Progress.start(progressTicket, n + n + n * k / 2);
64 Random random = new Random();
65 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
66
67 NodeDraft[] nodes = new NodeDraft[n];
68
69 // Creating a regular ring lattice
70 int ec = 0;
71 for (int i = 0; i < n && !cancel; ++i) {
72 NodeDraft node = container.factory().newNodeDraft();
73 node.setLabel("Node " + i);
74 nodes[i] = node;
75 container.addNode(node);
76 Progress.progress(progressTicket);
77 }
78 for (int i = 0; i < n && !cancel; ++i) {
79 EdgeDraft edge = container.factory().newEdgeDraft();
80 edge.setSource(nodes[i]);
81 edge.setTarget(nodes[(i + 1) % n]);
82 container.addEdge(edge);
83 ec++;
84 Progress.progress(progressTicket);
85 }
86
87 // Creating n * k / 2 edges
88 List<Integer> ids = new ArrayList<Integer>();
89 while (ec < n * k / 2 && !cancel) {
90 for (int i = 0; i < n && !cancel; ++i)
91 ids.add(new Integer(i));
92 while (ec < n * k / 2 && ids.size() > 0 && !cancel) {
93 Integer i = ids.remove(random.nextInt(ids.size()));
94 double[] Rij = new double[n];
95 double sumRij = 0.0;
96 for (int j = 0; j < n && !cancel; ++j) {
97 Rij[j] = calculateRij(container, nodes, i, j);
98 sumRij += Rij[j];
99 }
100 double r = random.nextDouble();
101 double pij = 0.0;
102 for (int j = 0; j < n && !cancel; ++j)
103 if (i != j) {
104 pij += Rij[j] / sumRij;
105 if (r <= pij) {
106 EdgeDraft edge = container.factory().newEdgeDraft();
107 edge.setSource(nodes[i]);
108 edge.setTarget(nodes[j]);
109 container.addEdge(edge);
110 ec++;
111
112 Progress.progress(progressTicket);
113 break;
114 }
115 }
116 }
117 }
118
119 Progress.finish(progressTicket);
120 progressTicket = null;
121 }
122
123 public double calculateRij(ContainerLoader container, NodeDraft[] nodes, int i, int j) {
124 if (i == j || edgeExists(container, nodes[i], nodes[j]))
125 return 0;
126 int mij = calculatemij(container, nodes, i, j);
127 if (mij >= k)
128 return 1;
129 if (mij == 0)
130 return p;
131 return Math.pow(mij / k, alpha) * (1 - p) + p;
132 }
133
134 public int calculatemij(ContainerLoader container, NodeDraft[] nodes, int i, int j) {
135 int mij = 0;
136 for (int l = 0; l < n && !cancel; ++l)
137 if (l != i && l != j &&
138 edgeExists(container, nodes[i], nodes[l]) &&
139 edgeExists(container, nodes[j], nodes[l]))
140 mij++;
141 return mij;
142 }
143
144 private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
145 return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
146 }
147
148 public int getn() {
149 return n;
150 }
151
152 public int getk() {
153 return k;
154 }
155
156 public double getalpha() {
157 return alpha;
158 }
159
160 public void setn(int n) {
161 this.n = n;
162 }
163
164 public void setk(int k) {
165 this.k = k;
166 }
167
168 public void setalpha(double alpha) {
169 this.alpha = alpha;
170 }
171
172 public String getName() {
173 return "Watts-Strogatz Small World model Alpha";
174 }
175
176 public GeneratorUI getUI() {
177 return Lookup.getDefault().lookup(WattsStrogatzAlphaUI.class);
178 }
179
180 public boolean cancel() {
181 cancel = true;
182 return true;
183 }
184
185 public void setProgressTicket(ProgressTicket progressTicket) {
186 this.progressTicket = progressTicket;
187 }
188}
0189
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzAlphaUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface WattsStrogatzAlphaUI extends GeneratorUI {
31
32}
033
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBeta.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,157 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import java.util.Random;
24import org.gephi.io.generator.spi.Generator;
25import org.gephi.io.generator.spi.GeneratorUI;
26import org.gephi.io.importer.api.ContainerLoader;
27import org.gephi.io.importer.api.EdgeDefault;
28import org.gephi.io.importer.api.EdgeDraft;
29import org.gephi.io.importer.api.NodeDraft;
30import org.gephi.utils.progress.Progress;
31import org.gephi.utils.progress.ProgressTicket;
32import org.openide.util.Lookup;
33import org.openide.util.lookup.ServiceProvider;
34
35/**
36 * Generates an undirected not necessarily connected graph.
37 *
38 * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model
39 * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf
40 * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf
41 * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf
42 *
43 * N > K >= ln(N) >= 1
44 * K % 2 == 0
45 * 0 <= beta <= 1
46 *
47 * Ω(N * K)
48 *
49 * @author Cezary Bartosiak
50 */
51@ServiceProvider(service = Generator.class)
52public class WattsStrogatzBeta implements Generator {
53 private boolean cancel = false;
54 private ProgressTicket progressTicket;
55
56 private int N = 20;
57 private int K = 4;
58 private double beta = 0.2;
59
60 public void generate(ContainerLoader container) {
61 Progress.start(progressTicket, N + N * K);
62 Random random = new Random();
63 container.setEdgeDefault(EdgeDefault.UNDIRECTED);
64
65 NodeDraft[] nodes = new NodeDraft[N];
66
67 // Creating a regular ring lattice
68 for (int i = 0; i < N && !cancel; ++i) {
69 NodeDraft node = container.factory().newNodeDraft();
70 node.setLabel("Node " + i);
71 nodes[i] = node;
72 container.addNode(node);
73 Progress.progress(progressTicket);
74 }
75 for (int i = 0; i < N && !cancel; ++i)
76 for (int j = 1; j <= K / 2 && !cancel; ++j) {
77 EdgeDraft edge = container.factory().newEdgeDraft();
78 edge.setSource(nodes[i]);
79 edge.setTarget(nodes[(i + j) % N]);
80 container.addEdge(edge);
81 Progress.progress(progressTicket);
82 }
83
84 // Rewiring edges
85 for (int i = 0; i < N && !cancel; ++i)
86 for (int j = 1; j <= K / 2 && !cancel; ++j)
87 if (random.nextDouble() <= beta) {
88 container.removeEdge(getEdge(container, nodes[i], nodes[(i + j) % N]));
89
90 int k = random.nextInt(N);
91 while ((k == i || edgeExists(container, nodes[i], nodes[k])) && !cancel)
92 k = random.nextInt(N);
93
94 EdgeDraft edge = container.factory().newEdgeDraft();
95 edge.setSource(nodes[i]);
96 edge.setTarget(nodes[k]);
97 container.addEdge(edge);
98
99 Progress.progress(progressTicket);
100 }
101
102 Progress.finish(progressTicket);
103 progressTicket = null;
104 }
105
106 private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
107 return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
108 }
109
110 private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
111 EdgeDraft edge = container.getEdge(node1, node2);
112 if (edge == null)
113 edge = container.getEdge(node2, node1);
114 return edge;
115 }
116
117 public int getN() {
118 return N;
119 }
120
121 public int getK() {
122 return K;
123 }
124
125 public double getbeta() {
126 return beta;
127 }
128
129 public void setN(int N) {
130 this.N = N;
131 }
132
133 public void setK(int K) {
134 this.K = K;
135 }
136
137 public void setbeta(double beta) {
138 this.beta = beta;
139 }
140
141 public String getName() {
142 return "Watts-Strogatz Small World model Beta";
143 }
144
145 public GeneratorUI getUI() {
146 return Lookup.getDefault().lookup(WattsStrogatzBetaUI.class);
147 }
148
149 public boolean cancel() {
150 cancel = true;
151 return true;
152 }
153
154 public void setProgressTicket(ProgressTicket progressTicket) {
155 this.progressTicket = progressTicket;
156 }
157}
0158
=== added file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java 1970-01-01 00:00:00 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzBetaUI.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 *
28 * @author Cezary Bartosiak
29 */
30public interface WattsStrogatzBetaUI extends GeneratorUI {
31
32}
033
=== removed file 'GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java'
--- GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java 2010-07-15 14:48:14 +0000
+++ GeneratorPlugin/src/org/gephi/io/generator/plugin/WattsStrogatzUI.java 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20*/
21package org.gephi.io.generator.plugin;
22
23import org.gephi.io.generator.spi.GeneratorUI;
24
25/**
26 *
27 * @author Mathieu Bastian
28 */
29public interface WattsStrogatzUI extends GeneratorUI {
30}
310
=== modified file 'GeneratorPluginUI/manifest.mf'
--- GeneratorPluginUI/manifest.mf 2010-08-19 09:38:57 +0000
+++ GeneratorPluginUI/manifest.mf 2010-12-17 03:47:30 +0000
@@ -2,5 +2,5 @@
2AutoUpdate-Essential-Module: true2AutoUpdate-Essential-Module: true
3OpenIDE-Module: org.gephi.ui.generator.plugin3OpenIDE-Module: org.gephi.ui.generator.plugin
4OpenIDE-Module-Localizing-Bundle: org/gephi/ui/generator/plugin/Bundle.properties4OpenIDE-Module-Localizing-Bundle: org/gephi/ui/generator/plugin/Bundle.properties
5OpenIDE-Module-Specification-Version: 0.7.15OpenIDE-Module-Specification-Version: 0.7.2
66
77
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,110 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[330, 102]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" attributes="0">
25 <Group type="103" groupAlignment="0" attributes="0">
26 <Group type="102" attributes="0">
27 <EmptySpace max="-2" attributes="0"/>
28 <Group type="103" groupAlignment="0" attributes="0">
29 <Component id="rLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="hLabel" alignment="0" min="-2" max="-2" attributes="0"/>
31 </Group>
32 <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
33 <Group type="103" groupAlignment="1" attributes="0">
34 <Component id="hField" alignment="0" pref="134" max="32767" attributes="1"/>
35 <Component id="rField" alignment="0" pref="134" max="32767" attributes="1"/>
36 </Group>
37 </Group>
38 <Group type="102" alignment="0" attributes="0">
39 <EmptySpace min="-2" pref="136" max="-2" attributes="0"/>
40 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
41 </Group>
42 </Group>
43 <EmptySpace max="-2" attributes="0"/>
44 </Group>
45 </Group>
46 </DimensionLayout>
47 <DimensionLayout dim="1">
48 <Group type="103" groupAlignment="0" attributes="0">
49 <Group type="102" alignment="0" attributes="0">
50 <EmptySpace max="-2" attributes="0"/>
51 <Group type="103" groupAlignment="3" attributes="0">
52 <Component id="rField" alignment="3" min="-2" max="-2" attributes="0"/>
53 <Component id="rLabel" alignment="3" min="-2" max="-2" attributes="0"/>
54 </Group>
55 <EmptySpace max="-2" attributes="0"/>
56 <Group type="103" groupAlignment="3" attributes="0">
57 <Component id="hField" alignment="3" min="-2" max="-2" attributes="0"/>
58 <Component id="hLabel" alignment="3" min="-2" max="-2" attributes="0"/>
59 </Group>
60 <EmptySpace max="-2" attributes="0"/>
61 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
62 <EmptySpace max="32767" attributes="0"/>
63 </Group>
64 </Group>
65 </DimensionLayout>
66 </Layout>
67 <SubComponents>
68 <Component class="javax.swing.JTextField" name="rField">
69 <Properties>
70 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72 </Property>
73 </Properties>
74 <AuxValues>
75 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
76 </AuxValues>
77 </Component>
78 <Component class="javax.swing.JTextField" name="hField">
79 <Properties>
80 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
82 </Property>
83 </Properties>
84 <AuxValues>
85 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
86 </AuxValues>
87 </Component>
88 <Component class="javax.swing.JLabel" name="rLabel">
89 <Properties>
90 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
91 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
92 </Property>
93 </Properties>
94 </Component>
95 <Component class="javax.swing.JLabel" name="hLabel">
96 <Properties>
97 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
98 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
99 </Property>
100 </Properties>
101 </Component>
102 <Component class="javax.swing.JLabel" name="constraintsLabel">
103 <Properties>
104 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
105 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
106 </Property>
107 </Properties>
108 </Component>
109 </SubComponents>
110</Form>
0111
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreePanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,180 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.netbeans.validation.api.Problems;
24import org.netbeans.validation.api.Validator;
25import org.netbeans.validation.api.builtin.Validators;
26import org.netbeans.validation.api.ui.ValidationGroup;
27import org.netbeans.validation.api.ui.ValidationPanel;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34public class BalancedTreePanel extends javax.swing.JPanel {
35
36 /** Creates new form BarabasiAlbertPanel */
37 public BalancedTreePanel() {
38 initComponents();
39 }
40
41 public static ValidationPanel createValidationPanel(BalancedTreePanel innerPanel) {
42 ValidationPanel validationPanel = new ValidationPanel();
43 if (innerPanel == null)
44 innerPanel = new BalancedTreePanel();
45 validationPanel.setInnerComponent(innerPanel);
46
47 ValidationGroup group = validationPanel.getValidationGroup();
48
49 group.add(innerPanel.rField, Validators.REQUIRE_NON_EMPTY_STRING,
50 new rValidator(innerPanel));
51 group.add(innerPanel.hField, Validators.REQUIRE_NON_EMPTY_STRING,
52 new hValidator(innerPanel));
53
54 return validationPanel;
55 }
56
57 private static class rValidator implements Validator<String> {
58 private BalancedTreePanel innerPanel;
59
60 public rValidator(BalancedTreePanel innerPanel) {
61 this.innerPanel = innerPanel;
62 }
63
64 @Override
65 public boolean validate(Problems problems, String compName, String model) {
66 boolean result = false;
67
68 try {
69 Integer r = Integer.parseInt(innerPanel.rField.getText());
70 result = r >= 2;
71 }
72 catch (Exception e) { }
73 if (!result) {
74 String message = "<html>r &gt;= 2</html>";
75 problems.add(message);
76 }
77
78 return result;
79 }
80 }
81
82 private static class hValidator implements Validator<String> {
83 private BalancedTreePanel innerPanel;
84
85 public hValidator(BalancedTreePanel innerPanel) {
86 this.innerPanel = innerPanel;
87 }
88
89 @Override
90 public boolean validate(Problems problems, String compName, String model) {
91 boolean result = false;
92
93 try {
94 Integer h = Integer.parseInt(innerPanel.hField.getText());
95 result = h >= 1;
96 }
97 catch (Exception e) { }
98 if (!result) {
99 String message = "<html>h &gt;= 1</html>";
100 problems.add(message);
101 }
102
103 return result;
104 }
105 }
106
107 /** This method is called from within the constructor to
108 * initialize the form.
109 * WARNING: Do NOT modify this code. The content of this method is
110 * always regenerated by the Form Editor.
111 */
112 @SuppressWarnings("unchecked")
113 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
114 private void initComponents() {
115
116 rField = new javax.swing.JTextField();
117 hField = new javax.swing.JTextField();
118 rLabel = new javax.swing.JLabel();
119 hLabel = new javax.swing.JLabel();
120 constraintsLabel = new javax.swing.JLabel();
121
122 setPreferredSize(new java.awt.Dimension(330, 102));
123
124 rField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rField.text")); // NOI18N
125
126 hField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hField.text")); // NOI18N
127
128 rLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rLabel.text")); // NOI18N
129
130 hLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hLabel.text")); // NOI18N
131
132 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.constraintsLabel.text")); // NOI18N
133
134 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
135 this.setLayout(layout);
136 layout.setHorizontalGroup(
137 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
138 .addGroup(layout.createSequentialGroup()
139 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
140 .addGroup(layout.createSequentialGroup()
141 .addContainerGap()
142 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
143 .addComponent(rLabel)
144 .addComponent(hLabel))
145 .addGap(60, 60, 60)
146 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
147 .addComponent(hField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
148 .addComponent(rField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)))
149 .addGroup(layout.createSequentialGroup()
150 .addGap(136, 136, 136)
151 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
152 .addContainerGap())
153 );
154 layout.setVerticalGroup(
155 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
156 .addGroup(layout.createSequentialGroup()
157 .addContainerGap()
158 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
159 .addComponent(rField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
160 .addComponent(rLabel))
161 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
162 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
163 .addComponent(hField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
164 .addComponent(hLabel))
165 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
166 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
167 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
168 );
169 }// </editor-fold>//GEN-END:initComponents
170
171
172 // Variables declaration - do not modify//GEN-BEGIN:variables
173 private javax.swing.JLabel constraintsLabel;
174 protected javax.swing.JTextField hField;
175 private javax.swing.JLabel hLabel;
176 protected javax.swing.JTextField rField;
177 private javax.swing.JLabel rLabel;
178 // End of variables declaration//GEN-END:variables
179
180}
0181
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BalancedTreeUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.BalancedTree;
25import org.gephi.io.generator.plugin.BalancedTreeUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = BalancedTreeUI.class)
35public class BalancedTreeUIImpl implements BalancedTreeUI {
36 private BalancedTreePanel panel;
37 private BalancedTree balancedTree;
38
39 public BalancedTreeUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new BalancedTreePanel();
44 return BalancedTreePanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.balancedTree = (BalancedTree)generator;
49
50 if (panel == null)
51 panel = new BalancedTreePanel();
52
53 panel.rField.setText(String.valueOf(balancedTree.getr()));
54 panel.hField.setText(String.valueOf(balancedTree.geth()));
55 }
56
57 public void unsetup() {
58 balancedTree.setr(Integer.parseInt(panel.rField.getText()));
59 balancedTree.seth(Integer.parseInt(panel.hField.getText()));
60 panel = null;
61 }
62}
063
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,182 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[548, 236]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" attributes="0">
25 <Group type="103" groupAlignment="0" attributes="0">
26 <Group type="102" attributes="0">
27 <EmptySpace max="-2" attributes="0"/>
28 <Group type="103" groupAlignment="0" attributes="0">
29 <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
31 <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
32 <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/>
33 <Component id="qLabel" alignment="0" min="-2" max="-2" attributes="0"/>
34 </Group>
35 <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
36 <Group type="103" groupAlignment="0" attributes="0">
37 <Component id="qField" alignment="0" pref="153" max="32767" attributes="1"/>
38 <Component id="pField" alignment="0" pref="153" max="32767" attributes="1"/>
39 <Component id="m0Field" alignment="0" pref="153" max="32767" attributes="1"/>
40 <Component id="MField" alignment="0" pref="153" max="32767" attributes="1"/>
41 <Component id="NField" alignment="0" pref="153" max="32767" attributes="1"/>
42 </Group>
43 </Group>
44 <Group type="102" alignment="0" attributes="0">
45 <EmptySpace min="-2" pref="233" max="-2" attributes="0"/>
46 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
47 </Group>
48 </Group>
49 <EmptySpace max="-2" attributes="0"/>
50 </Group>
51 </Group>
52 </DimensionLayout>
53 <DimensionLayout dim="1">
54 <Group type="103" groupAlignment="0" attributes="0">
55 <Group type="102" alignment="0" attributes="0">
56 <EmptySpace max="-2" attributes="0"/>
57 <Group type="103" groupAlignment="3" attributes="0">
58 <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
59 <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
60 </Group>
61 <EmptySpace max="-2" attributes="0"/>
62 <Group type="103" groupAlignment="3" attributes="0">
63 <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
64 <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
65 </Group>
66 <EmptySpace max="-2" attributes="0"/>
67 <Group type="103" groupAlignment="3" attributes="0">
68 <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
69 <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
70 </Group>
71 <EmptySpace max="-2" attributes="0"/>
72 <Group type="103" groupAlignment="3" attributes="0">
73 <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/>
74 <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/>
75 </Group>
76 <EmptySpace max="-2" attributes="0"/>
77 <Group type="103" groupAlignment="3" attributes="0">
78 <Component id="qField" alignment="3" min="-2" max="-2" attributes="0"/>
79 <Component id="qLabel" alignment="3" min="-2" max="-2" attributes="0"/>
80 </Group>
81 <EmptySpace max="-2" attributes="0"/>
82 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
83 <EmptySpace max="32767" attributes="0"/>
84 </Group>
85 </Group>
86 </DimensionLayout>
87 </Layout>
88 <SubComponents>
89 <Component class="javax.swing.JLabel" name="MLabel">
90 <Properties>
91 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
92 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
93 </Property>
94 </Properties>
95 </Component>
96 <Component class="javax.swing.JTextField" name="MField">
97 <Properties>
98 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
99 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
100 </Property>
101 </Properties>
102 <AuxValues>
103 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
104 </AuxValues>
105 </Component>
106 <Component class="javax.swing.JTextField" name="NField">
107 <Properties>
108 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
109 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
110 </Property>
111 </Properties>
112 <AuxValues>
113 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
114 </AuxValues>
115 </Component>
116 <Component class="javax.swing.JTextField" name="m0Field">
117 <Properties>
118 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
119 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
120 </Property>
121 </Properties>
122 <AuxValues>
123 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
124 </AuxValues>
125 </Component>
126 <Component class="javax.swing.JLabel" name="NLabel">
127 <Properties>
128 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
129 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
130 </Property>
131 </Properties>
132 </Component>
133 <Component class="javax.swing.JLabel" name="m0Label">
134 <Properties>
135 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
136 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
137 </Property>
138 </Properties>
139 </Component>
140 <Component class="javax.swing.JLabel" name="constraintsLabel">
141 <Properties>
142 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
143 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
144 </Property>
145 </Properties>
146 </Component>
147 <Component class="javax.swing.JLabel" name="pLabel">
148 <Properties>
149 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
150 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
151 </Property>
152 </Properties>
153 </Component>
154 <Component class="javax.swing.JTextField" name="pField">
155 <Properties>
156 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
157 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
158 </Property>
159 </Properties>
160 <AuxValues>
161 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
162 </AuxValues>
163 </Component>
164 <Component class="javax.swing.JLabel" name="qLabel">
165 <Properties>
166 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
167 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
168 </Property>
169 </Properties>
170 </Component>
171 <Component class="javax.swing.JTextField" name="qField">
172 <Properties>
173 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
174 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
175 </Property>
176 </Properties>
177 <AuxValues>
178 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
179 </AuxValues>
180 </Component>
181 </SubComponents>
182</Form>
0183
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,238 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.BetweenZeroAndOneValidator;
24import org.gephi.lib.validation.PositiveNumberValidator;
25import org.netbeans.validation.api.Problems;
26import org.netbeans.validation.api.Validator;
27import org.netbeans.validation.api.builtin.Validators;
28import org.netbeans.validation.api.ui.ValidationGroup;
29import org.netbeans.validation.api.ui.ValidationPanel;
30
31/**
32 *
33 *
34 * @author Cezary Bartosiak
35 */
36public class BarabasiAlbertGeneralizedPanel extends javax.swing.JPanel {
37
38 /** Creates new form BarabasiAlbertPanel */
39 public BarabasiAlbertGeneralizedPanel() {
40 initComponents();
41 }
42
43 public static ValidationPanel createValidationPanel(BarabasiAlbertGeneralizedPanel innerPanel) {
44 ValidationPanel validationPanel = new ValidationPanel();
45 if (innerPanel == null)
46 innerPanel = new BarabasiAlbertGeneralizedPanel();
47 validationPanel.setInnerComponent(innerPanel);
48
49 ValidationGroup group = validationPanel.getValidationGroup();
50
51 group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
52 new PositiveNumberValidator());
53 group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
54 new PositiveNumberValidator());
55 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
56 new PositiveNumberValidator());
57 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
58 new MValidator(innerPanel));
59 group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
60 new BetweenZeroAndOneValidator());
61 group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
62 new pqValidator(innerPanel));
63 group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING,
64 new BetweenZeroAndOneValidator());
65 group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING,
66 new pqValidator(innerPanel));
67
68 return validationPanel;
69 }
70
71 private static class MValidator implements Validator<String> {
72 private BarabasiAlbertGeneralizedPanel innerPanel;
73
74 public MValidator(BarabasiAlbertGeneralizedPanel innerPanel) {
75 this.innerPanel = innerPanel;
76 }
77
78 @Override
79 public boolean validate(Problems problems, String compName, String model) {
80 boolean result = false;
81
82 try {
83 Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
84 Integer M = Integer.parseInt(innerPanel.MField.getText());
85 result = M <= m0;
86 }
87 catch (Exception e) { }
88 if (!result) {
89 String message = "<html>M &lt;= m0</html>";
90 problems.add(message);
91 }
92
93 return result;
94 }
95 }
96
97 private static class pqValidator implements Validator<String> {
98 private BarabasiAlbertGeneralizedPanel innerPanel;
99
100 public pqValidator(BarabasiAlbertGeneralizedPanel innerPanel) {
101 this.innerPanel = innerPanel;
102 }
103
104 @Override
105 public boolean validate(Problems problems, String compName, String model) {
106 boolean result = false;
107
108 try {
109 Double p = Double.parseDouble(innerPanel.pField.getText());
110 Double q = Double.parseDouble(innerPanel.qField.getText());
111 result = p + q < 1.0;
112 }
113 catch (Exception e) { }
114 if (!result) {
115 String message = "<html>p + q &lt; 1.0</html>";
116 problems.add(message);
117 }
118
119 return result;
120 }
121 }
122
123 /** This method is called from within the constructor to
124 * initialize the form.
125 * WARNING: Do NOT modify this code. The content of this method is
126 * always regenerated by the Form Editor.
127 */
128 @SuppressWarnings("unchecked")
129 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
130 private void initComponents() {
131
132 MLabel = new javax.swing.JLabel();
133 MField = new javax.swing.JTextField();
134 NField = new javax.swing.JTextField();
135 m0Field = new javax.swing.JTextField();
136 NLabel = new javax.swing.JLabel();
137 m0Label = new javax.swing.JLabel();
138 constraintsLabel = new javax.swing.JLabel();
139 pLabel = new javax.swing.JLabel();
140 pField = new javax.swing.JTextField();
141 qLabel = new javax.swing.JLabel();
142 qField = new javax.swing.JTextField();
143
144 setPreferredSize(new java.awt.Dimension(548, 236));
145
146 MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MLabel.text")); // NOI18N
147
148 MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MField.text")); // NOI18N
149
150 NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NField.text")); // NOI18N
151
152 m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Field.text")); // NOI18N
153
154 NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NLabel.text")); // NOI18N
155
156 m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Label.text")); // NOI18N
157
158 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.constraintsLabel.text")); // NOI18N
159
160 pLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pLabel.text")); // NOI18N
161
162 pField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pField.text")); // NOI18N
163
164 qLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qLabel.text")); // NOI18N
165
166 qField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qField.text")); // NOI18N
167
168 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
169 this.setLayout(layout);
170 layout.setHorizontalGroup(
171 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
172 .addGroup(layout.createSequentialGroup()
173 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174 .addGroup(layout.createSequentialGroup()
175 .addContainerGap()
176 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177 .addComponent(NLabel)
178 .addComponent(m0Label)
179 .addComponent(MLabel)
180 .addComponent(pLabel)
181 .addComponent(qLabel))
182 .addGap(25, 25, 25)
183 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addComponent(qField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
185 .addComponent(pField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
186 .addComponent(m0Field, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
187 .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
188 .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)))
189 .addGroup(layout.createSequentialGroup()
190 .addGap(233, 233, 233)
191 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
192 .addContainerGap())
193 );
194 layout.setVerticalGroup(
195 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addGroup(layout.createSequentialGroup()
197 .addContainerGap()
198 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
199 .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
200 .addComponent(NLabel))
201 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
203 .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
204 .addComponent(m0Label))
205 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
206 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
207 .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
208 .addComponent(MLabel))
209 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
210 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
211 .addComponent(pField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
212 .addComponent(pLabel))
213 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
214 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
215 .addComponent(qField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
216 .addComponent(qLabel))
217 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
218 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
219 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
220 );
221 }// </editor-fold>//GEN-END:initComponents
222
223
224 // Variables declaration - do not modify//GEN-BEGIN:variables
225 protected javax.swing.JTextField MField;
226 private javax.swing.JLabel MLabel;
227 protected javax.swing.JTextField NField;
228 private javax.swing.JLabel NLabel;
229 private javax.swing.JLabel constraintsLabel;
230 protected javax.swing.JTextField m0Field;
231 private javax.swing.JLabel m0Label;
232 protected javax.swing.JTextField pField;
233 private javax.swing.JLabel pLabel;
234 protected javax.swing.JTextField qField;
235 private javax.swing.JLabel qLabel;
236 // End of variables declaration//GEN-END:variables
237
238}
0239
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertGeneralizedUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.BarabasiAlbertGeneralized;
25import org.gephi.io.generator.plugin.BarabasiAlbertGeneralizedUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = BarabasiAlbertGeneralizedUI.class)
35public class BarabasiAlbertGeneralizedUIImpl implements BarabasiAlbertGeneralizedUI {
36 private BarabasiAlbertGeneralizedPanel panel;
37 private BarabasiAlbertGeneralized barabasiAlbertGeneralized;
38
39 public BarabasiAlbertGeneralizedUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new BarabasiAlbertGeneralizedPanel();
44 return BarabasiAlbertGeneralizedPanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.barabasiAlbertGeneralized = (BarabasiAlbertGeneralized)generator;
49
50 if (panel == null)
51 panel = new BarabasiAlbertGeneralizedPanel();
52
53 panel.NField.setText(String.valueOf(barabasiAlbertGeneralized.getN()));
54 panel.m0Field.setText(String.valueOf(barabasiAlbertGeneralized.getm0()));
55 panel.MField.setText(String.valueOf(barabasiAlbertGeneralized.getM()));
56 panel.pField.setText(String.valueOf(barabasiAlbertGeneralized.getp()));
57 panel.qField.setText(String.valueOf(barabasiAlbertGeneralized.getq()));
58 }
59
60 public void unsetup() {
61 barabasiAlbertGeneralized.setN(Integer.parseInt(panel.NField.getText()));
62 barabasiAlbertGeneralized.setm0(Integer.parseInt(panel.m0Field.getText()));
63 barabasiAlbertGeneralized.setM(Integer.parseInt(panel.MField.getText()));
64 barabasiAlbertGeneralized.setp(Double.parseDouble(panel.pField.getText()));
65 barabasiAlbertGeneralized.setq(Double.parseDouble(panel.qField.getText()));
66 panel = null;
67 }
68}
069
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,129 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[451, 170]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" alignment="0" attributes="0">
25 <EmptySpace max="-2" attributes="0"/>
26 <Group type="103" groupAlignment="1" attributes="0">
27 <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/>
28 <Group type="103" alignment="1" groupAlignment="0" attributes="0">
29 <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
31 <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
32 </Group>
33 </Group>
34 <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
35 <Group type="103" groupAlignment="1" attributes="0">
36 <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/>
37 <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
38 <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
39 </Group>
40 <EmptySpace max="-2" attributes="0"/>
41 </Group>
42 </Group>
43 </DimensionLayout>
44 <DimensionLayout dim="1">
45 <Group type="103" groupAlignment="0" attributes="0">
46 <Group type="102" alignment="0" attributes="0">
47 <EmptySpace max="-2" attributes="0"/>
48 <Group type="103" groupAlignment="3" attributes="0">
49 <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
50 <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
51 </Group>
52 <EmptySpace max="-2" attributes="0"/>
53 <Group type="103" groupAlignment="3" attributes="0">
54 <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
55 <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
56 </Group>
57 <EmptySpace max="-2" attributes="0"/>
58 <Group type="103" groupAlignment="3" attributes="0">
59 <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
60 <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
61 </Group>
62 <EmptySpace max="-2" attributes="0"/>
63 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
64 <EmptySpace max="32767" attributes="0"/>
65 </Group>
66 </Group>
67 </DimensionLayout>
68 </Layout>
69 <SubComponents>
70 <Component class="javax.swing.JLabel" name="MLabel">
71 <Properties>
72 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
73 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
74 </Property>
75 </Properties>
76 </Component>
77 <Component class="javax.swing.JTextField" name="MField">
78 <Properties>
79 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
80 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
81 </Property>
82 </Properties>
83 <AuxValues>
84 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
85 </AuxValues>
86 </Component>
87 <Component class="javax.swing.JTextField" name="NField">
88 <Properties>
89 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
90 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
91 </Property>
92 </Properties>
93 <AuxValues>
94 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
95 </AuxValues>
96 </Component>
97 <Component class="javax.swing.JTextField" name="m0Field">
98 <Properties>
99 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
100 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
101 </Property>
102 </Properties>
103 <AuxValues>
104 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
105 </AuxValues>
106 </Component>
107 <Component class="javax.swing.JLabel" name="NLabel">
108 <Properties>
109 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
110 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
111 </Property>
112 </Properties>
113 </Component>
114 <Component class="javax.swing.JLabel" name="m0Label">
115 <Properties>
116 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
117 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
118 </Property>
119 </Properties>
120 </Component>
121 <Component class="javax.swing.JLabel" name="constraintsLabel">
122 <Properties>
123 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
124 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
125 </Property>
126 </Properties>
127 </Component>
128 </SubComponents>
129</Form>
0130
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,200 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.PositiveNumberValidator;
24import org.netbeans.validation.api.Problems;
25import org.netbeans.validation.api.Validator;
26import org.netbeans.validation.api.builtin.Validators;
27import org.netbeans.validation.api.ui.ValidationGroup;
28import org.netbeans.validation.api.ui.ValidationPanel;
29
30/**
31 *
32 *
33 * @author Cezary Bartosiak
34 */
35public class BarabasiAlbertPanel extends javax.swing.JPanel {
36
37 /** Creates new form BarabasiAlbertPanel */
38 public BarabasiAlbertPanel() {
39 initComponents();
40 }
41
42 public static ValidationPanel createValidationPanel(BarabasiAlbertPanel innerPanel) {
43 ValidationPanel validationPanel = new ValidationPanel();
44 if (innerPanel == null)
45 innerPanel = new BarabasiAlbertPanel();
46 validationPanel.setInnerComponent(innerPanel);
47
48 ValidationGroup group = validationPanel.getValidationGroup();
49
50 group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
51 new PositiveNumberValidator());
52 group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
53 new PositiveNumberValidator());
54 group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
55 new m0Validator(innerPanel));
56 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
57 new PositiveNumberValidator());
58 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
59 new MValidator(innerPanel));
60
61 return validationPanel;
62 }
63
64 private static class m0Validator implements Validator<String> {
65 private BarabasiAlbertPanel innerPanel;
66
67 public m0Validator(BarabasiAlbertPanel innerPanel) {
68 this.innerPanel = innerPanel;
69 }
70
71 @Override
72 public boolean validate(Problems problems, String compName, String model) {
73 boolean result = false;
74
75 try {
76 Integer N = Integer.parseInt(innerPanel.NField.getText());
77 Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
78 result = m0 < N;
79 }
80 catch (Exception e) { }
81 if (!result) {
82 String message = "<html>m0 &lt; N</html>";
83 problems.add(message);
84 }
85
86 return result;
87 }
88 }
89
90 private static class MValidator implements Validator<String> {
91 private BarabasiAlbertPanel innerPanel;
92
93 public MValidator(BarabasiAlbertPanel innerPanel) {
94 this.innerPanel = innerPanel;
95 }
96
97 @Override
98 public boolean validate(Problems problems, String compName, String model) {
99 boolean result = false;
100
101 try {
102 Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
103 Integer M = Integer.parseInt(innerPanel.MField.getText());
104 result = M <= m0;
105 }
106 catch (Exception e) { }
107 if (!result) {
108 String message = "<html>M &lt;= m0</html>";
109 problems.add(message);
110 }
111
112 return result;
113 }
114 }
115
116 /** This method is called from within the constructor to
117 * initialize the form.
118 * WARNING: Do NOT modify this code. The content of this method is
119 * always regenerated by the Form Editor.
120 */
121 @SuppressWarnings("unchecked")
122 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
123 private void initComponents() {
124
125 MLabel = new javax.swing.JLabel();
126 MField = new javax.swing.JTextField();
127 NField = new javax.swing.JTextField();
128 m0Field = new javax.swing.JTextField();
129 NLabel = new javax.swing.JLabel();
130 m0Label = new javax.swing.JLabel();
131 constraintsLabel = new javax.swing.JLabel();
132
133 setPreferredSize(new java.awt.Dimension(451, 170));
134
135 MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MLabel.text")); // NOI18N
136
137 MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MField.text")); // NOI18N
138
139 NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NField.text")); // NOI18N
140
141 m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Field.text")); // NOI18N
142
143 NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NLabel.text")); // NOI18N
144
145 m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Label.text")); // NOI18N
146
147 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.constraintsLabel.text")); // NOI18N
148
149 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
150 this.setLayout(layout);
151 layout.setHorizontalGroup(
152 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 .addGroup(layout.createSequentialGroup()
154 .addContainerGap()
155 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
156 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
157 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
158 .addComponent(NLabel)
159 .addComponent(m0Label)
160 .addComponent(MLabel)))
161 .addGap(25, 25, 25)
162 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
163 .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
164 .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
165 .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
166 .addContainerGap())
167 );
168 layout.setVerticalGroup(
169 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170 .addGroup(layout.createSequentialGroup()
171 .addContainerGap()
172 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
173 .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
174 .addComponent(NLabel))
175 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
176 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
177 .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
178 .addComponent(m0Label))
179 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
181 .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
182 .addComponent(MLabel))
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
185 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
186 );
187 }// </editor-fold>//GEN-END:initComponents
188
189
190 // Variables declaration - do not modify//GEN-BEGIN:variables
191 protected javax.swing.JTextField MField;
192 private javax.swing.JLabel MLabel;
193 protected javax.swing.JTextField NField;
194 private javax.swing.JLabel NLabel;
195 private javax.swing.JLabel constraintsLabel;
196 protected javax.swing.JTextField m0Field;
197 private javax.swing.JLabel m0Label;
198 // End of variables declaration//GEN-END:variables
199
200}
0201
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,129 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[451, 170]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" alignment="0" attributes="0">
25 <EmptySpace max="-2" attributes="0"/>
26 <Group type="103" groupAlignment="1" attributes="0">
27 <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/>
28 <Group type="103" alignment="1" groupAlignment="0" attributes="0">
29 <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
31 <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
32 </Group>
33 </Group>
34 <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
35 <Group type="103" groupAlignment="1" attributes="0">
36 <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/>
37 <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
38 <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
39 </Group>
40 <EmptySpace max="-2" attributes="0"/>
41 </Group>
42 </Group>
43 </DimensionLayout>
44 <DimensionLayout dim="1">
45 <Group type="103" groupAlignment="0" attributes="0">
46 <Group type="102" alignment="0" attributes="0">
47 <EmptySpace max="-2" attributes="0"/>
48 <Group type="103" groupAlignment="3" attributes="0">
49 <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
50 <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
51 </Group>
52 <EmptySpace max="-2" attributes="0"/>
53 <Group type="103" groupAlignment="3" attributes="0">
54 <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
55 <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
56 </Group>
57 <EmptySpace max="-2" attributes="0"/>
58 <Group type="103" groupAlignment="3" attributes="0">
59 <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
60 <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
61 </Group>
62 <EmptySpace max="-2" attributes="0"/>
63 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
64 <EmptySpace max="32767" attributes="0"/>
65 </Group>
66 </Group>
67 </DimensionLayout>
68 </Layout>
69 <SubComponents>
70 <Component class="javax.swing.JLabel" name="MLabel">
71 <Properties>
72 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
73 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
74 </Property>
75 </Properties>
76 </Component>
77 <Component class="javax.swing.JTextField" name="MField">
78 <Properties>
79 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
80 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
81 </Property>
82 </Properties>
83 <AuxValues>
84 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
85 </AuxValues>
86 </Component>
87 <Component class="javax.swing.JTextField" name="NField">
88 <Properties>
89 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
90 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
91 </Property>
92 </Properties>
93 <AuxValues>
94 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
95 </AuxValues>
96 </Component>
97 <Component class="javax.swing.JTextField" name="m0Field">
98 <Properties>
99 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
100 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
101 </Property>
102 </Properties>
103 <AuxValues>
104 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
105 </AuxValues>
106 </Component>
107 <Component class="javax.swing.JLabel" name="NLabel">
108 <Properties>
109 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
110 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
111 </Property>
112 </Properties>
113 </Component>
114 <Component class="javax.swing.JLabel" name="m0Label">
115 <Properties>
116 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
117 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
118 </Property>
119 </Properties>
120 </Component>
121 <Component class="javax.swing.JLabel" name="constraintsLabel">
122 <Properties>
123 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
124 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
125 </Property>
126 </Properties>
127 </Component>
128 </SubComponents>
129</Form>
0130
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,200 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.PositiveNumberValidator;
24import org.netbeans.validation.api.Problems;
25import org.netbeans.validation.api.Validator;
26import org.netbeans.validation.api.builtin.Validators;
27import org.netbeans.validation.api.ui.ValidationGroup;
28import org.netbeans.validation.api.ui.ValidationPanel;
29
30/**
31 *
32 *
33 * @author Cezary Bartosiak
34 */
35public class BarabasiAlbertSimplifiedAPanel extends javax.swing.JPanel {
36
37 /** Creates new form BarabasiAlbertPanel */
38 public BarabasiAlbertSimplifiedAPanel() {
39 initComponents();
40 }
41
42 public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedAPanel innerPanel) {
43 ValidationPanel validationPanel = new ValidationPanel();
44 if (innerPanel == null)
45 innerPanel = new BarabasiAlbertSimplifiedAPanel();
46 validationPanel.setInnerComponent(innerPanel);
47
48 ValidationGroup group = validationPanel.getValidationGroup();
49
50 group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
51 new PositiveNumberValidator());
52 group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
53 new PositiveNumberValidator());
54 group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
55 new m0Validator(innerPanel));
56 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
57 new PositiveNumberValidator());
58 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
59 new MValidator(innerPanel));
60
61 return validationPanel;
62 }
63
64 private static class m0Validator implements Validator<String> {
65 private BarabasiAlbertSimplifiedAPanel innerPanel;
66
67 public m0Validator(BarabasiAlbertSimplifiedAPanel innerPanel) {
68 this.innerPanel = innerPanel;
69 }
70
71 @Override
72 public boolean validate(Problems problems, String compName, String model) {
73 boolean result = false;
74
75 try {
76 Integer N = Integer.parseInt(innerPanel.NField.getText());
77 Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
78 result = m0 < N;
79 }
80 catch (Exception e) { }
81 if (!result) {
82 String message = "<html>m0 &lt; N</html>";
83 problems.add(message);
84 }
85
86 return result;
87 }
88 }
89
90 private static class MValidator implements Validator<String> {
91 private BarabasiAlbertSimplifiedAPanel innerPanel;
92
93 public MValidator(BarabasiAlbertSimplifiedAPanel innerPanel) {
94 this.innerPanel = innerPanel;
95 }
96
97 @Override
98 public boolean validate(Problems problems, String compName, String model) {
99 boolean result = false;
100
101 try {
102 Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
103 Integer M = Integer.parseInt(innerPanel.MField.getText());
104 result = M <= m0;
105 }
106 catch (Exception e) { }
107 if (!result) {
108 String message = "<html>M &lt;= m0</html>";
109 problems.add(message);
110 }
111
112 return result;
113 }
114 }
115
116 /** This method is called from within the constructor to
117 * initialize the form.
118 * WARNING: Do NOT modify this code. The content of this method is
119 * always regenerated by the Form Editor.
120 */
121 @SuppressWarnings("unchecked")
122 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
123 private void initComponents() {
124
125 MLabel = new javax.swing.JLabel();
126 MField = new javax.swing.JTextField();
127 NField = new javax.swing.JTextField();
128 m0Field = new javax.swing.JTextField();
129 NLabel = new javax.swing.JLabel();
130 m0Label = new javax.swing.JLabel();
131 constraintsLabel = new javax.swing.JLabel();
132
133 setPreferredSize(new java.awt.Dimension(451, 170));
134
135 MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MLabel.text")); // NOI18N
136
137 MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MField.text")); // NOI18N
138
139 NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NField.text")); // NOI18N
140
141 m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Field.text")); // NOI18N
142
143 NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NLabel.text")); // NOI18N
144
145 m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Label.text")); // NOI18N
146
147 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.constraintsLabel.text")); // NOI18N
148
149 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
150 this.setLayout(layout);
151 layout.setHorizontalGroup(
152 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 .addGroup(layout.createSequentialGroup()
154 .addContainerGap()
155 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
156 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
157 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
158 .addComponent(NLabel)
159 .addComponent(m0Label)
160 .addComponent(MLabel)))
161 .addGap(25, 25, 25)
162 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
163 .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
164 .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
165 .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
166 .addContainerGap())
167 );
168 layout.setVerticalGroup(
169 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170 .addGroup(layout.createSequentialGroup()
171 .addContainerGap()
172 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
173 .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
174 .addComponent(NLabel))
175 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
176 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
177 .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
178 .addComponent(m0Label))
179 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
181 .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
182 .addComponent(MLabel))
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
185 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
186 );
187 }// </editor-fold>//GEN-END:initComponents
188
189
190 // Variables declaration - do not modify//GEN-BEGIN:variables
191 protected javax.swing.JTextField MField;
192 private javax.swing.JLabel MLabel;
193 protected javax.swing.JTextField NField;
194 private javax.swing.JLabel NLabel;
195 private javax.swing.JLabel constraintsLabel;
196 protected javax.swing.JTextField m0Field;
197 private javax.swing.JLabel m0Label;
198 // End of variables declaration//GEN-END:variables
199
200}
0201
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedAUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedA;
25import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedAUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = BarabasiAlbertSimplifiedAUI.class)
35public class BarabasiAlbertSimplifiedAUIImpl implements BarabasiAlbertSimplifiedAUI {
36 private BarabasiAlbertSimplifiedAPanel panel;
37 private BarabasiAlbertSimplifiedA barabasiAlbertSimplifiedA;
38
39 public BarabasiAlbertSimplifiedAUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new BarabasiAlbertSimplifiedAPanel();
44 return BarabasiAlbertSimplifiedAPanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.barabasiAlbertSimplifiedA = (BarabasiAlbertSimplifiedA)generator;
49
50 if (panel == null)
51 panel = new BarabasiAlbertSimplifiedAPanel();
52
53 panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedA.getN()));
54 panel.m0Field.setText(String.valueOf(barabasiAlbertSimplifiedA.getm0()));
55 panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedA.getM()));
56 }
57
58 public void unsetup() {
59 barabasiAlbertSimplifiedA.setN(Integer.parseInt(panel.NField.getText()));
60 barabasiAlbertSimplifiedA.setm0(Integer.parseInt(panel.m0Field.getText()));
61 barabasiAlbertSimplifiedA.setM(Integer.parseInt(panel.MField.getText()));
62 panel = null;
63 }
64}
065
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,110 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[451, 116]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" attributes="0">
25 <Group type="103" groupAlignment="0" attributes="0">
26 <Group type="102" attributes="0">
27 <EmptySpace max="-2" attributes="0"/>
28 <Group type="103" groupAlignment="0" attributes="0">
29 <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
31 </Group>
32 <EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
33 <Group type="103" groupAlignment="0" attributes="0">
34 <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
35 <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
36 </Group>
37 </Group>
38 <Group type="102" alignment="0" attributes="0">
39 <EmptySpace min="-2" pref="167" max="-2" attributes="0"/>
40 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
41 </Group>
42 </Group>
43 <EmptySpace max="-2" attributes="0"/>
44 </Group>
45 </Group>
46 </DimensionLayout>
47 <DimensionLayout dim="1">
48 <Group type="103" groupAlignment="0" attributes="0">
49 <Group type="102" alignment="0" attributes="0">
50 <EmptySpace max="-2" attributes="0"/>
51 <Group type="103" groupAlignment="3" attributes="0">
52 <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
53 <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
54 </Group>
55 <EmptySpace max="-2" attributes="0"/>
56 <Group type="103" groupAlignment="0" attributes="0">
57 <Component id="MLabel" min="-2" max="-2" attributes="0"/>
58 <Component id="MField" min="-2" max="-2" attributes="0"/>
59 </Group>
60 <EmptySpace max="-2" attributes="0"/>
61 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
62 <EmptySpace max="32767" attributes="0"/>
63 </Group>
64 </Group>
65 </DimensionLayout>
66 </Layout>
67 <SubComponents>
68 <Component class="javax.swing.JLabel" name="MLabel">
69 <Properties>
70 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72 </Property>
73 </Properties>
74 </Component>
75 <Component class="javax.swing.JTextField" name="MField">
76 <Properties>
77 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
78 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
79 </Property>
80 </Properties>
81 <AuxValues>
82 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
83 </AuxValues>
84 </Component>
85 <Component class="javax.swing.JTextField" name="NField">
86 <Properties>
87 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
88 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
89 </Property>
90 </Properties>
91 <AuxValues>
92 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
93 </AuxValues>
94 </Component>
95 <Component class="javax.swing.JLabel" name="NLabel">
96 <Properties>
97 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
98 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
99 </Property>
100 </Properties>
101 </Component>
102 <Component class="javax.swing.JLabel" name="constraintsLabel">
103 <Properties>
104 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
105 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
106 </Property>
107 </Properties>
108 </Component>
109 </SubComponents>
110</Form>
0111
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,161 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.PositiveNumberValidator;
24import org.netbeans.validation.api.Problems;
25import org.netbeans.validation.api.Validator;
26import org.netbeans.validation.api.builtin.Validators;
27import org.netbeans.validation.api.ui.ValidationGroup;
28import org.netbeans.validation.api.ui.ValidationPanel;
29
30/**
31 *
32 *
33 * @author Cezary Bartosiak
34 */
35public class BarabasiAlbertSimplifiedBPanel extends javax.swing.JPanel {
36
37 /** Creates new form BarabasiAlbertPanel */
38 public BarabasiAlbertSimplifiedBPanel() {
39 initComponents();
40 }
41
42 public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedBPanel innerPanel) {
43 ValidationPanel validationPanel = new ValidationPanel();
44 if (innerPanel == null)
45 innerPanel = new BarabasiAlbertSimplifiedBPanel();
46 validationPanel.setInnerComponent(innerPanel);
47
48 ValidationGroup group = validationPanel.getValidationGroup();
49
50 group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
51 new PositiveNumberValidator());
52 group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
53 new MNValidator(innerPanel));
54 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
55 new PositiveNumberValidator());
56 group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
57 new MNValidator(innerPanel));
58
59 return validationPanel;
60 }
61
62 private static class MNValidator implements Validator<String> {
63 private BarabasiAlbertSimplifiedBPanel innerPanel;
64
65 public MNValidator(BarabasiAlbertSimplifiedBPanel innerPanel) {
66 this.innerPanel = innerPanel;
67 }
68
69 @Override
70 public boolean validate(Problems problems, String compName, String model) {
71 boolean result = false;
72
73 try {
74 Integer N = Integer.parseInt(innerPanel.NField.getText());
75 Integer M = Integer.parseInt(innerPanel.MField.getText());
76 result = M <= N * (N - 1) / 2;
77 }
78 catch (Exception e) { }
79 if (!result) {
80 String message = "<html>M &lt;= N * (N - 1) / 2</html>";
81 problems.add(message);
82 }
83
84 return result;
85 }
86 }
87
88 /** This method is called from within the constructor to
89 * initialize the form.
90 * WARNING: Do NOT modify this code. The content of this method is
91 * always regenerated by the Form Editor.
92 */
93 @SuppressWarnings("unchecked")
94 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
95 private void initComponents() {
96
97 MLabel = new javax.swing.JLabel();
98 MField = new javax.swing.JTextField();
99 NField = new javax.swing.JTextField();
100 NLabel = new javax.swing.JLabel();
101 constraintsLabel = new javax.swing.JLabel();
102
103 setPreferredSize(new java.awt.Dimension(451, 116));
104
105 MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MLabel.text")); // NOI18N
106
107 MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MField.text")); // NOI18N
108
109 NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NField.text")); // NOI18N
110
111 NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NLabel.text")); // NOI18N
112
113 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.constraintsLabel.text")); // NOI18N
114
115 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
116 this.setLayout(layout);
117 layout.setHorizontalGroup(
118 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119 .addGroup(layout.createSequentialGroup()
120 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121 .addGroup(layout.createSequentialGroup()
122 .addContainerGap()
123 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addComponent(NLabel)
125 .addComponent(MLabel))
126 .addGap(59, 59, 59)
127 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
128 .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
129 .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))
130 .addGroup(layout.createSequentialGroup()
131 .addGap(167, 167, 167)
132 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
133 .addContainerGap())
134 );
135 layout.setVerticalGroup(
136 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137 .addGroup(layout.createSequentialGroup()
138 .addContainerGap()
139 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
140 .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
141 .addComponent(NLabel))
142 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
143 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 .addComponent(MLabel)
145 .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
146 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
148 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
149 );
150 }// </editor-fold>//GEN-END:initComponents
151
152
153 // Variables declaration - do not modify//GEN-BEGIN:variables
154 protected javax.swing.JTextField MField;
155 private javax.swing.JLabel MLabel;
156 protected javax.swing.JTextField NField;
157 private javax.swing.JLabel NLabel;
158 private javax.swing.JLabel constraintsLabel;
159 // End of variables declaration//GEN-END:variables
160
161}
0162
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertSimplifiedBUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedB;
25import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedBUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = BarabasiAlbertSimplifiedBUI.class)
35public class BarabasiAlbertSimplifiedBUIImpl implements BarabasiAlbertSimplifiedBUI {
36 private BarabasiAlbertSimplifiedBPanel panel;
37 private BarabasiAlbertSimplifiedB barabasiAlbertSimplifiedB;
38
39 public BarabasiAlbertSimplifiedBUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new BarabasiAlbertSimplifiedBPanel();
44 return BarabasiAlbertSimplifiedBPanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.barabasiAlbertSimplifiedB = (BarabasiAlbertSimplifiedB)generator;
49
50 if (panel == null)
51 panel = new BarabasiAlbertSimplifiedBPanel();
52
53 panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedB.getN()));
54 panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedB.getM()));
55 }
56
57 public void unsetup() {
58 barabasiAlbertSimplifiedB.setN(Integer.parseInt(panel.NField.getText()));
59 barabasiAlbertSimplifiedB.setM(Integer.parseInt(panel.MField.getText()));
60 panel = null;
61 }
62}
063
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/BarabasiAlbertUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.BarabasiAlbert;
25import org.gephi.io.generator.plugin.BarabasiAlbertUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = BarabasiAlbertUI.class)
35public class BarabasiAlbertUIImpl implements BarabasiAlbertUI {
36 private BarabasiAlbertPanel panel;
37 private BarabasiAlbert barabasiAlbert;
38
39 public BarabasiAlbertUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new BarabasiAlbertPanel();
44 return BarabasiAlbertPanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.barabasiAlbert = (BarabasiAlbert)generator;
49
50 if (panel == null)
51 panel = new BarabasiAlbertPanel();
52
53 panel.NField.setText(String.valueOf(barabasiAlbert.getN()));
54 panel.m0Field.setText(String.valueOf(barabasiAlbert.getm0()));
55 panel.MField.setText(String.valueOf(barabasiAlbert.getM()));
56 }
57
58 public void unsetup() {
59 barabasiAlbert.setN(Integer.parseInt(panel.NField.getText()));
60 barabasiAlbert.setm0(Integer.parseInt(panel.m0Field.getText()));
61 barabasiAlbert.setM(Integer.parseInt(panel.MField.getText()));
62 panel = null;
63 }
64}
065
=== modified file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties 2010-04-12 12:48:22 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/Bundle.properties 2010-12-17 03:47:30 +0000
@@ -13,4 +13,73 @@
13WattsStrogatzPanel.neighborField.text=13WattsStrogatzPanel.neighborField.text=
14WattsStrogatzPanel.probabilityField.text=14WattsStrogatzPanel.probabilityField.text=
1515
16WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1}
17\ No newline at end of file16\ No newline at end of file
17WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1}
18BarabasiAlbertPanel.constraintsLabel.text=<html>\nN &gt; 0<br>\nm0 &gt; 0<br>\nm0 &lt; N<br>\nM &gt; 0<br>\nM &lt;= m0\n</html>
19BarabasiAlbertPanel.NLabel.text=N \u2013 number of nodes in generated network:
20BarabasiAlbertPanel.NField.text=
21BarabasiAlbertPanel.m0Label.text=m0 \u2013 number of nodes at the start time:
22BarabasiAlbertPanel.m0Field.text=
23BarabasiAlbertPanel.MLabel.text=M \u2013 number of edges coming with every new node:
24BarabasiAlbertPanel.MField.text=
25BarabasiAlbertGeneralizedPanel.MLabel.text=M \u2013 number of edges to add, rewire or coming with a node in every step:
26BarabasiAlbertGeneralizedPanel.NField.text=
27BarabasiAlbertGeneralizedPanel.MField.text=
28BarabasiAlbertGeneralizedPanel.NLabel.text=N \u2013 number of the algorithm's steps:
29BarabasiAlbertGeneralizedPanel.m0Field.text=
30BarabasiAlbertGeneralizedPanel.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>
31BarabasiAlbertGeneralizedPanel.m0Label.text=m0 \u2013 number of isolated nodes at the start time:
32BarabasiAlbertGeneralizedPanel.pLabel.text=p \u2013 probability of adding new edges:
33BarabasiAlbertGeneralizedPanel.pField.text=
34BarabasiAlbertGeneralizedPanel.qLabel.text=q \u2013 probability of rewiring existing edges:
35BarabasiAlbertGeneralizedPanel.qField.text=
36BarabasiAlbertSimplifiedAPanel.MField.text=
37BarabasiAlbertSimplifiedAPanel.m0Field.text=
38BarabasiAlbertSimplifiedAPanel.NField.text=
39BarabasiAlbertSimplifiedAPanel.m0Label.text=m0 \u2013 number of nodes at the start time:
40BarabasiAlbertSimplifiedAPanel.NLabel.text=N \u2013 number of nodes in generated network:
41BarabasiAlbertSimplifiedAPanel.constraintsLabel.text=<html>\nN &gt; 0<br>\nm0 &gt; 0<br>\nm0 &lt; N<br>\nM &gt; 0<br>\nM &lt;= m0\n</html>
42BarabasiAlbertSimplifiedAPanel.MLabel.text=M \u2013 number of edges coming with every new node:
43BarabasiAlbertSimplifiedBPanel.NField.text=
44BarabasiAlbertSimplifiedBPanel.MField.text=
45BarabasiAlbertSimplifiedBPanel.MLabel.text=M \u2013 number of edges in generated network:
46BarabasiAlbertSimplifiedBPanel.constraintsLabel.text=<html>\nN &gt; 0<br>\nM &gt; 0<br>\nM &lt;= N * (N - 1) / 2<br>\n</html>
47BarabasiAlbertSimplifiedBPanel.NLabel.text=N \u2013 number of nodes in generated network:
48ErdosRenyiGnpPanel.constraintsLabel.text=<html>\nn &gt; 0<br>\n0 &lt;= p &lt;= 1<br>\n</html>
49ErdosRenyiGnpPanel.nLabel.text=n \u2013 number of nodes in generated network:
50ErdosRenyiGnpPanel.nField.text=
51ErdosRenyiGnpPanel.pLabel.text=p \u2013 probability of edge existence between all pairs of nodes:
52ErdosRenyiGnpPanel.pField.text=
53ErdosRenyiGnmPanel.nField.text=
54ErdosRenyiGnmPanel.constraintsLabel.text=<html>\nn &gt; 0<br>\nm &gt;= 0<br>\nm &lt;= n * (n - 1) / 2\n</html>
55ErdosRenyiGnmPanel.nLabel.text=n \u2013 number of nodes in generated network:
56ErdosRenyiGnmPanel.mLabel.text=m \u2013 number of edges in generated network:
57ErdosRenyiGnmPanel.mField.text=
58KleinbergPanel.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>
59KleinbergPanel.nLabel.text=n \u2013 size of a lattice:
60KleinbergPanel.nField.text=
61KleinbergPanel.pLabel.text=p - lattice distance to local contacs:
62KleinbergPanel.pField.text=
63KleinbergPanel.qLabel.text=q - long-range contacs:
64KleinbergPanel.qField.text=
65KleinbergPanel.rLabel.text=r \u2013 clustering exponent:
66KleinbergPanel.rField.text=
67WattsStrogatzBetaPanel.constraintsLabel.text=<html>\nN &gt; K &gt;= ln(N) &gt;= 1<br>\nK is even<br>\n0 &lt;= beta &lt;= 1\n</html>
68WattsStrogatzBetaPanel.NField.text=
69WattsStrogatzBetaPanel.NLabel.text=N \u2013 the desired number of nodes:
70WattsStrogatzBetaPanel.KLabel.text=K \u2013 the number of edges connected to each node:
71WattsStrogatzBetaPanel.KField.text=
72WattsStrogatzBetaPanel.betaLabel.text=beta - the probability of an edge being rewired randomly:
73WattsStrogatzBetaPanel.betaField.text=
74WattsStrogatzAlphaPanel.constraintsLabel.text=<html>\nn &gt; k &gt; 0<br>\n0 &lt;= alpha\n</html>
75WattsStrogatzAlphaPanel.nLabel.text=n \u2013 the desired number of nodes:
76WattsStrogatzAlphaPanel.nField.text=
77WattsStrogatzAlphaPanel.kLabel.text=k \u2013 the average degree of the graph:
78WattsStrogatzAlphaPanel.kField.text=
79WattsStrogatzAlphaPanel.alphaLabel.text=alpha - a tunable parameter:
80WattsStrogatzAlphaPanel.alphaField.text=
81BalancedTreePanel.constraintsLabel.text=<html>\nr &gt;= 2<br>\nh &gt;= 1\n</html>
82BalancedTreePanel.rLabel.text=r - a degree of the root:
83BalancedTreePanel.rField.text=
84BalancedTreePanel.hLabel.text=h - a height of the tree:
85BalancedTreePanel.hField.text=
86KleinbergPanel.torusCheckBox.text=torus based
1887
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,110 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[431, 116]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" attributes="0">
25 <EmptySpace max="-2" attributes="0"/>
26 <Group type="103" groupAlignment="0" attributes="0">
27 <Group type="102" attributes="0">
28 <Group type="103" groupAlignment="0" attributes="0">
29 <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="mLabel" alignment="0" min="-2" max="-2" attributes="0"/>
31 </Group>
32 <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
33 <Group type="103" groupAlignment="1" attributes="0">
34 <Component id="mField" alignment="0" pref="140" max="32767" attributes="1"/>
35 <Component id="nField" alignment="0" pref="140" max="32767" attributes="1"/>
36 </Group>
37 <EmptySpace max="-2" attributes="0"/>
38 </Group>
39 <Group type="102" alignment="1" attributes="0">
40 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
41 <EmptySpace min="-2" pref="175" max="-2" attributes="0"/>
42 </Group>
43 </Group>
44 </Group>
45 </Group>
46 </DimensionLayout>
47 <DimensionLayout dim="1">
48 <Group type="103" groupAlignment="0" attributes="0">
49 <Group type="102" alignment="0" attributes="0">
50 <EmptySpace max="-2" attributes="0"/>
51 <Group type="103" groupAlignment="3" attributes="0">
52 <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
53 <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
54 </Group>
55 <EmptySpace max="-2" attributes="0"/>
56 <Group type="103" groupAlignment="3" attributes="0">
57 <Component id="mField" alignment="3" min="-2" max="-2" attributes="0"/>
58 <Component id="mLabel" alignment="3" min="-2" max="-2" attributes="0"/>
59 </Group>
60 <EmptySpace max="-2" attributes="0"/>
61 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
62 <EmptySpace max="32767" attributes="0"/>
63 </Group>
64 </Group>
65 </DimensionLayout>
66 </Layout>
67 <SubComponents>
68 <Component class="javax.swing.JTextField" name="nField">
69 <Properties>
70 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72 </Property>
73 </Properties>
74 <AuxValues>
75 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
76 </AuxValues>
77 </Component>
78 <Component class="javax.swing.JTextField" name="mField">
79 <Properties>
80 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
82 </Property>
83 </Properties>
84 <AuxValues>
85 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
86 </AuxValues>
87 </Component>
88 <Component class="javax.swing.JLabel" name="nLabel">
89 <Properties>
90 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
91 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
92 </Property>
93 </Properties>
94 </Component>
95 <Component class="javax.swing.JLabel" name="mLabel">
96 <Properties>
97 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
98 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
99 </Property>
100 </Properties>
101 </Component>
102 <Component class="javax.swing.JLabel" name="constraintsLabel">
103 <Properties>
104 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
105 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
106 </Property>
107 </Properties>
108 </Component>
109 </SubComponents>
110</Form>
0111
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,186 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.PositiveNumberValidator;
24import org.netbeans.validation.api.Problems;
25import org.netbeans.validation.api.Validator;
26import org.netbeans.validation.api.builtin.Validators;
27import org.netbeans.validation.api.ui.ValidationGroup;
28import org.netbeans.validation.api.ui.ValidationPanel;
29
30/**
31 *
32 *
33 * @author Cezary Bartosiak
34 */
35public class ErdosRenyiGnmPanel extends javax.swing.JPanel {
36
37 /** Creates new form BarabasiAlbertPanel */
38 public ErdosRenyiGnmPanel() {
39 initComponents();
40 }
41
42 public static ValidationPanel createValidationPanel(ErdosRenyiGnmPanel innerPanel) {
43 ValidationPanel validationPanel = new ValidationPanel();
44 if (innerPanel == null)
45 innerPanel = new ErdosRenyiGnmPanel();
46 validationPanel.setInnerComponent(innerPanel);
47
48 ValidationGroup group = validationPanel.getValidationGroup();
49
50 group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
51 new PositiveNumberValidator());
52 group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
53 new mnValidator(innerPanel));
54 group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING,
55 new mValidator(innerPanel));
56 group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING,
57 new mnValidator(innerPanel));
58
59 return validationPanel;
60 }
61
62 private static class mValidator implements Validator<String> {
63 private ErdosRenyiGnmPanel innerPanel;
64
65 public mValidator(ErdosRenyiGnmPanel innerPanel) {
66 this.innerPanel = innerPanel;
67 }
68
69 @Override
70 public boolean validate(Problems problems, String compName, String model) {
71 boolean result = false;
72
73 try {
74 Integer m = Integer.parseInt(innerPanel.mField.getText());
75 result = m >= 0;
76 }
77 catch (Exception e) { }
78 if (!result) {
79 String message = "<html>m &gt;= 0</html>";
80 problems.add(message);
81 }
82
83 return result;
84 }
85 }
86
87 private static class mnValidator implements Validator<String> {
88 private ErdosRenyiGnmPanel innerPanel;
89
90 public mnValidator(ErdosRenyiGnmPanel innerPanel) {
91 this.innerPanel = innerPanel;
92 }
93
94 @Override
95 public boolean validate(Problems problems, String compName, String model) {
96 boolean result = false;
97
98 try {
99 Integer m = Integer.parseInt(innerPanel.mField.getText());
100 Integer n = Integer.parseInt(innerPanel.nField.getText());
101 result = m <= n * (n - 1) / 2;
102 }
103 catch (Exception e) { }
104 if (!result) {
105 String message = "<html>m &lt;= n * (n - 1) / 2</html>";
106 problems.add(message);
107 }
108
109 return result;
110 }
111 }
112
113 /** This method is called from within the constructor to
114 * initialize the form.
115 * WARNING: Do NOT modify this code. The content of this method is
116 * always regenerated by the Form Editor.
117 */
118 @SuppressWarnings("unchecked")
119 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
120 private void initComponents() {
121
122 nField = new javax.swing.JTextField();
123 mField = new javax.swing.JTextField();
124 nLabel = new javax.swing.JLabel();
125 mLabel = new javax.swing.JLabel();
126 constraintsLabel = new javax.swing.JLabel();
127
128 setPreferredSize(new java.awt.Dimension(431, 116));
129
130 nField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nField.text")); // NOI18N
131
132 mField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mField.text")); // NOI18N
133
134 nLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nLabel.text")); // NOI18N
135
136 mLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mLabel.text")); // NOI18N
137
138 constraintsLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.constraintsLabel.text")); // NOI18N
139
140 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
141 this.setLayout(layout);
142 layout.setHorizontalGroup(
143 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 .addGroup(layout.createSequentialGroup()
145 .addContainerGap()
146 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147 .addGroup(layout.createSequentialGroup()
148 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149 .addComponent(nLabel)
150 .addComponent(mLabel))
151 .addGap(60, 60, 60)
152 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
153 .addComponent(mField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
154 .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
155 .addContainerGap())
156 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
157 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
158 .addGap(175, 175, 175))))
159 );
160 layout.setVerticalGroup(
161 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
162 .addGroup(layout.createSequentialGroup()
163 .addContainerGap()
164 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
165 .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
166 .addComponent(nLabel))
167 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
168 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
169 .addComponent(mField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
170 .addComponent(mLabel))
171 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
172 .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
173 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
174 );
175 }// </editor-fold>//GEN-END:initComponents
176
177
178 // Variables declaration - do not modify//GEN-BEGIN:variables
179 private javax.swing.JLabel constraintsLabel;
180 protected javax.swing.JTextField mField;
181 private javax.swing.JLabel mLabel;
182 protected javax.swing.JTextField nField;
183 private javax.swing.JLabel nLabel;
184 // End of variables declaration//GEN-END:variables
185
186}
0187
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnmUIImpl.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import javax.swing.JPanel;
24import org.gephi.io.generator.plugin.ErdosRenyiGnm;
25import org.gephi.io.generator.plugin.ErdosRenyiGnmUI;
26import org.gephi.io.generator.spi.Generator;
27import org.openide.util.lookup.ServiceProvider;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34@ServiceProvider(service = ErdosRenyiGnmUI.class)
35public class ErdosRenyiGnmUIImpl implements ErdosRenyiGnmUI {
36 private ErdosRenyiGnmPanel panel;
37 private ErdosRenyiGnm erdosRenyiGnm;
38
39 public ErdosRenyiGnmUIImpl() { }
40
41 public JPanel getPanel() {
42 if (panel == null)
43 panel = new ErdosRenyiGnmPanel();
44 return ErdosRenyiGnmPanel.createValidationPanel(panel);
45 }
46
47 public void setup(Generator generator) {
48 this.erdosRenyiGnm = (ErdosRenyiGnm)generator;
49
50 if (panel == null)
51 panel = new ErdosRenyiGnmPanel();
52
53 panel.nField.setText(String.valueOf(erdosRenyiGnm.getn()));
54 panel.mField.setText(String.valueOf(erdosRenyiGnm.getm()));
55 }
56
57 public void unsetup() {
58 erdosRenyiGnm.setn(Integer.parseInt(panel.nField.getText()));
59 erdosRenyiGnm.setm(Integer.parseInt(panel.mField.getText()));
60 panel = null;
61 }
62}
063
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.form 2010-12-17 03:47:30 +0000
@@ -0,0 +1,110 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <Properties>
5 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
6 <Dimension value="[498, 102]"/>
7 </Property>
8 </Properties>
9 <AuxValues>
10 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19 </AuxValues>
20
21 <Layout>
22 <DimensionLayout dim="0">
23 <Group type="103" groupAlignment="0" attributes="0">
24 <Group type="102" attributes="0">
25 <Group type="103" groupAlignment="0" attributes="0">
26 <Group type="102" attributes="0">
27 <EmptySpace max="-2" attributes="0"/>
28 <Group type="103" groupAlignment="0" attributes="0">
29 <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
30 <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/>
31 </Group>
32 <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
33 <Group type="103" groupAlignment="1" attributes="0">
34 <Component id="pField" alignment="0" pref="128" max="32767" attributes="1"/>
35 <Component id="nField" alignment="0" pref="128" max="32767" attributes="1"/>
36 </Group>
37 </Group>
38 <Group type="102" alignment="0" attributes="0">
39 <EmptySpace min="-2" pref="227" max="-2" attributes="0"/>
40 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
41 </Group>
42 </Group>
43 <EmptySpace max="-2" attributes="0"/>
44 </Group>
45 </Group>
46 </DimensionLayout>
47 <DimensionLayout dim="1">
48 <Group type="103" groupAlignment="0" attributes="0">
49 <Group type="102" alignment="0" attributes="0">
50 <EmptySpace max="-2" attributes="0"/>
51 <Group type="103" groupAlignment="3" attributes="0">
52 <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
53 <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
54 </Group>
55 <EmptySpace max="-2" attributes="0"/>
56 <Group type="103" groupAlignment="3" attributes="0">
57 <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/>
58 <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/>
59 </Group>
60 <EmptySpace max="-2" attributes="0"/>
61 <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
62 <EmptySpace max="32767" attributes="0"/>
63 </Group>
64 </Group>
65 </DimensionLayout>
66 </Layout>
67 <SubComponents>
68 <Component class="javax.swing.JTextField" name="nField">
69 <Properties>
70 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72 </Property>
73 </Properties>
74 <AuxValues>
75 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
76 </AuxValues>
77 </Component>
78 <Component class="javax.swing.JTextField" name="pField">
79 <Properties>
80 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
81 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
82 </Property>
83 </Properties>
84 <AuxValues>
85 <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
86 </AuxValues>
87 </Component>
88 <Component class="javax.swing.JLabel" name="nLabel">
89 <Properties>
90 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
91 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
92 </Property>
93 </Properties>
94 </Component>
95 <Component class="javax.swing.JLabel" name="pLabel">
96 <Properties>
97 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
98 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
99 </Property>
100 </Properties>
101 </Component>
102 <Component class="javax.swing.JLabel" name="constraintsLabel">
103 <Properties>
104 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
105 <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
106 </Property>
107 </Properties>
108 </Component>
109 </SubComponents>
110</Form>
0111
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpPanel.java 2010-12-17 03:47:30 +0000
@@ -0,0 +1,130 @@
1/*
2 * Copyright 2008-2010 Gephi
3 * Authors : Cezary Bartosiak
4 * Website : http://www.gephi.org
5 *
6 * This file is part of Gephi.
7 *
8 * Gephi is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Gephi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.ui.generator.plugin;
22
23import org.gephi.lib.validation.BetweenZeroAndOneValidator;
24import org.gephi.lib.validation.PositiveNumberValidator;
25import org.netbeans.validation.api.builtin.Validators;
26import org.netbeans.validation.api.ui.ValidationGroup;
27import org.netbeans.validation.api.ui.ValidationPanel;
28
29/**
30 *
31 *
32 * @author Cezary Bartosiak
33 */
34public class ErdosRenyiGnpPanel extends javax.swing.JPanel {
35
36 /** Creates new form BarabasiAlbertPanel */
37 public ErdosRenyiGnpPanel() {
38 initComponents();
39 }
40
41 public static ValidationPanel createValidationPanel(ErdosRenyiGnpPanel innerPanel) {
42 ValidationPanel validationPanel = new ValidationPanel();
43 if (innerPanel == null)
44 innerPanel = new ErdosRenyiGnpPanel();
45 validationPanel.setInnerComponent(innerPanel);
46
47 ValidationGroup group = validationPanel.getValidationGroup();
48
49 group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
50 new PositiveNumberValidator());
51 group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
52 new BetweenZeroAndOneValidator());
53
54 return validationPanel;
55 }
56
57 /** This method is called from within the constructor to
58 * initialize the form.
59 * WARNING: Do NOT modify this code. The content of this method is
60 * always regenerated by the Form Editor.
61 */
62 @SuppressWarnings("unchecked")
63 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
64 private void initComponents() {
65
66 nField = new javax.swing.JTextField();
67 pField = new javax.swing.JTextField();
68 nLabel = new javax.swing.JLabel();
69 pLabel = new javax.swing.JLabel();
70 constraintsLabel = new javax.swing.JLabel();
71
72 setPreferredSize(new java.awt.Dimension(498, 102));
73
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches