[virtualcommons-svn] commit/irrigation: alllee: refactoring ChatPanel, fixing chat instructions tem
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-02-01 00:10:36
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/d1297849a7ca/ changeset: d1297849a7ca user: alllee date: 2012-02-01 01:10:22 summary: refactoring ChatPanel, fixing chat instructions template and default dollars per token affected #: 8 files diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 build.xml --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ -<!-- $Id: build.xml 330 2008-02-13 05:31:26Z alllee $ +<!-- $Id$ vim:sts=2:sw=2: - Version: $Revision: 330 $ + Version: $Revision$ --><project xmlns:ivy='antlib:org.apache.ivy.ant' name="irrigation" default="build-all" basedir="."> @@ -220,6 +220,9 @@ <!-- Clean up build by deleting build directories --><target name="clean"> + <echo message="Removing ${user.home}/.ant/cache" /> + <delete dir='${user.home}/.ant/cache' /> + <delete dir='${user.home}/.m2/repository/edu/asu/commons' /><delete dir="${build.dir}"/><delete dir="${test.build.dir}"/><delete dir='${lib.dir}'/> diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java @@ -20,12 +20,12 @@ import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import javax.swing.text.StyledDocument; -import javax.swing.text.html.HTMLEditorKit; import edu.asu.commons.event.ChatEvent; import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.EventTypeProcessor; import edu.asu.commons.net.Identifier; +import edu.asu.commons.ui.UserInterfaceUtils; /** * $Id$ @@ -148,11 +148,7 @@ messageScrollPane = new JScrollPane(messageWindow); addStylesToMessageWindow(); textEntryPanel = new TextEntryPanel(); - chatInstructionsPane = new JEditorPane(); - chatInstructionsPane.setContentType("text/html"); - chatInstructionsPane.setEditorKit(new HTMLEditorKit()); - chatInstructionsPane.setEditable(false); - chatInstructionsPane.setBackground(Color.WHITE); + chatInstructionsPane = UserInterfaceUtils.createInstructionsEditorPane(); JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); add(chatInstructionsScrollPane, BorderLayout.PAGE_START); add(messageScrollPane, BorderLayout.CENTER); @@ -164,9 +160,9 @@ // String chatHandle = getChatHandle(source); final StyledDocument document = messageWindow.getStyledDocument(); try { - document.insertString(document.getLength(), chatHandle, document.getStyle("bold")); - document.insertString(document.getLength(), message + "\n", document.getStyle("italic")); - messageWindow.setCaretPosition(document.getLength()); + document.insertString(0, chatHandle, document.getStyle("bold")); + document.insertString(chatHandle.length(), message + "\n", document.getStyle("italic")); + messageWindow.setCaretPosition(0); } catch (BadLocationException e) { e.printStackTrace(); diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java @@ -24,7 +24,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class ClientDataModel implements DataModel<RoundConfiguration> { +public class ClientDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = -3424256672940188027L; @@ -135,5 +135,10 @@ return getClientData().isImmediateNeighbor(otherClientData); } + @Override + public ServerConfiguration getExperimentConfiguration() { + return serverConfiguration; + } + } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java --- a/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java +++ b/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java @@ -1,7 +1,5 @@ package edu.asu.commons.irrigation.client; -import java.awt.Dimension; - import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -30,6 +28,7 @@ import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.SocketIdentifier; +import edu.asu.commons.ui.UserInterfaceUtils; /** * $Id$ @@ -105,13 +104,9 @@ JFrame frame = new JFrame(); IrrigationClient client = new IrrigationClient(); client.initialize(); - frame.setTitle("Virtual Commons Experiment Client: " + client.id); - frame.setPreferredSize(new Dimension(1200, 800)); -// frame.setResizable(false); - frame.getContentPane().add(client.getExperimentGameWindow()); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); + frame.setTitle("Client Window: " + client.getId()); + frame.add(client.getExperimentGameWindow()); + UserInterfaceUtils.maximize(frame); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java @@ -28,7 +28,7 @@ private static final String DEFAULT_LOG_FILE_DESTINATION = "irrigation.log"; - private static final double DEFAULT_DOLLARS_PER_TOKEN = 0.50d; + private static final double DEFAULT_DOLLARS_PER_TOKEN = 0.05d; public ServerConfiguration() { super(); @@ -95,9 +95,11 @@ } public String getChatInstructions() { - ST template = createStringTemplate(assistant.getProperty("chat-instructions")); - template.add("chatDuration", getChatDuration()); - return template.render(); + return createStringTemplate(assistant.getProperty("chat-instructions")).render(); + } + + public String getChatDurationInMinutes() { + return assistant.inMinutes(getChatDuration()) + " minutes"; } public double getTotalIncome(ClientData data) { diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java @@ -10,6 +10,7 @@ import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.net.Identifier; /** @@ -21,7 +22,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class GroupDataModel implements DataModel<RoundConfiguration> { +public class GroupDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = 5817418171228817123L; @@ -239,5 +240,10 @@ this.serverDataModel = serverDataModel; } + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } + } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java --- a/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java @@ -1,6 +1,5 @@ package edu.asu.commons.irrigation.server; -import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -12,6 +11,7 @@ import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; import edu.asu.commons.irrigation.conf.RoundConfiguration; +import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.net.Identifier; /** @@ -21,7 +21,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ -public class ServerDataModel implements DataModel<RoundConfiguration>, Serializable { +public class ServerDataModel implements DataModel<ServerConfiguration, RoundConfiguration> { private static final long serialVersionUID = -2633842942700901843L; @@ -102,4 +102,9 @@ public List<Identifier> getAllClientIdentifiers() { return new ArrayList<Identifier>(clientsToGroups.keySet()); } + + @Override + public ServerConfiguration getExperimentConfiguration() { + return roundConfiguration.getParentConfiguration(); + } } diff -r 190307106d6904b6c74e26061360fbde17e987f5 -r d1297849a7ca83a02f28ff7188ad826751754ce7 src/main/resources/configuration/asu/2011/pretest/irrigation.xml --- a/src/main/resources/configuration/asu/2011/pretest/irrigation.xml +++ b/src/main/resources/configuration/asu/2011/pretest/irrigation.xml @@ -85,7 +85,7 @@ infrastructure. Based on the <b>water delivery capacity</b> of the irrigation infrastructure and the availability of water you will be able to grow crops. Tokens earned in a round is the sum of tokens not invested plus tokens earned by growing -crops. Each token is worth 5 cents. In each round you will first decide how much to +crops. Each token is worth {dollarsPerToken}. In each round you will first decide how much to invest in the irrigation infrastructure. Based on the combined contributions of all 5 participants in your group in each round, your group can maintain the capacity of the irrigation infrastructure for growing crops. @@ -93,9 +93,9 @@ <p> We will now start a practice round to help illustrate the experiment. Before each -round in this experiment you will have a chat period of %d seconds where you can -send text messages to the other participants. You may discuss any aspect of the -exercise with two important exceptions: +round in this experiment you will have a chat period of {self.chatDurationInMinutes} +where you can send text messages to the other participants. You may discuss any +aspect of the exercise with two important exceptions: </p><ol><li>You are <b>not allowed</b> to promise the other participants Repository URL: https://bitbucket.org/virtualcommons/irrigation/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |