Skip to content

Commit

Permalink
- Added string similarity measures package 'simetrics'
Browse files Browse the repository at this point in the history
- Added SwingX and used JXTable for whole network lists
- Added slf4j for logging; simply plugin your own slf4k jar for your logging framework and configure the framework. The default is currently JDK logging, which you should remove if you replace with one of your own.
  • Loading branch information
martinb3 committed May 1, 2009
1 parent 3c0a91b commit 8778934
Show file tree
Hide file tree
Showing 59 changed files with 628 additions and 363 deletions.
4 changes: 4 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
</classpathentry>
<classpathentry kind="lib" path="lib/jung/jung-io-2.0-beta1.jar"/>
<classpathentry kind="lib" path="lib/jung/jung-visualization-2.0-beta1.jar" sourcepath="C:/Documents and Settings/Martin/My Documents/Java Libraries/jung2-beta1/jung-visualization-2.0-beta1-sources.jar"/>
<classpathentry kind="lib" path="lib/swingx-0.9.7.jar"/>
<classpathentry kind="lib" path="lib/simmetrics_jar_v1_6_2_d07_02_07.jar" sourcepath="C:/Documents and Settings/Martin/My Documents/Java Libraries/simmetrics/src"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.5.6.jar"/>
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.5.6.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/miglayout-3.7-swing.jar"/>
<classpathentry kind="lib" path="lib/opencsv-1.8.jar"/>
Expand Down
4 changes: 4 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<zipfileset src="${dir.lib.Enet}/functionalj.jar" />
<zipfileset src="${dir.lib.Enet}/iText-2.1.5.jar" />
<zipfileset src="${dir.lib.Enet}/iText-rtf-2.1.5.jar" />
<zipfileset src="${dir.lib.Enet}/swingx-0.9.7.jar" />
<zipfileset src="${dir.lib.Enet}/simmetrics_jar_v1_6_2_d07_02_07.jar" />
<zipfileset src="${dir.lib.Enet}/slf4j-api-1.5.6.jar" />
<zipfileset src="${dir.lib.Enet}/slf4j-jdk14-1.5.6.jar" />

<zipfileset src="${dir.lib.Enet}/jung/collections-generic-4.01.jar" />
<zipfileset src="${dir.lib.Enet}/jung/colt-1.2.0.jar" />
Expand Down
Binary file added lib/simmetrics_jar_v1_6_2_d07_02_07.jar
Binary file not shown.
Binary file added lib/slf4j-api-1.5.6.jar
Binary file not shown.
Binary file added lib/slf4j-jdk14-1.5.6.jar
Binary file not shown.
Binary file added lib/swingx-0.9.7.jar
Binary file not shown.
16 changes: 8 additions & 8 deletions src/com/endlessloopsoftware/ego/author/CategoryInputPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.endlessloopsoftware.egonet.Question;
import com.endlessloopsoftware.egonet.Shared;

import org.egonet.util.CatchingAction;
import org.egonet.util.listbuilder.ListBuilder;
import org.egonet.util.listbuilder.Selection;

import com.endlessloopsoftware.egonet.Question;
import com.endlessloopsoftware.egonet.Shared;

public class CategoryInputPane extends JDialog {

private final JList parentList;

private final GridBagLayout gridBagLayout1 = new GridBagLayout();
Expand Down Expand Up @@ -168,7 +169,6 @@ void cancelButton_actionPerformed(ActionEvent e) {
}

void activate() {
//System.out.println("before activate lb.pref=" + disp());
Question q = (Question) parentList.getSelectedValue();

if (q != null) {
Expand All @@ -190,7 +190,7 @@ void activate() {
listBuilder.setPresetListsActive(q.answerType == Shared.AnswerType.CATEGORICAL);

// boolean preset = (q.answerType == Shared.AnswerType.CATEGORICAL) ? true : false;
// System.out.println("Is question categorical? " + preset);
// logger.info("Is question categorical? " + preset);
//
listBuilder.setAdjacencyActive(q.questionType == Shared.QuestionType.ALTER_PAIR);

Expand All @@ -204,16 +204,16 @@ void activate() {
jOKButton.setVisible(true);
jCancelButton.setText("Cancel");

//System.out.println("initial lb.pref=" + disp());
//logger.info("initial lb.pref=" + disp());

/* Pack since we've modified the GUI elements */
validate();
pack(); pack(); pack(); pack(); pack(); pack(); pack(); pack(); pack();

//System.out.println("after invalidate and pack lb.pref " + disp());
//logger.info("after invalidate and pack lb.pref " + disp());

this.setVisible(true);

//System.out.println("after it was visible lb.pref " + disp());
//logger.info("after it was visible lb.pref " + disp());
}
}
4 changes: 2 additions & 2 deletions src/com/endlessloopsoftware/ego/author/EgoFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ public void update(Observable o, Object arg) {
}

public void focusActivated() {
//System.out.println(this.getTitle() + " activated");
//logger.info(this.getTitle() + " activated");

}

public void focusDeactivated() {
//System.out.println(this.getTitle() + " deactivated");
//logger.info(this.getTitle() + " deactivated");

}

Expand Down
2 changes: 1 addition & 1 deletion src/com/endlessloopsoftware/ego/author/PromptPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void question_list_selectionChanged(ListSelectionEvent e)
*/
public void fillPanel()
{
//System.out.println("fillPanel() called in PromptPanel but questionType was " + questionType + " and curTab was " + egoNet.getFrame().curTab);
//logger.info("fillPanel() called in PromptPanel but questionType was " + questionType + " and curTab was " + egoNet.getFrame().curTab);
if (questionType == egoNet.getFrame().curTab)
{
storageUpdate();
Expand Down
16 changes: 10 additions & 6 deletions src/com/endlessloopsoftware/ego/client/ClientFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import org.egonet.util.FileHelpers;
import org.egonet.util.ImageFilter;
import org.egonet.util.SwingWorker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.endlessloopsoftware.ego.client.graph.*;
import com.endlessloopsoftware.ego.client.statistics.StatRecord;
Expand All @@ -60,6 +62,8 @@

// implement MdiChildFrame and molest the public menu!
public class ClientFrame extends MDIChildFrame {

final private static Logger logger = LoggerFactory.getLogger(ClientFrame.class);

/**
* Used to create drop down menus of different "modes"
Expand Down Expand Up @@ -241,7 +245,7 @@ public void flood() {
pack();
setMinimumSize(getPreferredSize());
setSize(getPreferredSize());
//System.out.println("flood");
//logger.info("flood");
}

// File | Exit action performed
Expand Down Expand Up @@ -349,7 +353,7 @@ void saveGraph_actionPerformed(ActionEvent e) {

String fmt = ImageFilter.getExtension(imageFile);
if (fmt != null && imageFilter.accept(imageFile)) {
System.out.println(imageFile.getName());
logger.info(imageFile.getName());
GraphData.writeImage(imageFile, fmt);
break;
} else {
Expand Down Expand Up @@ -502,8 +506,8 @@ protected void applyGraphSettings_actionPerformed(ActionEvent e) {

try {
GraphRenderer.getGraphSettings().loadSettingsFile(settingsFile);
} catch (Throwable cause) {
cause.printStackTrace();
} catch (Throwable ex) {
logger.error(ex.toString());
}
}
}
Expand Down Expand Up @@ -659,12 +663,12 @@ public void finished()
}

public void focusActivated() {
System.out.println(this.getTitle() + " activated");
logger.info(this.getTitle() + " activated");

}

public void focusDeactivated() {
System.out.println(this.getTitle() + " deactivated");
logger.info(this.getTitle() + " deactivated");

}

Expand Down
56 changes: 31 additions & 25 deletions src/com/endlessloopsoftware/ego/client/ClientQuestionPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
import org.egonet.util.WholeNumberDocument;
import org.egonet.util.listbuilder.ListBuilder;
import org.egonet.util.listbuilder.Selection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
Expand All @@ -63,6 +66,9 @@
* Generic Panel creation and handling routines for question editing
*/
public class ClientQuestionPanel extends JPanel implements Observer {

final private static Logger logger = LoggerFactory.getLogger(ClientQuestionPanel.class);

/* Lists */
private final JRadioButton[] answerButtons = {
new JRadioButton(), // 1
Expand Down Expand Up @@ -234,14 +240,14 @@ public void safeActionPerformed(ActionEvent e) throws Exception {

answerButtonListener = new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("answerButtonListener: " + e);
logger.info("answerButtonListener: " + e);
questionAnsweredEventHandler(e);
}
};

answerMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
//System.out.println("answerMenu.addActionListener: " + e);
//logger.info("answerMenu.addActionListener: " + e);
questionAnsweredEventHandler(e);
}
});
Expand Down Expand Up @@ -538,13 +544,13 @@ public void fillPanel() {
numericalTextField.requestFocusInWindow();
} else if(question.answerType == Shared.AnswerType.CATEGORICAL) {

System.out.println("Displaying CATEGORICAL question: " + question.text);
logger.info("Displaying CATEGORICAL question: " + question.text);
questionText.setText(question.text);
questionText.setCaretPosition(0);

// can we do radio buttons or do we need the dropdown?
if (question.getSelections().length <= answerButtons.length) { // radio buttons!
System.out.println(" -- doing radio buttons since there's room!");
logger.info(" -- doing radio buttons since there's room!");

for(int i = 0; i < answerButtons.length; i++)
{
Expand All @@ -561,23 +567,23 @@ public void fillPanel() {
answerButtons[i].setEnabled((egoClient.getUiPath() == ClientFrame.DO_INTERVIEW) || (egoClient.getUiPath() == ClientFrame.VIEW_INTERVIEW));
answerButtons[i].setActionCommand("User Input");

System.out.println("Creating radio button " + i + ": " + answerButtons[i].getText());
logger.info("Creating radio button " + i + ": " + answerButtons[i].getText());
}

System.out.println("-- answer: " + question.answer.answered + ", answer index: " + question.answer.getIndex());
logger.info("-- answer: " + question.answer.answered + ", answer index: " + question.answer.getIndex());
if (question.answer.answered && (question.answer.getIndex() >= -1)) {
System.out.println(" -- was it actually answered with index >= -1 (not unselected)");
logger.info(" -- was it actually answered with index >= -1 (not unselected)");
//int idx = question.selections.length - (question.answer.getValue() + 1);
if (answerButtons != null && answerButtons.length != 0) {
answerButtons[question.answer.getIndex()].setSelected(true);
System.out.println("-- YES -- setting a selection for the new loaded question's answer!");
logger.info("-- YES -- setting a selection for the new loaded question's answer!");
}
}

answerPanel.showCard(RADIO_CARD);
answerPanel.setVisible(true);
} else { // drop downs!
System.out.println(" -- doing drop downs!");
logger.info(" -- doing drop downs!");
questionText.setText(question.text);
questionText.setCaretPosition(0);
answerPanel.showCard(MENU_CARD);
Expand Down Expand Up @@ -626,17 +632,17 @@ private void fillAnswer(Answer answer) {
// if (egoClient.getUiPath() == ClientFrame.VIEW_INTERVIEW)
// return;

//System.out.println("fillAnswer called for " + answer.getString());
//logger.info("fillAnswer called for " + answer.getString());
Study study = egoClient.getStudy();

if (question.questionType == Shared.QuestionType.ALTER_PROMPT) {
answer.string = "Egonet - University of Florida";
boolean morePrompts = !egoClient.getInterview().isLastAlterPrompt();
System.out.println("More prompts? " + morePrompts);
logger.info("More prompts? " + morePrompts);

// value starts at zero, so add one to compare to # alters needed
boolean maxAlters = answer.getValue()+1 >= study.getNumAlters();
System.out.println("Max alters? " + maxAlters + " (answer value = " + answer.getValue() + " , network size = " + study.getNetworkSize());
logger.info("Max alters? " + maxAlters + " (answer value = " + answer.getValue() + " , network size = " + study.getNetworkSize());
answer.answered = morePrompts || maxAlters;

AlterSamplingModel alterSampleModel = study.getAlterSamplingModel();
Expand Down Expand Up @@ -684,7 +690,7 @@ private void fillAnswer(Answer answer) {
if (noAnswerBox.isSelected()
|| (numericalTextField.getText().length() > 0)) {
answer.timestamp = generateTimeStamp();
//System.out.println("Timestamp: " + answer.timestamp);
//logger.info("Timestamp: " + answer.timestamp);
if (noAnswerBox.isSelected()) {
answer.answered = true;
answer.setValue((Answer.NO_ANSWER));
Expand All @@ -703,7 +709,7 @@ private void fillAnswer(Answer answer) {
answer.answered = true;
} else if(question.answerType.equals(Shared.AnswerType.TEXT)) {
answer.timestamp = generateTimeStamp();
//System.out.println("Timestamp: " + answer.timestamp);
//logger.info("Timestamp: " + answer.timestamp);
answer.string = answerTextField.getText();
answer.setValue((answer.string.length()));
answer.answered = (answer.getValue() != 0);
Expand All @@ -718,14 +724,14 @@ private void fillAnswer(Answer answer) {
answer.timestamp = generateTimeStamp();

int selectionIndex = buttonIndex;
System.out.println("Selected button (index: " + buttonIndex + ") with selections ("+Arrays.asList(question.getSelections())+") of size " + question.getSelections().length);
logger.info("Selected button (index: " + buttonIndex + ") with selections ("+Arrays.asList(question.getSelections())+") of size " + question.getSelections().length);
answer.setValue((question.getSelections()[selectionIndex].getValue()));
// added 11/27/2007
answer.setIndex(question.getSelections()[selectionIndex].getIndex());
// answer.index = question.selections.length - question.selections[button].getIndex();
answer.adjacent = question.getSelections()[selectionIndex].isAdjacent();
answer.string = question.getSelections()[selectionIndex].getString();
//System.out.println("Timestamp: " + answer.timestamp + ", answer = " + answer.getString());
//logger.info("Timestamp: " + answer.timestamp + ", answer = " + answer.getString());
// answer.timestamp = DateFormat.getDateInstance().format(new Date());
}
} else {
Expand All @@ -737,7 +743,7 @@ private void fillAnswer(Answer answer) {

if (answer.answered) {
answer.timestamp = generateTimeStamp();
//System.out.println("Timestamp: " + answer.timestamp);
//logger.info("Timestamp: " + answer.timestamp);

Selection sel = question.getSelections()[selectionIndex];
answer.setValue(sel.getValue());
Expand All @@ -750,7 +756,7 @@ private void fillAnswer(Answer answer) {
answer.string = question.getSelections()[selectionIndex]
.getString();

System.out.println("Answered: " + answer.getString());
logger.info("Answered: " + answer.getString());
}
}
}
Expand Down Expand Up @@ -780,19 +786,19 @@ public String generateTimeStamp() {

private void numberKey_actionPerformed(ActionEvent e) throws IOException {
int key = Integer.parseInt(e.getActionCommand()) - 1;
System.out.println("Key pressed " + key);
logger.info("Key pressed " + key);
if (key == -1 && questionButtonNext.isEnabled())
questionButtonNext_actionPerformed(e);

if (question.answerType == Shared.AnswerType.CATEGORICAL) {
for (Selection sel : question.getSelections()) {
// int val = question.selections[i].value;
// System.out.println("Selection value :" +sel.getValue());
// logger.info("Selection value :" +sel.getValue());
if (key == sel.getValue()) {
// answerButtons[key - 1].setSelected(true);

answerButtons[sel.getIndex()].setSelected(true);
System.out.println("Number pressed w/ categorical question: numberKey_actionPerformed");
logger.info("Number pressed w/ categorical question: numberKey_actionPerformed");
questionAnsweredEventHandler(e);
break;
}
Expand Down Expand Up @@ -892,27 +898,27 @@ private void setButtonNextState() {
}

private void questionAnsweredEventHandler(ActionEvent e) {
//System.out.println("questionAnsweredEventHandler");
//logger.info("questionAnsweredEventHandler");
if (e.getActionCommand() != "Initialization") {
fillAnswer(question.answer);
setButtonNextState();
}
}

private void answerTextEvent(DocumentEvent e) {
System.out.println("answerTextEvent");
logger.info("answerTextEvent");
fillAnswer(question.answer);
setButtonNextState();
}

public void update(Observable o, Object arg) {
System.out.println("update");
logger.info("update");
fillAnswer(question.answer);
setButtonNextState();
}

private void noAnswerBox_actionPerformed(ActionEvent e) {
System.out.println("noAnswerBox_actionPerformed");
logger.info("noAnswerBox_actionPerformed");
if (noAnswerBox.isSelected()) {
numericalTextField.setText("");
}
Expand Down
Loading

0 comments on commit 8778934

Please sign in to comment.