gephi.team team mailing list archive
-
gephi.team team
-
Mailing list archive
-
Message #00957
[Merge] lp:~cezary-bartosiak/gephi/generator-plugin into lp:gephi
Cezary Bartosiak has proposed merging lp:~cezary-bartosiak/gephi/generator-plugin into lp:gephi.
Requested reviews:
Gephi Team (gephi.team)
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
--
https://code.launchpad.net/~cezary-bartosiak/gephi/generator-plugin/+merge/43858
Your team Gephi Team is requested to review the proposed merge of lp:~cezary-bartosiak/gephi/generator-plugin into lp:gephi.
=== modified file 'GeneratorPlugin/manifest.mf'
--- GeneratorPlugin/manifest.mf 2010-08-19 09:38:57 +0000
+++ GeneratorPlugin/manifest.mf 2010-12-16 02:37:54 +0000
@@ -2,5 +2,5 @@
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.io.generator.plugin
OpenIDE-Module-Localizing-Bundle: org/gephi/io/generator/plugin/Bundle.properties
-OpenIDE-Module-Specification-Version: 0.7.1
+OpenIDE-Module-Specification-Version: 0.7.2
=== 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-16 02:37:54 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates a perfectly balanced r-tree of height h (edges are undirected).
+ *
+ * r >= 2
+ * h >= 1
+ *
+ * O(r^h)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class BalancedTree implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int r = 2;
+ private int h = 4;
+
+ public void generate(ContainerLoader container) {
+ int n = ((int)Math.pow(r, h + 1) - 1) / (r - 1);
+
+ Progress.start(progressTicket, n - 1);
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ // Creating a root of degree r
+ NodeDraft root = container.factory().newNodeDraft();
+ root.setLabel("Node 0");
+ container.addNode(root);
+ List<NodeDraft> newLeaves = new ArrayList<NodeDraft>();
+ int v = 1;
+ for (int i = 0; i < r && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + v++);
+ newLeaves.add(node);
+ container.addNode(node);
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(root);
+ edge.setTarget(node);
+ container.addEdge(edge);
+
+ Progress.progress(progressTicket);
+ }
+
+ // Creating internal nodes
+ for (int height = 1; height < h && !cancel; ++height) {
+ List<NodeDraft> leaves = newLeaves;
+ newLeaves = new ArrayList<NodeDraft>();
+ for (NodeDraft leave : leaves)
+ for (int i = 0; i < r; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + v++);
+ newLeaves.add(node);
+ container.addNode(node);
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(leave);
+ edge.setTarget(node);
+ container.addEdge(edge);
+
+ Progress.progress(progressTicket);
+ }
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ public int getr() {
+ return r;
+ }
+
+ public int geth() {
+ return h;
+ }
+
+ public void setr(int r) {
+ this.r = r;
+ }
+
+ public void seth(int h) {
+ this.h = h;
+ }
+
+ public String getName() {
+ return "Balanced Tree";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(BalancedTreeUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface BalancedTreeUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected connected graph.
+ *
+ * http://en.wikipedia.org/wiki/BarabásiâAlbert_model
+ * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
+ * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
+ *
+ * N > 0
+ * m0 > 0 && m0 < N
+ * M > 0 && M <= m0
+ *
+ * O(N^2 * M)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class BarabasiAlbert implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int N = 50;
+ private int m0 = 1;
+ private int M = 1;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, N + M);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[N];
+ int[] degrees = new int[N];
+
+ // Creating m0 nodes
+ for (int i = 0; i < m0 && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ degrees[i] = 0;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Linking every node with each other (no self-loops)
+ for (int i = 0; i < m0 && !cancel; ++i)
+ for (int j = i + 1; j < m0 && !cancel; ++j) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ degrees[i]++;
+ degrees[j]++;
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+ }
+
+ // Adding N - m0 nodes, each with M edges
+ for (int i = m0; i < N && !cancel; ++i) {
+ // Adding new node
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ degrees[i] = 0;
+ container.addNode(node);
+
+ // Adding M edges out of the new node
+ double sum = 0.0; // sum of all nodes degrees
+ for (int j = 0; j < i && !cancel; ++j)
+ sum += degrees[j];
+ double s = 0.0;
+ for (int m = 0; m < M && !cancel; ++m) {
+ double r = random.nextDouble();
+ double p = 0.0;
+ for (int j = 0; j < i && !cancel; ++j) {
+ if (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i]))
+ continue;
+
+ if (i == 1)
+ p = 1.0;
+ else p += degrees[j] / sum + s / (i - m);
+
+ if (r <= p) {
+ s += degrees[j] / sum;
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ degrees[i]++;
+ degrees[j]++;
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+
+ break;
+ }
+ }
+ }
+
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getm0() {
+ return m0;
+ }
+
+ public int getM() {
+ return M;
+ }
+
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ public void setm0(int m0) {
+ this.m0 = m0;
+ }
+
+ public void setM(int M) {
+ this.M = M;
+ }
+
+ public String getName() {
+ return "Barabasi-Albert Scale Free model";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(BarabasiAlbertUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected not necessarily connected graph.
+ *
+ * http://en.wikipedia.org/wiki/BarabásiâAlbert_model
+ * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
+ * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
+ *
+ * N > 0
+ * m0 > 0
+ * M > 0 && M <= m0
+ * 0 <= p < 1
+ * 0 <= q < 1 - p
+ *
+ * Ω(N^2 * M)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class BarabasiAlbertGeneralized implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int N = 50;
+ private int m0 = 1;
+ private int M = 1;
+ private double p = 0.25;
+ private double q = 0.25;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, N);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[N + 1];
+ int[] degrees = new int[N + 1];
+
+ // Creating m0 isolated nodes
+ for (int i = 0; i < m0 && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ degrees[i] = 0;
+ container.addNode(node);
+ }
+
+ // Performing N steps of the algorithm
+ int n = m0; // the number of existing nodes
+ int ec = 0; // the number of existing edges
+ for (int i = 0; i < N && !cancel; ++i) {
+ double r = random.nextDouble();
+
+ if (r <= p) { // adding M edges
+ if (ec == n * (n - 1) / 2)
+ continue;
+
+ double sum = 0.0;
+ for (int j = 0; j < n && !cancel; ++j)
+ sum += degrees[j] + 1;
+ for (int m = 0; m < M && !cancel; ++m) {
+ int a = random.nextInt(n);
+ while (degrees[a] == n - 1 && !cancel)
+ a = random.nextInt(n);
+ double b = random.nextDouble();
+ boolean e = false;
+ while (!e && !cancel) {
+ double pki = 0.0;
+ for (int j = 0; j < n && !e && !cancel; ++j) {
+ pki += (degrees[j] + 1) / sum;
+
+ if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[a]);
+ edge.setTarget(nodes[j]);
+ degrees[a]++;
+ degrees[j]++;
+ sum += 2.0;
+ container.addEdge(edge);
+ ec++;
+
+ e = true;
+ }
+ else if (ec == n * (n - 1) / 2)
+ e = true;
+ }
+ b = random.nextDouble();
+ }
+ }
+ }
+ else if (r <= p + q) { // rewiring M edges
+ if (ec == 0 || ec == n * (n - 1) / 2)
+ continue;
+
+ double sum = 0.0;
+ for (int j = 0; j < n && !cancel; ++j)
+ sum += degrees[j] + 1;
+ for (int m = 0; m < M && !cancel; ++m) {
+ int a = random.nextInt(n);
+ while ((degrees[a] == 0 || degrees[a] == n - 1) && !cancel)
+ a = random.nextInt(n);
+ int l = random.nextInt(n);
+ while (!edgeExists(container, nodes[l], nodes[a]) && !cancel)
+ l = random.nextInt(n);
+ double b = random.nextDouble();
+ boolean e = false;
+ while (!e && !cancel) {
+ double pki = 0.0;
+ for (int j = 0; j < n && !e && !cancel; ++j) {
+ pki += (degrees[j] + 1) / sum;
+
+ if (b <= pki && a != j && !edgeExists(container, nodes[a], nodes[j])) {
+ container.removeEdge(getEdge(container, nodes[a], nodes[l]));
+ degrees[l]--;
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[a]);
+ edge.setTarget(nodes[j]);
+ degrees[j]++;
+ container.addEdge(edge);
+
+ e = true;
+ }
+ }
+ b = random.nextDouble();
+ }
+ }
+ }
+ else { // adding a new node with M edges
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + n);
+ nodes[n] = node;
+ degrees[n] = 0;
+ container.addNode(node);
+
+ // Adding M edges out of the new node
+ double sum = 0.0;
+ for (int j = 0; j < n && !cancel; ++j)
+ sum += degrees[j];
+ double s = 0.0;
+ for (int m = 0; m < M && !cancel; ++m) {
+ r = random.nextDouble();
+ double p = 0.0;
+ for (int j = 0; j < n && !cancel; ++j) {
+ if (edgeExists(container, nodes[n], nodes[j]))
+ continue;
+
+ if (n == 1)
+ p = 1.0;
+ else p += degrees[j] / sum + s / (n - m);
+
+ if (r <= p) {
+ s += degrees[j] / sum;
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[n]);
+ edge.setTarget(nodes[j]);
+ degrees[n]++;
+ degrees[j]++;
+ container.addEdge(edge);
+ ec++;
+
+ break;
+ }
+ }
+ }
+
+ n++;
+ }
+
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
+ }
+
+ private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ EdgeDraft edge = container.getEdge(node1, node2);
+ if (edge == null)
+ edge = container.getEdge(node2, node1);
+ return edge;
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getm0() {
+ return m0;
+ }
+
+ public int getM() {
+ return M;
+ }
+
+ public double getp() {
+ return p;
+ }
+
+ public double getq() {
+ return q;
+ }
+
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ public void setm0(int m0) {
+ this.m0 = m0;
+ }
+
+ public void setM(int M) {
+ this.M = M;
+ }
+
+ public void setp(double p) {
+ this.p = p;
+ }
+
+ public void setq(double q) {
+ this.q = q;
+ }
+
+ public String getName() {
+ return "Generalized Barabasi-Albert Scale Free model";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(BarabasiAlbertGeneralizedUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface BarabasiAlbertGeneralizedUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected connected graph.
+ *
+ * http://en.wikipedia.org/wiki/BarabásiâAlbert_model
+ * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
+ * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
+ *
+ * N > 0
+ * m0 > 0 && m0 < N
+ * M > 0 && M <= m0
+ *
+ * Ω(N * M)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class BarabasiAlbertSimplifiedA implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int N = 50;
+ private int m0 = 1;
+ private int M = 1;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, N + M);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[N];
+
+ // Creating m0 nodes
+ for (int i = 0; i < m0 && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Linking every node with each other (no self-loops)
+ for (int i = 0; i < m0 && !cancel; ++i)
+ for (int j = i + 1; j < m0 && !cancel; ++j) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+ }
+
+ // Adding N - m0 nodes, each with M edges
+ for (int i = m0; i < N && !cancel; ++i) {
+ // Adding new node
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+
+ // Adding M edges out of the new node
+ for (int m = 0; m < M && !cancel; ++m) {
+ int j = random.nextInt(i);
+ while (container.edgeExists(nodes[i], nodes[j]) || container.edgeExists(nodes[j], nodes[i]))
+ j = random.nextInt(i);
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+ }
+
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getm0() {
+ return m0;
+ }
+
+ public int getM() {
+ return M;
+ }
+
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ public void setm0(int m0) {
+ this.m0 = m0;
+ }
+
+ public void setM(int M) {
+ this.M = M;
+ }
+
+ public String getName() {
+ return "Barabasi-Albert Scale Free model A (uniform attachment)";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedAUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface BarabasiAlbertSimplifiedAUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected not necessarily connected graph.
+ *
+ * http://en.wikipedia.org/wiki/BarabásiâAlbert_model
+ * http://www.barabasilab.com/pubs/CCNR-ALB_Publications/199910-15_Science-Emergence/199910-15_Science-Emergence.pdf
+ * http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Spring2006/CNT/Resource/ba-model-2.pdf
+ *
+ * N > 0
+ * M > 0
+ * M <= N * (N - 1) / 2
+ *
+ * Ω(N * M)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class BarabasiAlbertSimplifiedB implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int N = 50;
+ private int M = 50;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, N + M);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[N];
+ int[] degrees = new int[N];
+
+ // Creating N nodes
+ for (int i = 0; i < N && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ degrees[i] = 0;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Creating M edges
+ for (int m = 0; m < M && !cancel; ++m) {
+ double sum = 0.0; // sum of all nodes degrees
+ for (int j = 0; j < N && !cancel; ++j)
+ sum += degrees[j] + 1;
+
+ // Selecting a node randomly
+ int i = random.nextInt(N);
+ while (degrees[i] == N - 1 && !cancel)
+ i = random.nextInt(N);
+
+ double b = random.nextDouble();
+ boolean e = false;
+ while (!e && !cancel) {
+ double pki = 0.0;
+ for (int j = 0; j < N && !e && !cancel; ++j) {
+ pki += (degrees[j] + 1) / sum;
+
+ if (b <= pki && i != j && !edgeExists(container, nodes[i], nodes[j])) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ degrees[i]++;
+ degrees[j]++;
+ container.addEdge(edge);
+
+ e = true;
+ }
+ }
+ b = random.nextDouble();
+ }
+
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getM() {
+ return M;
+ }
+
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ public void setM(int M) {
+ this.M = M;
+ }
+
+ public String getName() {
+ return "Barabasi-Albert Scale Free model B (no growth)";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(BarabasiAlbertSimplifiedBUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface BarabasiAlbertSimplifiedBUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface BarabasiAlbertUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected not necessarily connected graph.
+ *
+ * http://www.math-inst.hu/~p_erdos/1960-10.pdf
+ * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf
+ *
+ * n > 0
+ * m >= 0
+ * m <= n * (n - 1) / 2
+ *
+ * O(n^2)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class ErdosRenyiGnm implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int n = 50;
+ private int m = 50;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, n + n * n + m);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[n];
+
+ // Creating n nodes
+ for (int i = 0; i < n && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Creating a list of n^2 edges
+ List<EdgeDraft> edges = new ArrayList<EdgeDraft>();
+ for (int i = 0; i < n && !cancel; ++i)
+ for (int j = i + 1; j < n && !cancel; ++j) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ edges.add(edge);
+ Progress.progress(progressTicket);
+ }
+
+ // Drawing m edges
+ for (int i = 0; i < m; ++i) {
+ EdgeDraft e = edges.get(random.nextInt(edges.size()));
+ edges.remove(e);
+ container.addEdge(e);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ public int getn() {
+ return n;
+ }
+
+ public int getm() {
+ return m;
+ }
+
+ public void setn(int n) {
+ this.n = n;
+ }
+
+ public void setm(int m) {
+ this.m = m;
+ }
+
+ public String getName() {
+ return "Erdos-Renyi G(n, m) model";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(ErdosRenyiGnmUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface ErdosRenyiGnmUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected not necessarily connected graph.
+ *
+ * http://www.math-inst.hu/~p_erdos/1960-10.pdf
+ * http://www.inf.uni-konstanz.de/algo/publications/bb-eglrn-05.pdf
+ *
+ * n > 0
+ * 0 <= p <= 1
+ *
+ * O(n^2)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class ErdosRenyiGnp implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int n = 50;
+ private double p = 0.05;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, n + n * n);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[n];
+
+ // Creating n nodes
+ for (int i = 0; i < n && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Linking every node with each other with probability p (no self-loops)
+ for (int i = 0; i < n && !cancel; ++i)
+ for (int j = 0; j < n && !cancel; ++j)
+ if (i != j && !edgeExists(container, nodes[i], nodes[j]) && random.nextDouble() <= p) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
+ }
+
+ public int getn() {
+ return n;
+ }
+
+ public double getp() {
+ return p;
+ }
+
+ public void setn(int n) {
+ this.n = n;
+ }
+
+ public void setp(double p) {
+ this.p = p;
+ }
+
+ public String getName() {
+ return "Erdos-Renyi G(n, p) model";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(ErdosRenyiGnpUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface ErdosRenyiGnpUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates a directed connected graph.
+ *
+ * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.117.7097&rep=rep1&type=pdf
+ * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.83.381&rep=rep1&type=pdf
+ *
+ * n >= 2
+ * p >= 1
+ * p <= 2n - 2
+ * q >= 0
+ * q <= n^2 - p * (p + 3) / 2 - 1 for p < n
+ * q <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n
+ * r >= 0
+ *
+ * Ω(n^4 * q)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class Kleinberg implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int n = 10;
+ private int p = 2;
+ private int q = 2;
+ private int r = 0;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, n * n + n * n * (2 * p + 1) * (2 * p + 1) +
+ (int)Math.pow(n, 4) + n * n * q);
+ Random random = new Random();
+
+ // Creating lattice n x n
+ NodeDraft[][] nodes = new NodeDraft[n][n];
+ for (int i = 0; i < n && !cancel; ++i)
+ for (int j = 0; j < n && !cancel; ++j) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i + " " + j);
+ nodes[i][j] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+
+ // Creating edges from each node to p local contacts
+ for (int i = 0; i < n && !cancel; ++i)
+ for (int j = 0; j < n && !cancel; ++j)
+ for (int k = i - p; k <= i + p && !cancel; ++k)
+ for (int l = j - p; l <= j + p && !cancel; ++l) {
+ if (k >= 0 && k < n && l >= 0 && l < n && d(i, j, k, l) <= p && nodes[i][j] != nodes[k][l]) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i][j]);
+ edge.setTarget(nodes[k][l]);
+ container.addEdge(edge);
+ }
+ Progress.progress(progressTicket);
+ }
+
+ // Creating edges from each node to q long-range contacts
+ for (int i = 0; i < n && !cancel; ++i)
+ for (int j = 0; j < n && !cancel; ++j) {
+ double sum = 0.0;
+ for (int k = 0; k < n && !cancel; ++k)
+ for (int l = 0; l < n && !cancel; ++l) {
+ if (d(i, j, k, l) > p)
+ sum += Math.pow(d(i, j, k, l), -r);
+ Progress.progress(progressTicket);
+ }
+ for (int m = 0; m < q && !cancel; ++m) {
+ double b = random.nextDouble();
+ boolean e = false;
+ while (!e && !cancel) {
+ double pki = 0.0;
+ for (int k = 0; k < n && !e && !cancel; ++k)
+ for (int l = 0; l < n && !e && !cancel; ++l)
+ if (d(i, j, k, l) > p) {
+ pki += Math.pow(d(i, j, k, l), -r) / sum;
+
+ if (b <= pki && !container.edgeExists(nodes[i][j], nodes[k][l])) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i][j]);
+ edge.setTarget(nodes[k][l]);
+ container.addEdge(edge);
+
+ e = true;
+ }
+ }
+ b = random.nextDouble();
+ }
+ Progress.progress(progressTicket);
+ }
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ private int d(int i, int j, int k, int l) {
+ return Math.abs(k - i) + Math.abs(l - j);
+ }
+
+ public int getn() {
+ return n;
+ }
+
+ public int getp() {
+ return p;
+ }
+
+ public int getq() {
+ return q;
+ }
+
+ public int getr() {
+ return r;
+ }
+
+ public void setn(int n) {
+ this.n = n;
+ }
+
+ public void setp(int p) {
+ this.p = p;
+ }
+
+ public void setq(int q) {
+ this.q = q;
+ }
+
+ public void setr(int r) {
+ this.r = r;
+ }
+
+ public String getName() {
+ return "Kleinberg Small World model";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(KleinbergUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface KleinbergUI extends GeneratorUI {
+
+}
=== 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 @@
-/*
-Copyright 2008-2010 Gephi
-Authors : Mathieu Bastian <mathieu.bastian@xxxxxxxxx>
-Website : http://www.gephi.org
-
-This file is part of Gephi.
-
-Gephi is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-Gephi is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with Gephi. If not, see <http://www.gnu.org/licenses/>.
-*/
-package org.gephi.io.generator.plugin;
-
-import java.util.Random;
-import org.gephi.io.generator.spi.Generator;
-import org.gephi.io.generator.spi.GeneratorUI;
-import org.gephi.io.importer.api.ContainerLoader;
-import org.gephi.io.importer.api.EdgeDraft;
-import org.gephi.io.importer.api.NodeDraft;
-import org.gephi.utils.progress.Progress;
-import org.gephi.utils.progress.ProgressTicket;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author Mathieu Bastian
- */
-@ServiceProvider(service = Generator.class)
-public class WattsStrogatz implements Generator {
-
- protected int numberOfNodes = 50;
- protected int numberOfNeighbors = 3;
- protected double rewiringProbability = 0.5;
- protected ProgressTicket progress;
- protected boolean cancel = false;
-
- public void generate(ContainerLoader container) {
- Progress.start(progress, numberOfNodes);
- Random random = new Random();
-
- NodeDraft[] nodeArray = new NodeDraft[numberOfNodes];
-
- //Create ring lattice
- for (int i = 0; i < numberOfNodes && !cancel; i++) {
- NodeDraft node = container.factory().newNodeDraft();
- node.setLabel("Node " + i);
- nodeArray[i] = node;
- container.addNode(node);
- }
- for (int i = 0; i < numberOfNodes && !cancel; i++) {
- for (int j = 0; j < numberOfNeighbors; j++) {
- EdgeDraft edge = container.factory().newEdgeDraft();
- edge.setSource(nodeArray[i]);
- edge.setTarget(nodeArray[(i + (numberOfNeighbors - j)) % numberOfNodes]);
- container.addEdge(edge);
- }
- }
-
- //Rewire edges
- for (int i = 0; i < numberOfNodes && !cancel; i++) {
- for (int s = 1; s <= numberOfNeighbors && !cancel; s++) {
- while (true) {
- // randomly rewire a proportion, beta, of the edges in the graph.
- double r = random.nextDouble();
- if (r < rewiringProbability) {
- int v = random.nextInt(numberOfNeighbors);
-
- NodeDraft vthNode = nodeArray[v];
- NodeDraft ithNode = nodeArray[i];
- NodeDraft kthNode = nodeArray[((i + s) % numberOfNodes)];//upIndex(i, s));
- EdgeDraft e = container.getEdge(ithNode, kthNode);
-
- if (kthNode != vthNode && container.getEdge(kthNode, vthNode) == null) {
- container.removeEdge(e);
- EdgeDraft edgeDraft = container.factory().newEdgeDraft();
- edgeDraft.setSource(kthNode);
- edgeDraft.setTarget(vthNode);
- container.addEdge(edgeDraft);
- break;
- }
- } else {
- break;
- }
- }
- }
- Progress.progress(progress);
- }
-
- Progress.finish(progress);
- progress = null;
- }
-
- public int getNumberOfNeighbors() {
- return numberOfNeighbors;
- }
-
- public void setNumberOfNeighbors(int numberOfNeighbors) {
- if (numberOfNeighbors < 2 || numberOfNeighbors > numberOfNodes / 2) {
- throw new IllegalArgumentException("Neighbors must be between 2 and numberOfNodes / 2");
- }
- this.numberOfNeighbors = numberOfNeighbors;
- }
-
- public int getNumberOfNodes() {
- return numberOfNodes;
- }
-
- public void setNumberOfNodes(int numberOfNodes) {
- this.numberOfNodes = numberOfNodes;
- }
-
- public double getRewiringProbability() {
- return rewiringProbability;
- }
-
- public void setRewiringProbability(double rewiringProbability) {
- if (rewiringProbability < 0 || rewiringProbability > 1) {
- throw new IllegalArgumentException("Probability must be between 0.0 and 1.0");
- }
- this.rewiringProbability = rewiringProbability;
- }
-
- public String getName() {
- return "Watts-Strogatz Small World";
- }
-
- public GeneratorUI getUI() {
- return Lookup.getDefault().lookup(WattsStrogatzUI.class);
- }
-
- public boolean cancel() {
- cancel = true;
- return true;
- }
-
- public void setProgressTicket(ProgressTicket progressTicket) {
- this.progress = progressTicket;
- }
-}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected connected graph.
+ *
+ * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model
+ * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf
+ * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf
+ * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf
+ *
+ * n > k > 0
+ * 0 <= alpha
+ *
+ * O(n^3 * k)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class WattsStrogatzAlpha implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int n = 20;
+ private int k = 4;
+ private double alpha = 3.5;
+ private double p = Math.pow(10, -10);
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, n + n + n * k / 2);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[n];
+
+ // Creating a regular ring lattice
+ int ec = 0;
+ for (int i = 0; i < n && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+ for (int i = 0; i < n && !cancel; ++i) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[(i + 1) % n]);
+ container.addEdge(edge);
+ ec++;
+ Progress.progress(progressTicket);
+ }
+
+ // Creating n * k / 2 edges
+ List<Integer> ids = new ArrayList<Integer>();
+ while (ec < n * k / 2 && !cancel) {
+ for (int i = 0; i < n && !cancel; ++i)
+ ids.add(new Integer(i));
+ while (ec < n * k / 2 && ids.size() > 0 && !cancel) {
+ Integer i = ids.remove(random.nextInt(ids.size()));
+ double[] Rij = new double[n];
+ double sumRij = 0.0;
+ for (int j = 0; j < n && !cancel; ++j) {
+ Rij[j] = calculateRij(container, nodes, i, j);
+ sumRij += Rij[j];
+ }
+ double r = random.nextDouble();
+ double pij = 0.0;
+ for (int j = 0; j < n && !cancel; ++j)
+ if (i != j) {
+ pij += Rij[j] / sumRij;
+ if (r <= pij) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[j]);
+ container.addEdge(edge);
+ ec++;
+
+ Progress.progress(progressTicket);
+ break;
+ }
+ }
+ }
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ public double calculateRij(ContainerLoader container, NodeDraft[] nodes, int i, int j) {
+ if (i == j || edgeExists(container, nodes[i], nodes[j]))
+ return 0;
+ int mij = calculatemij(container, nodes, i, j);
+ if (mij >= k)
+ return 1;
+ if (mij == 0)
+ return p;
+ return Math.pow(mij / k, alpha) * (1 - p) + p;
+ }
+
+ public int calculatemij(ContainerLoader container, NodeDraft[] nodes, int i, int j) {
+ int mij = 0;
+ for (int l = 0; l < n && !cancel; ++l)
+ if (l != i && l != j &&
+ edgeExists(container, nodes[i], nodes[l]) &&
+ edgeExists(container, nodes[j], nodes[l]))
+ mij++;
+ return mij;
+ }
+
+ private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
+ }
+
+ public int getn() {
+ return n;
+ }
+
+ public int getk() {
+ return k;
+ }
+
+ public double getalpha() {
+ return alpha;
+ }
+
+ public void setn(int n) {
+ this.n = n;
+ }
+
+ public void setk(int k) {
+ this.k = k;
+ }
+
+ public void setalpha(double alpha) {
+ this.alpha = alpha;
+ }
+
+ public String getName() {
+ return "Watts-Strogatz Small World model Alpha";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(WattsStrogatzAlphaUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface WattsStrogatzAlphaUI extends GeneratorUI {
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import java.util.Random;
+import org.gephi.io.generator.spi.Generator;
+import org.gephi.io.generator.spi.GeneratorUI;
+import org.gephi.io.importer.api.ContainerLoader;
+import org.gephi.io.importer.api.EdgeDefault;
+import org.gephi.io.importer.api.EdgeDraft;
+import org.gephi.io.importer.api.NodeDraft;
+import org.gephi.utils.progress.Progress;
+import org.gephi.utils.progress.ProgressTicket;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Generates an undirected not necessarily connected graph.
+ *
+ * http://en.wikipedia.org/wiki/Watts_and_Strogatz_model
+ * http://tam.cornell.edu/tam/cms/manage/upload/SS_nature_smallworld.pdf
+ * http://www.bsos.umd.edu/socy/alan/stats/network-grad/summaries/Watts-Six%20Degrees-Ghosh.pdf
+ * http://www.cc.gatech.edu/~mihail/D.8802readings/watts-swp.pdf
+ *
+ * N > K >= ln(N) >= 1
+ * K % 2 == 0
+ * 0 <= beta <= 1
+ *
+ * Ω(N * K)
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = Generator.class)
+public class WattsStrogatzBeta implements Generator {
+ private boolean cancel = false;
+ private ProgressTicket progressTicket;
+
+ private int N = 20;
+ private int K = 4;
+ private double beta = 0.2;
+
+ public void generate(ContainerLoader container) {
+ Progress.start(progressTicket, N + N * K);
+ Random random = new Random();
+ container.setEdgeDefault(EdgeDefault.UNDIRECTED);
+
+ NodeDraft[] nodes = new NodeDraft[N];
+
+ // Creating a regular ring lattice
+ for (int i = 0; i < N && !cancel; ++i) {
+ NodeDraft node = container.factory().newNodeDraft();
+ node.setLabel("Node " + i);
+ nodes[i] = node;
+ container.addNode(node);
+ Progress.progress(progressTicket);
+ }
+ for (int i = 0; i < N && !cancel; ++i)
+ for (int j = 1; j <= K / 2 && !cancel; ++j) {
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[(i + j) % N]);
+ container.addEdge(edge);
+ Progress.progress(progressTicket);
+ }
+
+ // Rewiring edges
+ for (int i = 0; i < N && !cancel; ++i)
+ for (int j = 1; j <= K / 2 && !cancel; ++j)
+ if (random.nextDouble() <= beta) {
+ container.removeEdge(getEdge(container, nodes[i], nodes[(i + j) % N]));
+
+ int k = random.nextInt(N);
+ while ((k == i || edgeExists(container, nodes[i], nodes[k])) && !cancel)
+ k = random.nextInt(N);
+
+ EdgeDraft edge = container.factory().newEdgeDraft();
+ edge.setSource(nodes[i]);
+ edge.setTarget(nodes[k]);
+ container.addEdge(edge);
+
+ Progress.progress(progressTicket);
+ }
+
+ Progress.finish(progressTicket);
+ progressTicket = null;
+ }
+
+ private boolean edgeExists(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ return container.edgeExists(node1, node2) || container.edgeExists(node2, node1);
+ }
+
+ private EdgeDraft getEdge(ContainerLoader container, NodeDraft node1, NodeDraft node2) {
+ EdgeDraft edge = container.getEdge(node1, node2);
+ if (edge == null)
+ edge = container.getEdge(node2, node1);
+ return edge;
+ }
+
+ public int getN() {
+ return N;
+ }
+
+ public int getK() {
+ return K;
+ }
+
+ public double getbeta() {
+ return beta;
+ }
+
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ public void setK(int K) {
+ this.K = K;
+ }
+
+ public void setbeta(double beta) {
+ this.beta = beta;
+ }
+
+ public String getName() {
+ return "Watts-Strogatz Small World model Beta";
+ }
+
+ public GeneratorUI getUI() {
+ return Lookup.getDefault().lookup(WattsStrogatzBetaUI.class);
+ }
+
+ public boolean cancel() {
+ cancel = true;
+ return true;
+ }
+
+ public void setProgressTicket(ProgressTicket progressTicket) {
+ this.progressTicket = progressTicket;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.io.generator.plugin;
+
+import org.gephi.io.generator.spi.GeneratorUI;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public interface WattsStrogatzBetaUI extends GeneratorUI {
+
+}
=== 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 @@
-/*
-Copyright 2008-2010 Gephi
-Authors : Mathieu Bastian <mathieu.bastian@xxxxxxxxx>
-Website : http://www.gephi.org
-
-This file is part of Gephi.
-
-Gephi is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-Gephi is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with Gephi. If not, see <http://www.gnu.org/licenses/>.
-*/
-package org.gephi.io.generator.plugin;
-
-import org.gephi.io.generator.spi.GeneratorUI;
-
-/**
- *
- * @author Mathieu Bastian
- */
-public interface WattsStrogatzUI extends GeneratorUI {
-}
=== modified file 'GeneratorPluginUI/manifest.mf'
--- GeneratorPluginUI/manifest.mf 2010-08-19 09:38:57 +0000
+++ GeneratorPluginUI/manifest.mf 2010-12-16 02:37:54 +0000
@@ -2,5 +2,5 @@
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.ui.generator.plugin
OpenIDE-Module-Localizing-Bundle: org/gephi/ui/generator/plugin/Bundle.properties
-OpenIDE-Module-Specification-Version: 0.7.1
+OpenIDE-Module-Specification-Version: 0.7.2
=== 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-16 02:37:54 +0000
@@ -0,0 +1,110 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[330, 102]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="rLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="hLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="hField" alignment="0" pref="134" max="32767" attributes="1"/>
+ <Component id="rField" alignment="0" pref="134" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="136" max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="rField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="rLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="hField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="hLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="rField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="hField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="rLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.rLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="hLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.hLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BalancedTreePanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class BalancedTreePanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public BalancedTreePanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(BalancedTreePanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new BalancedTreePanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.rField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new rValidator(innerPanel));
+ group.add(innerPanel.hField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new hValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class rValidator implements Validator<String> {
+ private BalancedTreePanel innerPanel;
+
+ public rValidator(BalancedTreePanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer r = Integer.parseInt(innerPanel.rField.getText());
+ result = r >= 2;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>r >= 2</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class hValidator implements Validator<String> {
+ private BalancedTreePanel innerPanel;
+
+ public hValidator(BalancedTreePanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer h = Integer.parseInt(innerPanel.hField.getText());
+ result = h >= 1;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>h >= 1</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ rField = new javax.swing.JTextField();
+ hField = new javax.swing.JTextField();
+ rLabel = new javax.swing.JLabel();
+ hLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(330, 102));
+
+ rField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rField.text")); // NOI18N
+
+ hField.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hField.text")); // NOI18N
+
+ rLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.rLabel.text")); // NOI18N
+
+ hLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.hLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BalancedTreePanel.class, "BalancedTreePanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(rLabel)
+ .addComponent(hLabel))
+ .addGap(60, 60, 60)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(hField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
+ .addComponent(rField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(136, 136, 136)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(rField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(rLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(hField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(hLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField hField;
+ private javax.swing.JLabel hLabel;
+ protected javax.swing.JTextField rField;
+ private javax.swing.JLabel rLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.BalancedTree;
+import org.gephi.io.generator.plugin.BalancedTreeUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = BalancedTreeUI.class)
+public class BalancedTreeUIImpl implements BalancedTreeUI {
+ private BalancedTreePanel panel;
+ private BalancedTree balancedTree;
+
+ public BalancedTreeUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new BalancedTreePanel();
+ return BalancedTreePanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.balancedTree = (BalancedTree)generator;
+
+ if (panel == null)
+ panel = new BalancedTreePanel();
+
+ panel.rField.setText(String.valueOf(balancedTree.getr()));
+ panel.hField.setText(String.valueOf(balancedTree.geth()));
+ }
+
+ public void unsetup() {
+ balancedTree.setr(Integer.parseInt(panel.rField.getText()));
+ balancedTree.seth(Integer.parseInt(panel.hField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,182 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[548, 236]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="qLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="qField" alignment="0" pref="153" max="32767" attributes="1"/>
+ <Component id="pField" alignment="0" pref="153" max="32767" attributes="1"/>
+ <Component id="m0Field" alignment="0" pref="153" max="32767" attributes="1"/>
+ <Component id="MField" alignment="0" pref="153" max="32767" attributes="1"/>
+ <Component id="NField" alignment="0" pref="153" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="233" max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="qField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="qLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="MLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="MField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="NField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="m0Field">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="NLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="m0Label">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="pLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="pField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="qLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="qField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertGeneralizedPanel.qField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.BetweenZeroAndOneValidator;
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class BarabasiAlbertGeneralizedPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public BarabasiAlbertGeneralizedPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(BarabasiAlbertGeneralizedPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new BarabasiAlbertGeneralizedPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new MValidator(innerPanel));
+ group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new BetweenZeroAndOneValidator());
+ group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new pqValidator(innerPanel));
+ group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new BetweenZeroAndOneValidator());
+ group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new pqValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class MValidator implements Validator<String> {
+ private BarabasiAlbertGeneralizedPanel innerPanel;
+
+ public MValidator(BarabasiAlbertGeneralizedPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
+ Integer M = Integer.parseInt(innerPanel.MField.getText());
+ result = M <= m0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>M <= m0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class pqValidator implements Validator<String> {
+ private BarabasiAlbertGeneralizedPanel innerPanel;
+
+ public pqValidator(BarabasiAlbertGeneralizedPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Double p = Double.parseDouble(innerPanel.pField.getText());
+ Double q = Double.parseDouble(innerPanel.qField.getText());
+ result = p + q < 1.0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>p + q < 1.0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ MLabel = new javax.swing.JLabel();
+ MField = new javax.swing.JTextField();
+ NField = new javax.swing.JTextField();
+ m0Field = new javax.swing.JTextField();
+ NLabel = new javax.swing.JLabel();
+ m0Label = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+ pLabel = new javax.swing.JLabel();
+ pField = new javax.swing.JTextField();
+ qLabel = new javax.swing.JLabel();
+ qField = new javax.swing.JTextField();
+
+ setPreferredSize(new java.awt.Dimension(548, 236));
+
+ MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MLabel.text")); // NOI18N
+
+ MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.MField.text")); // NOI18N
+
+ NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NField.text")); // NOI18N
+
+ m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Field.text")); // NOI18N
+
+ NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.NLabel.text")); // NOI18N
+
+ m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.m0Label.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.constraintsLabel.text")); // NOI18N
+
+ pLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pLabel.text")); // NOI18N
+
+ pField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.pField.text")); // NOI18N
+
+ qLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qLabel.text")); // NOI18N
+
+ qField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertGeneralizedPanel.class, "BarabasiAlbertGeneralizedPanel.qField.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(NLabel)
+ .addComponent(m0Label)
+ .addComponent(MLabel)
+ .addComponent(pLabel)
+ .addComponent(qLabel))
+ .addGap(25, 25, 25)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(qField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
+ .addComponent(pField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
+ .addComponent(m0Field, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
+ .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
+ .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(233, 233, 233)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(NLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(m0Label))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(MLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(pField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(pLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(qField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(qLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField MField;
+ private javax.swing.JLabel MLabel;
+ protected javax.swing.JTextField NField;
+ private javax.swing.JLabel NLabel;
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField m0Field;
+ private javax.swing.JLabel m0Label;
+ protected javax.swing.JTextField pField;
+ private javax.swing.JLabel pLabel;
+ protected javax.swing.JTextField qField;
+ private javax.swing.JLabel qLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.BarabasiAlbertGeneralized;
+import org.gephi.io.generator.plugin.BarabasiAlbertGeneralizedUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = BarabasiAlbertGeneralizedUI.class)
+public class BarabasiAlbertGeneralizedUIImpl implements BarabasiAlbertGeneralizedUI {
+ private BarabasiAlbertGeneralizedPanel panel;
+ private BarabasiAlbertGeneralized barabasiAlbertGeneralized;
+
+ public BarabasiAlbertGeneralizedUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new BarabasiAlbertGeneralizedPanel();
+ return BarabasiAlbertGeneralizedPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.barabasiAlbertGeneralized = (BarabasiAlbertGeneralized)generator;
+
+ if (panel == null)
+ panel = new BarabasiAlbertGeneralizedPanel();
+
+ panel.NField.setText(String.valueOf(barabasiAlbertGeneralized.getN()));
+ panel.m0Field.setText(String.valueOf(barabasiAlbertGeneralized.getm0()));
+ panel.MField.setText(String.valueOf(barabasiAlbertGeneralized.getM()));
+ panel.pField.setText(String.valueOf(barabasiAlbertGeneralized.getp()));
+ panel.qField.setText(String.valueOf(barabasiAlbertGeneralized.getq()));
+ }
+
+ public void unsetup() {
+ barabasiAlbertGeneralized.setN(Integer.parseInt(panel.NField.getText()));
+ barabasiAlbertGeneralized.setm0(Integer.parseInt(panel.m0Field.getText()));
+ barabasiAlbertGeneralized.setM(Integer.parseInt(panel.MField.getText()));
+ barabasiAlbertGeneralized.setp(Double.parseDouble(panel.pField.getText()));
+ barabasiAlbertGeneralized.setq(Double.parseDouble(panel.qField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,129 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[451, 170]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+ <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/>
+ <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
+ <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="MLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="MField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="NField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="m0Field">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="NLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="m0Label">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class BarabasiAlbertPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public BarabasiAlbertPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(BarabasiAlbertPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new BarabasiAlbertPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
+ new m0Validator(innerPanel));
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new MValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class m0Validator implements Validator<String> {
+ private BarabasiAlbertPanel innerPanel;
+
+ public m0Validator(BarabasiAlbertPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer N = Integer.parseInt(innerPanel.NField.getText());
+ Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
+ result = m0 < N;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>m0 < N</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class MValidator implements Validator<String> {
+ private BarabasiAlbertPanel innerPanel;
+
+ public MValidator(BarabasiAlbertPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
+ Integer M = Integer.parseInt(innerPanel.MField.getText());
+ result = M <= m0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>M <= m0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ MLabel = new javax.swing.JLabel();
+ MField = new javax.swing.JTextField();
+ NField = new javax.swing.JTextField();
+ m0Field = new javax.swing.JTextField();
+ NLabel = new javax.swing.JLabel();
+ m0Label = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(451, 170));
+
+ MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MLabel.text")); // NOI18N
+
+ MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.MField.text")); // NOI18N
+
+ NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NField.text")); // NOI18N
+
+ m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Field.text")); // NOI18N
+
+ NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.NLabel.text")); // NOI18N
+
+ m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.m0Label.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertPanel.class, "BarabasiAlbertPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(NLabel)
+ .addComponent(m0Label)
+ .addComponent(MLabel)))
+ .addGap(25, 25, 25)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(NLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(m0Label))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(MLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField MField;
+ private javax.swing.JLabel MLabel;
+ protected javax.swing.JTextField NField;
+ private javax.swing.JLabel NLabel;
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField m0Field;
+ private javax.swing.JLabel m0Label;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,129 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[451, 170]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+ <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="m0Field" alignment="0" pref="161" max="32767" attributes="1"/>
+ <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
+ <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="m0Field" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="m0Label" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="MField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="MLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="MField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="NField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="m0Field">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Field.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="NLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="m0Label">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.m0Label.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedAPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class BarabasiAlbertSimplifiedAPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public BarabasiAlbertSimplifiedAPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedAPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new BarabasiAlbertSimplifiedAPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.m0Field, Validators.REQUIRE_NON_EMPTY_STRING,
+ new m0Validator(innerPanel));
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new MValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class m0Validator implements Validator<String> {
+ private BarabasiAlbertSimplifiedAPanel innerPanel;
+
+ public m0Validator(BarabasiAlbertSimplifiedAPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer N = Integer.parseInt(innerPanel.NField.getText());
+ Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
+ result = m0 < N;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>m0 < N</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class MValidator implements Validator<String> {
+ private BarabasiAlbertSimplifiedAPanel innerPanel;
+
+ public MValidator(BarabasiAlbertSimplifiedAPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer m0 = Integer.parseInt(innerPanel.m0Field.getText());
+ Integer M = Integer.parseInt(innerPanel.MField.getText());
+ result = M <= m0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>M <= m0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ MLabel = new javax.swing.JLabel();
+ MField = new javax.swing.JTextField();
+ NField = new javax.swing.JTextField();
+ m0Field = new javax.swing.JTextField();
+ NLabel = new javax.swing.JLabel();
+ m0Label = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(451, 170));
+
+ MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MLabel.text")); // NOI18N
+
+ MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.MField.text")); // NOI18N
+
+ NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NField.text")); // NOI18N
+
+ m0Field.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Field.text")); // NOI18N
+
+ NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.NLabel.text")); // NOI18N
+
+ m0Label.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.m0Label.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedAPanel.class, "BarabasiAlbertSimplifiedAPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(NLabel)
+ .addComponent(m0Label)
+ .addComponent(MLabel)))
+ .addGap(25, 25, 25)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(m0Field, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addComponent(MField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(NLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(m0Field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(m0Label))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(MLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField MField;
+ private javax.swing.JLabel MLabel;
+ protected javax.swing.JTextField NField;
+ private javax.swing.JLabel NLabel;
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField m0Field;
+ private javax.swing.JLabel m0Label;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedA;
+import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedAUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = BarabasiAlbertSimplifiedAUI.class)
+public class BarabasiAlbertSimplifiedAUIImpl implements BarabasiAlbertSimplifiedAUI {
+ private BarabasiAlbertSimplifiedAPanel panel;
+ private BarabasiAlbertSimplifiedA barabasiAlbertSimplifiedA;
+
+ public BarabasiAlbertSimplifiedAUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new BarabasiAlbertSimplifiedAPanel();
+ return BarabasiAlbertSimplifiedAPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.barabasiAlbertSimplifiedA = (BarabasiAlbertSimplifiedA)generator;
+
+ if (panel == null)
+ panel = new BarabasiAlbertSimplifiedAPanel();
+
+ panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedA.getN()));
+ panel.m0Field.setText(String.valueOf(barabasiAlbertSimplifiedA.getm0()));
+ panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedA.getM()));
+ }
+
+ public void unsetup() {
+ barabasiAlbertSimplifiedA.setN(Integer.parseInt(panel.NField.getText()));
+ barabasiAlbertSimplifiedA.setm0(Integer.parseInt(panel.m0Field.getText()));
+ barabasiAlbertSimplifiedA.setM(Integer.parseInt(panel.MField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,110 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[451, 116]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="MLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="MField" alignment="0" pref="161" max="32767" attributes="1"/>
+ <Component id="NField" alignment="0" pref="161" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="167" max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="MLabel" min="-2" max="-2" attributes="0"/>
+ <Component id="MField" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="MLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="MField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.MField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="NField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="NLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="BarabasiAlbertSimplifiedBPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class BarabasiAlbertSimplifiedBPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public BarabasiAlbertSimplifiedBPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(BarabasiAlbertSimplifiedBPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new BarabasiAlbertSimplifiedBPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new MNValidator(innerPanel));
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.MField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new MNValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class MNValidator implements Validator<String> {
+ private BarabasiAlbertSimplifiedBPanel innerPanel;
+
+ public MNValidator(BarabasiAlbertSimplifiedBPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer N = Integer.parseInt(innerPanel.NField.getText());
+ Integer M = Integer.parseInt(innerPanel.MField.getText());
+ result = M <= N * (N - 1) / 2;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>M <= N * (N - 1) / 2</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ MLabel = new javax.swing.JLabel();
+ MField = new javax.swing.JTextField();
+ NField = new javax.swing.JTextField();
+ NLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(451, 116));
+
+ MLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MLabel.text")); // NOI18N
+
+ MField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.MField.text")); // NOI18N
+
+ NField.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NField.text")); // NOI18N
+
+ NLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.NLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(BarabasiAlbertSimplifiedBPanel.class, "BarabasiAlbertSimplifiedBPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(NLabel)
+ .addComponent(MLabel))
+ .addGap(59, 59, 59)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(MField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+ .addComponent(NField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(167, 167, 167)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(NLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(MLabel)
+ .addComponent(MField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField MField;
+ private javax.swing.JLabel MLabel;
+ protected javax.swing.JTextField NField;
+ private javax.swing.JLabel NLabel;
+ private javax.swing.JLabel constraintsLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedB;
+import org.gephi.io.generator.plugin.BarabasiAlbertSimplifiedBUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = BarabasiAlbertSimplifiedBUI.class)
+public class BarabasiAlbertSimplifiedBUIImpl implements BarabasiAlbertSimplifiedBUI {
+ private BarabasiAlbertSimplifiedBPanel panel;
+ private BarabasiAlbertSimplifiedB barabasiAlbertSimplifiedB;
+
+ public BarabasiAlbertSimplifiedBUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new BarabasiAlbertSimplifiedBPanel();
+ return BarabasiAlbertSimplifiedBPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.barabasiAlbertSimplifiedB = (BarabasiAlbertSimplifiedB)generator;
+
+ if (panel == null)
+ panel = new BarabasiAlbertSimplifiedBPanel();
+
+ panel.NField.setText(String.valueOf(barabasiAlbertSimplifiedB.getN()));
+ panel.MField.setText(String.valueOf(barabasiAlbertSimplifiedB.getM()));
+ }
+
+ public void unsetup() {
+ barabasiAlbertSimplifiedB.setN(Integer.parseInt(panel.NField.getText()));
+ barabasiAlbertSimplifiedB.setM(Integer.parseInt(panel.MField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.BarabasiAlbert;
+import org.gephi.io.generator.plugin.BarabasiAlbertUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = BarabasiAlbertUI.class)
+public class BarabasiAlbertUIImpl implements BarabasiAlbertUI {
+ private BarabasiAlbertPanel panel;
+ private BarabasiAlbert barabasiAlbert;
+
+ public BarabasiAlbertUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new BarabasiAlbertPanel();
+ return BarabasiAlbertPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.barabasiAlbert = (BarabasiAlbert)generator;
+
+ if (panel == null)
+ panel = new BarabasiAlbertPanel();
+
+ panel.NField.setText(String.valueOf(barabasiAlbert.getN()));
+ panel.m0Field.setText(String.valueOf(barabasiAlbert.getm0()));
+ panel.MField.setText(String.valueOf(barabasiAlbert.getM()));
+ }
+
+ public void unsetup() {
+ barabasiAlbert.setN(Integer.parseInt(panel.NField.getText()));
+ barabasiAlbert.setm0(Integer.parseInt(panel.m0Field.getText()));
+ barabasiAlbert.setM(Integer.parseInt(panel.MField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -13,4 +13,72 @@
WattsStrogatzPanel.neighborField.text=
WattsStrogatzPanel.probabilityField.text=
-WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1}
\ No newline at end of file
+WattsStrogatzPanel.NeigborValidator.problem {0} must be between 2 and {1}
+BarabasiAlbertPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nm0 < N<br>\nM > 0<br>\nM <= m0\n</html>
+BarabasiAlbertPanel.NLabel.text=N \u2013 number of nodes in generated network:
+BarabasiAlbertPanel.NField.text=
+BarabasiAlbertPanel.m0Label.text=m0 \u2013 number of nodes at the start time:
+BarabasiAlbertPanel.m0Field.text=
+BarabasiAlbertPanel.MLabel.text=M \u2013 number of edges coming with every new node:
+BarabasiAlbertPanel.MField.text=
+BarabasiAlbertGeneralizedPanel.MLabel.text=M \u2013 number of edges to add, rewire or coming with a node in every step:
+BarabasiAlbertGeneralizedPanel.NField.text=
+BarabasiAlbertGeneralizedPanel.MField.text=
+BarabasiAlbertGeneralizedPanel.NLabel.text=N \u2013 number of the algorithm's steps:
+BarabasiAlbertGeneralizedPanel.m0Field.text=
+BarabasiAlbertGeneralizedPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nM > 0<br>\nM <= m0<br>\n0 <= p < 1<br>\n0 <= q < 1 - p\n</html>
+BarabasiAlbertGeneralizedPanel.m0Label.text=m0 \u2013 number of isolated nodes at the start time:
+BarabasiAlbertGeneralizedPanel.pLabel.text=p \u2013 probability of adding new edges:
+BarabasiAlbertGeneralizedPanel.pField.text=
+BarabasiAlbertGeneralizedPanel.qLabel.text=q \u2013 probability of rewiring existing edges:
+BarabasiAlbertGeneralizedPanel.qField.text=
+BarabasiAlbertSimplifiedAPanel.MField.text=
+BarabasiAlbertSimplifiedAPanel.m0Field.text=
+BarabasiAlbertSimplifiedAPanel.NField.text=
+BarabasiAlbertSimplifiedAPanel.m0Label.text=m0 \u2013 number of nodes at the start time:
+BarabasiAlbertSimplifiedAPanel.NLabel.text=N \u2013 number of nodes in generated network:
+BarabasiAlbertSimplifiedAPanel.constraintsLabel.text=<html>\nN > 0<br>\nm0 > 0<br>\nm0 < N<br>\nM > 0<br>\nM <= m0\n</html>
+BarabasiAlbertSimplifiedAPanel.MLabel.text=M \u2013 number of edges coming with every new node:
+BarabasiAlbertSimplifiedBPanel.NField.text=
+BarabasiAlbertSimplifiedBPanel.MField.text=
+BarabasiAlbertSimplifiedBPanel.MLabel.text=M \u2013 number of edges in generated network:
+BarabasiAlbertSimplifiedBPanel.constraintsLabel.text=<html>\nN > 0<br>\nM > 0<br>\nM <= N * (N - 1) / 2<br>\n</html>
+BarabasiAlbertSimplifiedBPanel.NLabel.text=N \u2013 number of nodes in generated network:
+ErdosRenyiGnpPanel.constraintsLabel.text=<html>\nn > 0<br>\n0 <= p <= 1<br>\n</html>
+ErdosRenyiGnpPanel.nLabel.text=n \u2013 number of nodes in generated network:
+ErdosRenyiGnpPanel.nField.text=
+ErdosRenyiGnpPanel.pLabel.text=p \u2013 probability of edge existence between all pairs of nodes:
+ErdosRenyiGnpPanel.pField.text=
+ErdosRenyiGnmPanel.nField.text=
+ErdosRenyiGnmPanel.constraintsLabel.text=<html>\nn > 0<br>\nm >= 0<br>\nm <= n * (n - 1) / 2\n</html>
+ErdosRenyiGnmPanel.nLabel.text=n \u2013 number of nodes in generated network:
+ErdosRenyiGnmPanel.mLabel.text=m \u2013 number of edges in generated network:
+ErdosRenyiGnmPanel.mField.text=
+KleinbergPanel.constraintsLabel.text=<html>\nn >= 2<br>\np >= 1<br>\np <= 2n - 2<br>\nq >= 0<br>\nq <= n^2 - p * (p + 3) / 2 - 1 for p < n<br>\nq <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n<br>\nr >= 0\n</html>
+KleinbergPanel.nLabel.text=n \u2013 size of a lattice:
+KleinbergPanel.nField.text=
+KleinbergPanel.pLabel.text=p - lattice distance to local contacs:
+KleinbergPanel.pField.text=
+KleinbergPanel.qLabel.text=q - long-range contacs:
+KleinbergPanel.qField.text=
+KleinbergPanel.rLabel.text=r \u2013 clustering exponent:
+KleinbergPanel.rField.text=
+WattsStrogatzBetaPanel.constraintsLabel.text=<html>\nN > K >= ln(N) >= 1<br>\nK is even<br>\n0 <= beta <= 1\n</html>
+WattsStrogatzBetaPanel.NField.text=
+WattsStrogatzBetaPanel.NLabel.text=N \u2013 the desired number of nodes:
+WattsStrogatzBetaPanel.KLabel.text=K \u2013 the number of edges connected to each node:
+WattsStrogatzBetaPanel.KField.text=
+WattsStrogatzBetaPanel.betaLabel.text=beta - the probability of an edge being rewired randomly:
+WattsStrogatzBetaPanel.betaField.text=
+WattsStrogatzAlphaPanel.constraintsLabel.text=<html>\nn > k > 0<br>\n0 <= alpha\n</html>
+WattsStrogatzAlphaPanel.nLabel.text=n \u2013 the desired number of nodes:
+WattsStrogatzAlphaPanel.nField.text=
+WattsStrogatzAlphaPanel.kLabel.text=k \u2013 the average degree of the graph:
+WattsStrogatzAlphaPanel.kField.text=
+WattsStrogatzAlphaPanel.alphaLabel.text=alpha - a tunable parameter:
+WattsStrogatzAlphaPanel.alphaField.text=
+BalancedTreePanel.constraintsLabel.text=<html>\nr >= 2<br>\nh >= 1\n</html>
+BalancedTreePanel.rLabel.text=r - a degree of the root:
+BalancedTreePanel.rField.text=
+BalancedTreePanel.hLabel.text=h - a height of the tree:
+BalancedTreePanel.hField.text=
=== 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-16 02:37:54 +0000
@@ -0,0 +1,110 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[431, 116]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="mLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="mField" alignment="0" pref="140" max="32767" attributes="1"/>
+ <Component id="nField" alignment="0" pref="140" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="175" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="mField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="mLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="nField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="mField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="nLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="mLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.mLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnmPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class ErdosRenyiGnmPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public ErdosRenyiGnmPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(ErdosRenyiGnmPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new ErdosRenyiGnmPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new mnValidator(innerPanel));
+ group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new mValidator(innerPanel));
+ group.add(innerPanel.mField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new mnValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class mValidator implements Validator<String> {
+ private ErdosRenyiGnmPanel innerPanel;
+
+ public mValidator(ErdosRenyiGnmPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer m = Integer.parseInt(innerPanel.mField.getText());
+ result = m >= 0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>m >= 0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class mnValidator implements Validator<String> {
+ private ErdosRenyiGnmPanel innerPanel;
+
+ public mnValidator(ErdosRenyiGnmPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer m = Integer.parseInt(innerPanel.mField.getText());
+ Integer n = Integer.parseInt(innerPanel.nField.getText());
+ result = m <= n * (n - 1) / 2;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>m <= n * (n - 1) / 2</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ nField = new javax.swing.JTextField();
+ mField = new javax.swing.JTextField();
+ nLabel = new javax.swing.JLabel();
+ mLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(431, 116));
+
+ nField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nField.text")); // NOI18N
+
+ mField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mField.text")); // NOI18N
+
+ nLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.nLabel.text")); // NOI18N
+
+ mLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.mLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnmPanel.class, "ErdosRenyiGnmPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(nLabel)
+ .addComponent(mLabel))
+ .addGap(60, 60, 60)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(mField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
+ .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
+ .addContainerGap())
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(175, 175, 175))))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(nLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(mField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(mLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField mField;
+ private javax.swing.JLabel mLabel;
+ protected javax.swing.JTextField nField;
+ private javax.swing.JLabel nLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.ErdosRenyiGnm;
+import org.gephi.io.generator.plugin.ErdosRenyiGnmUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = ErdosRenyiGnmUI.class)
+public class ErdosRenyiGnmUIImpl implements ErdosRenyiGnmUI {
+ private ErdosRenyiGnmPanel panel;
+ private ErdosRenyiGnm erdosRenyiGnm;
+
+ public ErdosRenyiGnmUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new ErdosRenyiGnmPanel();
+ return ErdosRenyiGnmPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.erdosRenyiGnm = (ErdosRenyiGnm)generator;
+
+ if (panel == null)
+ panel = new ErdosRenyiGnmPanel();
+
+ panel.nField.setText(String.valueOf(erdosRenyiGnm.getn()));
+ panel.mField.setText(String.valueOf(erdosRenyiGnm.getm()));
+ }
+
+ public void unsetup() {
+ erdosRenyiGnm.setn(Integer.parseInt(panel.nField.getText()));
+ erdosRenyiGnm.setm(Integer.parseInt(panel.mField.getText()));
+ panel = null;
+ }
+}
=== 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-16 02:37:54 +0000
@@ -0,0 +1,110 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[498, 102]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="60" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="pField" alignment="0" pref="128" max="32767" attributes="1"/>
+ <Component id="nField" alignment="0" pref="128" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="227" max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="nField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="pField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="nLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="pLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="ErdosRenyiGnpPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== 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-16 02:37:54 +0000
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.BetweenZeroAndOneValidator;
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class ErdosRenyiGnpPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public ErdosRenyiGnpPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(ErdosRenyiGnpPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new ErdosRenyiGnpPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new PositiveNumberValidator());
+ group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new BetweenZeroAndOneValidator());
+
+ return validationPanel;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ nField = new javax.swing.JTextField();
+ pField = new javax.swing.JTextField();
+ nLabel = new javax.swing.JLabel();
+ pLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(498, 102));
+
+ nField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnpPanel.class, "ErdosRenyiGnpPanel.nField.text")); // NOI18N
+
+ pField.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnpPanel.class, "ErdosRenyiGnpPanel.pField.text")); // NOI18N
+
+ nLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnpPanel.class, "ErdosRenyiGnpPanel.nLabel.text")); // NOI18N
+
+ pLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnpPanel.class, "ErdosRenyiGnpPanel.pLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(ErdosRenyiGnpPanel.class, "ErdosRenyiGnpPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(nLabel)
+ .addComponent(pLabel))
+ .addGap(60, 60, 60)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(pField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
+ .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(227, 227, 227)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(nLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(pField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(pLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField nField;
+ private javax.swing.JLabel nLabel;
+ protected javax.swing.JTextField pField;
+ private javax.swing.JLabel pLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/ErdosRenyiGnpUIImpl.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.ErdosRenyiGnp;
+import org.gephi.io.generator.plugin.ErdosRenyiGnpUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = ErdosRenyiGnpUI.class)
+public class ErdosRenyiGnpUIImpl implements ErdosRenyiGnpUI {
+ private ErdosRenyiGnpPanel panel;
+ private ErdosRenyiGnp erdosRenyiGnp;
+
+ public ErdosRenyiGnpUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new ErdosRenyiGnpPanel();
+ return ErdosRenyiGnpPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.erdosRenyiGnp = (ErdosRenyiGnp)generator;
+
+ if (panel == null)
+ panel = new ErdosRenyiGnpPanel();
+
+ panel.nField.setText(String.valueOf(erdosRenyiGnp.getn()));
+ panel.pField.setText(String.valueOf(erdosRenyiGnp.getp()));
+ }
+
+ public void unsetup() {
+ erdosRenyiGnp.setn(Integer.parseInt(panel.nField.getText()));
+ erdosRenyiGnp.setp(Double.parseDouble(panel.pField.getText()));
+ panel = null;
+ }
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.form 2010-12-16 02:37:54 +0000
@@ -0,0 +1,158 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[399, 224]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="qLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="rLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="74" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="rField" pref="136" max="32767" attributes="1"/>
+ <Component id="pField" alignment="0" pref="136" max="32767" attributes="1"/>
+ <Component id="qField" alignment="0" pref="136" max="32767" attributes="1"/>
+ <Component id="nField" alignment="0" pref="136" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="86" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="pField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="pLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="qField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="qLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="rField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="rLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="qLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.qLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="qField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.qField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="nField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="pField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.pField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="nLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="pLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.pLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="rLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.rLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="rField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="KleinbergPanel.rField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+</Form>
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergPanel.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.PositiveNumberValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class KleinbergPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public KleinbergPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(KleinbergPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new KleinbergPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new nValidator(innerPanel));
+ group.add(innerPanel.pField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new pValidator(innerPanel));
+ group.add(innerPanel.qField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new qValidator(innerPanel));
+ group.add(innerPanel.rField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new rValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class nValidator implements Validator<String> {
+ private KleinbergPanel innerPanel;
+
+ public nValidator(KleinbergPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer n = Integer.parseInt(innerPanel.nField.getText());
+ result = n >= 2;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>n >= 2</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class pValidator implements Validator<String> {
+ private KleinbergPanel innerPanel;
+
+ public pValidator(KleinbergPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer n = Integer.parseInt(innerPanel.nField.getText());
+ Integer p = Integer.parseInt(innerPanel.pField.getText());
+ result = p >= 1 && p <= 2 * n - 2;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>1 <= p <= 2n - 2</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class qValidator implements Validator<String> {
+ private KleinbergPanel innerPanel;
+
+ public qValidator(KleinbergPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer n = Integer.parseInt(innerPanel.nField.getText());
+ Integer p = Integer.parseInt(innerPanel.pField.getText());
+ Integer q = Integer.parseInt(innerPanel.qField.getText());
+ if (p < n)
+ result = q >= 0 && q <= n * n - p * (p + 3) / 2 - 1;
+ else result = q >= 0 && q <= (2 * n - p - 3) * (2 * n - p) / 2 + 1;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message =
+ "<html>q >= 0<br>" +
+ "q <= n^2 - p * (p + 3) / 2 - 1 for p < n<br>" +
+ "q <= (2n - p - 3) * (2n - p) / 2 + 1 for p >= n<br></html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class rValidator implements Validator<String> {
+ private KleinbergPanel innerPanel;
+
+ public rValidator(KleinbergPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer r = Integer.parseInt(innerPanel.rField.getText());
+ result = r >= 0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>r >= 0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ qLabel = new javax.swing.JLabel();
+ qField = new javax.swing.JTextField();
+ nField = new javax.swing.JTextField();
+ pField = new javax.swing.JTextField();
+ nLabel = new javax.swing.JLabel();
+ pLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+ rLabel = new javax.swing.JLabel();
+ rField = new javax.swing.JTextField();
+
+ setPreferredSize(new java.awt.Dimension(399, 224));
+
+ qLabel.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.qLabel.text")); // NOI18N
+
+ qField.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.qField.text")); // NOI18N
+
+ nField.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.nField.text")); // NOI18N
+
+ pField.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.pField.text")); // NOI18N
+
+ nLabel.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.nLabel.text")); // NOI18N
+
+ pLabel.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.pLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.constraintsLabel.text")); // NOI18N
+
+ rLabel.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.rLabel.text")); // NOI18N
+
+ rField.setText(org.openide.util.NbBundle.getMessage(KleinbergPanel.class, "KleinbergPanel.rField.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(nLabel)
+ .addComponent(pLabel)
+ .addComponent(qLabel)
+ .addComponent(rLabel))
+ .addGap(74, 74, 74)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(rField, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
+ .addComponent(pField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
+ .addComponent(qField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
+ .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
+ .addContainerGap())
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(86, 86, 86))))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(nLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(pField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(pLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(qField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(qLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(rField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(rLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField nField;
+ private javax.swing.JLabel nLabel;
+ protected javax.swing.JTextField pField;
+ private javax.swing.JLabel pLabel;
+ protected javax.swing.JTextField qField;
+ private javax.swing.JLabel qLabel;
+ protected javax.swing.JTextField rField;
+ private javax.swing.JLabel rLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/KleinbergUIImpl.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.Kleinberg;
+import org.gephi.io.generator.plugin.KleinbergUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = KleinbergUI.class)
+public class KleinbergUIImpl implements KleinbergUI {
+ private KleinbergPanel panel;
+ private Kleinberg kleinberg;
+
+ public KleinbergUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new KleinbergPanel();
+ return KleinbergPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.kleinberg = (Kleinberg)generator;
+
+ if (panel == null)
+ panel = new KleinbergPanel();
+
+ panel.nField.setText(String.valueOf(kleinberg.getn()));
+ panel.pField.setText(String.valueOf(kleinberg.getp()));
+ panel.qField.setText(String.valueOf(kleinberg.getq()));
+ panel.rField.setText(String.valueOf(kleinberg.getr()));
+ }
+
+ public void unsetup() {
+ kleinberg.setn(Integer.parseInt(panel.nField.getText()));
+ kleinberg.setp(Integer.parseInt(panel.pField.getText()));
+ kleinberg.setq(Integer.parseInt(panel.qField.getText()));
+ kleinberg.setr(Integer.parseInt(panel.rField.getText()));
+ panel = null;
+ }
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.form 2010-12-16 02:37:54 +0000
@@ -0,0 +1,134 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[364, 128]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="nLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="kLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="alphaLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="kField" alignment="0" pref="139" max="32767" attributes="1"/>
+ <Component id="alphaField" alignment="0" pref="139" max="32767" attributes="1"/>
+ <Component id="nField" alignment="0" pref="139" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="155" max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="nField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="nLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="kField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="kLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="alphaField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="alphaLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="alphaLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.alphaLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="alphaField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.alphaField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="nField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.nField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="kField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.kField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="nLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.nLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="kLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.kLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzAlphaPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaPanel.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.BetweenZeroAndOneValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class WattsStrogatzAlphaPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public WattsStrogatzAlphaPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(WattsStrogatzAlphaPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new WattsStrogatzAlphaPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.nField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new nkValidator(innerPanel));
+ group.add(innerPanel.kField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new nkValidator(innerPanel));
+ group.add(innerPanel.alphaField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new alphaValidator(innerPanel));
+
+ return validationPanel;
+ }
+
+ private static class nkValidator implements Validator<String> {
+ private WattsStrogatzAlphaPanel innerPanel;
+
+ public nkValidator(WattsStrogatzAlphaPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer n = Integer.parseInt(innerPanel.nField.getText());
+ Integer k = Integer.parseInt(innerPanel.kField.getText());
+ result = n > k && k > 0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>n > k > 0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class alphaValidator implements Validator<String> {
+ private WattsStrogatzAlphaPanel innerPanel;
+
+ public alphaValidator(WattsStrogatzAlphaPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Double alpha = Double.parseDouble(innerPanel.alphaField.getText());
+ result = alpha >= 0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>alpha >= 0</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ alphaLabel = new javax.swing.JLabel();
+ alphaField = new javax.swing.JTextField();
+ nField = new javax.swing.JTextField();
+ kField = new javax.swing.JTextField();
+ nLabel = new javax.swing.JLabel();
+ kLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(364, 128));
+
+ alphaLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.alphaLabel.text")); // NOI18N
+
+ alphaField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.alphaField.text")); // NOI18N
+
+ nField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.nField.text")); // NOI18N
+
+ kField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.kField.text")); // NOI18N
+
+ nLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.nLabel.text")); // NOI18N
+
+ kLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.kLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzAlphaPanel.class, "WattsStrogatzAlphaPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(nLabel)
+ .addComponent(kLabel)
+ .addComponent(alphaLabel))
+ .addGap(25, 25, 25)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(kField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
+ .addComponent(alphaField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
+ .addComponent(nField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(155, 155, 155)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(nField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(nLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(kField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(kLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(alphaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(alphaLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField alphaField;
+ private javax.swing.JLabel alphaLabel;
+ private javax.swing.JLabel constraintsLabel;
+ protected javax.swing.JTextField kField;
+ private javax.swing.JLabel kLabel;
+ protected javax.swing.JTextField nField;
+ private javax.swing.JLabel nLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzAlphaUIImpl.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.WattsStrogatzAlpha;
+import org.gephi.io.generator.plugin.WattsStrogatzAlphaUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = WattsStrogatzAlphaUI.class)
+public class WattsStrogatzAlphaUIImpl implements WattsStrogatzAlphaUI {
+ private WattsStrogatzAlphaPanel panel;
+ private WattsStrogatzAlpha wattsStrogatzAlpha;
+
+ public WattsStrogatzAlphaUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new WattsStrogatzAlphaPanel();
+ return WattsStrogatzAlphaPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.wattsStrogatzAlpha = (WattsStrogatzAlpha)generator;
+
+ if (panel == null)
+ panel = new WattsStrogatzAlphaPanel();
+
+ panel.nField.setText(String.valueOf(wattsStrogatzAlpha.getn()));
+ panel.kField.setText(String.valueOf(wattsStrogatzAlpha.getk()));
+ panel.alphaField.setText(String.valueOf(wattsStrogatzAlpha.getalpha()));
+ }
+
+ public void unsetup() {
+ wattsStrogatzAlpha.setn(Integer.parseInt(panel.nField.getText()));
+ wattsStrogatzAlpha.setk(Integer.parseInt(panel.kField.getText()));
+ wattsStrogatzAlpha.setalpha(Double.parseDouble(panel.alphaField.getText()));
+ panel = null;
+ }
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.form 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.form 2010-12-16 02:37:54 +0000
@@ -0,0 +1,129 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[451, 142]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="constraintsLabel" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+ <Component id="NLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="KLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="betaLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="KField" alignment="0" pref="131" max="32767" attributes="1"/>
+ <Component id="betaField" alignment="0" pref="131" max="32767" attributes="1"/>
+ <Component id="NField" alignment="0" pref="131" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="NField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="NLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="KField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="KLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="betaField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="betaLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="constraintsLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="betaLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.betaLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="betaField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.betaField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="NField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.NField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="KField">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.KField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JLabel" name="NLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.NLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="KLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.KLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="constraintsLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzBetaPanel.constraintsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaPanel.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import org.gephi.lib.validation.BetweenZeroAndOneValidator;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Validator;
+import org.netbeans.validation.api.builtin.Validators;
+import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationPanel;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+public class WattsStrogatzBetaPanel extends javax.swing.JPanel {
+
+ /** Creates new form BarabasiAlbertPanel */
+ public WattsStrogatzBetaPanel() {
+ initComponents();
+ }
+
+ public static ValidationPanel createValidationPanel(WattsStrogatzBetaPanel innerPanel) {
+ ValidationPanel validationPanel = new ValidationPanel();
+ if (innerPanel == null)
+ innerPanel = new WattsStrogatzBetaPanel();
+ validationPanel.setInnerComponent(innerPanel);
+
+ ValidationGroup group = validationPanel.getValidationGroup();
+
+ group.add(innerPanel.NField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new NValidator(innerPanel));
+ group.add(innerPanel.KField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new KValidator(innerPanel));
+ group.add(innerPanel.betaField, Validators.REQUIRE_NON_EMPTY_STRING,
+ new BetweenZeroAndOneValidator());
+
+ return validationPanel;
+ }
+
+ private static class NValidator implements Validator<String> {
+ private WattsStrogatzBetaPanel innerPanel;
+
+ public NValidator(WattsStrogatzBetaPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer N = Integer.parseInt(innerPanel.NField.getText());
+ Integer K = Integer.parseInt(innerPanel.KField.getText());
+ result = N > K;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>N > K</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ private static class KValidator implements Validator<String> {
+ private WattsStrogatzBetaPanel innerPanel;
+
+ public KValidator(WattsStrogatzBetaPanel innerPanel) {
+ this.innerPanel = innerPanel;
+ }
+
+ @Override
+ public boolean validate(Problems problems, String compName, String model) {
+ boolean result = false;
+
+ try {
+ Integer N = Integer.parseInt(innerPanel.NField.getText());
+ Integer K = Integer.parseInt(innerPanel.KField.getText());
+ Double lnN = Math.log(N);
+ result = K >= lnN && lnN >= 1 && K % 2 == 0;
+ }
+ catch (Exception e) { }
+ if (!result) {
+ String message = "<html>K >= ln(N) >= 1 and K is even</html>";
+ problems.add(message);
+ }
+
+ return result;
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ betaLabel = new javax.swing.JLabel();
+ betaField = new javax.swing.JTextField();
+ NField = new javax.swing.JTextField();
+ KField = new javax.swing.JTextField();
+ NLabel = new javax.swing.JLabel();
+ KLabel = new javax.swing.JLabel();
+ constraintsLabel = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(451, 142));
+
+ betaLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.betaLabel.text")); // NOI18N
+
+ betaField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.betaField.text")); // NOI18N
+
+ NField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.NField.text")); // NOI18N
+
+ KField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.KField.text")); // NOI18N
+
+ NLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.NLabel.text")); // NOI18N
+
+ KLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.KLabel.text")); // NOI18N
+
+ constraintsLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzBetaPanel.class, "WattsStrogatzBetaPanel.constraintsLabel.text")); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(NLabel)
+ .addComponent(KLabel)
+ .addComponent(betaLabel)))
+ .addGap(25, 25, 25)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(KField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
+ .addComponent(betaField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
+ .addComponent(NField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(NField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(NLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(KField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(KLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(betaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(betaLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(constraintsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// </editor-fold>//GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ protected javax.swing.JTextField KField;
+ private javax.swing.JLabel KLabel;
+ protected javax.swing.JTextField NField;
+ private javax.swing.JLabel NLabel;
+ protected javax.swing.JTextField betaField;
+ private javax.swing.JLabel betaLabel;
+ private javax.swing.JLabel constraintsLabel;
+ // End of variables declaration//GEN-END:variables
+
+}
=== added file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaUIImpl.java 1970-01-01 00:00:00 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzBetaUIImpl.java 2010-12-16 02:37:54 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008-2010 Gephi
+ * Authors : Cezary Bartosiak
+ * Website : http://www.gephi.org
+ *
+ * This file is part of Gephi.
+ *
+ * Gephi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gephi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gephi. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gephi.ui.generator.plugin;
+
+import javax.swing.JPanel;
+import org.gephi.io.generator.plugin.WattsStrogatzBeta;
+import org.gephi.io.generator.plugin.WattsStrogatzBetaUI;
+import org.gephi.io.generator.spi.Generator;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ *
+ * @author Cezary Bartosiak
+ */
+@ServiceProvider(service = WattsStrogatzBetaUI.class)
+public class WattsStrogatzBetaUIImpl implements WattsStrogatzBetaUI {
+ private WattsStrogatzBetaPanel panel;
+ private WattsStrogatzBeta wattsStrogatzBeta;
+
+ public WattsStrogatzBetaUIImpl() { }
+
+ public JPanel getPanel() {
+ if (panel == null)
+ panel = new WattsStrogatzBetaPanel();
+ return WattsStrogatzBetaPanel.createValidationPanel(panel);
+ }
+
+ public void setup(Generator generator) {
+ this.wattsStrogatzBeta = (WattsStrogatzBeta)generator;
+
+ if (panel == null)
+ panel = new WattsStrogatzBetaPanel();
+
+ panel.NField.setText(String.valueOf(wattsStrogatzBeta.getN()));
+ panel.KField.setText(String.valueOf(wattsStrogatzBeta.getK()));
+ panel.betaField.setText(String.valueOf(wattsStrogatzBeta.getbeta()));
+ }
+
+ public void unsetup() {
+ wattsStrogatzBeta.setN(Integer.parseInt(panel.NField.getText()));
+ wattsStrogatzBeta.setK(Integer.parseInt(panel.KField.getText()));
+ wattsStrogatzBeta.setbeta(Double.parseDouble(panel.betaField.getText()));
+ panel = null;
+ }
+}
=== removed file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.form'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.form 2010-04-12 12:48:22 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.form 1970-01-01 00:00:00 +0000
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
- <AuxValues>
- <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
- <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
- <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- </AuxValues>
-
- <Layout>
- <DimensionLayout dim="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="1" attributes="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="nodeLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- </Group>
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="edgeLabel" min="-2" max="-2" attributes="0"/>
- </Group>
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="edgeLabel1" min="-2" max="-2" attributes="0"/>
- </Group>
- </Group>
- <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="1" attributes="0">
- <Group type="102" alignment="1" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="nodeField" pref="120" max="32767" attributes="1"/>
- </Group>
- <Component id="neighborField" alignment="0" pref="120" max="32767" attributes="1"/>
- <Component id="probabilityField" alignment="0" pref="120" max="32767" attributes="1"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- </Group>
- </Group>
- </DimensionLayout>
- <DimensionLayout dim="1">
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="nodeField" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="nodeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="neighborField" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="edgeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="probabilityField" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="edgeLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace pref="46" max="32767" attributes="0"/>
- </Group>
- </Group>
- </DimensionLayout>
- </Layout>
- <SubComponents>
- <Component class="javax.swing.JLabel" name="nodeLabel">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.nodeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- </Component>
- <Component class="javax.swing.JLabel" name="edgeLabel">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.edgeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- </Component>
- <Component class="javax.swing.JTextField" name="nodeField">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.nodeField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- <AuxValues>
- <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
- </AuxValues>
- </Component>
- <Component class="javax.swing.JTextField" name="neighborField">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.neighborField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- <AuxValues>
- <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
- </AuxValues>
- </Component>
- <Component class="javax.swing.JTextField" name="probabilityField">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.probabilityField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- <AuxValues>
- <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
- </AuxValues>
- </Component>
- <Component class="javax.swing.JLabel" name="edgeLabel1">
- <Properties>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
- <ResourceString bundle="org/gephi/ui/generator/plugin/Bundle.properties" key="WattsStrogatzPanel.edgeLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
- </Property>
- </Properties>
- </Component>
- </SubComponents>
-</Form>
=== removed file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.java 2010-08-22 21:06:56 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzPanel.java 1970-01-01 00:00:00 +0000
@@ -1,174 +0,0 @@
-/*
-Copyright 2008-2010 Gephi
-Authors : Mathieu Bastian <mathieu.bastian@xxxxxxxxx>
-Website : http://www.gephi.org
-
-This file is part of Gephi.
-
-Gephi is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-Gephi is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with Gephi. If not, see <http://www.gnu.org/licenses/>.
-*/
-package org.gephi.ui.generator.plugin;
-
-import org.gephi.lib.validation.BetweenZeroAndOneValidator;
-import org.gephi.lib.validation.PositiveNumberValidator;
-import org.netbeans.validation.api.Problems;
-import org.netbeans.validation.api.Validator;
-import org.netbeans.validation.api.builtin.Validators;
-import org.netbeans.validation.api.ui.ValidationGroup;
-import org.netbeans.validation.api.ui.ValidationPanel;
-import org.openide.util.NbBundle;
-
-/**
- *
- * @author Mathieu Bastian
- */
-public class WattsStrogatzPanel extends javax.swing.JPanel {
-
- /** Creates new form RandomGraphPanel */
- public WattsStrogatzPanel() {
- initComponents();
- }
-
- public static ValidationPanel createValidationPanel(WattsStrogatzPanel innerPanel) {
- ValidationPanel validationPanel = new ValidationPanel();
- if (innerPanel == null) {
- innerPanel = new WattsStrogatzPanel();
- }
- validationPanel.setInnerComponent(innerPanel);
-
- ValidationGroup group = validationPanel.getValidationGroup();
-
- //Node field
- group.add(innerPanel.nodeField, Validators.REQUIRE_NON_EMPTY_STRING,
- new PositiveNumberValidator());
-
- //Neighbor field
- group.add(innerPanel.neighborField, Validators.REQUIRE_NON_EMPTY_STRING,
- new NeighborValidator(innerPanel));
-
- //Edge field
- group.add(innerPanel.probabilityField, Validators.REQUIRE_NON_EMPTY_STRING,
- new BetweenZeroAndOneValidator());
-
- return validationPanel;
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
-
- nodeLabel = new javax.swing.JLabel();
- edgeLabel = new javax.swing.JLabel();
- nodeField = new javax.swing.JTextField();
- neighborField = new javax.swing.JTextField();
- probabilityField = new javax.swing.JTextField();
- edgeLabel1 = new javax.swing.JLabel();
-
- nodeLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.nodeLabel.text")); // NOI18N
-
- edgeLabel.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.edgeLabel.text")); // NOI18N
-
- nodeField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.nodeField.text")); // NOI18N
-
- neighborField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.neighborField.text")); // NOI18N
-
- probabilityField.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.probabilityField.text")); // NOI18N
-
- edgeLabel1.setText(org.openide.util.NbBundle.getMessage(WattsStrogatzPanel.class, "WattsStrogatzPanel.edgeLabel1.text")); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(nodeLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(edgeLabel))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(edgeLabel1)))
- .addGap(25, 25, 25)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(nodeField, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
- .addComponent(neighborField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
- .addComponent(probabilityField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(nodeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(nodeLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(neighborField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(edgeLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(probabilityField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(edgeLabel1))
- .addContainerGap(46, Short.MAX_VALUE))
- );
- }// </editor-fold>//GEN-END:initComponents
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JLabel edgeLabel;
- private javax.swing.JLabel edgeLabel1;
- protected javax.swing.JTextField neighborField;
- protected javax.swing.JTextField nodeField;
- private javax.swing.JLabel nodeLabel;
- protected javax.swing.JTextField probabilityField;
- // End of variables declaration//GEN-END:variables
-
- private static class NeighborValidator implements Validator<String> {
-
- private WattsStrogatzPanel innerPanel;
-
- public NeighborValidator(WattsStrogatzPanel innerPanel) {
- this.innerPanel = innerPanel;
- }
-
- @Override
- public boolean validate(Problems problems, String compName, String model) {
- boolean result = false;
- int limit = 0;
- try {
- Integer i = Integer.parseInt(innerPanel.nodeField.getText());
- limit = i / 2;
- int neighbor = Integer.parseInt(model);
- result = neighbor >= 2 && neighbor <= limit;
- } catch (Exception e) {
- }
- if (!result) {
- String message = NbBundle.getMessage(WattsStrogatzPanel.class,
- "WattsStrogatzPanel.NeigborValidator.problem", model, String.valueOf(limit));
- problems.add(message);
- }
- return result;
- }
- }
-}
=== removed file 'GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzUIImpl.java'
--- GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzUIImpl.java 2010-07-15 14:48:14 +0000
+++ GeneratorPluginUI/src/org/gephi/ui/generator/plugin/WattsStrogatzUIImpl.java 1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
-/*
-Copyright 2008-2010 Gephi
-Authors : Mathieu Bastian <mathieu.bastian@xxxxxxxxx>
-Website : http://www.gephi.org
-
-This file is part of Gephi.
-
-Gephi is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-Gephi is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with Gephi. If not, see <http://www.gnu.org/licenses/>.
-*/
-package org.gephi.ui.generator.plugin;
-
-import javax.swing.JPanel;
-import org.gephi.io.generator.plugin.RandomGraph;
-import org.gephi.io.generator.plugin.RandomGraphUI;
-import org.gephi.io.generator.plugin.WattsStrogatz;
-import org.gephi.io.generator.plugin.WattsStrogatzUI;
-import org.gephi.io.generator.spi.Generator;
-import org.openide.util.lookup.ServiceProvider;
-
-/**
- *
- * @author Mathieu Bastian
- */
-@ServiceProvider(service = WattsStrogatzUI.class)
-public class WattsStrogatzUIImpl implements WattsStrogatzUI {
-
- private WattsStrogatzPanel panel;
- private WattsStrogatz wattsStrogatz;
-
- public WattsStrogatzUIImpl() {
- }
-
- public JPanel getPanel() {
- if (panel == null) {
- panel = new WattsStrogatzPanel();
- }
- return WattsStrogatzPanel.createValidationPanel(panel);
- }
-
- public void setup(Generator generator) {
- this.wattsStrogatz = (WattsStrogatz) generator;
-
- //Set UI
- if (panel == null) {
- panel = new WattsStrogatzPanel();
- }
- panel.nodeField.setText(String.valueOf(wattsStrogatz.getNumberOfNodes()));
- panel.neighborField.setText(String.valueOf(wattsStrogatz.getNumberOfNeighbors()));
- panel.probabilityField.setText(String.valueOf(wattsStrogatz.getRewiringProbability()));
- }
-
- public void unsetup() {
- //Set params
- wattsStrogatz.setNumberOfNodes(Integer.parseInt(panel.nodeField.getText()));
- wattsStrogatz.setNumberOfNeighbors(Integer.parseInt(panel.neighborField.getText()));
- wattsStrogatz.setRewiringProbability(Double.parseDouble(panel.probabilityField.getText()));
- panel = null;
- }
-}
\ No newline at end of file
Follow ups