diff --git a/.classpath b/.classpath
deleted file mode 100644
index 4cb2221..0000000
--- a/.classpath
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index d2fcacd..f7627c0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -161,3 +161,9 @@ pip-log.txt
# Mac crap
.DS_Store
+
+target
+.cache
+
+.classpath
+.project
diff --git a/.project b/.project
deleted file mode 100644
index 5e7b252..0000000
--- a/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Enet
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/build-launch4j.xml b/build-launch4j.xml
new file mode 100644
index 0000000..37fc30f
--- /dev/null
+++ b/build-launch4j.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ Egonet
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.sbt b/build.sbt
new file mode 100644
index 0000000..ab9586c
--- /dev/null
+++ b/build.sbt
@@ -0,0 +1,61 @@
+import AssemblyKeys._
+import Keys._
+import sbtassembly.Plugin._
+
+assemblySettings
+
+name := "egonet"
+
+libraryDependencies += "net.sf.jung" % "jung-api" % "2.0.1"
+
+libraryDependencies += "net.sf.jung" % "jung-graph-impl" % "2.0.1"
+
+libraryDependencies += "net.sf.jung" % "jung-algorithms" % "2.0.1"
+
+libraryDependencies += "net.sf.jung" % "jung-io" % "2.0.1"
+
+libraryDependencies += "net.sf.jung" % "jung-visualization" % "2.0.1"
+
+libraryDependencies += "org.swinglabs" % "swingx" % "0.9.7"
+
+libraryDependencies += "org.jdesktop" % "swing-worker" % "1.1"
+
+libraryDependencies += "org.swinglabs" % "swing-layout" % "1.0.3"
+
+libraryDependencies += "com.miglayout" % "miglayout" % "3.7"
+
+libraryDependencies += "com.jgoodies" % "forms" % "1.1.0"
+
+libraryDependencies += "com.jgoodies" % "looks" % "2.1.4"
+
+libraryDependencies += "com.google.guava" % "guava" % "r08"
+
+libraryDependencies += "com.jcraft" % "jsch" % "0.1.41"
+
+libraryDependencies += "net.sf.opencsv" % "opencsv" % "1.8"
+
+libraryDependencies += "com.lowagie" % "itext" % "2.1.5"
+
+libraryDependencies += "com.lowagie" % "itext-rtf" % "2.1.5"
+
+libraryDependencies += "junit" % "junit" % "4.3.1"
+
+libraryDependencies += "commons-codec" % "commons-codec" % "1.3"
+
+libraryDependencies += "org.slf4j" % "slf4j-api" % "1.5.6"
+
+libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "1.5.6"
+
+mainClass in (Compile, run) := Some("org.egonet.gui.EgonetRunner")
+
+mainClass in assembly := Some("org.egonet.gui.EgonetRunner")
+
+mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
+ {
+// case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
+// case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
+// case "application.conf" => MergeStrategy.concat
+ case "RELEASE-NOTES.txt" => MergeStrategy.discard
+ case x => old(x)
+ }
+}
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 8f35ba2..0000000
--- a/build.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
- Egonet
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/fest-swing-1.0b1/lib/MRJToolkitStubs-1.0.jar b/lib/MRJToolkitStubs-1.0.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/lib/MRJToolkitStubs-1.0.jar
rename to lib/MRJToolkitStubs-1.0.jar
diff --git a/lib/fest-swing-1.0b1/lib/fest-assert-1.0a1.jar b/lib/fest-assert-1.0a1.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/lib/fest-assert-1.0a1.jar
rename to lib/fest-assert-1.0a1.jar
diff --git a/lib/fest-swing-1.0b1/lib/fest-reflect-0.4.jar b/lib/fest-reflect-0.4.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/lib/fest-reflect-0.4.jar
rename to lib/fest-reflect-0.4.jar
diff --git a/lib/fest-swing-1.0b1/fest-swing-1.0b1.jar b/lib/fest-swing-1.0b1.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/fest-swing-1.0b1.jar
rename to lib/fest-swing-1.0b1.jar
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/fest-swing-junit-1.0b1-sources.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/fest-swing-junit-1.0b1-sources.jar
deleted file mode 100644
index 11344c5..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/fest-swing-junit-1.0b1-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/commons-codec-1.3.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/commons-codec-1.3.jar
deleted file mode 100644
index 957b675..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/commons-codec-1.3.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/junit-4.3.1.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/junit-4.3.1.jar
deleted file mode 100644
index 77b4fb0..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/lib/junit-4.3.1.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1-sources.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1-sources.jar
deleted file mode 100644
index c3c289f..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1.jar
deleted file mode 100644
index 3d02ef3..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/fest-swing-testng-1.0b1.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/lib/testng-5.5-jdk15.jar b/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/lib/testng-5.5-jdk15.jar
deleted file mode 100644
index 7d5651a..0000000
Binary files a/lib/fest-swing-1.0b1/extensions/fest-swing-testng-1.0b1/lib/testng-5.5-jdk15.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/fest-swing-1.0b1-sources.jar b/lib/fest-swing-1.0b1/fest-swing-1.0b1-sources.jar
deleted file mode 100644
index 3ed114b..0000000
Binary files a/lib/fest-swing-1.0b1/fest-swing-1.0b1-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/lib/fest-assert-1.0a1-sources.jar b/lib/fest-swing-1.0b1/lib/fest-assert-1.0a1-sources.jar
deleted file mode 100644
index a3bf47c..0000000
Binary files a/lib/fest-swing-1.0b1/lib/fest-assert-1.0a1-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/lib/fest-reflect-0.4-sources.jar b/lib/fest-swing-1.0b1/lib/fest-reflect-0.4-sources.jar
deleted file mode 100644
index e9233ea..0000000
Binary files a/lib/fest-swing-1.0b1/lib/fest-reflect-0.4-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/lib/fest-util-0.4-sources.jar b/lib/fest-swing-1.0b1/lib/fest-util-0.4-sources.jar
deleted file mode 100644
index 227e2a9..0000000
Binary files a/lib/fest-swing-1.0b1/lib/fest-util-0.4-sources.jar and /dev/null differ
diff --git a/lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/fest-swing-junit-1.0b1.jar b/lib/fest-swing-junit-1.0b1.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/extensions/fest-swing-junit-1.0b1/fest-swing-junit-1.0b1.jar
rename to lib/fest-swing-junit-1.0b1.jar
diff --git a/lib/fest-swing-1.0b1/lib/fest-util-0.4.jar b/lib/fest-util-0.4.jar
similarity index 100%
rename from lib/fest-swing-1.0b1/lib/fest-util-0.4.jar
rename to lib/fest-util-0.4.jar
diff --git a/lib/forms-1.1.0.jar b/lib/forms-1.1.0.jar
deleted file mode 100644
index 50c1eb8..0000000
Binary files a/lib/forms-1.1.0.jar and /dev/null differ
diff --git a/lib/guava-r08.jar b/lib/guava-r08.jar
deleted file mode 100644
index d18d0bd..0000000
Binary files a/lib/guava-r08.jar and /dev/null differ
diff --git a/lib/iText-2.1.5.jar b/lib/iText-2.1.5.jar
deleted file mode 100644
index f28be38..0000000
Binary files a/lib/iText-2.1.5.jar and /dev/null differ
diff --git a/lib/iText-rtf-2.1.5.jar b/lib/iText-rtf-2.1.5.jar
deleted file mode 100644
index dd4ebfc..0000000
Binary files a/lib/iText-rtf-2.1.5.jar and /dev/null differ
diff --git a/lib/jsch-0.1.40.jar b/lib/jsch-0.1.40.jar
deleted file mode 100644
index 67952d8..0000000
Binary files a/lib/jsch-0.1.40.jar and /dev/null differ
diff --git a/lib/jung/collections-generic-4.01.jar b/lib/jung/collections-generic-4.01.jar
deleted file mode 100644
index 92d009c..0000000
Binary files a/lib/jung/collections-generic-4.01.jar and /dev/null differ
diff --git a/lib/jung/colt-1.2.0.jar b/lib/jung/colt-1.2.0.jar
deleted file mode 100644
index a7192f6..0000000
Binary files a/lib/jung/colt-1.2.0.jar and /dev/null differ
diff --git a/lib/jung/concurrent-1.3.4.jar b/lib/jung/concurrent-1.3.4.jar
deleted file mode 100644
index 551f347..0000000
Binary files a/lib/jung/concurrent-1.3.4.jar and /dev/null differ
diff --git a/lib/jung/jung-algorithms-2.0-beta1.jar b/lib/jung/jung-algorithms-2.0-beta1.jar
deleted file mode 100644
index 280a998..0000000
Binary files a/lib/jung/jung-algorithms-2.0-beta1.jar and /dev/null differ
diff --git a/lib/jung/jung-api-2.0-beta1.jar b/lib/jung/jung-api-2.0-beta1.jar
deleted file mode 100644
index 7483cfc..0000000
Binary files a/lib/jung/jung-api-2.0-beta1.jar and /dev/null differ
diff --git a/lib/jung/jung-graph-impl-2.0-beta1.jar b/lib/jung/jung-graph-impl-2.0-beta1.jar
deleted file mode 100644
index 5d2e60c..0000000
Binary files a/lib/jung/jung-graph-impl-2.0-beta1.jar and /dev/null differ
diff --git a/lib/jung/jung-io-2.0-beta1.jar b/lib/jung/jung-io-2.0-beta1.jar
deleted file mode 100644
index 2a50dc3..0000000
Binary files a/lib/jung/jung-io-2.0-beta1.jar and /dev/null differ
diff --git a/lib/jung/jung-visualization-2.0-beta1.jar b/lib/jung/jung-visualization-2.0-beta1.jar
deleted file mode 100644
index 8fb2713..0000000
Binary files a/lib/jung/jung-visualization-2.0-beta1.jar and /dev/null differ
diff --git a/lib/junit-4.3.1.jar b/lib/junit-4.3.1.jar
deleted file mode 100644
index 6806753..0000000
Binary files a/lib/junit-4.3.1.jar and /dev/null differ
diff --git a/lib/looks-2.1.4.jar b/lib/looks-2.1.4.jar
deleted file mode 100644
index d2c47c7..0000000
Binary files a/lib/looks-2.1.4.jar and /dev/null differ
diff --git a/lib/miglayout-3.7-swing.jar b/lib/miglayout-3.7-swing.jar
deleted file mode 100644
index ad26e11..0000000
Binary files a/lib/miglayout-3.7-swing.jar and /dev/null differ
diff --git a/lib/opencsv-1.8.jar b/lib/opencsv-1.8.jar
deleted file mode 100644
index b684861..0000000
Binary files a/lib/opencsv-1.8.jar and /dev/null differ
diff --git a/lib/slf4j-api-1.5.6.jar b/lib/slf4j-api-1.5.6.jar
deleted file mode 100644
index 9b42216..0000000
Binary files a/lib/slf4j-api-1.5.6.jar and /dev/null differ
diff --git a/lib/slf4j-jdk14-1.5.6.jar b/lib/slf4j-jdk14-1.5.6.jar
deleted file mode 100644
index d41ca3f..0000000
Binary files a/lib/slf4j-jdk14-1.5.6.jar and /dev/null differ
diff --git a/lib/swing-layout-1.0.3.jar b/lib/swing-layout-1.0.3.jar
deleted file mode 100644
index 5353286..0000000
Binary files a/lib/swing-layout-1.0.3.jar and /dev/null differ
diff --git a/lib/swing-worker-1.1.jar b/lib/swing-worker-1.1.jar
deleted file mode 100644
index 3935611..0000000
Binary files a/lib/swing-worker-1.1.jar and /dev/null differ
diff --git a/lib/swingx-0.9.7.jar b/lib/swingx-0.9.7.jar
deleted file mode 100644
index 69a959a..0000000
Binary files a/lib/swingx-0.9.7.jar and /dev/null differ
diff --git a/project/plugins.sbt b/project/plugins.sbt
new file mode 100644
index 0000000..63cafdb
--- /dev/null
+++ b/project/plugins.sbt
@@ -0,0 +1,3 @@
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
+
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
diff --git a/src/com/endlessloopsoftware/ego/author/AuthoringQuestionPanel.java b/src/main/java/com/endlessloopsoftware/ego/author/AuthoringQuestionPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/author/AuthoringQuestionPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/author/AuthoringQuestionPanel.java
diff --git a/src/com/endlessloopsoftware/ego/author/CategoryInputPane.java b/src/main/java/com/endlessloopsoftware/ego/author/CategoryInputPane.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/author/CategoryInputPane.java
rename to src/main/java/com/endlessloopsoftware/ego/author/CategoryInputPane.java
index f534649..1b2502c 100644
--- a/src/com/endlessloopsoftware/ego/author/CategoryInputPane.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/CategoryInputPane.java
@@ -1,212 +1,212 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-import org.egonet.model.question.AlterPairQuestion;
-import org.egonet.model.question.AlterPromptQuestion;
-import org.egonet.model.question.Question;
-import org.egonet.util.CatchingAction;
-import org.egonet.util.listbuilder.ListBuilder;
-import org.egonet.util.listbuilder.Selection;
-
-import com.endlessloopsoftware.egonet.Shared;
-
-public class CategoryInputPane extends JDialog {
-
- private final JList parentList;
-
- private final GridBagLayout gridBagLayout1 = new GridBagLayout();
-
- // create list builder with preset values turned on.
- private final ListBuilder listBuilder = new ListBuilder();
-
- private final JButton jOKButton = new JButton("OK");
-
- private final JButton jCancelButton = new JButton("Cancel");
-
- private JScrollPane scrollPane;
-
- private final EgoNet egoNet;
-
- /**
- * Constructor for CategoryInputPane
- *
- * @param list
- * question list from parent frame used to determine which
- * question we are operating on
- */
- public CategoryInputPane(EgoNet egoNet, JList list) throws Exception
- {
- parentList = list;
- this.egoNet = egoNet;
- jbInit();
- }
-
- /**
- * Initializes layout and fields for the dialog
- *
- * @throws Exception
- * No idea, sorry
- */
- private void jbInit() throws Exception {
- JPanel panel = new JPanel();
-
- panel.setLayout(gridBagLayout1);
- this.setModal(true);
- this.setTitle("Category Options");
- this.setName(this.getTitle());
-
- panel.add(
- listBuilder,
- new GridBagConstraints(0, 0, 4, 1, 1.0, 0.9,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
- panel.add(
- jCancelButton,
- new GridBagConstraints(2, 1, 2, 1, 0.2, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(10, 0, 10, 10), 0, 0));
- panel.add(
- jOKButton,
- new GridBagConstraints(0, 1, 2, 1, 0.2, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(10, 20, 10, 0), 26, 0));
-
- jOKButton.addActionListener(new CatchingAction("jOKButton") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- OKButton_actionPerformed(e);
- }
- });
-
- jCancelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- cancelButton_actionPerformed(e);
- }
- });
-
- scrollPane = new JScrollPane(panel);
- this.getContentPane().add(scrollPane);
- }
-
- void OKButton_actionPerformed(ActionEvent e) throws IOException {
- boolean changed = false;
- boolean compatible = true;
- // boolean abort = false;
-
- Question q = (Question) parentList.getSelectedValue();
- if (q != null) {
- /* count choices */
-
- Selection[] newSelections = listBuilder.getListSelections();
-
- if (newSelections.length != q.getSelections().length) {
- if (egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame())) {
- compatible = false;
- changed = true;
-
- // If the number changed we know the list has changed, so
- // just copy over
- // the reference and let the loop trim the strings
- q.setSelections(newSelections);
- } else {
- // Don't make this change
- egoNet.getFrame().fillCurrentPanel();
- this.hide();
- return;
- }
- }
-
- // Trim the strings, check for changes
- for (int i = 0; i < q.getSelections().length; i++) {
- if (!q.getSelections()[i]
- .equals(newSelections[i].getString().trim())) {
- q.getSelections()[i].setString(newSelections[i].getString()
- .trim());
- changed = true;
- }
- // q.selections[i].value= newSelections[i].value;
- }
-
- egoNet.getStudy().setModified(changed);
- egoNet.getStudy().setCompatible(compatible);
-
- egoNet.getFrame().fillCurrentPanel();
- this.setVisible(false);
- }
-
- }
-
- void cancelButton_actionPerformed(ActionEvent e) {
- this.setVisible(false);
- }
-
- void activate() {
- Question q = (Question) parentList.getSelectedValue();
-
- if (q != null) {
- listBuilder.setListSelections(q.getSelections());
- } else {
- System.err.println("Parent list had no selections");
- }
-
- listBuilder.setEditable(true);
-
- listBuilder.setElementName("Option: ");
- listBuilder.setTitle("Category Options");
- listBuilder
- .setDescription("Enter possible answers to this question below. Press Return to add the option "
- + "to the options list. Press OK to set options or Cancel to undo changes.");
- if(q instanceof AlterPromptQuestion)
- listBuilder.setNameModel(egoNet.getStudy().getAlterNameModel());
- listBuilder.setLetUserPickValues(true);
- listBuilder.setPresetListsActive(q.answerType == Shared.AnswerType.CATEGORICAL);
-
-// boolean preset = (q.answerType == Shared.AnswerType.CATEGORICAL) ? true : false;
-// logger.info("Is question categorical? " + preset);
-//
- listBuilder.setAdjacencyActive(q instanceof AlterPairQuestion);
-
- this.setSize(500, 400); // width, height
-
- // Center the window
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = this.getSize();
- this.setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
-
- jOKButton.setVisible(true);
- jCancelButton.setText("Cancel");
-
- this.setVisible(true);
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.egonet.model.question.AlterPairQuestion;
+import org.egonet.model.question.AlterPromptQuestion;
+import org.egonet.model.question.Question;
+import org.egonet.util.CatchingAction;
+import org.egonet.util.listbuilder.ListBuilder;
+import org.egonet.util.listbuilder.Selection;
+
+import com.endlessloopsoftware.egonet.Shared;
+
+public class CategoryInputPane extends JDialog {
+
+ private final JList parentList;
+
+ private final GridBagLayout gridBagLayout1 = new GridBagLayout();
+
+ // create list builder with preset values turned on.
+ private final ListBuilder listBuilder = new ListBuilder();
+
+ private final JButton jOKButton = new JButton("OK");
+
+ private final JButton jCancelButton = new JButton("Cancel");
+
+ private JScrollPane scrollPane;
+
+ private final EgoNet egoNet;
+
+ /**
+ * Constructor for CategoryInputPane
+ *
+ * @param list
+ * question list from parent frame used to determine which
+ * question we are operating on
+ */
+ public CategoryInputPane(EgoNet egoNet, JList list) throws Exception
+ {
+ parentList = list;
+ this.egoNet = egoNet;
+ jbInit();
+ }
+
+ /**
+ * Initializes layout and fields for the dialog
+ *
+ * @throws Exception
+ * No idea, sorry
+ */
+ private void jbInit() throws Exception {
+ JPanel panel = new JPanel();
+
+ panel.setLayout(gridBagLayout1);
+ this.setModal(true);
+ this.setTitle("Category Options");
+ this.setName(this.getTitle());
+
+ panel.add(
+ listBuilder,
+ new GridBagConstraints(0, 0, 4, 1, 1.0, 0.9,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 0), 0, 0));
+ panel.add(
+ jCancelButton,
+ new GridBagConstraints(2, 1, 2, 1, 0.2, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(10, 0, 10, 10), 0, 0));
+ panel.add(
+ jOKButton,
+ new GridBagConstraints(0, 1, 2, 1, 0.2, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(10, 20, 10, 0), 26, 0));
+
+ jOKButton.addActionListener(new CatchingAction("jOKButton") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ OKButton_actionPerformed(e);
+ }
+ });
+
+ jCancelButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ cancelButton_actionPerformed(e);
+ }
+ });
+
+ scrollPane = new JScrollPane(panel);
+ this.getContentPane().add(scrollPane);
+ }
+
+ void OKButton_actionPerformed(ActionEvent e) throws IOException {
+ boolean changed = false;
+ boolean compatible = true;
+ // boolean abort = false;
+
+ Question q = (Question) parentList.getSelectedValue();
+ if (q != null) {
+ /* count choices */
+
+ Selection[] newSelections = listBuilder.getListSelections();
+
+ if (newSelections.length != q.getSelections().length) {
+ if (egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame())) {
+ compatible = false;
+ changed = true;
+
+ // If the number changed we know the list has changed, so
+ // just copy over
+ // the reference and let the loop trim the strings
+ q.setSelections(newSelections);
+ } else {
+ // Don't make this change
+ egoNet.getFrame().fillCurrentPanel();
+ this.hide();
+ return;
+ }
+ }
+
+ // Trim the strings, check for changes
+ for (int i = 0; i < q.getSelections().length; i++) {
+ if (!q.getSelections()[i]
+ .equals(newSelections[i].getString().trim())) {
+ q.getSelections()[i].setString(newSelections[i].getString()
+ .trim());
+ changed = true;
+ }
+ // q.selections[i].value= newSelections[i].value;
+ }
+
+ egoNet.getStudy().setModified(changed);
+ egoNet.getStudy().setCompatible(compatible);
+
+ egoNet.getFrame().fillCurrentPanel();
+ this.setVisible(false);
+ }
+
+ }
+
+ void cancelButton_actionPerformed(ActionEvent e) {
+ this.setVisible(false);
+ }
+
+ void activate() {
+ Question q = (Question) parentList.getSelectedValue();
+
+ if (q != null) {
+ listBuilder.setListSelections(q.getSelections());
+ } else {
+ System.err.println("Parent list had no selections");
+ }
+
+ listBuilder.setEditable(true);
+
+ listBuilder.setElementName("Option: ");
+ listBuilder.setTitle("Category Options");
+ listBuilder
+ .setDescription("Enter possible answers to this question below. Press Return to add the option "
+ + "to the options list. Press OK to set options or Cancel to undo changes.");
+ if(q instanceof AlterPromptQuestion)
+ listBuilder.setNameModel(egoNet.getStudy().getAlterNameModel());
+ listBuilder.setLetUserPickValues(true);
+ listBuilder.setPresetListsActive(q.answerType == Shared.AnswerType.CATEGORICAL);
+
+// boolean preset = (q.answerType == Shared.AnswerType.CATEGORICAL) ? true : false;
+// logger.info("Is question categorical? " + preset);
+//
+ listBuilder.setAdjacencyActive(q instanceof AlterPairQuestion);
+
+ this.setSize(500, 400); // width, height
+
+ // Center the window
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = this.getSize();
+ this.setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+
+ jOKButton.setVisible(true);
+ jCancelButton.setText("Cancel");
+
+ this.setVisible(true);
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/EgoFrame.java b/src/main/java/com/endlessloopsoftware/ego/author/EgoFrame.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/author/EgoFrame.java
rename to src/main/java/com/endlessloopsoftware/ego/author/EgoFrame.java
index 56d1d85..80849e3 100644
--- a/src/com/endlessloopsoftware/ego/author/EgoFrame.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/EgoFrame.java
@@ -1,572 +1,572 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-
-import org.egonet.model.question.*;
-import java.awt.AWTEvent;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Cursor;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.InternalFrameEvent;
-import javax.swing.event.InternalFrameListener;
-import javax.swing.text.DefaultEditorKit;
-
-import org.egonet.exceptions.CorruptedInterviewException;
-import org.egonet.gui.MDIChildFrame;
-import org.egonet.mdi.MDIContext;
-import org.egonet.model.question.Question;
-import org.egonet.util.CatchingAction;
-import org.egonet.util.EgonetAnalytics;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.endlessloopsoftware.egonet.Shared;
-
-import org.egonet.model.question.StudyQuestion;
-
-public class EgoFrame extends MDIChildFrame implements Observer, InternalFrameListener {
-
- final private static Logger logger = LoggerFactory.getLogger(EgoFrame.class);
-
- /**
- * Changes based on jTabbedPane_stateChanged, which is activated when tabs are clicked
- */
- Class extends Question> curTab = StudyQuestion.class;
- Class extends Question> lastTab = StudyQuestion.class;
-
- private final EgoNet egoNet;
- private JPanel contentPane;
-
- private final JMenuBar jEgonetMenuBar = new JMenuBar();
- private final JMenu jMenuFile = new JMenu("File");
- private final JMenuItem jMenuFileNew = new JMenuItem("New Study");
- private final JMenuItem jMenuFileOpen = new JMenuItem("Open Study");
- private final JMenuItem jMenuFileClose = new JMenuItem("Close Study");
- private final JMenuItem jMenuFileImport = new JMenuItem("Import Questions...");
- private final JMenuItem jMenuFileExport = new JMenuItem("Export Questions...");
- private final JMenuItem jMenuFileExportStudy = new JMenuItem("Export Study As...");
-
- private final JMenuItem jMenuFileSaveAs = new JMenuItem("Save Study As...");
- private final JMenuItem jMenuFileSave = new JMenuItem("Save Study");
-
-
-
- private final JMenuItem jMenuFileExit = new JMenuItem("Quit");
- private final JMenu jMenuEdit = new JMenu("Edit");
- private final JMenuItem jMenuEditCut = new JMenuItem(new DefaultEditorKit.CutAction());
- private final JMenuItem jMenuEditCopy = new JMenuItem(new DefaultEditorKit.CopyAction());
- private final JMenuItem jMenuEditPaste = new JMenuItem(new DefaultEditorKit.PasteAction());
-
- private final JTabbedPane jTabbedPane = new JTabbedPane();
- private final BorderLayout borderLayout1 = new BorderLayout();
-
- private final StudyPanel study_panel;
-
- private final Map,EgoQPanel> questionPanel;
-
- // Construct the frame
- public EgoFrame(EgoNet egoNet)
- {
- try {
- this.egoNet = egoNet;
- study_panel = new StudyPanel(egoNet);
-
- questionPanel = new HashMap,EgoQPanel>();
- questionPanel.put(EgoQuestion.class, new AuthoringQuestionPanel(egoNet, EgoQuestion.class));
- questionPanel.put(AlterPromptQuestion.class, new PromptPanel(egoNet, AlterPromptQuestion.class));
- questionPanel.put(AlterQuestion.class, new AuthoringQuestionPanel(egoNet, AlterQuestion.class));
- questionPanel.put(AlterPairQuestion.class, new AuthoringQuestionPanel(egoNet, AlterPairQuestion.class));
-
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- jbInit();
- }
- catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
- }
-
- // Component initialization
- private void jbInit() throws Exception {
- // Listen for window closing
- //this.addWindowListener(new CloseListener());
- this.addInternalFrameListener(this);
-
- //fixme
-
- this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- setResizable(true);
-
- contentPane = new JPanel();
- contentPane.setLayout(borderLayout1);
- setContentPane(contentPane);
- setTitle("Study Design Tool");
-
- jMenuFileExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_Q, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuFileNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_N, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuFileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_O, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuFileClose.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_W, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuEditCopy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_C, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuEditCut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_X, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
- jMenuEditPaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- KeyEvent.VK_V, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask()));
-
- jMenuEditCopy.setText("Copy");
- jMenuEditCut.setText("Cut");
- jMenuEditPaste.setText("Paste");
-
- jMenuFile.add(jMenuFileNew);
- jMenuFile.add(jMenuFileOpen);
- jMenuFile.add(jMenuFileClose);
- jMenuFile.addSeparator();
- jMenuFile.add(jMenuFileImport);
- jMenuFile.add(jMenuFileExport);
- jMenuFile.add(jMenuFileExportStudy);
- jMenuFile.addSeparator();
- jMenuFile.add(jMenuFileSave);
- jMenuFile.add(jMenuFileSaveAs);
- jMenuFile.addSeparator();
- jMenuFile.add(jMenuFileExit);
-
- jMenuEdit.add(jMenuEditCut);
- jMenuEdit.add(jMenuEditCopy);
- jMenuEdit.add(jMenuEditPaste);
- jEgonetMenuBar.add(jMenuFile);
- jEgonetMenuBar.add(jMenuEdit);
- this.setJMenuBar(jEgonetMenuBar);
-
- jTabbedPane.setTabPlacement(JTabbedPane.TOP);
- jTabbedPane.add(study_panel, "Study");
-
-
- for (Class extends Question> qT : Shared.questionClasses) {
- if(qT.equals(StudyQuestion.class))
- continue;
-
- jTabbedPane.add(questionPanel.get(qT), Question.getNiceName(qT));
- }
- contentPane.add(jTabbedPane);
-
- /***********************************************************************
- * Action Listeners for Menu Events
- */
- jMenuFileNew.addActionListener(new CatchingAction("jMenuFileNew") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileNew_actionPerformed(e);
- }
- });
-
- jMenuFileOpen.addActionListener(new CatchingAction("jMenuFileOpen") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileOpen_actionPerformed(e);
- }
- });
-
- jMenuFileClose.addActionListener(new CatchingAction("jMenuFileClose") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileClose_actionPerformed(e);
- }
- });
-
- jMenuFileSave.addActionListener(new CatchingAction("jMenuFileSave") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileSave_actionPerformed(e);
- }
- });
-
- jMenuFileExportStudy.addActionListener(new CatchingAction("jMenuFileExportStudy") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileExportStudy_actionPerformed(e);
- }
- });
-
- jMenuFileSaveAs.addActionListener(new CatchingAction("jMenuFileSaveAs") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileSaveAs_actionPerformed(e);
- }
- });
-
- jMenuFileImport.addActionListener(new CatchingAction("jMenuFileImport") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileImport_actionPerformed(e);
- }
- });
-
- jMenuFileExport.addActionListener(new CatchingAction("jMenuFileExport") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileExport_actionPerformed(e);
- }
- });
-
- jMenuFileExit.addActionListener(new CatchingAction("jMenuFileExit") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- jMenuFileExit_actionPerformed(e);
- }
- });
-
- /***********************************************************************
- * Change Listener for tabs
- */
- jTabbedPane.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- try {
- jTabbedPane_stateChanged(e);
- } catch (IOException ex)
- {
- throw new RuntimeException(ex);
- }
- }
- });
-
- /* Fill panel, initialize frame */
- egoNet.getStorage().createNewStudy();
- fillCurrentPanel();
-
- pack();
- setMinimumSize(getPreferredSize());
-
- setMaximizable(true);
- setIconifiable(true);
- setClosable(true);
-
- egoNet.getStudy().setModified(false);
- updateMenus();
- }
-
- /***************************************************************************
- * Updates menus to take dirty question and study into account
- */
- public void updateMenus() {
- if (egoNet.getStorage().getStudyFile() == null) {
- jMenuFileImport.setEnabled(false);
- jMenuFileClose.setEnabled(false);
- jMenuFileSave.setEnabled(false);
- jMenuFileExportStudy.setEnabled(false);
- jMenuFileSaveAs.setEnabled(false);
- jMenuFileExport.setEnabled(false);
- jTabbedPane.setEnabledAt(1, false);
- jTabbedPane.setEnabledAt(2, false);
- jTabbedPane.setEnabledAt(3, false);
- jTabbedPane.setEnabledAt(4, false);
- jTabbedPane.setSelectedIndex(0);
- } else {
- jMenuFileImport.setEnabled(true);
- jMenuFileClose.setEnabled(true);
- jMenuFileSave.setEnabled(egoNet.getStudy().isCompatible()
- && egoNet.getStudy().isModified());
- jMenuFileSaveAs.setEnabled(true);
- jMenuFileExportStudy.setEnabled(true);
- jMenuFileExport.setEnabled(true);
- jTabbedPane.setEnabledAt(1, true);
- jTabbedPane.setEnabledAt(2, true);
- jTabbedPane.setEnabledAt(3, true);
- jTabbedPane.setEnabledAt(4, true);
- }
- }
-
- // split the file menu functionality out into a class of functionality
- // and a class of the UI
- /**
- * New Study menu handler
- *
- * @param e
- * Menu UI Event
- * @throws IOException
- */
- private void jMenuFileNew_actionPerformed(ActionEvent e) throws IOException {
- boolean ok = closeStudyFile();
-
- if (ok) {
- egoNet.getStorage().newStudyFiles();
- fillCurrentPanel();
- egoNet.getStudy().setModified(false);
- egoNet.getStudy().setCompatible(true);
- egoNet.getStudy().addObserver(this);
- updateMenus();
- }
- }
-
- /***************************************************************************
- * Open Study menu handler
- *
- * @param e
- * Menu UI Event
- * @throws IOException
- */
- private void jMenuFileOpen_actionPerformed(ActionEvent e) throws IOException {
- boolean ok = closeStudyFile();
-
- if (ok) {
- egoNet.getStorage().selectStudy();
- fillCurrentPanel();
- egoNet.getStudy().setModified(false);
- egoNet.getStudy().setCompatible(true);
- egoNet.getStudy().addObserver(this);
- updateMenus();
- }
- }
-
- private void jMenuFileClose_actionPerformed(ActionEvent e) throws IOException {
- boolean ok = closeStudyFile();
-
- if (ok) {
- egoNet.getStorage().createNewStudy();
-
- fillCurrentPanel();
- egoNet.getStudy().addObserver(this);
- egoNet.getStudy().setModified(false);
- }
- }
-
- private void jMenuFileImport_actionPerformed(ActionEvent e) throws Exception {
- egoNet.getStorage().importQuestions();
- fillCurrentPanel();
- }
-
- private void jMenuFileExport_actionPerformed(ActionEvent e) {
- egoNet.getStorage().exportQuestions();
- }
-
- private void jMenuFileSave_actionPerformed(ActionEvent e) throws IOException {
- EgonetAnalytics.track("save study"); // track!
- if (egoNet.getStorage().getStudyFile() == null) {
- jMenuFileSaveAs_actionPerformed(e);
- } else {
- egoNet.getStorage().saveStudyFile();
- egoNet.getStudy().setModified(false);
- }
- }
-
- private void jMenuFileExportStudy_actionPerformed(ActionEvent e) throws IOException, CorruptedInterviewException {
- egoNet.getStorage().exportStudy(false);
- }
-
- private void jMenuFileSaveAs_actionPerformed(ActionEvent e) throws IOException {
- egoNet.getStorage().saveAsStudyFile();
- fillStudyPanel();
- egoNet.getStudy().addObserver(this);
- egoNet.getStudy().setModified(false);
- egoNet.getStudy().setCompatible(true);
- }
-
- // File | Exit action performed
- public void jMenuFileExit_actionPerformed(ActionEvent e) {
- try {
- boolean exit = closeStudyFile();
-
- if (exit) {
- dispose();
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Closes question file. If changes made gives user the option of saving.
- *
- * @return False iff user cancels save, True otherwise
- * @throws IOException
- */
- public boolean closeStudyFile() throws IOException {
- boolean exit = true;
-
- if (egoNet.getStudy().isModified()) {
- int confirm = JOptionPane
- .showConfirmDialog(
- this,
- "There are unsaved changes to the study. Would you like to save the study now?",
- "Save Study Changes",
- JOptionPane.YES_NO_CANCEL_OPTION);
-
- if (confirm == JOptionPane.YES_OPTION) {
- jMenuFileSave_actionPerformed(null);
- } else if (confirm == JOptionPane.CANCEL_OPTION) {
- exit = false;
- }
- }
-
- return exit;
- }
-
- public void fillCurrentPanel() throws IOException {
- boolean sd = egoNet.getStudy().isModified();
- boolean sc = egoNet.getStudy().isCompatible();
-
- if (curTab == StudyQuestion.class) {
- study_panel.fillPanel();
- } else {
- questionPanel.get(curTab).fillPanel();
- }
-
- egoNet.getStudy().setModified(sd);
- egoNet.getStudy().setCompatible(sc);
- }
-
- public void fillStudyPanel() throws IOException {
- boolean sd = egoNet.getStudy().isModified();
-
- if (curTab == StudyQuestion.class) {
- study_panel.fillPanel();
- }
-
- egoNet.getStudy().setModified(sd);
- }
-
- private void jTabbedPane_stateChanged(ChangeEvent e) throws IOException
- {
- lastTab = curTab;
- Component selectedTab = jTabbedPane.getSelectedComponent();
- if(selectedTab instanceof StudyPanel)
- {
- curTab = StudyQuestion.class;
- } else {
- curTab = ((EgoQPanel)selectedTab).questionType;
- }
-
- if ((lastTab == StudyQuestion.class) && (curTab != lastTab)) {
- egoNet.getStudy().validateQuestions();
- }
-
- if (curTab == StudyQuestion.class) {
- study_panel.fillPanel();
- } else {
- questionPanel.get(curTab).fillPanel();
- }
- }
-
- protected void setWaitCursor(boolean waitCursor) {
-
- if (waitCursor) {
- this.getGlassPane().setVisible(true);
- this.getGlassPane().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- } else {
- this.getGlassPane().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- this.getGlassPane().setVisible(false);
- }
- }
-
- class CloseListener extends WindowAdapter {
- /*
- * (non-Javadoc)
- *
- * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
- */
- public void windowClosing(WindowEvent arg0) {
- logger.info("Window close event received");
- try {
- jMenuFileExit_actionPerformed(null);
- } catch (Throwable cause)
- {
- throw new RuntimeException(cause);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
- */
- public void update(Observable o, Object arg) {
- updateMenus();
- }
-
- public void focusActivated() {
- //logger.info(this.getTitle() + " activated");
-
- }
-
- public void focusDeactivated() {
- //logger.info(this.getTitle() + " deactivated");
-
- }
-
- public JInternalFrame getInternalFrame() {
- return this;
- }
-
- public void setMdiContext(MDIContext context) {
-
- }
-
- public void internalFrameActivated(InternalFrameEvent e) {
-
-
- }
-
- public void internalFrameClosed(InternalFrameEvent e) {
-
-
- }
-
- public void internalFrameClosing(InternalFrameEvent e) {
- jMenuFileExit_actionPerformed(null);
- }
-
- public void internalFrameDeactivated(InternalFrameEvent e) {
-
-
- }
-
- public void internalFrameDeiconified(InternalFrameEvent e) {
-
-
- }
-
- public void internalFrameIconified(InternalFrameEvent e) {
-
-
- }
-
- public void internalFrameOpened(InternalFrameEvent e) {
-
-
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+
+import org.egonet.model.question.*;
+import java.awt.AWTEvent;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.InternalFrameEvent;
+import javax.swing.event.InternalFrameListener;
+import javax.swing.text.DefaultEditorKit;
+
+import org.egonet.exceptions.CorruptedInterviewException;
+import org.egonet.gui.MDIChildFrame;
+import org.egonet.mdi.MDIContext;
+import org.egonet.model.question.Question;
+import org.egonet.util.CatchingAction;
+import org.egonet.util.EgonetAnalytics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.endlessloopsoftware.egonet.Shared;
+
+import org.egonet.model.question.StudyQuestion;
+
+public class EgoFrame extends MDIChildFrame implements Observer, InternalFrameListener {
+
+ final private static Logger logger = LoggerFactory.getLogger(EgoFrame.class);
+
+ /**
+ * Changes based on jTabbedPane_stateChanged, which is activated when tabs are clicked
+ */
+ Class extends Question> curTab = StudyQuestion.class;
+ Class extends Question> lastTab = StudyQuestion.class;
+
+ private final EgoNet egoNet;
+ private JPanel contentPane;
+
+ private final JMenuBar jEgonetMenuBar = new JMenuBar();
+ private final JMenu jMenuFile = new JMenu("File");
+ private final JMenuItem jMenuFileNew = new JMenuItem("New Study");
+ private final JMenuItem jMenuFileOpen = new JMenuItem("Open Study");
+ private final JMenuItem jMenuFileClose = new JMenuItem("Close Study");
+ private final JMenuItem jMenuFileImport = new JMenuItem("Import Questions...");
+ private final JMenuItem jMenuFileExport = new JMenuItem("Export Questions...");
+ private final JMenuItem jMenuFileExportStudy = new JMenuItem("Export Study As...");
+
+ private final JMenuItem jMenuFileSaveAs = new JMenuItem("Save Study As...");
+ private final JMenuItem jMenuFileSave = new JMenuItem("Save Study");
+
+
+
+ private final JMenuItem jMenuFileExit = new JMenuItem("Quit");
+ private final JMenu jMenuEdit = new JMenu("Edit");
+ private final JMenuItem jMenuEditCut = new JMenuItem(new DefaultEditorKit.CutAction());
+ private final JMenuItem jMenuEditCopy = new JMenuItem(new DefaultEditorKit.CopyAction());
+ private final JMenuItem jMenuEditPaste = new JMenuItem(new DefaultEditorKit.PasteAction());
+
+ private final JTabbedPane jTabbedPane = new JTabbedPane();
+ private final BorderLayout borderLayout1 = new BorderLayout();
+
+ private final StudyPanel study_panel;
+
+ private final Map,EgoQPanel> questionPanel;
+
+ // Construct the frame
+ public EgoFrame(EgoNet egoNet)
+ {
+ try {
+ this.egoNet = egoNet;
+ study_panel = new StudyPanel(egoNet);
+
+ questionPanel = new HashMap,EgoQPanel>();
+ questionPanel.put(EgoQuestion.class, new AuthoringQuestionPanel(egoNet, EgoQuestion.class));
+ questionPanel.put(AlterPromptQuestion.class, new PromptPanel(egoNet, AlterPromptQuestion.class));
+ questionPanel.put(AlterQuestion.class, new AuthoringQuestionPanel(egoNet, AlterQuestion.class));
+ questionPanel.put(AlterPairQuestion.class, new AuthoringQuestionPanel(egoNet, AlterPairQuestion.class));
+
+ enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+ jbInit();
+ }
+ catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+
+ }
+
+ // Component initialization
+ private void jbInit() throws Exception {
+ // Listen for window closing
+ //this.addWindowListener(new CloseListener());
+ this.addInternalFrameListener(this);
+
+ //fixme
+
+ this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+ setResizable(true);
+
+ contentPane = new JPanel();
+ contentPane.setLayout(borderLayout1);
+ setContentPane(contentPane);
+ setTitle("Study Design Tool");
+
+ jMenuFileExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_Q, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuFileNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_N, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuFileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_O, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuFileClose.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_W, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuEditCopy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_C, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuEditCut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_X, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+ jMenuEditPaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
+ KeyEvent.VK_V, Toolkit.getDefaultToolkit()
+ .getMenuShortcutKeyMask()));
+
+ jMenuEditCopy.setText("Copy");
+ jMenuEditCut.setText("Cut");
+ jMenuEditPaste.setText("Paste");
+
+ jMenuFile.add(jMenuFileNew);
+ jMenuFile.add(jMenuFileOpen);
+ jMenuFile.add(jMenuFileClose);
+ jMenuFile.addSeparator();
+ jMenuFile.add(jMenuFileImport);
+ jMenuFile.add(jMenuFileExport);
+ jMenuFile.add(jMenuFileExportStudy);
+ jMenuFile.addSeparator();
+ jMenuFile.add(jMenuFileSave);
+ jMenuFile.add(jMenuFileSaveAs);
+ jMenuFile.addSeparator();
+ jMenuFile.add(jMenuFileExit);
+
+ jMenuEdit.add(jMenuEditCut);
+ jMenuEdit.add(jMenuEditCopy);
+ jMenuEdit.add(jMenuEditPaste);
+ jEgonetMenuBar.add(jMenuFile);
+ jEgonetMenuBar.add(jMenuEdit);
+ this.setJMenuBar(jEgonetMenuBar);
+
+ jTabbedPane.setTabPlacement(JTabbedPane.TOP);
+ jTabbedPane.add(study_panel, "Study");
+
+
+ for (Class extends Question> qT : Shared.questionClasses) {
+ if(qT.equals(StudyQuestion.class))
+ continue;
+
+ jTabbedPane.add(questionPanel.get(qT), Question.getNiceName(qT));
+ }
+ contentPane.add(jTabbedPane);
+
+ /***********************************************************************
+ * Action Listeners for Menu Events
+ */
+ jMenuFileNew.addActionListener(new CatchingAction("jMenuFileNew") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileNew_actionPerformed(e);
+ }
+ });
+
+ jMenuFileOpen.addActionListener(new CatchingAction("jMenuFileOpen") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileOpen_actionPerformed(e);
+ }
+ });
+
+ jMenuFileClose.addActionListener(new CatchingAction("jMenuFileClose") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileClose_actionPerformed(e);
+ }
+ });
+
+ jMenuFileSave.addActionListener(new CatchingAction("jMenuFileSave") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileSave_actionPerformed(e);
+ }
+ });
+
+ jMenuFileExportStudy.addActionListener(new CatchingAction("jMenuFileExportStudy") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileExportStudy_actionPerformed(e);
+ }
+ });
+
+ jMenuFileSaveAs.addActionListener(new CatchingAction("jMenuFileSaveAs") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileSaveAs_actionPerformed(e);
+ }
+ });
+
+ jMenuFileImport.addActionListener(new CatchingAction("jMenuFileImport") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileImport_actionPerformed(e);
+ }
+ });
+
+ jMenuFileExport.addActionListener(new CatchingAction("jMenuFileExport") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileExport_actionPerformed(e);
+ }
+ });
+
+ jMenuFileExit.addActionListener(new CatchingAction("jMenuFileExit") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ jMenuFileExit_actionPerformed(e);
+ }
+ });
+
+ /***********************************************************************
+ * Change Listener for tabs
+ */
+ jTabbedPane.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ try {
+ jTabbedPane_stateChanged(e);
+ } catch (IOException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+
+ /* Fill panel, initialize frame */
+ egoNet.getStorage().createNewStudy();
+ fillCurrentPanel();
+
+ pack();
+ setMinimumSize(getPreferredSize());
+
+ setMaximizable(true);
+ setIconifiable(true);
+ setClosable(true);
+
+ egoNet.getStudy().setModified(false);
+ updateMenus();
+ }
+
+ /***************************************************************************
+ * Updates menus to take dirty question and study into account
+ */
+ public void updateMenus() {
+ if (egoNet.getStorage().getStudyFile() == null) {
+ jMenuFileImport.setEnabled(false);
+ jMenuFileClose.setEnabled(false);
+ jMenuFileSave.setEnabled(false);
+ jMenuFileExportStudy.setEnabled(false);
+ jMenuFileSaveAs.setEnabled(false);
+ jMenuFileExport.setEnabled(false);
+ jTabbedPane.setEnabledAt(1, false);
+ jTabbedPane.setEnabledAt(2, false);
+ jTabbedPane.setEnabledAt(3, false);
+ jTabbedPane.setEnabledAt(4, false);
+ jTabbedPane.setSelectedIndex(0);
+ } else {
+ jMenuFileImport.setEnabled(true);
+ jMenuFileClose.setEnabled(true);
+ jMenuFileSave.setEnabled(egoNet.getStudy().isCompatible()
+ && egoNet.getStudy().isModified());
+ jMenuFileSaveAs.setEnabled(true);
+ jMenuFileExportStudy.setEnabled(true);
+ jMenuFileExport.setEnabled(true);
+ jTabbedPane.setEnabledAt(1, true);
+ jTabbedPane.setEnabledAt(2, true);
+ jTabbedPane.setEnabledAt(3, true);
+ jTabbedPane.setEnabledAt(4, true);
+ }
+ }
+
+ // split the file menu functionality out into a class of functionality
+ // and a class of the UI
+ /**
+ * New Study menu handler
+ *
+ * @param e
+ * Menu UI Event
+ * @throws IOException
+ */
+ private void jMenuFileNew_actionPerformed(ActionEvent e) throws IOException {
+ boolean ok = closeStudyFile();
+
+ if (ok) {
+ egoNet.getStorage().newStudyFiles();
+ fillCurrentPanel();
+ egoNet.getStudy().setModified(false);
+ egoNet.getStudy().setCompatible(true);
+ egoNet.getStudy().addObserver(this);
+ updateMenus();
+ }
+ }
+
+ /***************************************************************************
+ * Open Study menu handler
+ *
+ * @param e
+ * Menu UI Event
+ * @throws IOException
+ */
+ private void jMenuFileOpen_actionPerformed(ActionEvent e) throws IOException {
+ boolean ok = closeStudyFile();
+
+ if (ok) {
+ egoNet.getStorage().selectStudy();
+ fillCurrentPanel();
+ egoNet.getStudy().setModified(false);
+ egoNet.getStudy().setCompatible(true);
+ egoNet.getStudy().addObserver(this);
+ updateMenus();
+ }
+ }
+
+ private void jMenuFileClose_actionPerformed(ActionEvent e) throws IOException {
+ boolean ok = closeStudyFile();
+
+ if (ok) {
+ egoNet.getStorage().createNewStudy();
+
+ fillCurrentPanel();
+ egoNet.getStudy().addObserver(this);
+ egoNet.getStudy().setModified(false);
+ }
+ }
+
+ private void jMenuFileImport_actionPerformed(ActionEvent e) throws Exception {
+ egoNet.getStorage().importQuestions();
+ fillCurrentPanel();
+ }
+
+ private void jMenuFileExport_actionPerformed(ActionEvent e) {
+ egoNet.getStorage().exportQuestions();
+ }
+
+ private void jMenuFileSave_actionPerformed(ActionEvent e) throws IOException {
+ EgonetAnalytics.track("save study"); // track!
+ if (egoNet.getStorage().getStudyFile() == null) {
+ jMenuFileSaveAs_actionPerformed(e);
+ } else {
+ egoNet.getStorage().saveStudyFile();
+ egoNet.getStudy().setModified(false);
+ }
+ }
+
+ private void jMenuFileExportStudy_actionPerformed(ActionEvent e) throws IOException, CorruptedInterviewException {
+ egoNet.getStorage().exportStudy(false);
+ }
+
+ private void jMenuFileSaveAs_actionPerformed(ActionEvent e) throws IOException {
+ egoNet.getStorage().saveAsStudyFile();
+ fillStudyPanel();
+ egoNet.getStudy().addObserver(this);
+ egoNet.getStudy().setModified(false);
+ egoNet.getStudy().setCompatible(true);
+ }
+
+ // File | Exit action performed
+ public void jMenuFileExit_actionPerformed(ActionEvent e) {
+ try {
+ boolean exit = closeStudyFile();
+
+ if (exit) {
+ dispose();
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Closes question file. If changes made gives user the option of saving.
+ *
+ * @return False iff user cancels save, True otherwise
+ * @throws IOException
+ */
+ public boolean closeStudyFile() throws IOException {
+ boolean exit = true;
+
+ if (egoNet.getStudy().isModified()) {
+ int confirm = JOptionPane
+ .showConfirmDialog(
+ this,
+ "There are unsaved changes to the study. Would you like to save the study now?",
+ "Save Study Changes",
+ JOptionPane.YES_NO_CANCEL_OPTION);
+
+ if (confirm == JOptionPane.YES_OPTION) {
+ jMenuFileSave_actionPerformed(null);
+ } else if (confirm == JOptionPane.CANCEL_OPTION) {
+ exit = false;
+ }
+ }
+
+ return exit;
+ }
+
+ public void fillCurrentPanel() throws IOException {
+ boolean sd = egoNet.getStudy().isModified();
+ boolean sc = egoNet.getStudy().isCompatible();
+
+ if (curTab == StudyQuestion.class) {
+ study_panel.fillPanel();
+ } else {
+ questionPanel.get(curTab).fillPanel();
+ }
+
+ egoNet.getStudy().setModified(sd);
+ egoNet.getStudy().setCompatible(sc);
+ }
+
+ public void fillStudyPanel() throws IOException {
+ boolean sd = egoNet.getStudy().isModified();
+
+ if (curTab == StudyQuestion.class) {
+ study_panel.fillPanel();
+ }
+
+ egoNet.getStudy().setModified(sd);
+ }
+
+ private void jTabbedPane_stateChanged(ChangeEvent e) throws IOException
+ {
+ lastTab = curTab;
+ Component selectedTab = jTabbedPane.getSelectedComponent();
+ if(selectedTab instanceof StudyPanel)
+ {
+ curTab = StudyQuestion.class;
+ } else {
+ curTab = ((EgoQPanel)selectedTab).questionType;
+ }
+
+ if ((lastTab == StudyQuestion.class) && (curTab != lastTab)) {
+ egoNet.getStudy().validateQuestions();
+ }
+
+ if (curTab == StudyQuestion.class) {
+ study_panel.fillPanel();
+ } else {
+ questionPanel.get(curTab).fillPanel();
+ }
+ }
+
+ protected void setWaitCursor(boolean waitCursor) {
+
+ if (waitCursor) {
+ this.getGlassPane().setVisible(true);
+ this.getGlassPane().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ } else {
+ this.getGlassPane().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ this.getGlassPane().setVisible(false);
+ }
+ }
+
+ class CloseListener extends WindowAdapter {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ */
+ public void windowClosing(WindowEvent arg0) {
+ logger.info("Window close event received");
+ try {
+ jMenuFileExit_actionPerformed(null);
+ } catch (Throwable cause)
+ {
+ throw new RuntimeException(cause);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
+ */
+ public void update(Observable o, Object arg) {
+ updateMenus();
+ }
+
+ public void focusActivated() {
+ //logger.info(this.getTitle() + " activated");
+
+ }
+
+ public void focusDeactivated() {
+ //logger.info(this.getTitle() + " deactivated");
+
+ }
+
+ public JInternalFrame getInternalFrame() {
+ return this;
+ }
+
+ public void setMdiContext(MDIContext context) {
+
+ }
+
+ public void internalFrameActivated(InternalFrameEvent e) {
+
+
+ }
+
+ public void internalFrameClosed(InternalFrameEvent e) {
+
+
+ }
+
+ public void internalFrameClosing(InternalFrameEvent e) {
+ jMenuFileExit_actionPerformed(null);
+ }
+
+ public void internalFrameDeactivated(InternalFrameEvent e) {
+
+
+ }
+
+ public void internalFrameDeiconified(InternalFrameEvent e) {
+
+
+ }
+
+ public void internalFrameIconified(InternalFrameEvent e) {
+
+
+ }
+
+ public void internalFrameOpened(InternalFrameEvent e) {
+
+
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/EgoNet.java b/src/main/java/com/endlessloopsoftware/ego/author/EgoNet.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/author/EgoNet.java
rename to src/main/java/com/endlessloopsoftware/ego/author/EgoNet.java
index aaf46d5..2e27cea 100644
--- a/src/com/endlessloopsoftware/ego/author/EgoNet.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/EgoNet.java
@@ -1,60 +1,60 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-
-import org.egonet.gui.EgoStore;
-import org.egonet.util.EgonetAnalytics;
-
-import com.endlessloopsoftware.egonet.Study;
-
-/** ONLY USE THIS CLASS IN AUTHOR PART OF THE TOOL */
-public class EgoNet
-{
- private final EgoStore storage;
- private final EgoFrame frame;
-
- public EgoNet() {
- EgonetAnalytics.track("authoring client startup"); // track!
- storage = new EgoStore(null);
- storage.createNewStudy();
-
- frame = new EgoFrame(this);
- frame.validate();
- }
-
- public static void main(String[] args) throws Exception
- {
- //new Console();
- new EgoNet().getFrame().setVisible(true);
- }
-
- public EgoStore getStorage() {
- return storage;
- }
-
- public EgoFrame getFrame() {
- return frame;
- }
-
- public Study getStudy() {
- return storage.getStudy();
- }
-
-
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+
+import org.egonet.gui.EgoStore;
+import org.egonet.util.EgonetAnalytics;
+
+import com.endlessloopsoftware.egonet.Study;
+
+/** ONLY USE THIS CLASS IN AUTHOR PART OF THE TOOL */
+public class EgoNet
+{
+ private final EgoStore storage;
+ private final EgoFrame frame;
+
+ public EgoNet() {
+ EgonetAnalytics.track("authoring client startup"); // track!
+ storage = new EgoStore(null);
+ storage.createNewStudy();
+
+ frame = new EgoFrame(this);
+ frame.validate();
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ //new Console();
+ new EgoNet().getFrame().setVisible(true);
+ }
+
+ public EgoStore getStorage() {
+ return storage;
+ }
+
+ public EgoFrame getFrame() {
+ return frame;
+ }
+
+ public Study getStudy() {
+ return storage.getStudy();
+ }
+
+
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/EgoQPanel.java b/src/main/java/com/endlessloopsoftware/ego/author/EgoQPanel.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/author/EgoQPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/author/EgoQPanel.java
index e23fae9..0636de3 100644
--- a/src/com/endlessloopsoftware/ego/author/EgoQPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/EgoQPanel.java
@@ -1,35 +1,35 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-import javax.swing.JPanel;
-
-import org.egonet.model.question.Question;
-
-
-
-public abstract class EgoQPanel extends JPanel
-{
- protected final Class extends Question> questionType;
- abstract public void fillPanel();
- abstract public void clearPanel();
- public EgoQPanel(Class extends Question> questionType)
- {
- this.questionType = questionType;
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+import javax.swing.JPanel;
+
+import org.egonet.model.question.Question;
+
+
+
+public abstract class EgoQPanel extends JPanel
+{
+ protected final Class extends Question> questionType;
+ abstract public void fillPanel();
+ abstract public void clearPanel();
+ public EgoQPanel(Class extends Question> questionType)
+ {
+ this.questionType = questionType;
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/NoTabTextArea.java b/src/main/java/com/endlessloopsoftware/ego/author/NoTabTextArea.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/author/NoTabTextArea.java
rename to src/main/java/com/endlessloopsoftware/ego/author/NoTabTextArea.java
index 3b6cfe4..ffdab99 100644
--- a/src/com/endlessloopsoftware/ego/author/NoTabTextArea.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/NoTabTextArea.java
@@ -1,37 +1,37 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-import java.awt.KeyboardFocusManager;
-import java.util.Collections;
-
-import javax.swing.JTextArea;
-
-/**
- * Extends JTextArea to make tabs focus change events in question text areas
- */
-public class NoTabTextArea extends JTextArea
-{
- @SuppressWarnings("unchecked")
-public NoTabTextArea()
- {
- super();
- setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
- setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+import java.awt.KeyboardFocusManager;
+import java.util.Collections;
+
+import javax.swing.JTextArea;
+
+/**
+ * Extends JTextArea to make tabs focus change events in question text areas
+ */
+public class NoTabTextArea extends JTextArea
+{
+ @SuppressWarnings("unchecked")
+public NoTabTextArea()
+ {
+ super();
+ setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
+ setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/PromptPanel.java b/src/main/java/com/endlessloopsoftware/ego/author/PromptPanel.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/author/PromptPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/author/PromptPanel.java
index 46c8b76..51005a8 100644
--- a/src/com/endlessloopsoftware/ego/author/PromptPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/PromptPanel.java
@@ -1,498 +1,498 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-import javax.swing.border.EtchedBorder;
-import javax.swing.border.TitledBorder;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import org.egonet.exceptions.DuplicateQuestionException;
-import org.egonet.model.question.AlterPromptQuestion;
-import org.egonet.model.question.Question;
-
-import com.endlessloopsoftware.ego.client.ClientQuestionPanel;
-
-
-/**
- * Generic Panel creation and handling routines for question editing
- */
-public class PromptPanel extends EgoQPanel
-{
- private boolean inUpdate;
-
- private final JSplitPane question_split = new JSplitPane();
- private final JList question_list = new JList();
- private final JScrollPane question_list_scroll = new JScrollPane(question_list);
- private final JPanel question_panel_right = new RightPanel();
- private final JLabel question_title_label = new JLabel("Title:");
- private final JLabel question_question_label = new JLabel("Question:");
- private final JLabel question_citation_label = new JLabel("Citation:");
- private final JLabel question_follows_label = new JLabel("Follows Question:");
- private final JTextArea question_question_field = new NoTabTextArea();
- private final JTextArea question_citation_field = new NoTabTextArea();
- private final JTextField question_title_field = new JTextField();
- private final JButton question_new_button = new JButton("New");
- private final JButton question_preview_button = new JButton("Preview");
- private final JComboBox question_follows_menu = new JComboBox();
- private final JButton question_delete_button = new JButton("Delete");
- private final Border listBorder;
-
- private final EgoNet egoNet;
-
- /**
- * Generates Panel for question editing to insert in file tab window
- *
- * @param type Type of questions on Page (e.g. Alter Questions)
- * @param parent parent frame for referencing composed objects
- */
- public PromptPanel(EgoNet egoNet, Class extends Question> type) throws Exception
- {
- super(type);
- this.egoNet = egoNet;
-
-
- question_question_field.setName("question_question_field");
- question_citation_field.setName("question_citation_field");
- question_title_field.setName("question_title_field");
-
- listBorder = BorderFactory.createCompoundBorder(
- new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(178, 178, 178)),
- Question.getNiceName(questionType)),
- BorderFactory.createEmptyBorder(10,10,10,10));
-
- jbInit();
- }
-
- /**
- * Component initialization
- *
- * @throws Exception
- */
- private void jbInit() throws Exception
- {
- inUpdate = true;
-
- // Configure Split Frame
- question_split.setMinimumSize(new Dimension(430, 330));
- question_split.setPreferredSize(new Dimension(430, 330));
- question_split.setResizeWeight(.33);
- question_split.setDividerLocation(.33);
- question_list_scroll.setRequestFocusEnabled(false);
- question_split.add(question_list_scroll, JSplitPane.LEFT);
- question_split.add(question_panel_right, JSplitPane.RIGHT);
-
- this.setLayout(new GridLayout());
-
- // Configure List
- question_list_scroll.setBorder(listBorder);
- question_list_scroll.setMinimumSize(new Dimension(150, 150));
- question_list_scroll.setPreferredSize(new Dimension(150, 150));
- question_list_scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
-
- question_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- question_list.setCellRenderer(new QuestionListCellRenderer());
-
- // Configure question fields
- question_panel_right.setLayout(new GridBagLayout());
- question_question_field.setMaximumSize(new Dimension(280, 64));
- question_question_field.setMinimumSize(new Dimension(72, 16));
- question_question_field.setPreferredSize(new Dimension(72, 16));
- question_question_field.setLineWrap(true);
- question_question_field.setRows(1);
- question_question_field.setTabSize(4);
- question_question_field.setWrapStyleWord(true);
-
- question_citation_field.setMaximumSize(new Dimension(280, 64));
- question_citation_field.setMinimumSize(new Dimension(72, 16));
- question_citation_field.setPreferredSize(new Dimension(72, 16));
- question_citation_field.setLineWrap(true);
- question_citation_field.setRows(1);
- question_citation_field.setTabSize(4);
- question_citation_field.setWrapStyleWord(true);
-
- /* Question Layout */
- question_panel_right.add(question_title_label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
- GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_title_field, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 4));
- question_panel_right.add(question_question_label, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(new JScrollPane(question_question_field), new GridBagConstraints(1, 1, 2, 2, 0.0, 0.4,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_citation_label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(new JScrollPane(question_citation_field), new GridBagConstraints(1, 3, 2, 2, 0.0, 0.3,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_new_button, new GridBagConstraints(0, 7, 1, 1, 0.33, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_preview_button, new GridBagConstraints(1, 7, 1, 1, 0.33, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_delete_button, new GridBagConstraints(2, 7, 1, 1, 0.33, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_follows_label, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- question_panel_right.add(question_follows_menu, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,
- GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
-
- DefaultListModel listModel = new DefaultListModel();
- question_list.setModel(listModel);
- egoNet.getStudy().fillList(questionType, listModel);
-
- question_list.getSelectionModel().addListSelectionListener(new ListSelectionListener()
- {
- public void valueChanged(ListSelectionEvent e)
- {
- question_list_selectionChanged(e);
- }
- });
-
- question_new_button.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e) {
- question_new_button_actionPerformed(e);
- }
- });
-
- question_preview_button.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ClientQuestionPanel.showPreview(
- question_title_field.getText(),question_question_field.getText(),
- AlterPromptQuestion.class,null,null);
- }
- });
-
- question_delete_button.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- question_delete_button_actionPerformed(e);
- }
- });
-
- question_follows_menu.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- question_follows_menu_actionPerformed(e);
- }
- });
-
- question_title_field.getDocument().addDocumentListener(new DocumentListener()
- {
- public void insertUpdate(DocumentEvent e)
- {
- questionTitleEvent();
- }
-
- public void changedUpdate(DocumentEvent e)
- {
- questionTitleEvent();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- questionTitleEvent();
- }
- });
-
- question_question_field.getDocument().addDocumentListener(new DocumentListener()
- {
- public void insertUpdate(DocumentEvent e)
- {
- questionTextEvent();
- }
-
- public void changedUpdate(DocumentEvent e)
- {
- questionTextEvent();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- questionTextEvent();
- }
- });
-
- question_citation_field.getDocument().addDocumentListener(new DocumentListener()
- {
- public void insertUpdate(DocumentEvent e)
- {
- questionCitationEvent();
- }
-
- public void changedUpdate(DocumentEvent e)
- {
- questionCitationEvent();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- questionCitationEvent();
- }
- });
-
- add(question_split);
-
- inUpdate = false;
- }
-
- /**
- * Updates right side question fields when the selection changes
- *
- * @param e event generated by selection change.
- */
- public void question_list_selectionChanged(ListSelectionEvent e)
- {
- if (!inUpdate)
- {
- questionUpdate();
- }
- }
-
- /****
- * fill List with appropriate questions Set other fields to selected
- * question
- */
- public void fillPanel()
- {
- //logger.info("fillPanel() called in PromptPanel but questionType was " + questionType + " and curTab was " + egoNet.getFrame().curTab);
- if (questionType == egoNet.getFrame().curTab)
- {
- storageUpdate();
- questionUpdate();
- }
- }
-
- /**
- * Called when file changes to load new questions into list
- */
- void storageUpdate()
- {
- inUpdate = true;
-
- if (questionType == egoNet.getFrame().curTab)
- {
- ((DefaultListModel) question_list.getModel()).removeAllElements();
- egoNet.getStudy().fillList(questionType, (DefaultListModel)question_list.getModel());
- }
-
- inUpdate = false;
- }
-
- void questionUpdate()
- {
- inUpdate = true;
-
- /** @todo Use List Data Listener? */
- if (questionType.equals(egoNet.getFrame().curTab)) {
- int index = question_list.getSelectedIndex();
- if ((question_list.getModel().getSize() > 0) && (index == -1))
- {
- index = 0;
- }
-
- question_follows_menu.removeAllItems();
- question_follows_menu.addItem(egoNet.getStudy().getFirstQuestion());
- for (int i = 0; i < question_list.getModel().getSize(); i++)
- {
- if (i != index)
- {
- question_follows_menu.addItem(question_list.getModel().getElementAt(i));
- }
- }
-
- question_list.setSelectedIndex(index);
- Question q = (Question) question_list.getSelectedValue();
- if (q != null)
- {
- question_question_field.setText(q.text);
- question_citation_field.setText(q.citation);
- question_title_field.setText(q.title);
- question_follows_menu.setSelectedIndex(index);
-
- question_question_field.setEditable(true);
- question_citation_field.setEditable(true);
- question_title_field.setEditable(true);
- question_delete_button.setEnabled(true);
- question_follows_menu.setEnabled(true);
- }
- else
- {
- question_question_field.setText(null);
- question_citation_field.setText(null);
- question_title_field.setText(null);
-
- question_question_field.setEditable(false);
- question_citation_field.setEditable(false);
- question_title_field.setEditable(false);
- question_delete_button.setEnabled(false);
- question_follows_menu.setEnabled(false);
- }
- }
-
- inUpdate = false;
- }
-
- /****
- * Clear all on screen editable fields Generally called when a new survey is
- * started
- */
- public void clearPanel()
- {
- inUpdate = true;
- ((DefaultListModel) question_list.getModel()).removeAllElements();
- inUpdate = false;
- }
-
- /****
- * Document event handler used to read text fields
- *
- * @param e Document Event
- */
- private void questionTitleEvent()
- {
- Question q = (Question) question_list.getSelectedValue();
- String s;
-
- if ((q != null) && !inUpdate)
- {
- s = question_title_field.getText().trim();
- if ((q.title == null) || (!q.title.equals(s)))
- {
- q.title = question_title_field.getText().trim();
- egoNet.getStudy().setModified(true);
- question_list.repaint();
- }
- }
- }
-
- /****
- * Document event handler used to read text fields
- *
- * @param e Document Event
- */
- private void questionTextEvent()
- {
- Question q = (Question) question_list.getSelectedValue();
- String s;
-
- if ((q != null) && !inUpdate)
- {
- s = question_question_field.getText().trim();
- if ((q.text == null) || (!q.text.equals(s)))
- {
- q.text = question_question_field.getText().trim();
- egoNet.getStudy().setModified(true);
- }
- }
- }
-
- /****
- * Document event handler used to read text fields
- *
- * @param e Document Event
- */
- private void questionCitationEvent()
- {
- Question q = (Question) question_list.getSelectedValue();
- String s;
-
- if ((q != null) && !inUpdate)
- {
- s = question_citation_field.getText().trim();
- if ((q.citation == null) || (!q.citation.equals(s)))
- {
- q.citation = question_citation_field.getText().trim();
- egoNet.getStudy().setModified(true);
- }
- }
- }
-
- void question_new_button_actionPerformed(ActionEvent e) {
-
- Question q;
- try { q = questionType.newInstance(); } catch (Exception ex) { throw new RuntimeException(ex); }
- q.title = new String("Untitled Question");
-
- try
- {
- egoNet.getStudy().addQuestion(q);
- }
- catch (DuplicateQuestionException e1)
- {
- throw new RuntimeException(e1);
- }
-
- fillPanel();
- question_list.setSelectedValue(q, true);
-
- question_title_field.requestFocus();
- question_title_field.setSelectionStart(0);
- question_title_field.setSelectionEnd(question_title_field.getText().length());
- }
-
- void question_delete_button_actionPerformed(ActionEvent e)
- {
- Question q = (Question) question_list.getSelectedValue();
-
- if (q != null)
- {
- int confirm = JOptionPane.showConfirmDialog(egoNet.getFrame(), "Permanently remove this questions?",
- "Delete Question", JOptionPane.OK_CANCEL_OPTION);
-
- if (confirm == JOptionPane.OK_OPTION)
- {
- egoNet.getStudy().removeQuestion(q);
- fillPanel();
- }
- }
- }
-
- /**
- * Changes order of questions
- *
- * @param e UI event
- */
- void question_follows_menu_actionPerformed(ActionEvent e)
- {
- if (!inUpdate)
- {
- Question follows = (Question) question_follows_menu.getSelectedItem();
- Question q = (Question) question_list.getSelectedValue();
-
- egoNet.getStudy().moveQuestionAfter(q, follows);
- fillPanel();
- }
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.egonet.exceptions.DuplicateQuestionException;
+import org.egonet.model.question.AlterPromptQuestion;
+import org.egonet.model.question.Question;
+
+import com.endlessloopsoftware.ego.client.ClientQuestionPanel;
+
+
+/**
+ * Generic Panel creation and handling routines for question editing
+ */
+public class PromptPanel extends EgoQPanel
+{
+ private boolean inUpdate;
+
+ private final JSplitPane question_split = new JSplitPane();
+ private final JList question_list = new JList();
+ private final JScrollPane question_list_scroll = new JScrollPane(question_list);
+ private final JPanel question_panel_right = new RightPanel();
+ private final JLabel question_title_label = new JLabel("Title:");
+ private final JLabel question_question_label = new JLabel("Question:");
+ private final JLabel question_citation_label = new JLabel("Citation:");
+ private final JLabel question_follows_label = new JLabel("Follows Question:");
+ private final JTextArea question_question_field = new NoTabTextArea();
+ private final JTextArea question_citation_field = new NoTabTextArea();
+ private final JTextField question_title_field = new JTextField();
+ private final JButton question_new_button = new JButton("New");
+ private final JButton question_preview_button = new JButton("Preview");
+ private final JComboBox question_follows_menu = new JComboBox();
+ private final JButton question_delete_button = new JButton("Delete");
+ private final Border listBorder;
+
+ private final EgoNet egoNet;
+
+ /**
+ * Generates Panel for question editing to insert in file tab window
+ *
+ * @param type Type of questions on Page (e.g. Alter Questions)
+ * @param parent parent frame for referencing composed objects
+ */
+ public PromptPanel(EgoNet egoNet, Class extends Question> type) throws Exception
+ {
+ super(type);
+ this.egoNet = egoNet;
+
+
+ question_question_field.setName("question_question_field");
+ question_citation_field.setName("question_citation_field");
+ question_title_field.setName("question_title_field");
+
+ listBorder = BorderFactory.createCompoundBorder(
+ new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(178, 178, 178)),
+ Question.getNiceName(questionType)),
+ BorderFactory.createEmptyBorder(10,10,10,10));
+
+ jbInit();
+ }
+
+ /**
+ * Component initialization
+ *
+ * @throws Exception
+ */
+ private void jbInit() throws Exception
+ {
+ inUpdate = true;
+
+ // Configure Split Frame
+ question_split.setMinimumSize(new Dimension(430, 330));
+ question_split.setPreferredSize(new Dimension(430, 330));
+ question_split.setResizeWeight(.33);
+ question_split.setDividerLocation(.33);
+ question_list_scroll.setRequestFocusEnabled(false);
+ question_split.add(question_list_scroll, JSplitPane.LEFT);
+ question_split.add(question_panel_right, JSplitPane.RIGHT);
+
+ this.setLayout(new GridLayout());
+
+ // Configure List
+ question_list_scroll.setBorder(listBorder);
+ question_list_scroll.setMinimumSize(new Dimension(150, 150));
+ question_list_scroll.setPreferredSize(new Dimension(150, 150));
+ question_list_scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+
+ question_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ question_list.setCellRenderer(new QuestionListCellRenderer());
+
+ // Configure question fields
+ question_panel_right.setLayout(new GridBagLayout());
+ question_question_field.setMaximumSize(new Dimension(280, 64));
+ question_question_field.setMinimumSize(new Dimension(72, 16));
+ question_question_field.setPreferredSize(new Dimension(72, 16));
+ question_question_field.setLineWrap(true);
+ question_question_field.setRows(1);
+ question_question_field.setTabSize(4);
+ question_question_field.setWrapStyleWord(true);
+
+ question_citation_field.setMaximumSize(new Dimension(280, 64));
+ question_citation_field.setMinimumSize(new Dimension(72, 16));
+ question_citation_field.setPreferredSize(new Dimension(72, 16));
+ question_citation_field.setLineWrap(true);
+ question_citation_field.setRows(1);
+ question_citation_field.setTabSize(4);
+ question_citation_field.setWrapStyleWord(true);
+
+ /* Question Layout */
+ question_panel_right.add(question_title_label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_title_field, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 4));
+ question_panel_right.add(question_question_label, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
+ GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(new JScrollPane(question_question_field), new GridBagConstraints(1, 1, 2, 2, 0.0, 0.4,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_citation_label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,
+ GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(new JScrollPane(question_citation_field), new GridBagConstraints(1, 3, 2, 2, 0.0, 0.3,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_new_button, new GridBagConstraints(0, 7, 1, 1, 0.33, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_preview_button, new GridBagConstraints(1, 7, 1, 1, 0.33, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_delete_button, new GridBagConstraints(2, 7, 1, 1, 0.33, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_follows_label, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,
+ GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ question_panel_right.add(question_follows_menu, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
+
+ DefaultListModel listModel = new DefaultListModel();
+ question_list.setModel(listModel);
+ egoNet.getStudy().fillList(questionType, listModel);
+
+ question_list.getSelectionModel().addListSelectionListener(new ListSelectionListener()
+ {
+ public void valueChanged(ListSelectionEvent e)
+ {
+ question_list_selectionChanged(e);
+ }
+ });
+
+ question_new_button.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e) {
+ question_new_button_actionPerformed(e);
+ }
+ });
+
+ question_preview_button.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ ClientQuestionPanel.showPreview(
+ question_title_field.getText(),question_question_field.getText(),
+ AlterPromptQuestion.class,null,null);
+ }
+ });
+
+ question_delete_button.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ question_delete_button_actionPerformed(e);
+ }
+ });
+
+ question_follows_menu.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ question_follows_menu_actionPerformed(e);
+ }
+ });
+
+ question_title_field.getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void insertUpdate(DocumentEvent e)
+ {
+ questionTitleEvent();
+ }
+
+ public void changedUpdate(DocumentEvent e)
+ {
+ questionTitleEvent();
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ questionTitleEvent();
+ }
+ });
+
+ question_question_field.getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void insertUpdate(DocumentEvent e)
+ {
+ questionTextEvent();
+ }
+
+ public void changedUpdate(DocumentEvent e)
+ {
+ questionTextEvent();
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ questionTextEvent();
+ }
+ });
+
+ question_citation_field.getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void insertUpdate(DocumentEvent e)
+ {
+ questionCitationEvent();
+ }
+
+ public void changedUpdate(DocumentEvent e)
+ {
+ questionCitationEvent();
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ questionCitationEvent();
+ }
+ });
+
+ add(question_split);
+
+ inUpdate = false;
+ }
+
+ /**
+ * Updates right side question fields when the selection changes
+ *
+ * @param e event generated by selection change.
+ */
+ public void question_list_selectionChanged(ListSelectionEvent e)
+ {
+ if (!inUpdate)
+ {
+ questionUpdate();
+ }
+ }
+
+ /****
+ * fill List with appropriate questions Set other fields to selected
+ * question
+ */
+ public void fillPanel()
+ {
+ //logger.info("fillPanel() called in PromptPanel but questionType was " + questionType + " and curTab was " + egoNet.getFrame().curTab);
+ if (questionType == egoNet.getFrame().curTab)
+ {
+ storageUpdate();
+ questionUpdate();
+ }
+ }
+
+ /**
+ * Called when file changes to load new questions into list
+ */
+ void storageUpdate()
+ {
+ inUpdate = true;
+
+ if (questionType == egoNet.getFrame().curTab)
+ {
+ ((DefaultListModel) question_list.getModel()).removeAllElements();
+ egoNet.getStudy().fillList(questionType, (DefaultListModel)question_list.getModel());
+ }
+
+ inUpdate = false;
+ }
+
+ void questionUpdate()
+ {
+ inUpdate = true;
+
+ /** @todo Use List Data Listener? */
+ if (questionType.equals(egoNet.getFrame().curTab)) {
+ int index = question_list.getSelectedIndex();
+ if ((question_list.getModel().getSize() > 0) && (index == -1))
+ {
+ index = 0;
+ }
+
+ question_follows_menu.removeAllItems();
+ question_follows_menu.addItem(egoNet.getStudy().getFirstQuestion());
+ for (int i = 0; i < question_list.getModel().getSize(); i++)
+ {
+ if (i != index)
+ {
+ question_follows_menu.addItem(question_list.getModel().getElementAt(i));
+ }
+ }
+
+ question_list.setSelectedIndex(index);
+ Question q = (Question) question_list.getSelectedValue();
+ if (q != null)
+ {
+ question_question_field.setText(q.text);
+ question_citation_field.setText(q.citation);
+ question_title_field.setText(q.title);
+ question_follows_menu.setSelectedIndex(index);
+
+ question_question_field.setEditable(true);
+ question_citation_field.setEditable(true);
+ question_title_field.setEditable(true);
+ question_delete_button.setEnabled(true);
+ question_follows_menu.setEnabled(true);
+ }
+ else
+ {
+ question_question_field.setText(null);
+ question_citation_field.setText(null);
+ question_title_field.setText(null);
+
+ question_question_field.setEditable(false);
+ question_citation_field.setEditable(false);
+ question_title_field.setEditable(false);
+ question_delete_button.setEnabled(false);
+ question_follows_menu.setEnabled(false);
+ }
+ }
+
+ inUpdate = false;
+ }
+
+ /****
+ * Clear all on screen editable fields Generally called when a new survey is
+ * started
+ */
+ public void clearPanel()
+ {
+ inUpdate = true;
+ ((DefaultListModel) question_list.getModel()).removeAllElements();
+ inUpdate = false;
+ }
+
+ /****
+ * Document event handler used to read text fields
+ *
+ * @param e Document Event
+ */
+ private void questionTitleEvent()
+ {
+ Question q = (Question) question_list.getSelectedValue();
+ String s;
+
+ if ((q != null) && !inUpdate)
+ {
+ s = question_title_field.getText().trim();
+ if ((q.title == null) || (!q.title.equals(s)))
+ {
+ q.title = question_title_field.getText().trim();
+ egoNet.getStudy().setModified(true);
+ question_list.repaint();
+ }
+ }
+ }
+
+ /****
+ * Document event handler used to read text fields
+ *
+ * @param e Document Event
+ */
+ private void questionTextEvent()
+ {
+ Question q = (Question) question_list.getSelectedValue();
+ String s;
+
+ if ((q != null) && !inUpdate)
+ {
+ s = question_question_field.getText().trim();
+ if ((q.text == null) || (!q.text.equals(s)))
+ {
+ q.text = question_question_field.getText().trim();
+ egoNet.getStudy().setModified(true);
+ }
+ }
+ }
+
+ /****
+ * Document event handler used to read text fields
+ *
+ * @param e Document Event
+ */
+ private void questionCitationEvent()
+ {
+ Question q = (Question) question_list.getSelectedValue();
+ String s;
+
+ if ((q != null) && !inUpdate)
+ {
+ s = question_citation_field.getText().trim();
+ if ((q.citation == null) || (!q.citation.equals(s)))
+ {
+ q.citation = question_citation_field.getText().trim();
+ egoNet.getStudy().setModified(true);
+ }
+ }
+ }
+
+ void question_new_button_actionPerformed(ActionEvent e) {
+
+ Question q;
+ try { q = questionType.newInstance(); } catch (Exception ex) { throw new RuntimeException(ex); }
+ q.title = new String("Untitled Question");
+
+ try
+ {
+ egoNet.getStudy().addQuestion(q);
+ }
+ catch (DuplicateQuestionException e1)
+ {
+ throw new RuntimeException(e1);
+ }
+
+ fillPanel();
+ question_list.setSelectedValue(q, true);
+
+ question_title_field.requestFocus();
+ question_title_field.setSelectionStart(0);
+ question_title_field.setSelectionEnd(question_title_field.getText().length());
+ }
+
+ void question_delete_button_actionPerformed(ActionEvent e)
+ {
+ Question q = (Question) question_list.getSelectedValue();
+
+ if (q != null)
+ {
+ int confirm = JOptionPane.showConfirmDialog(egoNet.getFrame(), "Permanently remove this questions?",
+ "Delete Question", JOptionPane.OK_CANCEL_OPTION);
+
+ if (confirm == JOptionPane.OK_OPTION)
+ {
+ egoNet.getStudy().removeQuestion(q);
+ fillPanel();
+ }
+ }
+ }
+
+ /**
+ * Changes order of questions
+ *
+ * @param e UI event
+ */
+ void question_follows_menu_actionPerformed(ActionEvent e)
+ {
+ if (!inUpdate)
+ {
+ Question follows = (Question) question_follows_menu.getSelectedItem();
+ Question q = (Question) question_list.getSelectedValue();
+
+ egoNet.getStudy().moveQuestionAfter(q, follows);
+ fillPanel();
+ }
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java b/src/main/java/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java
rename to src/main/java/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java
index 6d6a421..cf74f11 100644
--- a/src/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/QuestionLinkDialog.java
@@ -1,663 +1,663 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.IOException;
-import java.util.Observable;
-import java.util.Observer;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-import javax.swing.border.EtchedBorder;
-import javax.swing.border.TitledBorder;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.text.PlainDocument;
-
-import org.egonet.model.question.AlterPairQuestion;
-import org.egonet.model.question.AlterPromptQuestion;
-import org.egonet.model.question.Question;
-import org.egonet.util.CatchingAction;
-import org.egonet.util.WholeNumberDocument;
-import org.egonet.util.listbuilder.Selection;
-
-import com.endlessloopsoftware.egonet.Answer;
-import com.endlessloopsoftware.egonet.Shared;
-
-/**
- * Generic Panel creation and handling routines for question editing
- */
-public class QuestionLinkDialog extends JDialog
- implements Observer
-{
- private Question baseQuestion;
- private Answer linkAnswer = new Answer(new Long(-1));
-
- /* Containers */
- private final JSplitPane questionSplit = new JSplitPane();
- private final JList questionList = new JList();
- private final JScrollPane questionListScroll = new JScrollPane(questionList);
- private final JPanel answerPanel = new JPanel();
- private final JPanel radioPanel = new JPanel();
- private final JPanel menuPanel = new JPanel();
- private final JPanel textPanel = new JPanel();
- private final JPanel questionPanelLeft = new JPanel();
- private final JPanel questionPanelRight = new RightPanel();
- private final GridBagLayout questionListLayout = new GridBagLayout();
- private final GridBagLayout answerRadioLayout = new GridBagLayout();
- private final GridBagLayout answerTextLayout = new GridBagLayout();
- private final GridBagLayout answerMenuLayout = new GridBagLayout();
- private final GridLayout answerPanelLayout = new GridLayout();
-
- /* UI Elements */
- private final Border listBorder;
- private final JLabel titleText = new JLabel();
- private final JTextArea questionText = new JTextArea();
- private final JTextArea answerTextField = new NoTabTextArea();
- private final JButton questionButtonOK = new JButton("OK");
- private final JButton questionButtonCancel = new JButton("Cancel");
- private final JButton questionButtonNone = new JButton("No Link");
- private final JLabel textAnswerLabel = new JLabel("Answer: ");
- private final JLabel menuAnswerLabel = new JLabel("Answer: ");
- private final JLabel radioAnswerLabel = new JLabel("Answer: ");
- private final JComboBox answerMenu = new JComboBox();
- private final JCheckBox allAdjacentCheck = new JCheckBox("All Adjacent Selections");
-
- private final ButtonGroup answerButtonGroup = new ButtonGroup();
- private ActionListener answerButtonListener;
- private final WholeNumberDocument wholeNumberDocument = new WholeNumberDocument();
- private final PlainDocument plainDocument = new PlainDocument();
-
- /* Lists */
- private final static int MAX_BUTTONS = 5;
- private final JRadioButton[] answerButtons = { new JRadioButton(), new JRadioButton(),
- new JRadioButton(), new JRadioButton(), new JRadioButton(), new JRadioButton()};
-
- /* Question Iteration Variables */
- private Question question;
-
- private EgoNet egoNet;
-
-
- /**
- * Generates Panel for question editing to insert in file tab window
- * @param parent parent frame for referencing composed objects
- */
- public QuestionLinkDialog(EgoNet egoNet) throws Exception
- {
- this.egoNet = egoNet;
- listBorder = BorderFactory.createCompoundBorder(
- new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(178, 178, 178)), "Questions"),
- BorderFactory.createEmptyBorder(10,10,10,10));
- jbInit();
- }
-
- /**
- * Component initialization
- * @throws Exception
- */
- private void jbInit()
- throws Exception
- {
- /* Overview Layout */
- this.getContentPane().setLayout(new GridLayout());
-
- // Configure Split Frame
- questionSplit.setMinimumSize(new Dimension(430, 330));
- questionSplit.setPreferredSize(new Dimension(430, 330));
- questionSplit.setResizeWeight(.33);
- questionSplit.setDividerLocation(.33);
- questionText.setBackground(SystemColor.window);
- questionText.setFont(new java.awt.Font("Serif", 0, 16));
- questionText.setLineWrap(true);
- questionText.setTabSize(4);
- questionText.setWrapStyleWord(true);
- questionText.setEditable(false);
-
- questionSplit.add(questionPanelLeft, JSplitPane.LEFT);
- questionSplit.add(questionPanelRight, JSplitPane.RIGHT);
-
- questionPanelLeft.setLayout(questionListLayout);
- questionPanelLeft.setVisible(true);
-
- titleText.setFont(new java.awt.Font("Lucida Grande Bold", 0, 16));
-
- // Configure List
- questionListScroll.setBorder(listBorder);
- questionListScroll.setMinimumSize(new Dimension(150, 150));
- questionListScroll.setPreferredSize(new Dimension(150, 150));
- questionListScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
-
- questionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
- // Configure question fields
- questionPanelRight.setLayout(new GridBagLayout());
- radioPanel.setLayout(answerRadioLayout);
- textPanel.setLayout(answerTextLayout);
- menuPanel.setLayout(answerMenuLayout);
-
- questionText.setBorder(BorderFactory.createLoweredBevelBorder());
- answerMenu.setOpaque(true);
- answerPanel.setLayout(answerPanelLayout);
-
- answerTextField.setFont(new java.awt.Font("SansSerif", 0, 14));
- answerTextField.setMaximumSize(new Dimension(72, 64));
- answerTextField.setMinimumSize(new Dimension(72, 16));
- answerTextField.setPreferredSize(new Dimension(72, 16));
- answerTextField.setLineWrap(true);
- answerTextField.setRows(1);
- answerTextField.setTabSize(4);
- answerTextField.setWrapStyleWord(true);
-
- /* List Layout */
- questionPanelLeft.add(questionListScroll, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 29, 302));
-
- /* Question Layout */
- questionPanelRight.add(titleText, new GridBagConstraints(0, 1, 4, 1, 0.0, 0.1
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- questionPanelRight.add(questionText, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.3
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 10, 10), 0, 0));
-
- /* Radio Panel Answer Layout */
- radioPanel.add(radioAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
-
- for (int i = 0; i < MAX_BUTTONS; i++)
- {
- radioPanel.add(answerButtons[i], new GridBagConstraints(1, i, 1, 1, 0.6, 0.2,
- GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- }
-
- /* Text Answer Layout */
- textPanel.add(textAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
- textPanel.add(answerTextField, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- /* Popup Menu Answer Layout */
- menuPanel.add(menuAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
- menuPanel.add(answerMenu, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
- ,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 10), 0, 0));
-
- /* Misc Button Layout */
- questionPanelRight.add(questionButtonOK, new GridBagConstraints(0, 11, 1, 1, 0.33, 0.1
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- questionPanelRight.add(questionButtonNone, new GridBagConstraints(2, 11, 1, 1, 0.33, 0.1
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- questionPanelRight.add(questionButtonCancel, new GridBagConstraints(3, 11, 1, 1, 0.33, 0.1
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
- questionPanelRight.add(answerPanel, new GridBagConstraints(0, 5, 4, 4, 1.0, 0.5
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
- questionPanelRight.add(allAdjacentCheck, new GridBagConstraints(0, 10, 4, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
-
-
- /* Install event Handlers */
- questionList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- question_list_selectionChanged(e); }});
-
- questionButtonOK.addActionListener(new CatchingAction("questionButtonOK") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionButtonOK_actionPerformed(e);}});
-
- questionButtonNone.addActionListener(new CatchingAction("questionButtonNone") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionButtonNone_actionPerformed(e);}});
-
- questionButtonCancel.addActionListener(new CatchingAction("questionButtonCancel") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionButtonCancel_actionPerformed(e);}});
-
- answerButtonListener = new CatchingAction("answerButtonListener") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionAnsweredEventHandler(e);}};
-
- answerMenu.addActionListener(new CatchingAction("answerMenu") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionAnsweredEventHandler(e); }});
-
- wholeNumberDocument.addDocumentListener(new DocumentListener() {
- public void insertUpdate(DocumentEvent e) { answerTextEvent(e); }
- public void changedUpdate(DocumentEvent e) { answerTextEvent(e); }
- public void removeUpdate(DocumentEvent e) { answerTextEvent(e); }});
-
- plainDocument.addDocumentListener(new DocumentListener() {
- public void insertUpdate(DocumentEvent e) { answerTextEvent(e); }
- public void changedUpdate(DocumentEvent e) { answerTextEvent(e); }
- public void removeUpdate(DocumentEvent e) { answerTextEvent(e); }});
-
- answerButtonListener = new CatchingAction("") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- questionAnsweredEventHandler(e);}};
-
- allAdjacentCheck.addActionListener(new CatchingAction(""){
- public void safeActionPerformed(ActionEvent e) throws Exception {
- allAdjacentCheck_actionPerformed(e);}});
-
- for (int i = 0; i <= MAX_BUTTONS; i++)
- {
- answerButtonGroup.add(answerButtons[i]);
- answerButtons[i].addActionListener(answerButtonListener);
- }
-
- this.getContentPane().add(questionSplit, null);
- }
-
-
- void activate(Question q)
- {
- question = null;
- linkAnswer = null;
- baseQuestion = q;
-
- // Question vars
- questionList.setModel(new DefaultListModel());
- egoNet.getStudy().fillList((DefaultListModel) questionList.getModel(), q.UniqueId);
-
- // Set Selection
- if (baseQuestion.link.isActive())
- {
- Question selected = egoNet.getStudy().getQuestions().getQuestion(baseQuestion.link.getAnswer().questionId);
- questionList.setSelectedValue(selected, true);
- }
-
- if ((questionList.getSelectedIndex() == -1) && (questionList.getModel().getSize() > 0))
- {
- questionList.setSelectedIndex(0);
- }
-
- /* Prepare starting question and answer, fill with stored values */
- question = (Question) questionList.getSelectedValue();
-
- if (question != null)
- {
- linkAnswer = new Answer(question.UniqueId);
-
- if (baseQuestion.link.isActive() && (question.UniqueId.equals(baseQuestion.link.getAnswer().questionId)))
- {
- linkAnswer.setValue(baseQuestion.link.getAnswer().getValue());
- linkAnswer.string = baseQuestion.link.getAnswer().string;
- linkAnswer.setAnswered(true);
- }
- }
-
-
- // Init
- fillPanel();
-
- this.setTitle("Set Link for Question \"" + q.title + "\"");
- this.setSize(550, 500);
-
- //Center the window
- /* Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = this.getSize();
- if (frameSize.height > screenSize.height)
- {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width)
- {
- frameSize.width = screenSize.width;
- }
- this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); */
-
- this.show();
- }
-
-
- /**
- * Updates right side question fields when the selection changes
- * @param e event generated by selection change.
- */
- public void question_list_selectionChanged(ListSelectionEvent e)
- {
- if (!e.getValueIsAdjusting() && !questionList.isSelectionEmpty())
- {
- question = (Question) questionList.getSelectedValue();
-
- if (question != null)
- {
- linkAnswer = new Answer(question.UniqueId);
-
- if (baseQuestion.link.isActive() && (question.UniqueId.equals(baseQuestion.link.getAnswer().questionId)))
- {
- linkAnswer.setValue(baseQuestion.link.getAnswer().getValue());
- linkAnswer.setIndex(baseQuestion.link.getAnswer().getIndex());
- linkAnswer.string = baseQuestion.link.getAnswer().string;
- linkAnswer.setAnswered(true);
- }
- }
-
- setOKButtonState();
- fillPanel();
- }
- }
-
- /****
- * fill List with appropriate questions
- * Set other fields to selected question
- */
- public void fillPanel()
- {
- allAdjacentCheck.setVisible(false);
-
- if (question != null)
- {
- titleText.setText(question.title);
-
- answerPanel.setVisible(false);
- answerPanel.removeAll();
- questionText.setText("Please select a question and an answer which will trigger the inclusion of the current question");
- if (question instanceof AlterPromptQuestion)
- {
- // Should never be here
- //assert(false);
- }
- else if (question.answerType == Shared.AnswerType.TEXT)
- {
- answerPanel.add(textPanel);
- answerPanel.validate();
- answerTextField.setDocument(plainDocument);
- answerTextField.requestFocus();
-
- if (linkAnswer.isAnswered())
- {
- answerTextField.setText(linkAnswer.string);
- }
- else
- {
- answerTextField.setText("");
- }
- }
- else if (question.answerType == Shared.AnswerType.NUMERICAL)
- {
- answerPanel.add(textPanel);
- answerTextField.setDocument(wholeNumberDocument);
- answerTextField.requestFocus();
-
- if (linkAnswer.isAnswered())
- {
- answerTextField.setText(linkAnswer.string);
- }
- else
- {
- answerTextField.setText("");
- }
- }
- else if (question.getSelections().length <= 5)
- {
- allAdjacentCheck.setVisible(question instanceof AlterPairQuestion);
- questionText.setText(question.text);
-
- answerPanel.add(radioPanel);
-
- if (linkAnswer.isAnswered())
- {
- if (linkAnswer.getValue() == Answer.ALL_ADJACENT)
- {
- allAdjacentCheck.setSelected(true);
- answerButtons[MAX_BUTTONS].setSelected(true);
- }
- else
- {
- allAdjacentCheck.setSelected(false);
- answerButtons[question.getSelections().length - (linkAnswer.getValue() + 1)].setSelected(true);
- }
- }
- else
- {
- answerButtons[MAX_BUTTONS].setSelected(true);
- }
-
- for (int i = 0; i < question.getSelections().length; i++)
- {
- answerButtons[i].setText(question.getSelections()[i].getString());
- answerButtons[i].setVisible(true);
- answerButtons[i].setEnabled(linkAnswer.getValue() != Answer.ALL_ADJACENT);
- }
-
- for (int i = question.getSelections().length; i < MAX_BUTTONS; i++)
- {
- answerButtons[i].setVisible(false);
- }
- }
- else
- {
- allAdjacentCheck.setVisible(question instanceof AlterPairQuestion);
- questionText.setText(question.text);
- answerPanel.add(menuPanel);
-
- answerMenu.removeAllItems();
-
- answerMenu.addItem(new Selection("Select an answer"));
- for (int i = 0; i < question.getSelections().length; i++)
- {
- answerMenu.addItem(question.getSelections()[i]);
- }
-
- if (linkAnswer.getValue() == Answer.ALL_ADJACENT)
- {
- allAdjacentCheck.setSelected(true);
- answerMenu.setEnabled(false);
- }
- else if (linkAnswer.getValue() != Answer.NO_ANSWER)
- {
- allAdjacentCheck.setSelected(false);
- answerMenu.setEnabled(true);
- answerMenu.setSelectedIndex(question.getSelections().length - linkAnswer.getValue());
- }
- else
- {
- allAdjacentCheck.setSelected(false);
- answerMenu.setEnabled(true);
- answerMenu.setSelectedIndex(0);
- }
- }
-
- answerPanel.validate();
- answerPanel.setVisible(true);
- }
- }
-
- /****
- * Clear all on screen editable fields
- * Generally called when a new survey is started
- */
- public void clearPanel()
- {
- ((DefaultListModel) questionList.getModel()).removeAllElements();
- }
-
- /****
- * Parses answer fields to retrieve answer to question
- * @param answer Answer from interview to fill with correct values
- */
- void fillAnswer()
- {
- linkAnswer.string = null;
-
- if(question.answerType.equals(Shared.AnswerType.NUMERICAL)) {
- if (answerTextField.getText().length() > 0)
- {
- linkAnswer.string = answerTextField.getText();
- linkAnswer.setValue(Integer.valueOf(linkAnswer.string).intValue());
- linkAnswer.setAnswered(true);
- }
- else
- {
- linkAnswer.setValue(Answer.NO_ANSWER);
- linkAnswer.setAnswered(false);
- }
- } else if(question.answerType.equals(Shared.AnswerType.TEXT)) {
- linkAnswer.string = answerTextField.getText();
- linkAnswer.setValue(linkAnswer.string.length());
- linkAnswer.setAnswered((linkAnswer.getValue() != 0));
- } else if(question.answerType.equals(Shared.AnswerType.INFORMATIONAL)) {
- linkAnswer.string = "informational";
- linkAnswer.setValue(1);
- linkAnswer.setAnswered(true);
- } else if(question.answerType.equals(Shared.AnswerType.CATEGORICAL)) {
-
- // option/radio buttons
- if (question.getSelections().length <= 5) {
- if (allAdjacentCheck.isSelected()) {
- linkAnswer.setValue(Answer.ALL_ADJACENT);
- linkAnswer.string = "All Adjacent";
- linkAnswer.setAnswered(true);
- }
- else {
- int button = selectedButtonIndex(answerButtons);
- linkAnswer.setAnswered( (button != MAX_BUTTONS));
-
- if (linkAnswer.isAnswered())
- {
- linkAnswer.setValue(question.getSelections()[button].getValue());
- linkAnswer.setIndex(question.getSelections()[button].getIndex());
- linkAnswer.string = answerButtons[button].getActionCommand();
- }
- else
- {
- linkAnswer.setValue(Answer.NO_ANSWER);
- linkAnswer.setIndex(Answer.NO_ANSWER);
- linkAnswer.string = "";
- }
- }
- }
-
- // drop down buttons
- else {
- if (allAdjacentCheck.isSelected())
- {
- linkAnswer.setValue(Answer.ALL_ADJACENT);
- linkAnswer.string = "All Adjacent";
- linkAnswer.setAnswered(true);
- }
- else if (answerMenu.getSelectedIndex() > 0) // 0th option is "Select an answer"
- {
- int selectionIndex = answerMenu.getSelectedIndex() - 1;
- linkAnswer.setValue(question.getSelections()[selectionIndex].getValue());
- linkAnswer.string = answerMenu.getSelectedItem().toString();
- linkAnswer.setAnswered((selectionIndex <= question.getSelections().length));
- }
- else
- {
- linkAnswer.setValue(Answer.NO_ANSWER);
- linkAnswer.string = "";
- linkAnswer.setAnswered(false);
- }
- }
- }
- }
-
-
- void jShowListButton_actionPerformed(ActionEvent e)
- {
- questionPanelLeft.setVisible(!questionPanelLeft.isVisible());
- questionSplit.setDividerLocation(.33);
- questionSplit.repaint();
- }
-
- void questionButtonNone_actionPerformed(ActionEvent e) throws IOException
- {
- if (egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame()))
- {
- baseQuestion.link.setAnswer(null);
- egoNet.getStudy().setModified(true);
- egoNet.getStudy().setCompatible(false);
- }
-
- egoNet.getFrame().fillCurrentPanel();
- this.hide();
- }
-
- void questionButtonCancel_actionPerformed(ActionEvent e)
- {
- this.hide();
- }
-
- void questionButtonOK_actionPerformed(ActionEvent e) throws IOException
- {
- if ((linkAnswer != null) && (linkAnswer.isAnswered()) && egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame()))
- {
- baseQuestion.link.setAnswer(linkAnswer);
- egoNet.getStudy().setModified(true);
- egoNet.getStudy().setCompatible(false);
- }
-
- this.hide();
- egoNet.getFrame().fillCurrentPanel();
- }
-
- int selectedButtonIndex(JRadioButton[] group)
- {
- int ri = -1;
-
- for (int i = 0; i < group.length; i++)
- {
- if (group[i].isSelected())
- {
- ri = i;
- break;
- }
- }
-
- return (ri);
- }
-
- void setOKButtonState()
- {
- questionButtonOK.setEnabled((question != null) && linkAnswer.isAnswered());
- }
-
-
- void questionAnsweredEventHandler(ActionEvent e)
- {
- if (e.getActionCommand() != "Initialization")
- {
- fillAnswer();
- setOKButtonState();
- }
- }
-
- void answerTextEvent(DocumentEvent e)
- {
- fillAnswer();
- setOKButtonState();
- }
-
- public void update(Observable o, Object arg)
- {
- fillAnswer();
- setOKButtonState();
- }
-
- void allAdjacentCheck_actionPerformed(ActionEvent e)
- {
- fillAnswer();
- fillPanel();
- setOKButtonState();
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.util.Observable;
+import java.util.Observer;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.text.PlainDocument;
+
+import org.egonet.model.question.AlterPairQuestion;
+import org.egonet.model.question.AlterPromptQuestion;
+import org.egonet.model.question.Question;
+import org.egonet.util.CatchingAction;
+import org.egonet.util.WholeNumberDocument;
+import org.egonet.util.listbuilder.Selection;
+
+import com.endlessloopsoftware.egonet.Answer;
+import com.endlessloopsoftware.egonet.Shared;
+
+/**
+ * Generic Panel creation and handling routines for question editing
+ */
+public class QuestionLinkDialog extends JDialog
+ implements Observer
+{
+ private Question baseQuestion;
+ private Answer linkAnswer = new Answer(new Long(-1));
+
+ /* Containers */
+ private final JSplitPane questionSplit = new JSplitPane();
+ private final JList questionList = new JList();
+ private final JScrollPane questionListScroll = new JScrollPane(questionList);
+ private final JPanel answerPanel = new JPanel();
+ private final JPanel radioPanel = new JPanel();
+ private final JPanel menuPanel = new JPanel();
+ private final JPanel textPanel = new JPanel();
+ private final JPanel questionPanelLeft = new JPanel();
+ private final JPanel questionPanelRight = new RightPanel();
+ private final GridBagLayout questionListLayout = new GridBagLayout();
+ private final GridBagLayout answerRadioLayout = new GridBagLayout();
+ private final GridBagLayout answerTextLayout = new GridBagLayout();
+ private final GridBagLayout answerMenuLayout = new GridBagLayout();
+ private final GridLayout answerPanelLayout = new GridLayout();
+
+ /* UI Elements */
+ private final Border listBorder;
+ private final JLabel titleText = new JLabel();
+ private final JTextArea questionText = new JTextArea();
+ private final JTextArea answerTextField = new NoTabTextArea();
+ private final JButton questionButtonOK = new JButton("OK");
+ private final JButton questionButtonCancel = new JButton("Cancel");
+ private final JButton questionButtonNone = new JButton("No Link");
+ private final JLabel textAnswerLabel = new JLabel("Answer: ");
+ private final JLabel menuAnswerLabel = new JLabel("Answer: ");
+ private final JLabel radioAnswerLabel = new JLabel("Answer: ");
+ private final JComboBox answerMenu = new JComboBox();
+ private final JCheckBox allAdjacentCheck = new JCheckBox("All Adjacent Selections");
+
+ private final ButtonGroup answerButtonGroup = new ButtonGroup();
+ private ActionListener answerButtonListener;
+ private final WholeNumberDocument wholeNumberDocument = new WholeNumberDocument();
+ private final PlainDocument plainDocument = new PlainDocument();
+
+ /* Lists */
+ private final static int MAX_BUTTONS = 5;
+ private final JRadioButton[] answerButtons = { new JRadioButton(), new JRadioButton(),
+ new JRadioButton(), new JRadioButton(), new JRadioButton(), new JRadioButton()};
+
+ /* Question Iteration Variables */
+ private Question question;
+
+ private EgoNet egoNet;
+
+
+ /**
+ * Generates Panel for question editing to insert in file tab window
+ * @param parent parent frame for referencing composed objects
+ */
+ public QuestionLinkDialog(EgoNet egoNet) throws Exception
+ {
+ this.egoNet = egoNet;
+ listBorder = BorderFactory.createCompoundBorder(
+ new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(178, 178, 178)), "Questions"),
+ BorderFactory.createEmptyBorder(10,10,10,10));
+ jbInit();
+ }
+
+ /**
+ * Component initialization
+ * @throws Exception
+ */
+ private void jbInit()
+ throws Exception
+ {
+ /* Overview Layout */
+ this.getContentPane().setLayout(new GridLayout());
+
+ // Configure Split Frame
+ questionSplit.setMinimumSize(new Dimension(430, 330));
+ questionSplit.setPreferredSize(new Dimension(430, 330));
+ questionSplit.setResizeWeight(.33);
+ questionSplit.setDividerLocation(.33);
+ questionText.setBackground(SystemColor.window);
+ questionText.setFont(new java.awt.Font("Serif", 0, 16));
+ questionText.setLineWrap(true);
+ questionText.setTabSize(4);
+ questionText.setWrapStyleWord(true);
+ questionText.setEditable(false);
+
+ questionSplit.add(questionPanelLeft, JSplitPane.LEFT);
+ questionSplit.add(questionPanelRight, JSplitPane.RIGHT);
+
+ questionPanelLeft.setLayout(questionListLayout);
+ questionPanelLeft.setVisible(true);
+
+ titleText.setFont(new java.awt.Font("Lucida Grande Bold", 0, 16));
+
+ // Configure List
+ questionListScroll.setBorder(listBorder);
+ questionListScroll.setMinimumSize(new Dimension(150, 150));
+ questionListScroll.setPreferredSize(new Dimension(150, 150));
+ questionListScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+
+ questionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+ // Configure question fields
+ questionPanelRight.setLayout(new GridBagLayout());
+ radioPanel.setLayout(answerRadioLayout);
+ textPanel.setLayout(answerTextLayout);
+ menuPanel.setLayout(answerMenuLayout);
+
+ questionText.setBorder(BorderFactory.createLoweredBevelBorder());
+ answerMenu.setOpaque(true);
+ answerPanel.setLayout(answerPanelLayout);
+
+ answerTextField.setFont(new java.awt.Font("SansSerif", 0, 14));
+ answerTextField.setMaximumSize(new Dimension(72, 64));
+ answerTextField.setMinimumSize(new Dimension(72, 16));
+ answerTextField.setPreferredSize(new Dimension(72, 16));
+ answerTextField.setLineWrap(true);
+ answerTextField.setRows(1);
+ answerTextField.setTabSize(4);
+ answerTextField.setWrapStyleWord(true);
+
+ /* List Layout */
+ questionPanelLeft.add(questionListScroll, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0
+ ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 29, 302));
+
+ /* Question Layout */
+ questionPanelRight.add(titleText, new GridBagConstraints(0, 1, 4, 1, 0.0, 0.1
+ ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ questionPanelRight.add(questionText, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.3
+ ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 10, 10), 0, 0));
+
+ /* Radio Panel Answer Layout */
+ radioPanel.add(radioAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
+ ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
+
+ for (int i = 0; i < MAX_BUTTONS; i++)
+ {
+ radioPanel.add(answerButtons[i], new GridBagConstraints(1, i, 1, 1, 0.6, 0.2,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+ }
+
+ /* Text Answer Layout */
+ textPanel.add(textAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
+ ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
+ textPanel.add(answerTextField, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
+ ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+
+ /* Popup Menu Answer Layout */
+ menuPanel.add(menuAnswerLabel, new GridBagConstraints(0, 0, 1, 1, 0.3, 0.0
+ ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
+ menuPanel.add(answerMenu, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
+ ,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 10), 0, 0));
+
+ /* Misc Button Layout */
+ questionPanelRight.add(questionButtonOK, new GridBagConstraints(0, 11, 1, 1, 0.33, 0.1
+ ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ questionPanelRight.add(questionButtonNone, new GridBagConstraints(2, 11, 1, 1, 0.33, 0.1
+ ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ questionPanelRight.add(questionButtonCancel, new GridBagConstraints(3, 11, 1, 1, 0.33, 0.1
+ ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ questionPanelRight.add(answerPanel, new GridBagConstraints(0, 5, 4, 4, 1.0, 0.5
+ ,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
+ questionPanelRight.add(allAdjacentCheck, new GridBagConstraints(0, 10, 4, 1, 0.0, 0.0
+ ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
+
+
+ /* Install event Handlers */
+ questionList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ question_list_selectionChanged(e); }});
+
+ questionButtonOK.addActionListener(new CatchingAction("questionButtonOK") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionButtonOK_actionPerformed(e);}});
+
+ questionButtonNone.addActionListener(new CatchingAction("questionButtonNone") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionButtonNone_actionPerformed(e);}});
+
+ questionButtonCancel.addActionListener(new CatchingAction("questionButtonCancel") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionButtonCancel_actionPerformed(e);}});
+
+ answerButtonListener = new CatchingAction("answerButtonListener") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionAnsweredEventHandler(e);}};
+
+ answerMenu.addActionListener(new CatchingAction("answerMenu") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionAnsweredEventHandler(e); }});
+
+ wholeNumberDocument.addDocumentListener(new DocumentListener() {
+ public void insertUpdate(DocumentEvent e) { answerTextEvent(e); }
+ public void changedUpdate(DocumentEvent e) { answerTextEvent(e); }
+ public void removeUpdate(DocumentEvent e) { answerTextEvent(e); }});
+
+ plainDocument.addDocumentListener(new DocumentListener() {
+ public void insertUpdate(DocumentEvent e) { answerTextEvent(e); }
+ public void changedUpdate(DocumentEvent e) { answerTextEvent(e); }
+ public void removeUpdate(DocumentEvent e) { answerTextEvent(e); }});
+
+ answerButtonListener = new CatchingAction("") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ questionAnsweredEventHandler(e);}};
+
+ allAdjacentCheck.addActionListener(new CatchingAction(""){
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ allAdjacentCheck_actionPerformed(e);}});
+
+ for (int i = 0; i <= MAX_BUTTONS; i++)
+ {
+ answerButtonGroup.add(answerButtons[i]);
+ answerButtons[i].addActionListener(answerButtonListener);
+ }
+
+ this.getContentPane().add(questionSplit, null);
+ }
+
+
+ void activate(Question q)
+ {
+ question = null;
+ linkAnswer = null;
+ baseQuestion = q;
+
+ // Question vars
+ questionList.setModel(new DefaultListModel());
+ egoNet.getStudy().fillList((DefaultListModel) questionList.getModel(), q.UniqueId);
+
+ // Set Selection
+ if (baseQuestion.link.isActive())
+ {
+ Question selected = egoNet.getStudy().getQuestions().getQuestion(baseQuestion.link.getAnswer().questionId);
+ questionList.setSelectedValue(selected, true);
+ }
+
+ if ((questionList.getSelectedIndex() == -1) && (questionList.getModel().getSize() > 0))
+ {
+ questionList.setSelectedIndex(0);
+ }
+
+ /* Prepare starting question and answer, fill with stored values */
+ question = (Question) questionList.getSelectedValue();
+
+ if (question != null)
+ {
+ linkAnswer = new Answer(question.UniqueId);
+
+ if (baseQuestion.link.isActive() && (question.UniqueId.equals(baseQuestion.link.getAnswer().questionId)))
+ {
+ linkAnswer.setValue(baseQuestion.link.getAnswer().getValue());
+ linkAnswer.string = baseQuestion.link.getAnswer().string;
+ linkAnswer.setAnswered(true);
+ }
+ }
+
+
+ // Init
+ fillPanel();
+
+ this.setTitle("Set Link for Question \"" + q.title + "\"");
+ this.setSize(550, 500);
+
+ //Center the window
+ /* Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = this.getSize();
+ if (frameSize.height > screenSize.height)
+ {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width)
+ {
+ frameSize.width = screenSize.width;
+ }
+ this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); */
+
+ this.show();
+ }
+
+
+ /**
+ * Updates right side question fields when the selection changes
+ * @param e event generated by selection change.
+ */
+ public void question_list_selectionChanged(ListSelectionEvent e)
+ {
+ if (!e.getValueIsAdjusting() && !questionList.isSelectionEmpty())
+ {
+ question = (Question) questionList.getSelectedValue();
+
+ if (question != null)
+ {
+ linkAnswer = new Answer(question.UniqueId);
+
+ if (baseQuestion.link.isActive() && (question.UniqueId.equals(baseQuestion.link.getAnswer().questionId)))
+ {
+ linkAnswer.setValue(baseQuestion.link.getAnswer().getValue());
+ linkAnswer.setIndex(baseQuestion.link.getAnswer().getIndex());
+ linkAnswer.string = baseQuestion.link.getAnswer().string;
+ linkAnswer.setAnswered(true);
+ }
+ }
+
+ setOKButtonState();
+ fillPanel();
+ }
+ }
+
+ /****
+ * fill List with appropriate questions
+ * Set other fields to selected question
+ */
+ public void fillPanel()
+ {
+ allAdjacentCheck.setVisible(false);
+
+ if (question != null)
+ {
+ titleText.setText(question.title);
+
+ answerPanel.setVisible(false);
+ answerPanel.removeAll();
+ questionText.setText("Please select a question and an answer which will trigger the inclusion of the current question");
+ if (question instanceof AlterPromptQuestion)
+ {
+ // Should never be here
+ //assert(false);
+ }
+ else if (question.answerType == Shared.AnswerType.TEXT)
+ {
+ answerPanel.add(textPanel);
+ answerPanel.validate();
+ answerTextField.setDocument(plainDocument);
+ answerTextField.requestFocus();
+
+ if (linkAnswer.isAnswered())
+ {
+ answerTextField.setText(linkAnswer.string);
+ }
+ else
+ {
+ answerTextField.setText("");
+ }
+ }
+ else if (question.answerType == Shared.AnswerType.NUMERICAL)
+ {
+ answerPanel.add(textPanel);
+ answerTextField.setDocument(wholeNumberDocument);
+ answerTextField.requestFocus();
+
+ if (linkAnswer.isAnswered())
+ {
+ answerTextField.setText(linkAnswer.string);
+ }
+ else
+ {
+ answerTextField.setText("");
+ }
+ }
+ else if (question.getSelections().length <= 5)
+ {
+ allAdjacentCheck.setVisible(question instanceof AlterPairQuestion);
+ questionText.setText(question.text);
+
+ answerPanel.add(radioPanel);
+
+ if (linkAnswer.isAnswered())
+ {
+ if (linkAnswer.getValue() == Answer.ALL_ADJACENT)
+ {
+ allAdjacentCheck.setSelected(true);
+ answerButtons[MAX_BUTTONS].setSelected(true);
+ }
+ else
+ {
+ allAdjacentCheck.setSelected(false);
+ answerButtons[question.getSelections().length - (linkAnswer.getValue() + 1)].setSelected(true);
+ }
+ }
+ else
+ {
+ answerButtons[MAX_BUTTONS].setSelected(true);
+ }
+
+ for (int i = 0; i < question.getSelections().length; i++)
+ {
+ answerButtons[i].setText(question.getSelections()[i].getString());
+ answerButtons[i].setVisible(true);
+ answerButtons[i].setEnabled(linkAnswer.getValue() != Answer.ALL_ADJACENT);
+ }
+
+ for (int i = question.getSelections().length; i < MAX_BUTTONS; i++)
+ {
+ answerButtons[i].setVisible(false);
+ }
+ }
+ else
+ {
+ allAdjacentCheck.setVisible(question instanceof AlterPairQuestion);
+ questionText.setText(question.text);
+ answerPanel.add(menuPanel);
+
+ answerMenu.removeAllItems();
+
+ answerMenu.addItem(new Selection("Select an answer"));
+ for (int i = 0; i < question.getSelections().length; i++)
+ {
+ answerMenu.addItem(question.getSelections()[i]);
+ }
+
+ if (linkAnswer.getValue() == Answer.ALL_ADJACENT)
+ {
+ allAdjacentCheck.setSelected(true);
+ answerMenu.setEnabled(false);
+ }
+ else if (linkAnswer.getValue() != Answer.NO_ANSWER)
+ {
+ allAdjacentCheck.setSelected(false);
+ answerMenu.setEnabled(true);
+ answerMenu.setSelectedIndex(question.getSelections().length - linkAnswer.getValue());
+ }
+ else
+ {
+ allAdjacentCheck.setSelected(false);
+ answerMenu.setEnabled(true);
+ answerMenu.setSelectedIndex(0);
+ }
+ }
+
+ answerPanel.validate();
+ answerPanel.setVisible(true);
+ }
+ }
+
+ /****
+ * Clear all on screen editable fields
+ * Generally called when a new survey is started
+ */
+ public void clearPanel()
+ {
+ ((DefaultListModel) questionList.getModel()).removeAllElements();
+ }
+
+ /****
+ * Parses answer fields to retrieve answer to question
+ * @param answer Answer from interview to fill with correct values
+ */
+ void fillAnswer()
+ {
+ linkAnswer.string = null;
+
+ if(question.answerType.equals(Shared.AnswerType.NUMERICAL)) {
+ if (answerTextField.getText().length() > 0)
+ {
+ linkAnswer.string = answerTextField.getText();
+ linkAnswer.setValue(Integer.valueOf(linkAnswer.string).intValue());
+ linkAnswer.setAnswered(true);
+ }
+ else
+ {
+ linkAnswer.setValue(Answer.NO_ANSWER);
+ linkAnswer.setAnswered(false);
+ }
+ } else if(question.answerType.equals(Shared.AnswerType.TEXT)) {
+ linkAnswer.string = answerTextField.getText();
+ linkAnswer.setValue(linkAnswer.string.length());
+ linkAnswer.setAnswered((linkAnswer.getValue() != 0));
+ } else if(question.answerType.equals(Shared.AnswerType.INFORMATIONAL)) {
+ linkAnswer.string = "informational";
+ linkAnswer.setValue(1);
+ linkAnswer.setAnswered(true);
+ } else if(question.answerType.equals(Shared.AnswerType.CATEGORICAL)) {
+
+ // option/radio buttons
+ if (question.getSelections().length <= 5) {
+ if (allAdjacentCheck.isSelected()) {
+ linkAnswer.setValue(Answer.ALL_ADJACENT);
+ linkAnswer.string = "All Adjacent";
+ linkAnswer.setAnswered(true);
+ }
+ else {
+ int button = selectedButtonIndex(answerButtons);
+ linkAnswer.setAnswered( (button != MAX_BUTTONS));
+
+ if (linkAnswer.isAnswered())
+ {
+ linkAnswer.setValue(question.getSelections()[button].getValue());
+ linkAnswer.setIndex(question.getSelections()[button].getIndex());
+ linkAnswer.string = answerButtons[button].getActionCommand();
+ }
+ else
+ {
+ linkAnswer.setValue(Answer.NO_ANSWER);
+ linkAnswer.setIndex(Answer.NO_ANSWER);
+ linkAnswer.string = "";
+ }
+ }
+ }
+
+ // drop down buttons
+ else {
+ if (allAdjacentCheck.isSelected())
+ {
+ linkAnswer.setValue(Answer.ALL_ADJACENT);
+ linkAnswer.string = "All Adjacent";
+ linkAnswer.setAnswered(true);
+ }
+ else if (answerMenu.getSelectedIndex() > 0) // 0th option is "Select an answer"
+ {
+ int selectionIndex = answerMenu.getSelectedIndex() - 1;
+ linkAnswer.setValue(question.getSelections()[selectionIndex].getValue());
+ linkAnswer.string = answerMenu.getSelectedItem().toString();
+ linkAnswer.setAnswered((selectionIndex <= question.getSelections().length));
+ }
+ else
+ {
+ linkAnswer.setValue(Answer.NO_ANSWER);
+ linkAnswer.string = "";
+ linkAnswer.setAnswered(false);
+ }
+ }
+ }
+ }
+
+
+ void jShowListButton_actionPerformed(ActionEvent e)
+ {
+ questionPanelLeft.setVisible(!questionPanelLeft.isVisible());
+ questionSplit.setDividerLocation(.33);
+ questionSplit.repaint();
+ }
+
+ void questionButtonNone_actionPerformed(ActionEvent e) throws IOException
+ {
+ if (egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame()))
+ {
+ baseQuestion.link.setAnswer(null);
+ egoNet.getStudy().setModified(true);
+ egoNet.getStudy().setCompatible(false);
+ }
+
+ egoNet.getFrame().fillCurrentPanel();
+ this.hide();
+ }
+
+ void questionButtonCancel_actionPerformed(ActionEvent e)
+ {
+ this.hide();
+ }
+
+ void questionButtonOK_actionPerformed(ActionEvent e) throws IOException
+ {
+ if ((linkAnswer != null) && (linkAnswer.isAnswered()) && egoNet.getStudy().confirmIncompatibleChange(egoNet.getFrame()))
+ {
+ baseQuestion.link.setAnswer(linkAnswer);
+ egoNet.getStudy().setModified(true);
+ egoNet.getStudy().setCompatible(false);
+ }
+
+ this.hide();
+ egoNet.getFrame().fillCurrentPanel();
+ }
+
+ int selectedButtonIndex(JRadioButton[] group)
+ {
+ int ri = -1;
+
+ for (int i = 0; i < group.length; i++)
+ {
+ if (group[i].isSelected())
+ {
+ ri = i;
+ break;
+ }
+ }
+
+ return (ri);
+ }
+
+ void setOKButtonState()
+ {
+ questionButtonOK.setEnabled((question != null) && linkAnswer.isAnswered());
+ }
+
+
+ void questionAnsweredEventHandler(ActionEvent e)
+ {
+ if (e.getActionCommand() != "Initialization")
+ {
+ fillAnswer();
+ setOKButtonState();
+ }
+ }
+
+ void answerTextEvent(DocumentEvent e)
+ {
+ fillAnswer();
+ setOKButtonState();
+ }
+
+ public void update(Observable o, Object arg)
+ {
+ fillAnswer();
+ setOKButtonState();
+ }
+
+ void allAdjacentCheck_actionPerformed(ActionEvent e)
+ {
+ fillAnswer();
+ fillPanel();
+ setOKButtonState();
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/author/RightPanel.java b/src/main/java/com/endlessloopsoftware/ego/author/RightPanel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/author/RightPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/author/RightPanel.java
index 61cff2e..dae4dfa 100644
--- a/src/com/endlessloopsoftware/ego/author/RightPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/author/RightPanel.java
@@ -1,31 +1,31 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.author;
-import javax.swing.JPanel;
-
-/**
- * Extends JPanel class to keep focus in right panel of split question panel
- */
-public class RightPanel extends JPanel
-{
- public boolean isFocusCycleRoot()
- {
- return (true);
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.author;
+import javax.swing.JPanel;
+
+/**
+ * Extends JPanel class to keep focus in right panel of split question panel
+ */
+public class RightPanel extends JPanel
+{
+ public boolean isFocusCycleRoot()
+ {
+ return (true);
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/author/SelectStudyDialog.gui_xml b/src/main/java/com/endlessloopsoftware/ego/author/SelectStudyDialog.gui_xml
similarity index 100%
rename from src/com/endlessloopsoftware/ego/author/SelectStudyDialog.gui_xml
rename to src/main/java/com/endlessloopsoftware/ego/author/SelectStudyDialog.gui_xml
diff --git a/src/com/endlessloopsoftware/ego/author/StoreSurvey.gui_xml b/src/main/java/com/endlessloopsoftware/ego/author/StoreSurvey.gui_xml
similarity index 100%
rename from src/com/endlessloopsoftware/ego/author/StoreSurvey.gui_xml
rename to src/main/java/com/endlessloopsoftware/ego/author/StoreSurvey.gui_xml
diff --git a/src/com/endlessloopsoftware/ego/author/StudyPanel.java b/src/main/java/com/endlessloopsoftware/ego/author/StudyPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/author/StudyPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/author/StudyPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/ClientFrame.java b/src/main/java/com/endlessloopsoftware/ego/client/ClientFrame.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/ClientFrame.java
rename to src/main/java/com/endlessloopsoftware/ego/client/ClientFrame.java
diff --git a/src/com/endlessloopsoftware/ego/client/ClientPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/ClientPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/ClientPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/ClientPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/ClientQuestionPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/ClientQuestionPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/ClientQuestionPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/ClientQuestionPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/EgoClient.java b/src/main/java/com/endlessloopsoftware/ego/client/EgoClient.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/EgoClient.java
rename to src/main/java/com/endlessloopsoftware/ego/client/EgoClient.java
index 65dcfa4..7689d80 100644
--- a/src/com/endlessloopsoftware/ego/client/EgoClient.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/EgoClient.java
@@ -1,90 +1,90 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client;
-
-import org.egonet.gui.EgoStore;
-import org.egonet.util.EgonetAnalytics;
-
-import com.endlessloopsoftware.egonet.Interview;
-import com.endlessloopsoftware.egonet.Study;
-
-/**
- * ONLY USE THIS CLASS IN INTERVIEWING PART OF THE TOOL Session object
- * representing the session of the user and the EgoNet software
- *
- *
- * @author peters
- * @author martins
- *
- */
-public class EgoClient {
- private EgoStore storage;
- private ClientFrame frame;
- private int uiPath;
-
- // Construct the application
- public EgoClient() {
- EgonetAnalytics.track("interviewing client startup"); // track!
-
- storage = new EgoStore(null);
- frame = new ClientFrame(this);
-
- frame.gotoSourceSelectPanel();
- frame.setVisible(true);
-
- }
-
- // Main method
- public static void main(String[] args) throws Exception {
- // new Console();
- new EgoClient().getFrame().setVisible(true);
- }
-
- public Study getStudy() {
- return storage.getStudy();
- }
-
- public EgoStore getStorage() {
- return storage;
- }
-
- public void setStorage(EgoStore storage) {
- this.storage = storage;
- }
-
- public ClientFrame getFrame() {
- return frame;
- }
-
- public void setFrame(ClientFrame frame) {
- this.frame = frame;
- }
-
- public Interview getInterview() {
- return storage.getInterview();
- }
-
- public int getUiPath() {
- return uiPath;
- }
-
- public void setUiPath(int uiPath) {
- this.uiPath = uiPath;
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client;
+
+import org.egonet.gui.EgoStore;
+import org.egonet.util.EgonetAnalytics;
+
+import com.endlessloopsoftware.egonet.Interview;
+import com.endlessloopsoftware.egonet.Study;
+
+/**
+ * ONLY USE THIS CLASS IN INTERVIEWING PART OF THE TOOL Session object
+ * representing the session of the user and the EgoNet software
+ *
+ *
+ * @author peters
+ * @author martins
+ *
+ */
+public class EgoClient {
+ private EgoStore storage;
+ private ClientFrame frame;
+ private int uiPath;
+
+ // Construct the application
+ public EgoClient() {
+ EgonetAnalytics.track("interviewing client startup"); // track!
+
+ storage = new EgoStore(null);
+ frame = new ClientFrame(this);
+
+ frame.gotoSourceSelectPanel();
+ frame.setVisible(true);
+
+ }
+
+ // Main method
+ public static void main(String[] args) throws Exception {
+ // new Console();
+ new EgoClient().getFrame().setVisible(true);
+ }
+
+ public Study getStudy() {
+ return storage.getStudy();
+ }
+
+ public EgoStore getStorage() {
+ return storage;
+ }
+
+ public void setStorage(EgoStore storage) {
+ this.storage = storage;
+ }
+
+ public ClientFrame getFrame() {
+ return frame;
+ }
+
+ public void setFrame(ClientFrame frame) {
+ this.frame = frame;
+ }
+
+ public Interview getInterview() {
+ return storage.getInterview();
+ }
+
+ public int getUiPath() {
+ return uiPath;
+ }
+
+ public void setUiPath(int uiPath) {
+ this.uiPath = uiPath;
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/StartPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/StartPanel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/StartPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/StartPanel.java
index 1493ae9..cea1525 100644
--- a/src/com/endlessloopsoftware/ego/client/StartPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/StartPanel.java
@@ -1,282 +1,282 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.SwingConstants;
-import org.egonet.exceptions.CorruptedInterviewException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-
-
-public class StartPanel extends JPanel
-{
- final private static Logger logger = LoggerFactory.getLogger(StartPanel.class);
-
- private final GridBagLayout gridBagLayout1 = new GridBagLayout();
- private final JLabel titleLabel = new JLabel("Create a new interview file");
-
- private final JButton startBrandNewInterviewButton = new JButton("Save or Continue a Respondent Interview (New Respondent)");
- private final JButton startLongitudinalInterviewButton = new JButton("Save New Longitudinal Interview (Existing Respondent)");
-
- private final EgoClient egoClient;
-
- public StartPanel(EgoClient egoClient) throws Exception
- {
- this.egoClient = egoClient;
- logger.info("Create of start panel using " + egoClient + " - " + egoClient.getStudy().getAlterNameModel());
-
- jbInit();
- }
-
- private void jbInit() throws Exception
- {
- this.setLayout(gridBagLayout1);
-
- titleLabel.setFont(new java.awt.Font("Lucida Grande", 1, 16));
- titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
- titleLabel.setHorizontalTextPosition(SwingConstants.CENTER);
-
- this.setBorder(BorderFactory.createEtchedBorder());
- this.add(
- titleLabel,
- new GridBagConstraints(
- 0,
- 0,
- 2,
- 1,
- 1.0,
- 0.2,
- GridBagConstraints.CENTER,
- GridBagConstraints.HORIZONTAL,
- new Insets(0, 0, 0, 0),
- 0,
- 0));
-
- logger.info(egoClient.getStudy().getAlterNameModel().toString());
- logger.info(egoClient.getStudy().getStudyName());
-
- this.add(
- startBrandNewInterviewButton,
- new GridBagConstraints(
- 1,
- 2,
- 1,
- 1,
- 0.0,
- 0.0,
- GridBagConstraints.CENTER,
- GridBagConstraints.HORIZONTAL,
- new Insets(10, 10, 10, 10),
- 0,
- 6));
- this.add(
- startLongitudinalInterviewButton,
- new GridBagConstraints(
- 0,
- 3,
- 2,
- 1,
- 0.0,
- 0.0,
- GridBagConstraints.CENTER,
- GridBagConstraints.HORIZONTAL,
- new Insets(10, 10, 10, 10),
- 0,
- 0));
-
- startBrandNewInterviewButton.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- startBrandNewInterviewButton_actionPerformed(e);
- }
- });
-
-
- startLongitudinalInterviewButton.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- startLongitudinalInterviewButton_actionPerformed(e);
- }
-
- });
- }
-
- private void startLongitudinalInterviewButton_actionPerformed(ActionEvent e) {
- boolean success = false;
-
- /* Logic */
- try
- {
-
- File studyFile = egoClient.getStorage().getStudyFile();
- File studyPath = studyFile.getParentFile();
-
- final JFileChooser fcOpen = new JFileChooser();
-
- final JFileChooser fcSave = new JFileChooser() {
-
- // this chooser needs to understand the "overwrite?" confirmation
-
- @Override
- public void approveSelection(){
- File f = getSelectedFile();
- if(f.exists() && getDialogType() == SAVE_DIALOG){
- int result = JOptionPane.showConfirmDialog(this,"The file exists, overwrite?","Existing file",JOptionPane.YES_NO_CANCEL_OPTION);
- switch(result){
- case JOptionPane.YES_OPTION:
- super.approveSelection();
- return;
- case JOptionPane.NO_OPTION:
- return;
- case JOptionPane.CLOSED_OPTION:
- return;
- case JOptionPane.CANCEL_OPTION:
- cancelSelection();
- return;
- }
- }
- super.approveSelection();
- }
-
- };
-
- fcOpen.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
- fcSave.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
-
- int rOpen = fcOpen.showOpenDialog(this);
- if(rOpen != JFileChooser.APPROVE_OPTION)
- return;
-
- int rSave = fcSave.showSaveDialog(this);
- if(rSave != JFileChooser.APPROVE_OPTION)
- return;
-
- // don't warn about incomplete?
- // copy extant interview
-
-
- success = egoClient.getStorage().saveLongitudinalFile(fcOpen.getSelectedFile(), fcSave.getSelectedFile());
- }
- catch (IOException ex)
- {
- success = false;
- } catch (CorruptedInterviewException ex) {
- JOptionPane.showMessageDialog(this, "The original interview you selected is corrupted. Will not proceed.");
- success = false;
- logger.info("Corrupted interview while trying to start a longitudinal study", ex);
- }
-
- /* UI */
- if (success)
- {
- egoClient.getFrame().gotoClientQuestionPanel();
- }
- else
- {
- egoClient.getFrame().gotoSourceSelectPanel();
- }
- }
-
- void startBrandNewInterviewButton_actionPerformed(ActionEvent e)
- {
- boolean success = false;
-
- /* Logic */
- try
- {
-
- File studyFile = egoClient.getStorage().getStudyFile();
- File studyPath = studyFile.getParentFile();
-
- final JFileChooser fc = new JFileChooser() {
-
- // this chooser needs to understand the "overwrite?" confirmation
-
- @Override
- public void approveSelection(){
- File f = getSelectedFile();
- if(f.exists() && getDialogType() == SAVE_DIALOG){
- int result = JOptionPane.showConfirmDialog(this,"The file exists, are you sure you want to continue with an existing interview?","Existing file",JOptionPane.YES_NO_CANCEL_OPTION);
- switch(result){
- case JOptionPane.YES_OPTION:
- super.approveSelection();
- return;
- case JOptionPane.NO_OPTION:
- return;
- case JOptionPane.CLOSED_OPTION:
- return;
- case JOptionPane.CANCEL_OPTION:
- cancelSelection();
- return;
- }
- }
- super.approveSelection();
- }
-
- };
- fc.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
-
- int result = fc.showSaveDialog(this);
- if(result != JFileChooser.APPROVE_OPTION)
- return;
-
- File fSelected = fc.getSelectedFile();
- if(fSelected.exists() && fSelected.canRead())
- success = egoClient.getStorage().continueInterview(fSelected);
- else
- success = egoClient.getStorage().saveInterview(fSelected);
- }
- catch (IOException ex)
- {
- success = false;
- } catch (CorruptedInterviewException ex) {
- JOptionPane.showMessageDialog(this, "The interview you selected is corrupted. Will not proceed.");
- success = false;
- logger.info("Corrupted interview while trying to continue a brand new interview", ex);
- }
-
- /* UI */
- if (success)
- {
- egoClient.getFrame().gotoClientQuestionPanel();
- }
- else
- {
- egoClient.getFrame().gotoSourceSelectPanel();
- }
- }
-
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import org.egonet.exceptions.CorruptedInterviewException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+
+
+
+public class StartPanel extends JPanel
+{
+ final private static Logger logger = LoggerFactory.getLogger(StartPanel.class);
+
+ private final GridBagLayout gridBagLayout1 = new GridBagLayout();
+ private final JLabel titleLabel = new JLabel("Create a new interview file");
+
+ private final JButton startBrandNewInterviewButton = new JButton("Save or Continue a Respondent Interview (New Respondent)");
+ private final JButton startLongitudinalInterviewButton = new JButton("Save New Longitudinal Interview (Existing Respondent)");
+
+ private final EgoClient egoClient;
+
+ public StartPanel(EgoClient egoClient) throws Exception
+ {
+ this.egoClient = egoClient;
+ logger.info("Create of start panel using " + egoClient + " - " + egoClient.getStudy().getAlterNameModel());
+
+ jbInit();
+ }
+
+ private void jbInit() throws Exception
+ {
+ this.setLayout(gridBagLayout1);
+
+ titleLabel.setFont(new java.awt.Font("Lucida Grande", 1, 16));
+ titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
+ titleLabel.setHorizontalTextPosition(SwingConstants.CENTER);
+
+ this.setBorder(BorderFactory.createEtchedBorder());
+ this.add(
+ titleLabel,
+ new GridBagConstraints(
+ 0,
+ 0,
+ 2,
+ 1,
+ 1.0,
+ 0.2,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(0, 0, 0, 0),
+ 0,
+ 0));
+
+ logger.info(egoClient.getStudy().getAlterNameModel().toString());
+ logger.info(egoClient.getStudy().getStudyName());
+
+ this.add(
+ startBrandNewInterviewButton,
+ new GridBagConstraints(
+ 1,
+ 2,
+ 1,
+ 1,
+ 0.0,
+ 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 10, 10),
+ 0,
+ 6));
+ this.add(
+ startLongitudinalInterviewButton,
+ new GridBagConstraints(
+ 0,
+ 3,
+ 2,
+ 1,
+ 0.0,
+ 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 10, 10),
+ 0,
+ 0));
+
+ startBrandNewInterviewButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ startBrandNewInterviewButton_actionPerformed(e);
+ }
+ });
+
+
+ startLongitudinalInterviewButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ startLongitudinalInterviewButton_actionPerformed(e);
+ }
+
+ });
+ }
+
+ private void startLongitudinalInterviewButton_actionPerformed(ActionEvent e) {
+ boolean success = false;
+
+ /* Logic */
+ try
+ {
+
+ File studyFile = egoClient.getStorage().getStudyFile();
+ File studyPath = studyFile.getParentFile();
+
+ final JFileChooser fcOpen = new JFileChooser();
+
+ final JFileChooser fcSave = new JFileChooser() {
+
+ // this chooser needs to understand the "overwrite?" confirmation
+
+ @Override
+ public void approveSelection(){
+ File f = getSelectedFile();
+ if(f.exists() && getDialogType() == SAVE_DIALOG){
+ int result = JOptionPane.showConfirmDialog(this,"The file exists, overwrite?","Existing file",JOptionPane.YES_NO_CANCEL_OPTION);
+ switch(result){
+ case JOptionPane.YES_OPTION:
+ super.approveSelection();
+ return;
+ case JOptionPane.NO_OPTION:
+ return;
+ case JOptionPane.CLOSED_OPTION:
+ return;
+ case JOptionPane.CANCEL_OPTION:
+ cancelSelection();
+ return;
+ }
+ }
+ super.approveSelection();
+ }
+
+ };
+
+ fcOpen.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
+ fcSave.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
+
+ int rOpen = fcOpen.showOpenDialog(this);
+ if(rOpen != JFileChooser.APPROVE_OPTION)
+ return;
+
+ int rSave = fcSave.showSaveDialog(this);
+ if(rSave != JFileChooser.APPROVE_OPTION)
+ return;
+
+ // don't warn about incomplete?
+ // copy extant interview
+
+
+ success = egoClient.getStorage().saveLongitudinalFile(fcOpen.getSelectedFile(), fcSave.getSelectedFile());
+ }
+ catch (IOException ex)
+ {
+ success = false;
+ } catch (CorruptedInterviewException ex) {
+ JOptionPane.showMessageDialog(this, "The original interview you selected is corrupted. Will not proceed.");
+ success = false;
+ logger.info("Corrupted interview while trying to start a longitudinal study", ex);
+ }
+
+ /* UI */
+ if (success)
+ {
+ egoClient.getFrame().gotoClientQuestionPanel();
+ }
+ else
+ {
+ egoClient.getFrame().gotoSourceSelectPanel();
+ }
+ }
+
+ void startBrandNewInterviewButton_actionPerformed(ActionEvent e)
+ {
+ boolean success = false;
+
+ /* Logic */
+ try
+ {
+
+ File studyFile = egoClient.getStorage().getStudyFile();
+ File studyPath = studyFile.getParentFile();
+
+ final JFileChooser fc = new JFileChooser() {
+
+ // this chooser needs to understand the "overwrite?" confirmation
+
+ @Override
+ public void approveSelection(){
+ File f = getSelectedFile();
+ if(f.exists() && getDialogType() == SAVE_DIALOG){
+ int result = JOptionPane.showConfirmDialog(this,"The file exists, are you sure you want to continue with an existing interview?","Existing file",JOptionPane.YES_NO_CANCEL_OPTION);
+ switch(result){
+ case JOptionPane.YES_OPTION:
+ super.approveSelection();
+ return;
+ case JOptionPane.NO_OPTION:
+ return;
+ case JOptionPane.CLOSED_OPTION:
+ return;
+ case JOptionPane.CANCEL_OPTION:
+ cancelSelection();
+ return;
+ }
+ }
+ super.approveSelection();
+ }
+
+ };
+ fc.setCurrentDirectory(new File(studyPath.getAbsolutePath()+"/Interviews/"));
+
+ int result = fc.showSaveDialog(this);
+ if(result != JFileChooser.APPROVE_OPTION)
+ return;
+
+ File fSelected = fc.getSelectedFile();
+ if(fSelected.exists() && fSelected.canRead())
+ success = egoClient.getStorage().continueInterview(fSelected);
+ else
+ success = egoClient.getStorage().saveInterview(fSelected);
+ }
+ catch (IOException ex)
+ {
+ success = false;
+ } catch (CorruptedInterviewException ex) {
+ JOptionPane.showMessageDialog(this, "The interview you selected is corrupted. Will not proceed.");
+ success = false;
+ logger.info("Corrupted interview while trying to continue a brand new interview", ex);
+ }
+
+ /* UI */
+ if (success)
+ {
+ egoClient.getFrame().gotoClientQuestionPanel();
+ }
+ else
+ {
+ egoClient.getFrame().gotoSourceSelectPanel();
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/SummaryPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/SummaryPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/SummaryPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/SummaryPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java
index 36a8c25..85a4f0c 100644
--- a/src/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/ViewInterviewPanel.java
@@ -1,51 +1,51 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client;
-
-import javax.swing.JTabbedPane;
-import javax.swing.ProgressMonitor;
-
-import java.util.*;
-
-import com.endlessloopsoftware.ego.client.statistics.StatisticsFrame;
-import com.endlessloopsoftware.ego.client.graph.*;
-
-public class ViewInterviewPanel
- extends JTabbedPane
-{
- GraphPanel graphPanel;
- public ViewInterviewPanel(EgoClient egoClient, ProgressMonitor progress)
- {
- super();
- progress.setProgress(10);
- this.addTab("Interview", new ClientQuestionPanel(egoClient));
- progress.setProgress(15);
-
- if(egoClient.getInterview().isComplete()) {
- this.addTab("Statistics", new StatisticsFrame(egoClient));
- graphPanel = new GraphPanel(egoClient);
- this.addTab("Graph", graphPanel);
- }
- progress.setProgress(70);
- }
-
- public Iterator settingsIterator() {
- return graphPanel.getSettingsIterator();
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client;
+
+import javax.swing.JTabbedPane;
+import javax.swing.ProgressMonitor;
+
+import java.util.*;
+
+import com.endlessloopsoftware.ego.client.statistics.StatisticsFrame;
+import com.endlessloopsoftware.ego.client.graph.*;
+
+public class ViewInterviewPanel
+ extends JTabbedPane
+{
+ GraphPanel graphPanel;
+ public ViewInterviewPanel(EgoClient egoClient, ProgressMonitor progress)
+ {
+ super();
+ progress.setProgress(10);
+ this.addTab("Interview", new ClientQuestionPanel(egoClient));
+ progress.setProgress(15);
+
+ if(egoClient.getInterview().isComplete()) {
+ this.addTab("Statistics", new StatisticsFrame(egoClient));
+ graphPanel = new GraphPanel(egoClient);
+ this.addTab("Graph", graphPanel);
+ }
+ progress.setProgress(70);
+ }
+
+ public Iterator settingsIterator() {
+ return graphPanel.getSettingsIterator();
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/WorkingDialog.java b/src/main/java/com/endlessloopsoftware/ego/client/WorkingDialog.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/WorkingDialog.java
rename to src/main/java/com/endlessloopsoftware/ego/client/WorkingDialog.java
index 3c30c5e..de8d2d2 100644
--- a/src/com/endlessloopsoftware/ego/client/WorkingDialog.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/WorkingDialog.java
@@ -1,54 +1,54 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client;
-
-import java.awt.BorderLayout;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-public class WorkingDialog extends JDialog
-{
- private JPanel panel1 = new JPanel();
- private BorderLayout borderLayout1 = new BorderLayout();
- private JLabel jLabel1 = new JLabel();
-
- public WorkingDialog(JFrame frame, String title, boolean modal)
- {
- super(frame, title, modal);
- jbInit();
- pack();
- }
-
- public WorkingDialog()
- {
- this(null, "", false);
- }
-
- private void jbInit()
- {
- panel1.setLayout(borderLayout1);
- jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
- jLabel1.setToolTipText("");
- jLabel1.setText("Working...");
- getContentPane().add(panel1);
- panel1.add(jLabel1, BorderLayout.CENTER);
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client;
+
+import java.awt.BorderLayout;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+public class WorkingDialog extends JDialog
+{
+ private JPanel panel1 = new JPanel();
+ private BorderLayout borderLayout1 = new BorderLayout();
+ private JLabel jLabel1 = new JLabel();
+
+ public WorkingDialog(JFrame frame, String title, boolean modal)
+ {
+ super(frame, title, modal);
+ jbInit();
+ pack();
+ }
+
+ public WorkingDialog()
+ {
+ this(null, "", false);
+ }
+
+ private void jbInit()
+ {
+ panel1.setLayout(borderLayout1);
+ jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
+ jLabel1.setToolTipText("");
+ jLabel1.setText("Working...");
+ getContentPane().add(panel1);
+ panel1.add(jLabel1, BorderLayout.CENTER);
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/graph/ELSFRLayout2.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/ELSFRLayout2.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/ELSFRLayout2.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/ELSFRLayout2.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/Edge.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/Edge.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/graph/Edge.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/Edge.java
index e47548a..64525a9 100644
--- a/src/com/endlessloopsoftware/ego/client/graph/Edge.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/graph/Edge.java
@@ -1,67 +1,67 @@
-package com.endlessloopsoftware.ego.client.graph;
-
-import edu.uci.ics.jung.graph.util.Pair;
-
-public class Edge {
-
- public final Pair pair;
- private String notes;
-
- public Edge(String a, String b) {
- super();
- this.pair = buildEdge(a,b);
- this.notes = "";
- }
-
- public String getNotes() {
- return notes;
- }
-
- public void setNotes(String notes) {
- this.notes = notes;
- }
-
- public Edge(Vertex a, Vertex b) {
- super();
- this.pair = buildEdge(a.name,b.name);
- this.notes = "";
- }
-
- // keep them ordered for edge identity
- public static Pair buildEdge(String a, String b) {
- return a.compareTo(b) > 0 ? new Pair(b,a) : new Pair(a,b);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((pair == null) ? 0 : pair.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Edge))
- return false;
- Edge other = (Edge) obj;
- if (pair == null) {
- if (other.pair != null)
- return false;
- } else if (!pair.equals(other.pair))
- return false;
- return true;
- }
-
- public Pair getEndpoints() {
- return pair;
- }
-
- public String toString() {
- return "edge1="+pair.getFirst()+",edge2="+pair.getSecond();
- }
-}
+package com.endlessloopsoftware.ego.client.graph;
+
+import edu.uci.ics.jung.graph.util.Pair;
+
+public class Edge {
+
+ public final Pair pair;
+ private String notes;
+
+ public Edge(String a, String b) {
+ super();
+ this.pair = buildEdge(a,b);
+ this.notes = "";
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public Edge(Vertex a, Vertex b) {
+ super();
+ this.pair = buildEdge(a.name,b.name);
+ this.notes = "";
+ }
+
+ // keep them ordered for edge identity
+ public static Pair buildEdge(String a, String b) {
+ return a.compareTo(b) > 0 ? new Pair(b,a) : new Pair(a,b);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((pair == null) ? 0 : pair.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Edge))
+ return false;
+ Edge other = (Edge) obj;
+ if (pair == null) {
+ if (other.pair != null)
+ return false;
+ } else if (!pair.equals(other.pair))
+ return false;
+ return true;
+ }
+
+ public Pair getEndpoints() {
+ return pair;
+ }
+
+ public String toString() {
+ return "edge1="+pair.getFirst()+",edge2="+pair.getSecond();
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/graph/EdgeColorPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeColorPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/EdgeColorPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeColorPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/EdgeProperty.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeProperty.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/EdgeProperty.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeProperty.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/EdgeShapePanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeShapePanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/EdgeShapePanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeShapePanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/EdgeSizePanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeSizePanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/EdgeSizePanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/EdgeSizePanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/EllipseVertexShapeFunction.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/EllipseVertexShapeFunction.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/EllipseVertexShapeFunction.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/EllipseVertexShapeFunction.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphData.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphData.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphData.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphData.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphProperty.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphProperty.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphProperty.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphProperty.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphQuestionSelectionPair.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphQuestionSelectionPair.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphQuestionSelectionPair.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphQuestionSelectionPair.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphRenderer.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphRenderer.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphRenderer.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphRenderer.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphSettings.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphSettings.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphSettings.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphSettings.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java
index 0045b47..c7f48ef 100644
--- a/src/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphSettingsEntry.java
@@ -1,142 +1,142 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.graph;
-
-import org.w3c.dom.*;
-
-import com.endlessloopsoftware.ego.client.graph.EdgeProperty.EdgePropertyType;
-import com.endlessloopsoftware.ego.client.graph.NodeProperty.NodePropertyType;
-
-public class GraphSettingsEntry {
-
- public enum GraphSettingType {
- Node, Edge
- }
-
- GraphQuestionSelectionPair graphQuestion = null;
-
- GraphProperty property = null;
-
- GraphSettingType type;
-
- public GraphSettingsEntry(GraphQuestionSelectionPair gq, NodeProperty np,
- GraphSettingType type) {
- this.graphQuestion = gq;
- this.property = np;
- this.type = type;
- }
-
- public GraphSettingsEntry(GraphQuestionSelectionPair gq, EdgeProperty ep,
- GraphSettingType type) {
- this.graphQuestion = gq;
- this.property = ep;
- this.type = type;
- }
-
- public GraphQuestionSelectionPair getGraphQuestion() {
- return graphQuestion;
- }
-
- public GraphProperty getProperty() {
- return property;
- }
-
- public String toString() {
- return "[questionSelectionPair=("+graphQuestion.toString() + "),(property=" + property.toString() + ")]";
- }
-
- public GraphSettingType getType() {
- return type;
- }
-
- public void writeEntryElement(Document doc, Element rootElement) {
- Element entryElement = doc.createElement("Entry");
-
- // Record Graph Question (Question , Answer)
- Element graphQuestionElement = doc.createElement("GraphQuestionSelectionPair");
- // Question
- Element questionElement = doc.createElement("Question");
- questionElement.setAttribute("id", graphQuestion.getQuestion().UniqueId
- .toString());
- // Selection
- Element selectionElement = doc.createElement("Selection");
- selectionElement.setAttribute("text", graphQuestion.getSelection().getString());
- // Type
- Element categoryElement = doc.createElement("Category");
- String category = graphQuestion.getCategory().getSimpleName()+"";
- categoryElement.setAttribute("category", category);
- // Append all three to graphQuestion Element
- graphQuestionElement.appendChild(questionElement);
- graphQuestionElement.appendChild(selectionElement);
- graphQuestionElement.appendChild(categoryElement);
-
- // Record Property(Color Shape Size Label)
- Element propertyElement = doc.createElement("Property");
- propertyElement.setAttribute("type", type.toString());
-
- if (property instanceof NodeProperty) {
- NodeProperty np = ((NodeProperty) property);
- if(np.getProperty().equals(NodePropertyType.Color))
- {
- String rgb = ((Integer) property.getColor().getRGB()).toString();
- propertyElement.setAttribute("color", rgb);
- } else if(np.getProperty().equals(NodePropertyType.Label)) {
- // doesn't save label yet!
- } else if(np.getProperty().equals(NodePropertyType.Shape)) {
- String shape = np.getShape().toString();
- propertyElement.setAttribute("shape", shape);
- } else if(np.getProperty().equals(NodePropertyType.Size)) {
- String size = ((Integer) property.getSize()).toString();
- propertyElement.setAttribute("size", size);
- }
-
- // no visible property on nodes
- } else {
-
- EdgeProperty ep = ((EdgeProperty) property);
- if(ep.getProperty().equals(EdgePropertyType.Color))
- {
- String rgb = ((Integer) property.getColor().getRGB()).toString();
- propertyElement.setAttribute("color", rgb);
- } else if(ep.getProperty().equals(EdgePropertyType.Label)) {
- // doesn't save label yet!
- } else if(ep.getProperty().equals(EdgePropertyType.Shape)) {
- String shape = ep.getShape().toString();
- propertyElement.setAttribute("shape", shape);
- } else if(ep.getProperty().equals(EdgePropertyType.Size)) {
- String size = ((Integer) property.getSize()).toString();
- propertyElement.setAttribute("size", size);
- }
-
- Element visibleElement = doc.createElement("Visible");
- if (((EdgeProperty) property).isVisible())
- visibleElement.setAttribute("visible", "true");
- else
- visibleElement.setAttribute("visible", "false");
- propertyElement.appendChild(visibleElement);
- }
-
-
- entryElement.appendChild(graphQuestionElement);
- entryElement.appendChild(propertyElement);
-
- rootElement.appendChild(entryElement);
- }
-
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.graph;
+
+import org.w3c.dom.*;
+
+import com.endlessloopsoftware.ego.client.graph.EdgeProperty.EdgePropertyType;
+import com.endlessloopsoftware.ego.client.graph.NodeProperty.NodePropertyType;
+
+public class GraphSettingsEntry {
+
+ public enum GraphSettingType {
+ Node, Edge
+ }
+
+ GraphQuestionSelectionPair graphQuestion = null;
+
+ GraphProperty property = null;
+
+ GraphSettingType type;
+
+ public GraphSettingsEntry(GraphQuestionSelectionPair gq, NodeProperty np,
+ GraphSettingType type) {
+ this.graphQuestion = gq;
+ this.property = np;
+ this.type = type;
+ }
+
+ public GraphSettingsEntry(GraphQuestionSelectionPair gq, EdgeProperty ep,
+ GraphSettingType type) {
+ this.graphQuestion = gq;
+ this.property = ep;
+ this.type = type;
+ }
+
+ public GraphQuestionSelectionPair getGraphQuestion() {
+ return graphQuestion;
+ }
+
+ public GraphProperty getProperty() {
+ return property;
+ }
+
+ public String toString() {
+ return "[questionSelectionPair=("+graphQuestion.toString() + "),(property=" + property.toString() + ")]";
+ }
+
+ public GraphSettingType getType() {
+ return type;
+ }
+
+ public void writeEntryElement(Document doc, Element rootElement) {
+ Element entryElement = doc.createElement("Entry");
+
+ // Record Graph Question (Question , Answer)
+ Element graphQuestionElement = doc.createElement("GraphQuestionSelectionPair");
+ // Question
+ Element questionElement = doc.createElement("Question");
+ questionElement.setAttribute("id", graphQuestion.getQuestion().UniqueId
+ .toString());
+ // Selection
+ Element selectionElement = doc.createElement("Selection");
+ selectionElement.setAttribute("text", graphQuestion.getSelection().getString());
+ // Type
+ Element categoryElement = doc.createElement("Category");
+ String category = graphQuestion.getCategory().getSimpleName()+"";
+ categoryElement.setAttribute("category", category);
+ // Append all three to graphQuestion Element
+ graphQuestionElement.appendChild(questionElement);
+ graphQuestionElement.appendChild(selectionElement);
+ graphQuestionElement.appendChild(categoryElement);
+
+ // Record Property(Color Shape Size Label)
+ Element propertyElement = doc.createElement("Property");
+ propertyElement.setAttribute("type", type.toString());
+
+ if (property instanceof NodeProperty) {
+ NodeProperty np = ((NodeProperty) property);
+ if(np.getProperty().equals(NodePropertyType.Color))
+ {
+ String rgb = ((Integer) property.getColor().getRGB()).toString();
+ propertyElement.setAttribute("color", rgb);
+ } else if(np.getProperty().equals(NodePropertyType.Label)) {
+ // doesn't save label yet!
+ } else if(np.getProperty().equals(NodePropertyType.Shape)) {
+ String shape = np.getShape().toString();
+ propertyElement.setAttribute("shape", shape);
+ } else if(np.getProperty().equals(NodePropertyType.Size)) {
+ String size = ((Integer) property.getSize()).toString();
+ propertyElement.setAttribute("size", size);
+ }
+
+ // no visible property on nodes
+ } else {
+
+ EdgeProperty ep = ((EdgeProperty) property);
+ if(ep.getProperty().equals(EdgePropertyType.Color))
+ {
+ String rgb = ((Integer) property.getColor().getRGB()).toString();
+ propertyElement.setAttribute("color", rgb);
+ } else if(ep.getProperty().equals(EdgePropertyType.Label)) {
+ // doesn't save label yet!
+ } else if(ep.getProperty().equals(EdgePropertyType.Shape)) {
+ String shape = ep.getShape().toString();
+ propertyElement.setAttribute("shape", shape);
+ } else if(ep.getProperty().equals(EdgePropertyType.Size)) {
+ String size = ((Integer) property.getSize()).toString();
+ propertyElement.setAttribute("size", size);
+ }
+
+ Element visibleElement = doc.createElement("Visible");
+ if (((EdgeProperty) property).isVisible())
+ visibleElement.setAttribute("visible", "true");
+ else
+ visibleElement.setAttribute("visible", "false");
+ propertyElement.appendChild(visibleElement);
+ }
+
+
+ entryElement.appendChild(graphQuestionElement);
+ entryElement.appendChild(propertyElement);
+
+ rootElement.appendChild(entryElement);
+ }
+
+}
diff --git a/src/com/endlessloopsoftware/ego/client/graph/GraphTabPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/GraphTabPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/GraphTabPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/GraphTabPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/NodeColorPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/NodeColorPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/NodeColorPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/NodeColorPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/NodeLabelPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/NodeLabelPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/NodeLabelPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/NodeLabelPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/NodeProperty.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/NodeProperty.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/NodeProperty.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/NodeProperty.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/NodeShapePanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/NodeShapePanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/NodeShapePanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/NodeShapePanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/NodeSizePanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/NodeSizePanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/NodeSizePanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/NodeSizePanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/PolygonVertexShapeFunction.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/PolygonVertexShapeFunction.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/PolygonVertexShapeFunction.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/PolygonVertexShapeFunction.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/StructuralMeasuresPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/StructuralMeasuresPanel.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/StructuralMeasuresPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/StructuralMeasuresPanel.java
diff --git a/src/com/endlessloopsoftware/ego/client/graph/Vertex.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/Vertex.java
similarity index 94%
rename from src/com/endlessloopsoftware/ego/client/graph/Vertex.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/Vertex.java
index 56c0d77..e0da1df 100644
--- a/src/com/endlessloopsoftware/ego/client/graph/Vertex.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/graph/Vertex.java
@@ -1,40 +1,40 @@
-package com.endlessloopsoftware.ego.client.graph;
-
-public class Vertex {
-
- public final String name;
-
- public Vertex(String name) {
- super();
- this.name = name;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Vertex))
- return false;
- Vertex other = (Vertex) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
- public String toString() {
- return "vertex="+name;
- }
-}
+package com.endlessloopsoftware.ego.client.graph;
+
+public class Vertex {
+
+ public final String name;
+
+ public Vertex(String name) {
+ super();
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Vertex))
+ return false;
+ Vertex other = (Vertex) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ return "vertex="+name;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/graph/VertexToolTipFunction.java b/src/main/java/com/endlessloopsoftware/ego/client/graph/VertexToolTipFunction.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/graph/VertexToolTipFunction.java
rename to src/main/java/com/endlessloopsoftware/ego/client/graph/VertexToolTipFunction.java
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/AlterStats.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/AlterStats.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/client/statistics/AlterStats.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/AlterStats.java
index ee27093..6590fdb 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/AlterStats.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/AlterStats.java
@@ -1,32 +1,32 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics;
-
-import com.endlessloopsoftware.egonet.Shared;
-
-public class AlterStats
-{
- public String qTitle;
- public Shared.AnswerType answerType;
- public Long questionId;
- public int answerCount;
- public String[] answerText;
- public int answerTotals[];
-}
-
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics;
+
+import com.endlessloopsoftware.egonet.Shared;
+
+public class AlterStats
+{
+ public String qTitle;
+ public Shared.AnswerType answerType;
+ public Long questionId;
+ public int answerCount;
+ public String[] answerText;
+ public int answerTotals[];
+}
+
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/StatRecord.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatRecord.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/statistics/StatRecord.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/StatRecord.java
index a6a30f6..c153505 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/StatRecord.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatRecord.java
@@ -1,159 +1,159 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.egonet.util.Name;
-
-
-public class StatRecord
-{
- private String name = "";
- public String degreeName = "";
- public Integer degreeValue = new Integer(0);
- public Float degreeMean = new Float(0);
- public Float degreeNC = new Float(0);
-
- public String betweenName = "";
- public Float betweenValue = new Float(0);
- public Float betweenMean = new Float(0);
- public Float betweenNC = new Float(0);
-
- public String closenessName = "";
- public Float closenessValue = new Float(0);
- public Float closenessMean = new Float(0);
- public Float closenessNC = new Float(0);
-
- public Integer numCliques = new Integer(0);
- public Integer numComponents = new Integer(0);
- public Integer numIsolates = new Integer(0);
- public Integer numDyads = new Integer(0);
-
- public List egoAnswers = new ArrayList();
- public List alterAnswers = new ArrayList();
-
- public StatRecord()
- {
-
- }
-
- public List getEgoAnswers()
- {
- return egoAnswers;
- }
- public List getAlterAnswers()
- {
- return alterAnswers;
- }
-
- public StatRecord(Statistics stats)
- {
- setName(new Name(stats.getInterview().getIntName()).toString());
-
- degreeName = stats.mostCentralDegreeAlterName;
- degreeValue = new Integer(stats.mostCentralDegreeAlterValue);
- degreeMean = new Float(stats.meanCentralDegreeValue);
- degreeNC = new Float(stats.degreeNC);
-
- closenessName = stats.mostCentralClosenessAlterName;
- closenessValue = new Float(stats.mostCentralClosenessAlterValue);
- closenessMean = new Float(stats.meanCentralClosenessValue);
- closenessNC = new Float(stats.closenessNC);
-
- betweenName = stats.mostCentralBetweenAlterName;
- betweenValue = new Float(stats.mostCentralBetweenAlterValue);
- betweenMean = new Float(stats.meanCentralBetweenAlterValue);
- betweenNC = new Float(stats.betweenNC);
-
- numCliques = new Integer(stats.cliqueSet.size());
- numComponents = new Integer(stats.componentSet.size() - stats.isolates - stats.dyads);
- numIsolates = new Integer(stats.isolates);
- numDyads = new Integer(stats.dyads);
-
- egoAnswers = Arrays.asList(stats.getInterview().getEgoAnswerArray(this));
-
- for (int i = 0; i < stats.alterStatArray.length; ++i)
- {
- alterAnswers.add(new AlterAnswer(stats.alterStatArray[i]));
- }
- }
-
- public void setName(String name) {
- this.name = name;
-}
-
-public String getName() {
- return name;
-}
-
-public static class EgoAnswer
- {
- public final String title;
- public final String answer;
- public final int index;
-
- public EgoAnswer(String title, String answer, int index)
- {
- this.title = title;
- this.answer = answer;
- this.index = index;
- }
- }
-
- public static class AlterAnswer
- {
- public String title;
- public int count;
- public String[] selections;
- public int[] totals;
- //code added
- public int[] AnswerIndex;
- //end of add
-
- public AlterAnswer(String title, int count, String[] selections,
- int[] totals, int[] answerIndex) {
- super();
- this.title = title;
- this.count = count;
- this.selections = selections;
- this.totals = totals;
- AnswerIndex = answerIndex;
- }
-
- public AlterAnswer(AlterStats alterStats)
- {
- title = alterStats.qTitle;
- count = alterStats.answerCount;
- selections = (String[]) alterStats.answerText.clone();
- totals = (int[]) alterStats.answerTotals.clone();
- }
-
- public String[] getSelections() {
- return selections;
- }
-
- public String getTitle() {
- return title;
- }
-
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.egonet.util.Name;
+
+
+public class StatRecord
+{
+ private String name = "";
+ public String degreeName = "";
+ public Integer degreeValue = new Integer(0);
+ public Float degreeMean = new Float(0);
+ public Float degreeNC = new Float(0);
+
+ public String betweenName = "";
+ public Float betweenValue = new Float(0);
+ public Float betweenMean = new Float(0);
+ public Float betweenNC = new Float(0);
+
+ public String closenessName = "";
+ public Float closenessValue = new Float(0);
+ public Float closenessMean = new Float(0);
+ public Float closenessNC = new Float(0);
+
+ public Integer numCliques = new Integer(0);
+ public Integer numComponents = new Integer(0);
+ public Integer numIsolates = new Integer(0);
+ public Integer numDyads = new Integer(0);
+
+ public List egoAnswers = new ArrayList();
+ public List alterAnswers = new ArrayList();
+
+ public StatRecord()
+ {
+
+ }
+
+ public List getEgoAnswers()
+ {
+ return egoAnswers;
+ }
+ public List getAlterAnswers()
+ {
+ return alterAnswers;
+ }
+
+ public StatRecord(Statistics stats)
+ {
+ setName(new Name(stats.getInterview().getIntName()).toString());
+
+ degreeName = stats.mostCentralDegreeAlterName;
+ degreeValue = new Integer(stats.mostCentralDegreeAlterValue);
+ degreeMean = new Float(stats.meanCentralDegreeValue);
+ degreeNC = new Float(stats.degreeNC);
+
+ closenessName = stats.mostCentralClosenessAlterName;
+ closenessValue = new Float(stats.mostCentralClosenessAlterValue);
+ closenessMean = new Float(stats.meanCentralClosenessValue);
+ closenessNC = new Float(stats.closenessNC);
+
+ betweenName = stats.mostCentralBetweenAlterName;
+ betweenValue = new Float(stats.mostCentralBetweenAlterValue);
+ betweenMean = new Float(stats.meanCentralBetweenAlterValue);
+ betweenNC = new Float(stats.betweenNC);
+
+ numCliques = new Integer(stats.cliqueSet.size());
+ numComponents = new Integer(stats.componentSet.size() - stats.isolates - stats.dyads);
+ numIsolates = new Integer(stats.isolates);
+ numDyads = new Integer(stats.dyads);
+
+ egoAnswers = Arrays.asList(stats.getInterview().getEgoAnswerArray(this));
+
+ for (int i = 0; i < stats.alterStatArray.length; ++i)
+ {
+ alterAnswers.add(new AlterAnswer(stats.alterStatArray[i]));
+ }
+ }
+
+ public void setName(String name) {
+ this.name = name;
+}
+
+public String getName() {
+ return name;
+}
+
+public static class EgoAnswer
+ {
+ public final String title;
+ public final String answer;
+ public final int index;
+
+ public EgoAnswer(String title, String answer, int index)
+ {
+ this.title = title;
+ this.answer = answer;
+ this.index = index;
+ }
+ }
+
+ public static class AlterAnswer
+ {
+ public String title;
+ public int count;
+ public String[] selections;
+ public int[] totals;
+ //code added
+ public int[] AnswerIndex;
+ //end of add
+
+ public AlterAnswer(String title, int count, String[] selections,
+ int[] totals, int[] answerIndex) {
+ super();
+ this.title = title;
+ this.count = count;
+ this.selections = selections;
+ this.totals = totals;
+ AnswerIndex = answerIndex;
+ }
+
+ public AlterAnswer(AlterStats alterStats)
+ {
+ title = alterStats.qTitle;
+ count = alterStats.answerCount;
+ selections = (String[]) alterStats.answerText.clone();
+ totals = (int[]) alterStats.answerTotals.clone();
+ }
+
+ public String[] getSelections() {
+ return selections;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/Statistics.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/Statistics.java
similarity index 100%
rename from src/com/endlessloopsoftware/ego/client/statistics/Statistics.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/Statistics.java
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java
index 5f14e05..449135e 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsArrayPanel.java
@@ -1,86 +1,86 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.endlessloopsoftware.ego.client.statistics.models.StatTableModel;
-
-public class StatisticsArrayPanel extends JPanel
-{
- final private static Logger logger = LoggerFactory.getLogger(StatisticsArrayPanel.class);
-
- StatTableModel data;
- private JTable dataTable;
- private JScrollPane dataScroll = new JScrollPane();
- private GridBagLayout gridBagLayout1 = new GridBagLayout();
-
- public StatisticsArrayPanel(StatTableModel data)
- {
- this.data = data;
-
- try
- {
- jbInit();
- }
- catch (Exception ex)
- {
- logger.error(ex.toString());
- }
- }
-
- private void jbInit() throws Exception
- {
- dataTable = new JTable(data);
-
- this.setLayout(gridBagLayout1);
-
- dataTable.setAutoResizeMode(data.getResizeMode());
- dataTable.setRowHeight(16);
- this.add(
- dataScroll,
- new GridBagConstraints(
- 0,
- 0,
- 1,
- 1,
- 1.0,
- 1.0,
- GridBagConstraints.CENTER,
- GridBagConstraints.BOTH,
- new Insets(5, 5, 5, 5),
- 0,
- 0));
- dataScroll.getViewport().add(dataTable, null);
- }
-
- public StatTableModel getTableModel()
- {
- return data;
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.endlessloopsoftware.ego.client.statistics.models.StatTableModel;
+
+public class StatisticsArrayPanel extends JPanel
+{
+ final private static Logger logger = LoggerFactory.getLogger(StatisticsArrayPanel.class);
+
+ StatTableModel data;
+ private JTable dataTable;
+ private JScrollPane dataScroll = new JScrollPane();
+ private GridBagLayout gridBagLayout1 = new GridBagLayout();
+
+ public StatisticsArrayPanel(StatTableModel data)
+ {
+ this.data = data;
+
+ try
+ {
+ jbInit();
+ }
+ catch (Exception ex)
+ {
+ logger.error(ex.toString());
+ }
+ }
+
+ private void jbInit() throws Exception
+ {
+ dataTable = new JTable(data);
+
+ this.setLayout(gridBagLayout1);
+
+ dataTable.setAutoResizeMode(data.getResizeMode());
+ dataTable.setRowHeight(16);
+ this.add(
+ dataScroll,
+ new GridBagConstraints(
+ 0,
+ 0,
+ 1,
+ 1,
+ 1.0,
+ 1.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH,
+ new Insets(5, 5, 5, 5),
+ 0,
+ 0));
+ dataScroll.getViewport().add(dataTable, null);
+ }
+
+ public StatTableModel getTableModel()
+ {
+ return data;
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java
similarity index 97%
rename from src/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java
index 1152cb7..02da62f 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/StatisticsFrame.java
@@ -1,313 +1,313 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics;
-import java.awt.Container;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.PrintWriter;
-import java.util.Iterator;
-
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-
-import org.egonet.model.question.AlterPairQuestion;
-import org.egonet.model.question.Question;
-import org.egonet.util.CatchingAction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-import com.endlessloopsoftware.ego.client.EgoClient;
-import com.endlessloopsoftware.ego.client.statistics.models.BetweennessModel;
-import com.endlessloopsoftware.ego.client.statistics.models.CliqueModel;
-import com.endlessloopsoftware.ego.client.statistics.models.ClosenessModel;
-import com.endlessloopsoftware.ego.client.statistics.models.CompositionalStatsModel;
-import com.endlessloopsoftware.ego.client.statistics.models.DegreeModel;
-import com.endlessloopsoftware.ego.client.statistics.models.InterviewSummaryModel;
-import com.endlessloopsoftware.ego.client.statistics.models.QSummaryModel;
-
-
-
-public class StatisticsFrame extends JPanel {
- private Statistics stats = null;
-
- private JTabbedPane tabs = new JTabbedPane();
-
- private JPanel summaryPanel = null;
-
- private JPanel dcPanel = null;
-
- private JPanel ccPanel = null;
-
- private JPanel bcPanel = null;
-
- private JPanel cliquePanel = null;
-
- private JPanel componentPanel = null;
-
- private JPanel qSummaryPanel = null;
-
- private EgoClient egoClient;
-
- final private static Logger logger = LoggerFactory.getLogger(StatisticsFrame.class);
-
- public StatisticsFrame(EgoClient egoClient) {
- this.egoClient = egoClient;
- jbInit();
- }
-
- private void jbInit() {
- boolean studyStatable = false;
-
- /***********************************************************************
- * Fill in alter pair question selection menu
- **********************************************************************/
- Iterator questions = egoClient.getStudy().getQuestionOrder(AlterPairQuestion.class).iterator();
- while (questions.hasNext()) {
- Question q = egoClient.getStudy().getQuestion((Long) questions.next());
-
- if (q.isStatable()) {
- //alterQuestionMenu.addItem(q);
- studyStatable = true;
- stats = egoClient.getInterview().generateStatistics(q);
-
- // Use stats to initialize panels
- summaryPanel = new StatisticsArrayPanel(new InterviewSummaryModel(
- stats));
- dcPanel = new StatisticsArrayPanel(new DegreeModel(stats));
- ccPanel = new StatisticsArrayPanel(new ClosenessModel(stats));
- bcPanel = new StatisticsArrayPanel(new BetweennessModel(stats));
- cliquePanel = new StatisticsArrayPanel(new CliqueModel(stats));
- componentPanel = new StatisticsArrayPanel(
- new CompositionalStatsModel(stats));
- qSummaryPanel = new StatisticsArrayPanel(new QSummaryModel(stats));
-
- /*******************************************************************
- * Create UI
- ******************************************************************/
- // setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- // Container panel = this.getContentPane();
- Container panel = this;
-
- panel.setLayout(new GridBagLayout());
- tabs.addTab("Structural Measures", summaryPanel);
- tabs.addTab("Compositional Summary", qSummaryPanel);
- tabs.addTab("Degree Centrality", dcPanel);
- tabs.addTab("Closeness Centrality", ccPanel);
- tabs.addTab("Betweenness Centrality", bcPanel);
- tabs.addTab("Cliques", cliquePanel);
- tabs.addTab("Components", componentPanel);
- // tabs.addTab("Graph", graphPanel);
-
- /*******************************************************************
- * Layout
- ******************************************************************/
- this.add(tabs);
- panel.add(tabs, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.9,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
-
- /*******************************************************************
- * Event Handlers
- ******************************************************************/
- /*alterQuestionMenu
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- alterQuestionMenu_actionPerformed(e);
- }
- });*/
-
- removeAllActionListeners(egoClient.getFrame().saveAlterSummary);
- egoClient.getFrame().saveAlterSummary
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- saveAlterSummary_actionPerformed(e);
- }
- });
-
- removeAllActionListeners(egoClient.getFrame().saveTextSummary);
- egoClient.getFrame().saveTextSummary
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- saveTextSummary_actionPerformed(e);
- }
- });
-
- removeAllActionListeners(egoClient.getFrame().saveWeightedAdjacencyMatrix);
- egoClient.getFrame().saveWeightedAdjacencyMatrix
- .addActionListener(new CatchingAction("saveWeightedAdjacencyMatrix") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- saveAdjacencyMatrix_actionPerformed(e, true);
- }
- });
-
-
- removeAllActionListeners(egoClient.getFrame().saveAlterByAlterPromptMatrix);
- egoClient.getFrame().saveAlterByAlterPromptMatrix
- .addActionListener(new CatchingAction("saveAlterByAlterPromptMatrix") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- saveAlterByAlterPromptMatrix_actionPerformed(e);
- }
- });
-
- removeAllActionListeners(egoClient.getFrame().saveAdjacencyMatrix);
- egoClient.getFrame().saveAdjacencyMatrix
- .addActionListener(new CatchingAction("saveAdjacencyMatrix") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- saveAdjacencyMatrix_actionPerformed(e, false);
- }
- });
-
- removeAllActionListeners(egoClient.getFrame().saveInterviewStatistics);
- egoClient.getFrame().saveInterviewStatistics
- .addActionListener(new CatchingAction("saveInterviewStatistics") {
- public void safeActionPerformed(ActionEvent e) throws Exception {
- saveInterviewStatistics_actionPerformed(e);
- }
- });
-
-
- updateAll();
- }
- else {
- logger.error("No stateable ALTER_PAIR question, bailing on lots of stuff");
- }
- }
-
- /***********************************************************************
- * Check that there is at least one statable question, if not abort this
- */
- if (!studyStatable) {
- /*******************************************************************
- * No Statable Questions
- */
- this.setLayout(new GridLayout());
- this
- .add(new JLabel(
- "No questions with adjacent and non-adjacent selections found."));
- }
-
- egoClient.getFrame().close
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- close_actionPerformed(e);
- }
- });
- }
-
- private static void removeAllActionListeners(JMenuItem saveAlterSummary) {
- ActionListener[] listeners = saveAlterSummary.getActionListeners();
- for(ActionListener l : listeners)
- saveAlterSummary.removeActionListener(l);
- }
-
- void updateAll() {
- for (int i = 0; i < tabs.getTabCount(); i++) {
- JComponent component = (JComponent) tabs.getComponentAt(i);
-
- if (component instanceof StatisticsArrayPanel) {
- ((StatisticsArrayPanel) component).getTableModel().setStats(
- stats);
- ((StatisticsArrayPanel) component).getTableModel().update();
- }
- }
- }
-
- //TODO: We need to do alter pair stats when a question is selected, since we got rid of the drop down list.
- /*void alterQuestionMenu_actionPerformed(ActionEvent e) {
- if (!e.getActionCommand().equals("Initialization")) {
- stats = egoClient.getInterview()
- .generateStatistics((Question) alterQuestionMenu
- .getSelectedItem());
-
- updateAll();
- }
- }*/
-
- void saveAlterSummary_actionPerformed(ActionEvent e) {
- String name = egoClient.getInterview().getIntName();
- String filename = name + "_alter_summary";
- PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter("Alter Summary", "csv", filename);
-
- try {
- stats.writeAlterArray(w);
- } finally {
- w.close();
- }
- }
-
- void saveTextSummary_actionPerformed(ActionEvent e) {
- String name = egoClient.getInterview().getIntName();
- String filename = name + "_Text_Summary";
- PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(
- "Text Summary", "txt", filename);
-
- if (w != null) {
- try {
- stats.writeTextAnswers(w);
- } finally {
- w.close();
- }
- }
- }
-
- void saveAdjacencyMatrix_actionPerformed(ActionEvent e, boolean weighted) throws IOException {
- String filename = egoClient.getStorage().getInterviewFile().getName() + (weighted ? "_Weighted" : "") + "_Adjacency_Matrix";
-
- PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(filename, "csv", filename);
-
- stats.writeAdjacencyFile(w, egoClient.getStorage().getInterviewFile().getName().replace(".int", ""), weighted);
- }
-
- void saveAlterByAlterPromptMatrix_actionPerformed(ActionEvent e) throws IOException
- {
- String filename = egoClient.getStorage().getInterviewFile().getName() + ("_alter_by_alter_prompt");
-
- PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(filename, "csv", filename);
-
- stats.writeAlterByPromptFile(w, filename);
- }
-
- void close_actionPerformed(ActionEvent e) {
- //logger.info("Return");
- egoClient.getFrame().gotoSourceSelectPanel();
- }
-
- void saveInterviewStatistics_actionPerformed(ActionEvent e) throws IOException {
- /***********************************************************************
- * Generate statistics for the first statable question
- */
- Question q = egoClient.getStudy().getFirstStatableQuestion();
-
- if (q != null) {
- egoClient.getStorage().writeStatisticsFiles(stats);
- } else {
- throw new IOException("No statable questions");
- }
-
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics;
+import java.awt.Container;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+import org.egonet.model.question.AlterPairQuestion;
+import org.egonet.model.question.Question;
+import org.egonet.util.CatchingAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+import com.endlessloopsoftware.ego.client.EgoClient;
+import com.endlessloopsoftware.ego.client.statistics.models.BetweennessModel;
+import com.endlessloopsoftware.ego.client.statistics.models.CliqueModel;
+import com.endlessloopsoftware.ego.client.statistics.models.ClosenessModel;
+import com.endlessloopsoftware.ego.client.statistics.models.CompositionalStatsModel;
+import com.endlessloopsoftware.ego.client.statistics.models.DegreeModel;
+import com.endlessloopsoftware.ego.client.statistics.models.InterviewSummaryModel;
+import com.endlessloopsoftware.ego.client.statistics.models.QSummaryModel;
+
+
+
+public class StatisticsFrame extends JPanel {
+ private Statistics stats = null;
+
+ private JTabbedPane tabs = new JTabbedPane();
+
+ private JPanel summaryPanel = null;
+
+ private JPanel dcPanel = null;
+
+ private JPanel ccPanel = null;
+
+ private JPanel bcPanel = null;
+
+ private JPanel cliquePanel = null;
+
+ private JPanel componentPanel = null;
+
+ private JPanel qSummaryPanel = null;
+
+ private EgoClient egoClient;
+
+ final private static Logger logger = LoggerFactory.getLogger(StatisticsFrame.class);
+
+ public StatisticsFrame(EgoClient egoClient) {
+ this.egoClient = egoClient;
+ jbInit();
+ }
+
+ private void jbInit() {
+ boolean studyStatable = false;
+
+ /***********************************************************************
+ * Fill in alter pair question selection menu
+ **********************************************************************/
+ Iterator questions = egoClient.getStudy().getQuestionOrder(AlterPairQuestion.class).iterator();
+ while (questions.hasNext()) {
+ Question q = egoClient.getStudy().getQuestion((Long) questions.next());
+
+ if (q.isStatable()) {
+ //alterQuestionMenu.addItem(q);
+ studyStatable = true;
+ stats = egoClient.getInterview().generateStatistics(q);
+
+ // Use stats to initialize panels
+ summaryPanel = new StatisticsArrayPanel(new InterviewSummaryModel(
+ stats));
+ dcPanel = new StatisticsArrayPanel(new DegreeModel(stats));
+ ccPanel = new StatisticsArrayPanel(new ClosenessModel(stats));
+ bcPanel = new StatisticsArrayPanel(new BetweennessModel(stats));
+ cliquePanel = new StatisticsArrayPanel(new CliqueModel(stats));
+ componentPanel = new StatisticsArrayPanel(
+ new CompositionalStatsModel(stats));
+ qSummaryPanel = new StatisticsArrayPanel(new QSummaryModel(stats));
+
+ /*******************************************************************
+ * Create UI
+ ******************************************************************/
+ // setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // Container panel = this.getContentPane();
+ Container panel = this;
+
+ panel.setLayout(new GridBagLayout());
+ tabs.addTab("Structural Measures", summaryPanel);
+ tabs.addTab("Compositional Summary", qSummaryPanel);
+ tabs.addTab("Degree Centrality", dcPanel);
+ tabs.addTab("Closeness Centrality", ccPanel);
+ tabs.addTab("Betweenness Centrality", bcPanel);
+ tabs.addTab("Cliques", cliquePanel);
+ tabs.addTab("Components", componentPanel);
+ // tabs.addTab("Graph", graphPanel);
+
+ /*******************************************************************
+ * Layout
+ ******************************************************************/
+ this.add(tabs);
+ panel.add(tabs, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.9,
+ GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 0), 0, 0));
+
+ /*******************************************************************
+ * Event Handlers
+ ******************************************************************/
+ /*alterQuestionMenu
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ alterQuestionMenu_actionPerformed(e);
+ }
+ });*/
+
+ removeAllActionListeners(egoClient.getFrame().saveAlterSummary);
+ egoClient.getFrame().saveAlterSummary
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ saveAlterSummary_actionPerformed(e);
+ }
+ });
+
+ removeAllActionListeners(egoClient.getFrame().saveTextSummary);
+ egoClient.getFrame().saveTextSummary
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ saveTextSummary_actionPerformed(e);
+ }
+ });
+
+ removeAllActionListeners(egoClient.getFrame().saveWeightedAdjacencyMatrix);
+ egoClient.getFrame().saveWeightedAdjacencyMatrix
+ .addActionListener(new CatchingAction("saveWeightedAdjacencyMatrix") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ saveAdjacencyMatrix_actionPerformed(e, true);
+ }
+ });
+
+
+ removeAllActionListeners(egoClient.getFrame().saveAlterByAlterPromptMatrix);
+ egoClient.getFrame().saveAlterByAlterPromptMatrix
+ .addActionListener(new CatchingAction("saveAlterByAlterPromptMatrix") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ saveAlterByAlterPromptMatrix_actionPerformed(e);
+ }
+ });
+
+ removeAllActionListeners(egoClient.getFrame().saveAdjacencyMatrix);
+ egoClient.getFrame().saveAdjacencyMatrix
+ .addActionListener(new CatchingAction("saveAdjacencyMatrix") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ saveAdjacencyMatrix_actionPerformed(e, false);
+ }
+ });
+
+ removeAllActionListeners(egoClient.getFrame().saveInterviewStatistics);
+ egoClient.getFrame().saveInterviewStatistics
+ .addActionListener(new CatchingAction("saveInterviewStatistics") {
+ public void safeActionPerformed(ActionEvent e) throws Exception {
+ saveInterviewStatistics_actionPerformed(e);
+ }
+ });
+
+
+ updateAll();
+ }
+ else {
+ logger.error("No stateable ALTER_PAIR question, bailing on lots of stuff");
+ }
+ }
+
+ /***********************************************************************
+ * Check that there is at least one statable question, if not abort this
+ */
+ if (!studyStatable) {
+ /*******************************************************************
+ * No Statable Questions
+ */
+ this.setLayout(new GridLayout());
+ this
+ .add(new JLabel(
+ "No questions with adjacent and non-adjacent selections found."));
+ }
+
+ egoClient.getFrame().close
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ close_actionPerformed(e);
+ }
+ });
+ }
+
+ private static void removeAllActionListeners(JMenuItem saveAlterSummary) {
+ ActionListener[] listeners = saveAlterSummary.getActionListeners();
+ for(ActionListener l : listeners)
+ saveAlterSummary.removeActionListener(l);
+ }
+
+ void updateAll() {
+ for (int i = 0; i < tabs.getTabCount(); i++) {
+ JComponent component = (JComponent) tabs.getComponentAt(i);
+
+ if (component instanceof StatisticsArrayPanel) {
+ ((StatisticsArrayPanel) component).getTableModel().setStats(
+ stats);
+ ((StatisticsArrayPanel) component).getTableModel().update();
+ }
+ }
+ }
+
+ //TODO: We need to do alter pair stats when a question is selected, since we got rid of the drop down list.
+ /*void alterQuestionMenu_actionPerformed(ActionEvent e) {
+ if (!e.getActionCommand().equals("Initialization")) {
+ stats = egoClient.getInterview()
+ .generateStatistics((Question) alterQuestionMenu
+ .getSelectedItem());
+
+ updateAll();
+ }
+ }*/
+
+ void saveAlterSummary_actionPerformed(ActionEvent e) {
+ String name = egoClient.getInterview().getIntName();
+ String filename = name + "_alter_summary";
+ PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter("Alter Summary", "csv", filename);
+
+ try {
+ stats.writeAlterArray(w);
+ } finally {
+ w.close();
+ }
+ }
+
+ void saveTextSummary_actionPerformed(ActionEvent e) {
+ String name = egoClient.getInterview().getIntName();
+ String filename = name + "_Text_Summary";
+ PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(
+ "Text Summary", "txt", filename);
+
+ if (w != null) {
+ try {
+ stats.writeTextAnswers(w);
+ } finally {
+ w.close();
+ }
+ }
+ }
+
+ void saveAdjacencyMatrix_actionPerformed(ActionEvent e, boolean weighted) throws IOException {
+ String filename = egoClient.getStorage().getInterviewFile().getName() + (weighted ? "_Weighted" : "") + "_Adjacency_Matrix";
+
+ PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(filename, "csv", filename);
+
+ stats.writeAdjacencyFile(w, egoClient.getStorage().getInterviewFile().getName().replace(".int", ""), weighted);
+ }
+
+ void saveAlterByAlterPromptMatrix_actionPerformed(ActionEvent e) throws IOException
+ {
+ String filename = egoClient.getStorage().getInterviewFile().getName() + ("_alter_by_alter_prompt");
+
+ PrintWriter w = egoClient.getStorage().newStatisticsPrintWriter(filename, "csv", filename);
+
+ stats.writeAlterByPromptFile(w, filename);
+ }
+
+ void close_actionPerformed(ActionEvent e) {
+ //logger.info("Return");
+ egoClient.getFrame().gotoSourceSelectPanel();
+ }
+
+ void saveInterviewStatistics_actionPerformed(ActionEvent e) throws IOException {
+ /***********************************************************************
+ * Generate statistics for the first statable question
+ */
+ Question q = egoClient.getStudy().getFirstStatableQuestion();
+
+ if (q != null) {
+ egoClient.getStorage().writeStatisticsFiles(stats);
+ } else {
+ throw new IOException("No statable questions");
+ }
+
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java
index d66af73..89aee08 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/BetweennessModel.java
@@ -1,87 +1,87 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class BetweennessModel extends StatTableModel
-{
- public BetweennessModel(Statistics stats)
- {
- super(stats);
- }
-
- public int getColumnCount()
- {
- return (3);
- }
-
- public int getRowCount()
- {
- return (stats.degreeArray.length);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- try
- {
- if (columnIndex == 0)
- {
- return (stats.alterList[rowIndex]);
- }
- else if (columnIndex == 1)
- {
- return (new Float(stats.betweennessArray[rowIndex]));
- }
- else
- {
- double big = stats.proximityMatrix.length - 1;
- big *= big;
- return (new Float(stats.betweennessArray[rowIndex] / big));
- }
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- public String getColumnName(int column)
- {
- if (column == 0)
- {
- return ("Alters");
- }
- else if (column == 1)
- {
- return ("Raw");
- }
- else
- {
- return ("Normalized");
- }
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_ALL_COLUMNS;
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class BetweennessModel extends StatTableModel
+{
+ public BetweennessModel(Statistics stats)
+ {
+ super(stats);
+ }
+
+ public int getColumnCount()
+ {
+ return (3);
+ }
+
+ public int getRowCount()
+ {
+ return (stats.degreeArray.length);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ try
+ {
+ if (columnIndex == 0)
+ {
+ return (stats.alterList[rowIndex]);
+ }
+ else if (columnIndex == 1)
+ {
+ return (new Float(stats.betweennessArray[rowIndex]));
+ }
+ else
+ {
+ double big = stats.proximityMatrix.length - 1;
+ big *= big;
+ return (new Float(stats.betweennessArray[rowIndex] / big));
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ if (column == 0)
+ {
+ return ("Alters");
+ }
+ else if (column == 1)
+ {
+ return ("Raw");
+ }
+ else
+ {
+ return ("Normalized");
+ }
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_ALL_COLUMNS;
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java
index 0b82d1c..adbe1e1 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CliqueModel.java
@@ -1,106 +1,106 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import java.util.Iterator;
-import java.util.Stack;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class CliqueModel extends StatTableModel
-{
- private Stack[] cliqueArray;
- private int cliqueDepth;
-
- public CliqueModel(Statistics stats)
- {
- super(stats);
- initModel();
- }
-
- private void initModel()
- {
- cliqueArray = new Stack[stats.cliqueSet.size()];
- stats.cliqueSet.toArray(cliqueArray);
-
- /* Determine deepest clique */
- Iterator it = stats.cliqueSet.iterator();
- int maxCount = 0;
-
- while (it.hasNext())
- {
- Stack s = (Stack) it.next();
-
- if (s.size() > maxCount)
- {
- maxCount = s.size();
- }
- }
-
- cliqueDepth = maxCount;
- }
-
- public void update()
- {
- initModel();
- this.fireTableStructureChanged();
- fireTableDataChanged();
- }
-
- public int getColumnCount()
- {
- return (cliqueArray.length);
- }
-
- public int getRowCount()
- {
- return (cliqueDepth);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- if (rowIndex < cliqueArray[columnIndex].size())
- {
- try
- {
- return (stats.alterList[((Integer) cliqueArray[columnIndex].get(rowIndex)).intValue()]);
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
- }
- else
- {
- return null;
- }
- }
-
- public String getColumnName(int column)
- {
- return ("Clique " + (column + 1));
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_OFF;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class CliqueModel extends StatTableModel
+{
+ private Stack[] cliqueArray;
+ private int cliqueDepth;
+
+ public CliqueModel(Statistics stats)
+ {
+ super(stats);
+ initModel();
+ }
+
+ private void initModel()
+ {
+ cliqueArray = new Stack[stats.cliqueSet.size()];
+ stats.cliqueSet.toArray(cliqueArray);
+
+ /* Determine deepest clique */
+ Iterator it = stats.cliqueSet.iterator();
+ int maxCount = 0;
+
+ while (it.hasNext())
+ {
+ Stack s = (Stack) it.next();
+
+ if (s.size() > maxCount)
+ {
+ maxCount = s.size();
+ }
+ }
+
+ cliqueDepth = maxCount;
+ }
+
+ public void update()
+ {
+ initModel();
+ this.fireTableStructureChanged();
+ fireTableDataChanged();
+ }
+
+ public int getColumnCount()
+ {
+ return (cliqueArray.length);
+ }
+
+ public int getRowCount()
+ {
+ return (cliqueDepth);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ if (rowIndex < cliqueArray[columnIndex].size())
+ {
+ try
+ {
+ return (stats.alterList[((Integer) cliqueArray[columnIndex].get(rowIndex)).intValue()]);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ return ("Clique " + (column + 1));
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_OFF;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java
index adf06e8..ca43118 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/ClosenessModel.java
@@ -1,93 +1,93 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class ClosenessModel extends StatTableModel
-{
- public ClosenessModel(Statistics stats)
- {
- super(stats);
- }
-
- public int getColumnCount()
- {
- return (stats.proximityMatrix.length + 3);
- }
-
- public int getRowCount()
- {
- return (stats.proximityMatrix.length);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- try
- {
- if (columnIndex == 0)
- {
- return (stats.alterList[rowIndex]);
- }
- else if (columnIndex == (getColumnCount() - 2))
- {
- return (new Integer(stats.farnessArray[rowIndex]));
- }
- else if (columnIndex == (getColumnCount() - 1))
- {
- return (new Float(stats.closenessArray[rowIndex]));
- }
- else
- {
- return (new Integer(stats.proximityMatrix[rowIndex][columnIndex - 1]));
- }
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- public String getColumnName(int column)
- {
- if (column == 0)
- {
- return (" ");
- }
- else if (column == (getColumnCount() - 2))
- {
- return ("Farness");
- }
- else if (column == (getColumnCount() - 1))
- {
- return ("nCloseness");
- }
- else
- {
- return stats.alterList[column - 1];
- }
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_OFF;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class ClosenessModel extends StatTableModel
+{
+ public ClosenessModel(Statistics stats)
+ {
+ super(stats);
+ }
+
+ public int getColumnCount()
+ {
+ return (stats.proximityMatrix.length + 3);
+ }
+
+ public int getRowCount()
+ {
+ return (stats.proximityMatrix.length);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ try
+ {
+ if (columnIndex == 0)
+ {
+ return (stats.alterList[rowIndex]);
+ }
+ else if (columnIndex == (getColumnCount() - 2))
+ {
+ return (new Integer(stats.farnessArray[rowIndex]));
+ }
+ else if (columnIndex == (getColumnCount() - 1))
+ {
+ return (new Float(stats.closenessArray[rowIndex]));
+ }
+ else
+ {
+ return (new Integer(stats.proximityMatrix[rowIndex][columnIndex - 1]));
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ if (column == 0)
+ {
+ return (" ");
+ }
+ else if (column == (getColumnCount() - 2))
+ {
+ return ("Farness");
+ }
+ else if (column == (getColumnCount() - 1))
+ {
+ return ("nCloseness");
+ }
+ else
+ {
+ return stats.alterList[column - 1];
+ }
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_OFF;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java
index 07065cf..e7274eb 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/CompositionalStatsModel.java
@@ -1,103 +1,103 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class CompositionalStatsModel extends StatTableModel
-{
- private Integer[][] componentArray;
- private int componentDepth;
-
- public CompositionalStatsModel(Statistics stats)
- {
- super(stats);
- initModel();
- }
-
- private void initModel()
- {
- Iterator> it = stats.componentSet.iterator();
- int index = 0;
- int maxCount = 0;
-
- componentArray = new Integer[stats.componentSet.size()][];
-
- while (it.hasNext())
- {
- Set s = it.next();
-
- componentArray[index] = new Integer[s.size()];
- s.toArray(componentArray[index]);
-
- if (s.size() > maxCount)
- {
- maxCount = s.size();
- }
-
- index++;
- }
-
- componentDepth = maxCount;
- }
-
- public void update()
- {
- initModel();
- this.fireTableStructureChanged();
- fireTableDataChanged();
- }
-
- public int getColumnCount()
- {
- return (componentArray.length);
- }
-
- public int getRowCount()
- {
- return (componentDepth);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- if (rowIndex < componentArray[columnIndex].length)
- {
- return (stats.alterList[componentArray[columnIndex][rowIndex].intValue()]);
- }
- else
- {
- return null;
- }
- }
-
- public String getColumnName(int column)
- {
- return ("Component " + (column + 1));
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_OFF;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class CompositionalStatsModel extends StatTableModel
+{
+ private Integer[][] componentArray;
+ private int componentDepth;
+
+ public CompositionalStatsModel(Statistics stats)
+ {
+ super(stats);
+ initModel();
+ }
+
+ private void initModel()
+ {
+ Iterator> it = stats.componentSet.iterator();
+ int index = 0;
+ int maxCount = 0;
+
+ componentArray = new Integer[stats.componentSet.size()][];
+
+ while (it.hasNext())
+ {
+ Set s = it.next();
+
+ componentArray[index] = new Integer[s.size()];
+ s.toArray(componentArray[index]);
+
+ if (s.size() > maxCount)
+ {
+ maxCount = s.size();
+ }
+
+ index++;
+ }
+
+ componentDepth = maxCount;
+ }
+
+ public void update()
+ {
+ initModel();
+ this.fireTableStructureChanged();
+ fireTableDataChanged();
+ }
+
+ public int getColumnCount()
+ {
+ return (componentArray.length);
+ }
+
+ public int getRowCount()
+ {
+ return (componentDepth);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ if (rowIndex < componentArray[columnIndex].length)
+ {
+ return (stats.alterList[componentArray[columnIndex][rowIndex].intValue()]);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ return ("Component " + (column + 1));
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_OFF;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java
index ae6642c..3d2200e 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/DegreeModel.java
@@ -1,85 +1,85 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class DegreeModel extends StatTableModel
-{
- public DegreeModel(Statistics stats)
- {
- super(stats);
- }
-
- public int getColumnCount()
- {
- return (3);
- }
-
- public int getRowCount()
- {
- return (stats.degreeArray.length);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- try
- {
- if (columnIndex == 0)
- {
- return (stats.alterList[rowIndex]);
- }
- else if (columnIndex == 1)
- {
- return (new Integer(stats.degreeArray[rowIndex]));
- }
- else
- {
- return (new Float(stats.degreeArray[rowIndex] / ((float) (stats.proximityMatrix.length - 1))));
- }
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- public String getColumnName(int column)
- {
- if (column == 0)
- {
- return ("Alter");
- }
- else if (column == 1)
- {
- return ("Raw");
- }
- else
- {
- return ("Normalized");
- }
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_ALL_COLUMNS;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class DegreeModel extends StatTableModel
+{
+ public DegreeModel(Statistics stats)
+ {
+ super(stats);
+ }
+
+ public int getColumnCount()
+ {
+ return (3);
+ }
+
+ public int getRowCount()
+ {
+ return (stats.degreeArray.length);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ try
+ {
+ if (columnIndex == 0)
+ {
+ return (stats.alterList[rowIndex]);
+ }
+ else if (columnIndex == 1)
+ {
+ return (new Integer(stats.degreeArray[rowIndex]));
+ }
+ else
+ {
+ return (new Float(stats.degreeArray[rowIndex] / ((float) (stats.proximityMatrix.length - 1))));
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ if (column == 0)
+ {
+ return ("Alter");
+ }
+ else if (column == 1)
+ {
+ return ("Raw");
+ }
+ else
+ {
+ return ("Normalized");
+ }
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_ALL_COLUMNS;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java
index 897c0ef..0b2633e 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/InterviewSummaryModel.java
@@ -1,128 +1,128 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public class InterviewSummaryModel extends StatTableModel
-{
- public InterviewSummaryModel(Statistics stats)
- {
- super(stats);
- }
-
- public int getColumnCount()
- {
- if (stats.adjacencyMatrix.length > 0)
- {
- return 3;
- }
- else
- {
- return 1;
- }
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- switch (columnIndex)
- {
- case 0 :
- switch (rowIndex)
- {
- case 0 :
- return ("Degree Centrality Maximum");
- case 1 :
- return ("Closeness Centrality Maximum");
- case 2 :
- return ("Betweenness Centrality Maximum");
- case 3 :
- return ("Number of Cliques");
- case 4 :
- return ("Number of Components");
- default :
- return (null);
- }
-
- case 1 :
- switch (rowIndex)
- {
- case 0 :
- return (stats.mostCentralDegreeAlterName);
- case 1 :
- return (stats.mostCentralClosenessAlterName);
- case 2 :
- return (stats.mostCentralBetweenAlterName);
- case 3 :
- return (new Integer(stats.cliqueSet.size()));
- case 4 :
- return (new Integer(stats.componentSet.size()));
- default :
- return (null);
- }
-
- case 2 :
- switch (rowIndex)
- {
- case 0 :
- return (new Integer(stats.mostCentralDegreeAlterValue));
- case 1 :
- return (new Float(stats.mostCentralClosenessAlterValue));
- case 2 :
- return (new Float(stats.mostCentralBetweenAlterValue));
- default :
- return (null);
- }
-
- default :
- return (null);
- }
- }
-
- public int getRowCount()
- {
- if (stats.adjacencyMatrix.length > 0)
- {
- return 5;
- }
- else
- {
- return 0;
- }
- }
-
- public String getColumnName(int column)
- {
- if (stats.adjacencyMatrix.length > 0)
- {
- return null;
- }
- else
- {
- return ("No Structural Measures question specified in study");
- }
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_ALL_COLUMNS;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public class InterviewSummaryModel extends StatTableModel
+{
+ public InterviewSummaryModel(Statistics stats)
+ {
+ super(stats);
+ }
+
+ public int getColumnCount()
+ {
+ if (stats.adjacencyMatrix.length > 0)
+ {
+ return 3;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ switch (columnIndex)
+ {
+ case 0 :
+ switch (rowIndex)
+ {
+ case 0 :
+ return ("Degree Centrality Maximum");
+ case 1 :
+ return ("Closeness Centrality Maximum");
+ case 2 :
+ return ("Betweenness Centrality Maximum");
+ case 3 :
+ return ("Number of Cliques");
+ case 4 :
+ return ("Number of Components");
+ default :
+ return (null);
+ }
+
+ case 1 :
+ switch (rowIndex)
+ {
+ case 0 :
+ return (stats.mostCentralDegreeAlterName);
+ case 1 :
+ return (stats.mostCentralClosenessAlterName);
+ case 2 :
+ return (stats.mostCentralBetweenAlterName);
+ case 3 :
+ return (new Integer(stats.cliqueSet.size()));
+ case 4 :
+ return (new Integer(stats.componentSet.size()));
+ default :
+ return (null);
+ }
+
+ case 2 :
+ switch (rowIndex)
+ {
+ case 0 :
+ return (new Integer(stats.mostCentralDegreeAlterValue));
+ case 1 :
+ return (new Float(stats.mostCentralClosenessAlterValue));
+ case 2 :
+ return (new Float(stats.mostCentralBetweenAlterValue));
+ default :
+ return (null);
+ }
+
+ default :
+ return (null);
+ }
+ }
+
+ public int getRowCount()
+ {
+ if (stats.adjacencyMatrix.length > 0)
+ {
+ return 5;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ if (stats.adjacencyMatrix.length > 0)
+ {
+ return null;
+ }
+ else
+ {
+ return ("No Structural Measures question specified in study");
+ }
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_ALL_COLUMNS;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java
similarity index 95%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java
index 855a43d..40cdffc 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/QSummaryModel.java
@@ -1,136 +1,136 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-
-import javax.swing.JTable;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-import com.endlessloopsoftware.egonet.Shared;
-
-public class QSummaryModel extends StatTableModel
-{
- private int answerDepth;
-
- public QSummaryModel(Statistics stats)
- {
- super(stats);
- initModel();
- }
-
- private void initModel()
- {
- int maxCount = 0;
- for (int i = 0; i < stats.alterStatArray.length; i++)
- {
- if (stats.alterStatArray[i].answerTotals.length > maxCount)
- {
- maxCount = stats.alterStatArray[i].answerTotals.length;
- }
- }
-
- answerDepth = maxCount;
- }
-
- public void update()
- {
- initModel();
- this.fireTableStructureChanged();
- fireTableDataChanged();
- }
-
- public int getColumnCount()
- {
- return (answerDepth + 1);
- }
-
- public int getRowCount()
- {
- return (stats.alterStatArray.length);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- if (columnIndex == 0)
- {
- return (stats.alterStatArray[rowIndex].qTitle);
- }
- else if (columnIndex <= stats.alterStatArray[rowIndex].answerTotals.length)
- {
- if ((stats.alterStatArray[rowIndex].answerType == Shared.AnswerType.NUMERICAL) && (columnIndex == 1))
- {
- return (
- "Average: "
- + stats.alterStatArray[rowIndex].answerTotals[0] / stats.alterStatArray[rowIndex].answerCount);
- }
- else if (stats.alterStatArray[rowIndex].answerType == Shared.AnswerType.CATEGORICAL)
- {
- String s = null;
- try
- {
- if (stats.alterStatArray[rowIndex].answerCount == 0)
- {
- s = stats.alterStatArray[rowIndex].answerText[columnIndex - 1] + ": n/a";
- }
- else
- {
- s =
- stats.alterStatArray[rowIndex].answerText[columnIndex
- - 1]
- + ": "
- + ((stats.alterStatArray[rowIndex].answerTotals[columnIndex - 1] * 100)
- / stats.alterStatArray[rowIndex].answerCount)
- + "%";
- }
- }
- catch (Exception ex)
- {
- s = "Statistics Generation Error";
- System.err.println("Error in StatTableModel::getValueAt; " + ex);
- }
-
- return s;
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- }
-
- public String getColumnName(int column)
- {
- if (column == 0)
- {
- return ("Question");
- }
- else
- {
- return ("Answer " + column);
- }
- }
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_OFF;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+
+import javax.swing.JTable;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+import com.endlessloopsoftware.egonet.Shared;
+
+public class QSummaryModel extends StatTableModel
+{
+ private int answerDepth;
+
+ public QSummaryModel(Statistics stats)
+ {
+ super(stats);
+ initModel();
+ }
+
+ private void initModel()
+ {
+ int maxCount = 0;
+ for (int i = 0; i < stats.alterStatArray.length; i++)
+ {
+ if (stats.alterStatArray[i].answerTotals.length > maxCount)
+ {
+ maxCount = stats.alterStatArray[i].answerTotals.length;
+ }
+ }
+
+ answerDepth = maxCount;
+ }
+
+ public void update()
+ {
+ initModel();
+ this.fireTableStructureChanged();
+ fireTableDataChanged();
+ }
+
+ public int getColumnCount()
+ {
+ return (answerDepth + 1);
+ }
+
+ public int getRowCount()
+ {
+ return (stats.alterStatArray.length);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ if (columnIndex == 0)
+ {
+ return (stats.alterStatArray[rowIndex].qTitle);
+ }
+ else if (columnIndex <= stats.alterStatArray[rowIndex].answerTotals.length)
+ {
+ if ((stats.alterStatArray[rowIndex].answerType == Shared.AnswerType.NUMERICAL) && (columnIndex == 1))
+ {
+ return (
+ "Average: "
+ + stats.alterStatArray[rowIndex].answerTotals[0] / stats.alterStatArray[rowIndex].answerCount);
+ }
+ else if (stats.alterStatArray[rowIndex].answerType == Shared.AnswerType.CATEGORICAL)
+ {
+ String s = null;
+ try
+ {
+ if (stats.alterStatArray[rowIndex].answerCount == 0)
+ {
+ s = stats.alterStatArray[rowIndex].answerText[columnIndex - 1] + ": n/a";
+ }
+ else
+ {
+ s =
+ stats.alterStatArray[rowIndex].answerText[columnIndex
+ - 1]
+ + ": "
+ + ((stats.alterStatArray[rowIndex].answerTotals[columnIndex - 1] * 100)
+ / stats.alterStatArray[rowIndex].answerCount)
+ + "%";
+ }
+ }
+ catch (Exception ex)
+ {
+ s = "Statistics Generation Error";
+ System.err.println("Error in StatTableModel::getValueAt; " + ex);
+ }
+
+ return s;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getColumnName(int column)
+ {
+ if (column == 0)
+ {
+ return ("Question");
+ }
+ else
+ {
+ return ("Answer " + column);
+ }
+ }
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_OFF;
+ }
+}
diff --git a/src/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java
similarity index 96%
rename from src/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java
rename to src/main/java/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java
index 4c618ad..441cb12 100644
--- a/src/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java
+++ b/src/main/java/com/endlessloopsoftware/ego/client/statistics/models/StatTableModel.java
@@ -1,54 +1,54 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.ego.client.statistics.models;
-import javax.swing.JTable;
-import javax.swing.table.AbstractTableModel;
-
-import com.endlessloopsoftware.ego.client.statistics.Statistics;
-
-public abstract class StatTableModel extends AbstractTableModel
-{
- public Statistics stats;
-
- public StatTableModel(Statistics stats)
- {
- this.stats = stats;
- }
-
- public StatTableModel() {}
-
- public int getResizeMode()
- {
- return JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS;
- }
-
- public void update()
- {
- this.fireTableStructureChanged();
- fireTableDataChanged();
- }
-
- /**
- * @param stats The stats to set.
- */
- public void setStats(Statistics stats)
- {
- this.stats = stats;
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.ego.client.statistics.models;
+import javax.swing.JTable;
+import javax.swing.table.AbstractTableModel;
+
+import com.endlessloopsoftware.ego.client.statistics.Statistics;
+
+public abstract class StatTableModel extends AbstractTableModel
+{
+ public Statistics stats;
+
+ public StatTableModel(Statistics stats)
+ {
+ this.stats = stats;
+ }
+
+ public StatTableModel() {}
+
+ public int getResizeMode()
+ {
+ return JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS;
+ }
+
+ public void update()
+ {
+ this.fireTableStructureChanged();
+ fireTableDataChanged();
+ }
+
+ /**
+ * @param stats The stats to set.
+ */
+ public void setStats(Statistics stats)
+ {
+ this.stats = stats;
+ }
+}
diff --git a/src/com/endlessloopsoftware/egonet/.cvsignore b/src/main/java/com/endlessloopsoftware/egonet/.cvsignore
similarity index 100%
rename from src/com/endlessloopsoftware/egonet/.cvsignore
rename to src/main/java/com/endlessloopsoftware/egonet/.cvsignore
diff --git a/src/com/endlessloopsoftware/egonet/Answer.java b/src/main/java/com/endlessloopsoftware/egonet/Answer.java
similarity index 96%
rename from src/com/endlessloopsoftware/egonet/Answer.java
rename to src/main/java/com/endlessloopsoftware/egonet/Answer.java
index fa13a89..3528cf8 100644
--- a/src/com/endlessloopsoftware/egonet/Answer.java
+++ b/src/main/java/com/endlessloopsoftware/egonet/Answer.java
@@ -1,139 +1,139 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.egonet;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.text.*;
-
-public class Answer implements Cloneable {
- /**
- * Unique ID for every question
- */
- public Long questionId;
-
- /**
- * Represents the alter or alter pair that this answer is about. It may be a
- * single alter for alter questions, or two alters for an alter pair
- * question.
- */
- private List alters;
-
- private boolean _answered = false;
-
- public boolean isAnswered() {
- return _answered;
- }
-
- public void setAnswered(boolean _answered) {
- this._answered = _answered;
- }
-
- public boolean adjacent;
-
- private int value;
-
- private int index;
-
- public String string;
-
- public String timestamp;
-
- public static final int NO_ANSWER = -1;
- public static final int ALL_ADJACENT = -2;
-
- public Answer(Long Id) {
- this(Id, null);
- }
-
- public Answer(Long Id, int[] alters) {
- //logger.info("New answer object created with id="+Id+" and alters: " + Arrays.asList(alters));
- questionId = Id;
- setAnswered(false);
- adjacent = false;
- setValue(-1);
- string = "";
- timestamp = DateFormat.getDateInstance().format(new Date());
-
- if (alters == null) {
- this.alters = new ArrayList();
- } else {
- this.alters = new ArrayList(alters.length);
- for(Integer a : alters)
- this.alters.add(a);
- }
- }
-
- public Integer firstAlter()
- {
- return alters.get(0);
- }
-
- public Integer secondAlter()
- {
- return alters.get(1);
- }
-
- public boolean hasTwoAlters()
- {
- return alters.size() > 1;
- }
-
- public boolean hasAtLeastOneAlter()
- {
- return alters.size() > 0;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return (super.clone());
- }
-
- public String toString() {
- return string == null ? getValue()+"" : string;
- }
-
- public String getString() {
- String str = "";
- str = "questionId=" + questionId + ", answered=" + isAnswered() + ", adjacent=" + adjacent + ", string=" + string + ", index="+getIndex()+", value=" + getValue();
- return str;
-
- }
-
- public void setValue(int value) {
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- public int getIndex() {
- return index;
- }
-
- public List getAlters()
- {
- return Collections.unmodifiableList(alters);
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.egonet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.text.*;
+
+public class Answer implements Cloneable {
+ /**
+ * Unique ID for every question
+ */
+ public Long questionId;
+
+ /**
+ * Represents the alter or alter pair that this answer is about. It may be a
+ * single alter for alter questions, or two alters for an alter pair
+ * question.
+ */
+ private List alters;
+
+ private boolean _answered = false;
+
+ public boolean isAnswered() {
+ return _answered;
+ }
+
+ public void setAnswered(boolean _answered) {
+ this._answered = _answered;
+ }
+
+ public boolean adjacent;
+
+ private int value;
+
+ private int index;
+
+ public String string;
+
+ public String timestamp;
+
+ public static final int NO_ANSWER = -1;
+ public static final int ALL_ADJACENT = -2;
+
+ public Answer(Long Id) {
+ this(Id, null);
+ }
+
+ public Answer(Long Id, int[] alters) {
+ //logger.info("New answer object created with id="+Id+" and alters: " + Arrays.asList(alters));
+ questionId = Id;
+ setAnswered(false);
+ adjacent = false;
+ setValue(-1);
+ string = "";
+ timestamp = DateFormat.getDateInstance().format(new Date());
+
+ if (alters == null) {
+ this.alters = new ArrayList();
+ } else {
+ this.alters = new ArrayList(alters.length);
+ for(Integer a : alters)
+ this.alters.add(a);
+ }
+ }
+
+ public Integer firstAlter()
+ {
+ return alters.get(0);
+ }
+
+ public Integer secondAlter()
+ {
+ return alters.get(1);
+ }
+
+ public boolean hasTwoAlters()
+ {
+ return alters.size() > 1;
+ }
+
+ public boolean hasAtLeastOneAlter()
+ {
+ return alters.size() > 0;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return (super.clone());
+ }
+
+ public String toString() {
+ return string == null ? getValue()+"" : string;
+ }
+
+ public String getString() {
+ String str = "";
+ str = "questionId=" + questionId + ", answered=" + isAnswered() + ", adjacent=" + adjacent + ", string=" + string + ", index="+getIndex()+", value=" + getValue();
+ return str;
+
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public List getAlters()
+ {
+ return Collections.unmodifiableList(alters);
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/egonet/Interview.java b/src/main/java/com/endlessloopsoftware/egonet/Interview.java
similarity index 100%
rename from src/com/endlessloopsoftware/egonet/Interview.java
rename to src/main/java/com/endlessloopsoftware/egonet/Interview.java
diff --git a/src/com/endlessloopsoftware/egonet/QuestionLink.java b/src/main/java/com/endlessloopsoftware/egonet/QuestionLink.java
similarity index 96%
rename from src/com/endlessloopsoftware/egonet/QuestionLink.java
rename to src/main/java/com/endlessloopsoftware/egonet/QuestionLink.java
index 931ba6b..40c15aa 100644
--- a/src/com/endlessloopsoftware/egonet/QuestionLink.java
+++ b/src/main/java/com/endlessloopsoftware/egonet/QuestionLink.java
@@ -1,50 +1,50 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.egonet;
-public class QuestionLink implements Cloneable
-{
- private Answer answer = null;
-
- public Object clone()
- throws CloneNotSupportedException
- {
- QuestionLink q;
-
- q = (QuestionLink) super.clone();
-
- if (isActive())
- {
- q.setAnswer((Answer) this.getAnswer().clone());
- }
-
- return(q);
- }
-
- public void setAnswer(Answer answer) {
- this.answer = answer;
- }
-
- public Answer getAnswer() {
- return answer;
- }
-
- public boolean isActive() {
- return answer != null;
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.egonet;
+public class QuestionLink implements Cloneable
+{
+ private Answer answer = null;
+
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ QuestionLink q;
+
+ q = (QuestionLink) super.clone();
+
+ if (isActive())
+ {
+ q.setAnswer((Answer) this.getAnswer().clone());
+ }
+
+ return(q);
+ }
+
+ public void setAnswer(Answer answer) {
+ this.answer = answer;
+ }
+
+ public Answer getAnswer() {
+ return answer;
+ }
+
+ public boolean isActive() {
+ return answer != null;
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/egonet/QuestionList.java b/src/main/java/com/endlessloopsoftware/egonet/QuestionList.java
similarity index 96%
rename from src/com/endlessloopsoftware/egonet/QuestionList.java
rename to src/main/java/com/endlessloopsoftware/egonet/QuestionList.java
index 641e513..f9083ac 100644
--- a/src/com/endlessloopsoftware/egonet/QuestionList.java
+++ b/src/main/java/com/endlessloopsoftware/egonet/QuestionList.java
@@ -1,77 +1,77 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package com.endlessloopsoftware.egonet;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.egonet.model.question.Question;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A map of question id (long) to question object
- * @author martins
- *
- */
-public class QuestionList extends HashMap
-{
- final private static Logger logger = LoggerFactory.getLogger(QuestionList.class);
-
- public void addQuestion(Question q)
- {
- logger.debug("Question added: " + q.getString());
- put(q.UniqueId, q);
- }
-
- /****
- * Returns question from map identified by its UniqueId
- * @param l UniqueId of question
- * @return q question in list
- */
- public Question getQuestion(Long l)
- {
- return get(l);
- }
-
- public String dump()
- {
- StringBuffer buffer = new StringBuffer();
-
- Set keys = keySet();
- for (Iterator it = keys.iterator(); it.hasNext();)
- {
- Object key = it.next();
- buffer.append("[" + key + "," + get(key) + "]\n");
- }
-
- return buffer.toString();
- }
-
- public boolean contains(long questionId)
- {
- return containsKey(questionId);
- }
-
- public boolean contains(Question question)
- {
- return containsValue(question);
- }
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package com.endlessloopsoftware.egonet;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.egonet.model.question.Question;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A map of question id (long) to question object
+ * @author martins
+ *
+ */
+public class QuestionList extends HashMap
+{
+ final private static Logger logger = LoggerFactory.getLogger(QuestionList.class);
+
+ public void addQuestion(Question q)
+ {
+ logger.debug("Question added: " + q.getString());
+ put(q.UniqueId, q);
+ }
+
+ /****
+ * Returns question from map identified by its UniqueId
+ * @param l UniqueId of question
+ * @return q question in list
+ */
+ public Question getQuestion(Long l)
+ {
+ return get(l);
+ }
+
+ public String dump()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ Set keys = keySet();
+ for (Iterator it = keys.iterator(); it.hasNext();)
+ {
+ Object key = it.next();
+ buffer.append("[" + key + "," + get(key) + "]\n");
+ }
+
+ return buffer.toString();
+ }
+
+ public boolean contains(long questionId)
+ {
+ return containsKey(questionId);
+ }
+
+ public boolean contains(Question question)
+ {
+ return containsValue(question);
+ }
}
\ No newline at end of file
diff --git a/src/com/endlessloopsoftware/egonet/Shared.java b/src/main/java/com/endlessloopsoftware/egonet/Shared.java
similarity index 100%
rename from src/com/endlessloopsoftware/egonet/Shared.java
rename to src/main/java/com/endlessloopsoftware/egonet/Shared.java
diff --git a/src/com/endlessloopsoftware/egonet/Study.java b/src/main/java/com/endlessloopsoftware/egonet/Study.java
similarity index 100%
rename from src/com/endlessloopsoftware/egonet/Study.java
rename to src/main/java/com/endlessloopsoftware/egonet/Study.java
diff --git a/src/org/egonet/exceptions/CorruptedInterviewException.java b/src/main/java/org/egonet/exceptions/CorruptedInterviewException.java
similarity index 96%
rename from src/org/egonet/exceptions/CorruptedInterviewException.java
rename to src/main/java/org/egonet/exceptions/CorruptedInterviewException.java
index eede74c..1a9794a 100644
--- a/src/org/egonet/exceptions/CorruptedInterviewException.java
+++ b/src/main/java/org/egonet/exceptions/CorruptedInterviewException.java
@@ -1,39 +1,39 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package org.egonet.exceptions;
-
-public class CorruptedInterviewException extends org.egonet.exceptions.EgonetException
-{
-
- public CorruptedInterviewException() {
- super();
- }
-
- public CorruptedInterviewException(String s, Throwable t) {
- super(s, t);
- }
-
- public CorruptedInterviewException(String s) {
- super(s);
- }
-
- public CorruptedInterviewException(Throwable t) {
- super(t);
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package org.egonet.exceptions;
+
+public class CorruptedInterviewException extends org.egonet.exceptions.EgonetException
+{
+
+ public CorruptedInterviewException() {
+ super();
+ }
+
+ public CorruptedInterviewException(String s, Throwable t) {
+ super(s, t);
+ }
+
+ public CorruptedInterviewException(String s) {
+ super(s);
+ }
+
+ public CorruptedInterviewException(Throwable t) {
+ super(t);
+ }
+}
diff --git a/src/org/egonet/exceptions/DuplicateQuestionException.java b/src/main/java/org/egonet/exceptions/DuplicateQuestionException.java
similarity index 96%
rename from src/org/egonet/exceptions/DuplicateQuestionException.java
rename to src/main/java/org/egonet/exceptions/DuplicateQuestionException.java
index f414ffd..69cae04 100644
--- a/src/org/egonet/exceptions/DuplicateQuestionException.java
+++ b/src/main/java/org/egonet/exceptions/DuplicateQuestionException.java
@@ -1,43 +1,43 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package org.egonet.exceptions;
-
-public class DuplicateQuestionException extends EgonetException
-{
-
- public DuplicateQuestionException()
- {
- super();
- }
-
- public DuplicateQuestionException(String s, Throwable t)
- {
- super(s, t);
- }
-
- public DuplicateQuestionException(String s)
- {
- super(s);
- }
-
- public DuplicateQuestionException(Throwable t)
- {
- super(t);
- }
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package org.egonet.exceptions;
+
+public class DuplicateQuestionException extends EgonetException
+{
+
+ public DuplicateQuestionException()
+ {
+ super();
+ }
+
+ public DuplicateQuestionException(String s, Throwable t)
+ {
+ super(s, t);
+ }
+
+ public DuplicateQuestionException(String s)
+ {
+ super(s);
+ }
+
+ public DuplicateQuestionException(Throwable t)
+ {
+ super(t);
+ }
+}
diff --git a/src/org/egonet/exceptions/EgonetException.java b/src/main/java/org/egonet/exceptions/EgonetException.java
similarity index 100%
rename from src/org/egonet/exceptions/EgonetException.java
rename to src/main/java/org/egonet/exceptions/EgonetException.java
diff --git a/src/org/egonet/exceptions/FileMismatchException.java b/src/main/java/org/egonet/exceptions/FileMismatchException.java
similarity index 96%
rename from src/org/egonet/exceptions/FileMismatchException.java
rename to src/main/java/org/egonet/exceptions/FileMismatchException.java
index 8d38415..bba808e 100644
--- a/src/org/egonet/exceptions/FileMismatchException.java
+++ b/src/main/java/org/egonet/exceptions/FileMismatchException.java
@@ -1,43 +1,43 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package org.egonet.exceptions;
-
-public class FileMismatchException extends org.egonet.exceptions.EgonetException
-{
- public FileMismatchException()
- {
- super();
- }
-
- public FileMismatchException(String s)
- {
- super(s);
- }
-
- public FileMismatchException(Throwable t)
- {
- super(t);
- }
-
- public FileMismatchException(String s, Throwable t)
- {
- super(s,t);
- }
-
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package org.egonet.exceptions;
+
+public class FileMismatchException extends org.egonet.exceptions.EgonetException
+{
+ public FileMismatchException()
+ {
+ super();
+ }
+
+ public FileMismatchException(String s)
+ {
+ super(s);
+ }
+
+ public FileMismatchException(Throwable t)
+ {
+ super(t);
+ }
+
+ public FileMismatchException(String s, Throwable t)
+ {
+ super(s,t);
+ }
+
+}
diff --git a/src/org/egonet/exceptions/FileNotSetException.java b/src/main/java/org/egonet/exceptions/FileNotSetException.java
similarity index 100%
rename from src/org/egonet/exceptions/FileNotSetException.java
rename to src/main/java/org/egonet/exceptions/FileNotSetException.java
diff --git a/src/org/egonet/exceptions/MalformedQuestionException.java b/src/main/java/org/egonet/exceptions/MalformedQuestionException.java
similarity index 96%
rename from src/org/egonet/exceptions/MalformedQuestionException.java
rename to src/main/java/org/egonet/exceptions/MalformedQuestionException.java
index fabed40..ab644eb 100644
--- a/src/org/egonet/exceptions/MalformedQuestionException.java
+++ b/src/main/java/org/egonet/exceptions/MalformedQuestionException.java
@@ -1,43 +1,43 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package org.egonet.exceptions;
-
-public class MalformedQuestionException extends org.egonet.exceptions.EgonetException
-{
- public MalformedQuestionException()
- {
- super();
- }
-
- public MalformedQuestionException(String s)
- {
- super(s);
- }
-
- public MalformedQuestionException(Throwable t)
- {
- super(t);
- }
-
- public MalformedQuestionException(String s, Throwable t)
- {
- super(s,t);
- }
-
-}
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package org.egonet.exceptions;
+
+public class MalformedQuestionException extends org.egonet.exceptions.EgonetException
+{
+ public MalformedQuestionException()
+ {
+ super();
+ }
+
+ public MalformedQuestionException(String s)
+ {
+ super(s);
+ }
+
+ public MalformedQuestionException(Throwable t)
+ {
+ super(t);
+ }
+
+ public MalformedQuestionException(String s, Throwable t)
+ {
+ super(s,t);
+ }
+
+}
diff --git a/src/org/egonet/exceptions/MissingPairException.java b/src/main/java/org/egonet/exceptions/MissingPairException.java
similarity index 96%
rename from src/org/egonet/exceptions/MissingPairException.java
rename to src/main/java/org/egonet/exceptions/MissingPairException.java
index fdfa0cc..f148fd5 100644
--- a/src/org/egonet/exceptions/MissingPairException.java
+++ b/src/main/java/org/egonet/exceptions/MissingPairException.java
@@ -1,43 +1,43 @@
-/***
- * Copyright (c) 2008, Endless Loop Software, Inc.
- *
- * This file is part of EgoNet.
- *
- * EgoNet 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.
- *
- * EgoNet 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 this program. If not, see .
- */
-package org.egonet.exceptions;
-
-public class MissingPairException extends org.egonet.exceptions.EgonetException
-{
- public MissingPairException()
- {
- super();
- }
-
- public MissingPairException(String s)
- {
- super(s);
- }
-
- public MissingPairException(Throwable t)
- {
- super(t);
- }
-
- public MissingPairException(String s, Throwable t)
- {
- super(s,t);
- }
-
+/***
+ * Copyright (c) 2008, Endless Loop Software, Inc.
+ *
+ * This file is part of EgoNet.
+ *
+ * EgoNet 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.
+ *
+ * EgoNet 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 this program. If not, see .
+ */
+package org.egonet.exceptions;
+
+public class MissingPairException extends org.egonet.exceptions.EgonetException
+{
+ public MissingPairException()
+ {
+ super();
+ }
+
+ public MissingPairException(String s)
+ {
+ super(s);
+ }
+
+ public MissingPairException(Throwable t)
+ {
+ super(t);
+ }
+
+ public MissingPairException(String s, Throwable t)
+ {
+ super(s,t);
+ }
+
}
\ No newline at end of file
diff --git a/src/org/egonet/exceptions/StudyIdMismatchException.java b/src/main/java/org/egonet/exceptions/StudyIdMismatchException.java
similarity index 100%
rename from src/org/egonet/exceptions/StudyIdMismatchException.java
rename to src/main/java/org/egonet/exceptions/StudyIdMismatchException.java
diff --git a/src/org/egonet/graph/Graph.java b/src/main/java/org/egonet/graph/Graph.java
similarity index 96%
rename from src/org/egonet/graph/Graph.java
rename to src/main/java/org/egonet/graph/Graph.java
index ce15acc..1df210e 100644
--- a/src/org/egonet/graph/Graph.java
+++ b/src/main/java/org/egonet/graph/Graph.java
@@ -1,82 +1,82 @@
-package org.egonet.graph;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public class Graph {
-
- private Map> connections;
-
- public Graph() {
- this(new HashMap>());
- }
- public Graph(Map> connections) {
- this.connections = new HashMap>();
- for(N node : connections.keySet()) {
- Set set = Sets.newHashSet();
- set.addAll(connections.get(node));
- this.connections.put(node, set);
- }
- }
- public static Graph random(Integer numNodes, Double density) {
- Random rand = new Random();
- Map> connections = Maps.newHashMap();
- List nodes = Lists.newArrayList();
- for(Integer i = 0; i < numNodes; i++) {
- nodes.add(i);
- }
- for(Integer i = 0; i < numNodes; i++) {
- Collections.shuffle(nodes,rand);
- Integer expectedConnections = (int) Math.round(density * (numNodes - 1));
- Integer spread = Math.min(expectedConnections, numNodes-1-expectedConnections);
- Integer actual = rand.nextInt(2*spread+1) + expectedConnections - spread;
- Set connectionsForThisNode = Sets.newHashSet();
- for(Integer j = 0; j < actual && j < nodes.size(); j++) {
- if(nodes.get(j).equals(j)) {
- actual++;
- } else {
- connectionsForThisNode.add(nodes.get(j));
- }
- }
- connections.put(i, connectionsForThisNode);
- }
- return new Graph(connections);
- }
- public Double density() {
- Integer numNodes = connections.keySet().size();
- if(numNodes < 2) {
- return 1.0;
- }
- Integer maxConnectionsTimesTwo = numNodes * (numNodes-1);
- Integer actualConnectionsTimesTwo = 0;
- for(N node : connections.keySet()) {
- actualConnectionsTimesTwo += connections.get(node).size();
- }
- return actualConnectionsTimesTwo < 1 ? 0.0 :
- (actualConnectionsTimesTwo * 1.0 / maxConnectionsTimesTwo);
- }
- public Set nodes() {
- return connections.keySet();
- }
- public boolean connected(N n1, N n2) {
- return connections.get(n1).contains(n2);
- }
- // TODO: Double distance(N n1, N n2)
- public boolean equals(Object o) {
- if(o == null || ! (o instanceof Graph)) {
- return false;
- }
- return connections.equals(((Graph) o).connections);
- }
- public int hashCode() {
- return connections.hashCode();
- }
-}
+package org.egonet.graph;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+public class Graph {
+
+ private Map> connections;
+
+ public Graph() {
+ this(new HashMap>());
+ }
+ public Graph(Map> connections) {
+ this.connections = new HashMap>();
+ for(N node : connections.keySet()) {
+ Set set = Sets.newHashSet();
+ set.addAll(connections.get(node));
+ this.connections.put(node, set);
+ }
+ }
+ public static Graph random(Integer numNodes, Double density) {
+ Random rand = new Random();
+ Map> connections = Maps.newHashMap();
+ List nodes = Lists.newArrayList();
+ for(Integer i = 0; i < numNodes; i++) {
+ nodes.add(i);
+ }
+ for(Integer i = 0; i < numNodes; i++) {
+ Collections.shuffle(nodes,rand);
+ Integer expectedConnections = (int) Math.round(density * (numNodes - 1));
+ Integer spread = Math.min(expectedConnections, numNodes-1-expectedConnections);
+ Integer actual = rand.nextInt(2*spread+1) + expectedConnections - spread;
+ Set connectionsForThisNode = Sets.newHashSet();
+ for(Integer j = 0; j < actual && j < nodes.size(); j++) {
+ if(nodes.get(j).equals(j)) {
+ actual++;
+ } else {
+ connectionsForThisNode.add(nodes.get(j));
+ }
+ }
+ connections.put(i, connectionsForThisNode);
+ }
+ return new Graph(connections);
+ }
+ public Double density() {
+ Integer numNodes = connections.keySet().size();
+ if(numNodes < 2) {
+ return 1.0;
+ }
+ Integer maxConnectionsTimesTwo = numNodes * (numNodes-1);
+ Integer actualConnectionsTimesTwo = 0;
+ for(N node : connections.keySet()) {
+ actualConnectionsTimesTwo += connections.get(node).size();
+ }
+ return actualConnectionsTimesTwo < 1 ? 0.0 :
+ (actualConnectionsTimesTwo * 1.0 / maxConnectionsTimesTwo);
+ }
+ public Set nodes() {
+ return connections.keySet();
+ }
+ public boolean connected(N n1, N n2) {
+ return connections.get(n1).contains(n2);
+ }
+ // TODO: Double distance(N n1, N n2)
+ public boolean equals(Object o) {
+ if(o == null || ! (o instanceof Graph)) {
+ return false;
+ }
+ return connections.equals(((Graph) o).connections);
+ }
+ public int hashCode() {
+ return connections.hashCode();
+ }
+}
diff --git a/src/org/egonet/graph/IndexedSetOfSets.java b/src/main/java/org/egonet/graph/IndexedSetOfSets.java
similarity index 94%
rename from src/org/egonet/graph/IndexedSetOfSets.java
rename to src/main/java/org/egonet/graph/IndexedSetOfSets.java
index 8f7cbd5..73854e1 100644
--- a/src/org/egonet/graph/IndexedSetOfSets.java
+++ b/src/main/java/org/egonet/graph/IndexedSetOfSets.java
@@ -1,159 +1,159 @@
-package org.egonet.graph;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public class IndexedSetOfSets implements Set> {
-
- private Set> set;
- private Map>> index;
-
- public Set> findByIndex(N item) {
- Set> result = index.get(item);
- return result == null ? new HashSet>() : result;
- }
-
- public IndexedSetOfSets() {
- clear();
- }
-
- public boolean add(Set item) {
- if(set.contains(item)) {
- return false;
- } else {
- set.add(item);
- for(N n : item) {
- Set> nIndex = index.get(n);
- if(nIndex == null) {
- nIndex = Sets.newHashSet();
- index.put(n, nIndex);
- }
- nIndex.add(item);
- }
- return true;
- }
- }
-
- public boolean addAll(Collection extends Set> items) {
- boolean modified = false;
- for(Set item : items) {
- if(add(item)) {
- modified = true;
- }
- }
- return modified;
- }
-
- public void clear() {
- set = Sets.newHashSet();
- index = Maps.newHashMap();
- }
-
- public boolean contains(Object item) {
- return set.contains(item);
- }
-
- public boolean containsAll(Collection> items) {
- for(Object item : items) {
- if(! contains(item)) {
- return false;
- }
- }
- return true;
- }
-
- public boolean isEmpty() {
- return set.isEmpty();
- }
-
- private class IndexedIterator implements Iterator> {
-
- private List> items;
- int i = -1;
-
- public IndexedIterator() {
- items = Lists.newArrayList(set);
- }
-
- public boolean hasNext() {
- return items.size() > i+1;
- }
-
- public Set next() {
- i++;
- return items.get(i);
- }
-
- public void remove() {
- IndexedSetOfSets.this.remove(items.get(i));
- }
- }
-
- public Iterator> iterator() {
- return new IndexedIterator();
- }
-
- @SuppressWarnings("unchecked")
- public boolean remove(Object obj) {
- Set item = (Set) obj;
- boolean modified = set.remove(item);
- if(modified) {
- for(N n : item) {
- index.get(n).remove(item);
- }
- }
- return modified;
- }
-
- public boolean removeAll(Collection> items) {
- boolean modified = false;
- for(Object item : items) {
- if(remove(item)) {
- modified = true;
- }
- }
- return modified;
- }
-
- @SuppressWarnings("unchecked")
- public boolean retainAll(Collection> items) {
- Set> keepers = Sets.newHashSet();
- keepers.addAll((Collection>) items);
- boolean modified = false;
- Iterator> iter = iterator();
- while(iter.hasNext()) {
- Set item = iter.next();
- if(! keepers.contains(item)) {
- remove(item);
- }
- }
- return modified;
- }
-
- public int size() {
- return set.size();
- }
-
- public Object[] toArray() {
- return set.toArray();
- }
-
- public T[] toArray(T[] t) {
- return set.toArray(t);
- }
-
- public boolean equals(Object obj) {
- return set.equals(obj);
- }
- public int hashCode() {
- return set.hashCode();
- }
-}
+package org.egonet.graph;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+public class IndexedSetOfSets implements Set> {
+
+ private Set> set;
+ private Map>> index;
+
+ public Set> findByIndex(N item) {
+ Set> result = index.get(item);
+ return result == null ? new HashSet>() : result;
+ }
+
+ public IndexedSetOfSets() {
+ clear();
+ }
+
+ public boolean add(Set item) {
+ if(set.contains(item)) {
+ return false;
+ } else {
+ set.add(item);
+ for(N n : item) {
+ Set> nIndex = index.get(n);
+ if(nIndex == null) {
+ nIndex = Sets.newHashSet();
+ index.put(n, nIndex);
+ }
+ nIndex.add(item);
+ }
+ return true;
+ }
+ }
+
+ public boolean addAll(Collection extends Set> items) {
+ boolean modified = false;
+ for(Set item : items) {
+ if(add(item)) {
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ public void clear() {
+ set = Sets.newHashSet();
+ index = Maps.newHashMap();
+ }
+
+ public boolean contains(Object item) {
+ return set.contains(item);
+ }
+
+ public boolean containsAll(Collection> items) {
+ for(Object item : items) {
+ if(! contains(item)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean isEmpty() {
+ return set.isEmpty();
+ }
+
+ private class IndexedIterator implements Iterator> {
+
+ private List> items;
+ int i = -1;
+
+ public IndexedIterator() {
+ items = Lists.newArrayList(set);
+ }
+
+ public boolean hasNext() {
+ return items.size() > i+1;
+ }
+
+ public Set next() {
+ i++;
+ return items.get(i);
+ }
+
+ public void remove() {
+ IndexedSetOfSets.this.remove(items.get(i));
+ }
+ }
+
+ public Iterator> iterator() {
+ return new IndexedIterator();
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean remove(Object obj) {
+ Set item = (Set) obj;
+ boolean modified = set.remove(item);
+ if(modified) {
+ for(N n : item) {
+ index.get(n).remove(item);
+ }
+ }
+ return modified;
+ }
+
+ public boolean removeAll(Collection> items) {
+ boolean modified = false;
+ for(Object item : items) {
+ if(remove(item)) {
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean retainAll(Collection> items) {
+ Set> keepers = Sets.newHashSet();
+ keepers.addAll((Collection>) items);
+ boolean modified = false;
+ Iterator> iter = iterator();
+ while(iter.hasNext()) {
+ Set item = iter.next();
+ if(! keepers.contains(item)) {
+ remove(item);
+ }
+ }
+ return modified;
+ }
+
+ public int size() {
+ return set.size();
+ }
+
+ public Object[] toArray() {
+ return set.toArray();
+ }
+
+ public T[] toArray(T[] t) {
+ return set.toArray(t);
+ }
+
+ public boolean equals(Object obj) {
+ return set.equals(obj);
+ }
+ public int hashCode() {
+ return set.hashCode();
+ }
+}
diff --git a/src/org/egonet/graph/KPlexes.java b/src/main/java/org/egonet/graph/KPlexes.java
similarity index 97%
rename from src/org/egonet/graph/KPlexes.java
rename to src/main/java/org/egonet/graph/KPlexes.java
index 4c15ae3..5bd0a0e 100644
--- a/src/org/egonet/graph/KPlexes.java
+++ b/src/main/java/org/egonet/graph/KPlexes.java
@@ -1,177 +1,177 @@
-package org.egonet.graph;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public class KPlexes {
- // graph is Map>
- // kplex is >
- public Map connectionsByNode(Map> graph) {
- Map result = Maps.newHashMap();
- for(N n : graph.keySet()) {
- result.put(n, graph.get(n).size());
- }
- return result;
- }
- // This is similar to hIndex.
- // Connectedness of N for having N connections to nodes with N connections.
- public Map connectednessByNode(Map> graph) {
- Map connectionsByNode = connectionsByNode(graph);
- Map results = Maps.newHashMap();
- for(N n1 : graph.keySet()) {
- List connectednessOfConnections = Lists.newArrayList();
- for(N n2 : graph.get(n1)) {
- connectednessOfConnections.add(connectionsByNode.get(n2));
- }
- Collections.sort(connectednessOfConnections);
- Collections.reverse(connectednessOfConnections);
- Integer result = 0;
- for(Integer i = 0; i < connectednessOfConnections.size(); i++) {
- if(i < connectednessOfConnections.get(i)) {
- result = i+1;
- }
- }
- results.put(n1, result);
- }
- return results;
- }
- public Map connectionsWithinSubgroup(Map> graph, Set subgroup) {
- Map result = Maps.newHashMap();
- for(N n : graph.keySet()) {
- result.put(n, Sets.intersection(graph.get(n),subgroup).size());
- }
- return result;
- }
- public Integer highestConnectedness(Map> graph) {
- Integer highest = 0;
- for(Integer connectedness : connectednessByNode(graph).values()) {
- if(connectedness > highest) {
- highest = connectedness;
- }
- }
- return highest;
- }
- public Set meetConnectednessThreshold(Map> graph, Integer threshold) {
- Set result = Sets.newHashSet();
- Map connectedness = connectednessByNode(graph);
- for(N n : graph.keySet()) {
- if(connectedness.get(n) > threshold-1) {
- result.add(n);
- }
- }
- return result;
- }
- public Integer largestPossibleKPlex(Map> graph, Integer k) {
- return highestConnectedness(graph)+k;
- }
- public Set criticalNodesInKPlex(Map> graph, Set kplex, Integer k) {
- Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
- Set criticalNodes = Sets.newHashSet();
- for(N n : kplex) {
- Integer connections = connectionsWithinKPlex.get(n);
- if(connections == null) {
- throw new RuntimeException("null connections for "+n+" in "+kplex+" of graph "+graph);
- }
- if(connections < kplex.size()-k+1) {
- criticalNodes.add(n);
- }
- }
- return criticalNodes;
- }
- public Set nodesThatCanBeAddedToKPlex(Map> graph, Set kplex, Integer k) {
- if(kplex.isEmpty()) {
- if(k > 0) {
- return graph.keySet();
- } else {
- return new HashSet();
- }
- }
- Set criticalNodes = criticalNodesInKPlex(graph, kplex, k);
- if(criticalNodes.isEmpty()) {
- Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
- Set neighbors = Sets.newHashSet();
- for(N n : graph.keySet()) {
- if(connectionsWithinKPlex.get(n) > 0) {
- neighbors.add(n);
- }
- }
- neighbors.removeAll(kplex);
- return Sets.difference(neighbors,kplex);
- }
- Set eligible = Sets.difference(graph.keySet(),kplex);
- for(N n : criticalNodes) {
- // Must be neighbor of all critical nodes.
- eligible = Sets.intersection(eligible, graph.get(n));
- }
- return eligible;
- }
- public Map> createSubgraph(Map> graph, Set nodes) {
- Map> subgraph = Maps.newHashMap();
- for(N n : nodes) {
- subgraph.put(n, Sets.intersection(graph.get(n),nodes));
- }
- return subgraph;
- }
- public Map> subgraphBoundingFinalKPlex(
- Map> graph, Set kplex, Integer k, Integer targetSize)
- {
- Set includeInSubgraph =
- Sets.union(kplex,
- Sets.intersection(
- meetConnectednessThreshold(graph,targetSize-k),
- nodesThatCanBeAddedToKPlex(graph,kplex,k)));
- return createSubgraph(graph,includeInSubgraph);
- }
- public N chooseNodeForInclusionInKPlex(Map> graph, Set kplex, Integer k) {
- Integer highScore = 0;
- N choice = null;
- Map connectedness = connectednessByNode(graph);
- Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
- Set addable = nodesThatCanBeAddedToKPlex(graph, kplex, k);
- for(N n : addable) {
- Integer score = connectedness.get(n) + connectionsWithinKPlex.get(n);
- if(score > highScore) {
- highScore = score;
- choice = n;
- }
- }
- return choice;
- }
- public Set growKPlex(Map> graph, Set kplex, Integer k, Integer targetSize) {
- Map> boundingGraph = subgraphBoundingFinalKPlex(graph,kplex,k,targetSize);
- N newNode = chooseNodeForInclusionInKPlex(graph,kplex,k);
- if(newNode == null) {
- return kplex;
- }
- Set newKPlex = Sets.newHashSet();
- newKPlex.add(newNode);
- newKPlex.addAll(kplex);
- return growKPlex(boundingGraph,newKPlex,k,targetSize);
- }
- public Set findLargeKPlex(Map> graph, Integer k) {
- Set largestFound = Sets.newHashSet();
- for(Integer targetSize = largestPossibleKPlex(graph, k);
- targetSize > largestFound.size();
- targetSize--)
- {
- Set seeds = meetConnectednessThreshold(graph, targetSize-k);
- Map> boundedGraph = createSubgraph(graph,seeds);
- for(N seed : seeds) {
- Set kplex = Sets.newHashSet();
- kplex.add(seed);
- kplex = growKPlex(boundedGraph,kplex,k,targetSize);
- if(kplex.size() > largestFound.size()) {
- largestFound = kplex;
- }
- }
- }
- return largestFound;
- }
-}
+package org.egonet.graph;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+public class KPlexes {
+ // graph is Map>
+ // kplex is >
+ public Map connectionsByNode(Map> graph) {
+ Map result = Maps.newHashMap();
+ for(N n : graph.keySet()) {
+ result.put(n, graph.get(n).size());
+ }
+ return result;
+ }
+ // This is similar to hIndex.
+ // Connectedness of N for having N connections to nodes with N connections.
+ public Map connectednessByNode(Map> graph) {
+ Map connectionsByNode = connectionsByNode(graph);
+ Map results = Maps.newHashMap();
+ for(N n1 : graph.keySet()) {
+ List connectednessOfConnections = Lists.newArrayList();
+ for(N n2 : graph.get(n1)) {
+ connectednessOfConnections.add(connectionsByNode.get(n2));
+ }
+ Collections.sort(connectednessOfConnections);
+ Collections.reverse(connectednessOfConnections);
+ Integer result = 0;
+ for(Integer i = 0; i < connectednessOfConnections.size(); i++) {
+ if(i < connectednessOfConnections.get(i)) {
+ result = i+1;
+ }
+ }
+ results.put(n1, result);
+ }
+ return results;
+ }
+ public Map connectionsWithinSubgroup(Map> graph, Set subgroup) {
+ Map result = Maps.newHashMap();
+ for(N n : graph.keySet()) {
+ result.put(n, Sets.intersection(graph.get(n),subgroup).size());
+ }
+ return result;
+ }
+ public Integer highestConnectedness(Map> graph) {
+ Integer highest = 0;
+ for(Integer connectedness : connectednessByNode(graph).values()) {
+ if(connectedness > highest) {
+ highest = connectedness;
+ }
+ }
+ return highest;
+ }
+ public Set meetConnectednessThreshold(Map> graph, Integer threshold) {
+ Set result = Sets.newHashSet();
+ Map connectedness = connectednessByNode(graph);
+ for(N n : graph.keySet()) {
+ if(connectedness.get(n) > threshold-1) {
+ result.add(n);
+ }
+ }
+ return result;
+ }
+ public Integer largestPossibleKPlex(Map> graph, Integer k) {
+ return highestConnectedness(graph)+k;
+ }
+ public Set criticalNodesInKPlex(Map> graph, Set kplex, Integer k) {
+ Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
+ Set criticalNodes = Sets.newHashSet();
+ for(N n : kplex) {
+ Integer connections = connectionsWithinKPlex.get(n);
+ if(connections == null) {
+ throw new RuntimeException("null connections for "+n+" in "+kplex+" of graph "+graph);
+ }
+ if(connections < kplex.size()-k+1) {
+ criticalNodes.add(n);
+ }
+ }
+ return criticalNodes;
+ }
+ public Set nodesThatCanBeAddedToKPlex(Map> graph, Set kplex, Integer k) {
+ if(kplex.isEmpty()) {
+ if(k > 0) {
+ return graph.keySet();
+ } else {
+ return new HashSet();
+ }
+ }
+ Set criticalNodes = criticalNodesInKPlex(graph, kplex, k);
+ if(criticalNodes.isEmpty()) {
+ Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
+ Set neighbors = Sets.newHashSet();
+ for(N n : graph.keySet()) {
+ if(connectionsWithinKPlex.get(n) > 0) {
+ neighbors.add(n);
+ }
+ }
+ neighbors.removeAll(kplex);
+ return Sets.difference(neighbors,kplex);
+ }
+ Set eligible = Sets.difference(graph.keySet(),kplex);
+ for(N n : criticalNodes) {
+ // Must be neighbor of all critical nodes.
+ eligible = Sets.intersection(eligible, graph.get(n));
+ }
+ return eligible;
+ }
+ public Map> createSubgraph(Map> graph, Set nodes) {
+ Map> subgraph = Maps.newHashMap();
+ for(N n : nodes) {
+ subgraph.put(n, Sets.intersection(graph.get(n),nodes));
+ }
+ return subgraph;
+ }
+ public Map> subgraphBoundingFinalKPlex(
+ Map> graph, Set kplex, Integer k, Integer targetSize)
+ {
+ Set includeInSubgraph =
+ Sets.union(kplex,
+ Sets.intersection(
+ meetConnectednessThreshold(graph,targetSize-k),
+ nodesThatCanBeAddedToKPlex(graph,kplex,k)));
+ return createSubgraph(graph,includeInSubgraph);
+ }
+ public N chooseNodeForInclusionInKPlex(Map> graph, Set kplex, Integer k) {
+ Integer highScore = 0;
+ N choice = null;
+ Map connectedness = connectednessByNode(graph);
+ Map connectionsWithinKPlex = connectionsWithinSubgroup(graph,kplex);
+ Set addable = nodesThatCanBeAddedToKPlex(graph, kplex, k);
+ for(N n : addable) {
+ Integer score = connectedness.get(n) + connectionsWithinKPlex.get(n);
+ if(score > highScore) {
+ highScore = score;
+ choice = n;
+ }
+ }
+ return choice;
+ }
+ public Set growKPlex(Map> graph, Set kplex, Integer k, Integer targetSize) {
+ Map> boundingGraph = subgraphBoundingFinalKPlex(graph,kplex,k,targetSize);
+ N newNode = chooseNodeForInclusionInKPlex(graph,kplex,k);
+ if(newNode == null) {
+ return kplex;
+ }
+ Set newKPlex = Sets.newHashSet();
+ newKPlex.add(newNode);
+ newKPlex.addAll(kplex);
+ return growKPlex(boundingGraph,newKPlex,k,targetSize);
+ }
+ public Set findLargeKPlex(Map> graph, Integer k) {
+ Set largestFound = Sets.newHashSet();
+ for(Integer targetSize = largestPossibleKPlex(graph, k);
+ targetSize > largestFound.size();
+ targetSize--)
+ {
+ Set seeds = meetConnectednessThreshold(graph, targetSize-k);
+ Map> boundedGraph = createSubgraph(graph,seeds);
+ for(N seed : seeds) {
+ Set kplex = Sets.newHashSet();
+ kplex.add(seed);
+ kplex = growKPlex(boundedGraph,kplex,k,targetSize);
+ if(kplex.size() > largestFound.size()) {
+ largestFound = kplex;
+ }
+ }
+ }
+ return largestFound;
+ }
+}
diff --git a/src/org/egonet/graph/KPlexesTwoMode.java b/src/main/java/org/egonet/graph/KPlexesTwoMode.java
similarity index 97%
rename from src/org/egonet/graph/KPlexesTwoMode.java
rename to src/main/java/org/egonet/graph/KPlexesTwoMode.java
index f910f6b..b0c9a04 100644
--- a/src/org/egonet/graph/KPlexesTwoMode.java
+++ b/src/main/java/org/egonet/graph/KPlexesTwoMode.java
@@ -1,251 +1,251 @@
-package org.egonet.graph;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public class KPlexesTwoMode {
- // graph is Map> plus Set to indicate which are in first mode
- // kplex is >
- public Map connectionsByNode(Map> graph) {
- Map