[virtualcommons-svn] commit/irrigation: alllee: replacing contribution results generation with Stri
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-02-04 00:18:45
|
1 new commit in irrigation: https://bitbucket.org/virtualcommons/irrigation/changeset/41a912f9af5c/ changeset: 41a912f9af5c user: alllee date: 2012-02-04 01:18:38 summary: replacing contribution results generation with StringTemplate affected #: 7 files diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a ivy.xml --- a/ivy.xml +++ b/ivy.xml @@ -5,7 +5,7 @@ <ivy-module version="2.0"><info organisation="edu.asu.commons" module="irrigation"/><dependencies> - <dependency org="edu.asu.commons" name="csidex" rev="0.3-SNAPSHOT"/> + <dependency org="edu.asu.commons" name="csidex" rev="0.4-SNAPSHOT"/><dependency org="org.jfree" name="jfreechart" rev="1.0.14"/></dependencies></ivy-module> diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java --- a/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java +++ b/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java @@ -472,6 +472,7 @@ } + // FIXME: replace with StringTemplate public void displayContributionInformation(final ClientData clientData) { GroupDataModel groupDataModel = clientData.getGroupDataModel(); int totalContributedTokens = groupDataModel.getTotalContributedTokens(); diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/client/GamePanel.java --- a/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java +++ b/src/main/java/edu/asu/commons/irrigation/client/GamePanel.java @@ -32,7 +32,7 @@ * * Primary in-round game interface window for the irrigation game. Displays the * - * FIXME: refactor layout + * FIXME: refactor layout, currently a hodge podge of fixed sizes... * * @author <a href='mailto:All...@as...'>Allen Lee</a>, Sanket Joshi * @version $Rev$ diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a 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,5 +1,7 @@ package edu.asu.commons.irrigation.client; +import java.awt.Dimension; + import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -28,7 +30,6 @@ 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$ @@ -41,6 +42,8 @@ */ public class IrrigationClient { + private static final Dimension DEFAULT_FRAME_DIMENSION = new Dimension(1200, 800); + enum ClientState { UNCONNECTED, CONNECTED, READY, RUNNING, DENIED }; @@ -104,9 +107,13 @@ JFrame frame = new JFrame(); IrrigationClient client = new IrrigationClient(); client.initialize(); - frame.setTitle("Client Window: " + client.getId()); - frame.add(client.getExperimentGameWindow()); - UserInterfaceUtils.maximize(frame); + frame.setTitle("Virtual Commons Experiment Client: " + client.id); + frame.setPreferredSize(DEFAULT_FRAME_DIMENSION); +// frame.setResizable(false); + frame.getContentPane().add(client.getExperimentGameWindow()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); } }; SwingUtilities.invokeLater(createGuiRunnable); diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java @@ -47,7 +47,7 @@ } public int getTokenEndowment() { - return getIntProperty("token-endowment", 10); + return getIntProperty("token-endowment"); } /** @@ -173,5 +173,16 @@ st.add("showExitInstructions", showExitInstructions); return st.render(); } + + public String generateContributionSummary(ClientData clientData) { + ST st = createStringTemplate(getContributionSummaryTemplate()); + st.add("clientData", clientData); + st.add("groupDataModel", clientData.getGroupDataModel()); + return st.render(); + } + + private String getContributionSummaryTemplate() { + return getProperty("contribution-summary"); + } } diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a 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 @@ -172,7 +172,7 @@ } public String getInvestmentInstructions() { - return getProperty("investment-instructions"); + return render(getProperty("investment-instructions")); } public int getNumberOfQuizPages() { @@ -199,6 +199,10 @@ public double getDollarsPerToken() { return getDoubleProperty("dollars-per-token", DEFAULT_DOLLARS_PER_TOKEN); } + + public int getTokenEndowment() { + return getIntProperty("token-endowment", 10); + } public static int getTokensEarned(int waterCollected) { if (waterCollected < 150) { diff -r 7eddd3cd0a9c4aaaec33711bd55df034e0918ce6 -r 41a912f9af5cedbc37a7b5574bacd2b78fa8889a 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 @@ -310,15 +310,15 @@ <entry key="investment-instructions"><![CDATA[ <p> -You have been endowed with 10 tokens to invest. You must make a decision about -how much you wish to invest [0,10] in the irrigation infrastructure. You can -see the relationship between total investment and irrigation infrastructure in -the table below. After you have entered the number of tokens you'd like to -invest, hit the enter key or click the submit button to confirm your -investment. When everybody has made their decision, the total investment will -be calculated and the overall irrigation infrastructure will be displayed. -Each token you invest corresponds to one percent of infrastructure efficiency, -so if you invest 10 tokens you are contributing 10% to the overall +You have been endowed with {self.tokenEndowment} tokens to invest. You must make a decision about +how much you wish to invest in the irrigation infrastructure (choosing a number +between 0 and {self.tokenEndowment}. You can see the relationship between total +investment and irrigation infrastructure in the table below. After you have entered +the number of tokens you'd like to invest, hit the enter key or click the submit +button to confirm your investment. When everybody has made their decision, the total +investment will be calculated and the overall irrigation infrastructure will be +displayed. Each token you invest corresponds to one percent of infrastructure +efficiency, so if you invest 10 tokens you are contributing 10% to the overall infrastructure efficiency. </p><table border="1" cellspacing="2" cellpadding="2"> @@ -424,5 +424,25 @@ </p> ]]></entry> - +<entry key="contribution-summary"> +<![CDATA[ +<h1>Contributions Summary</h1> +<hr> +<p> +Your group invested a total of <b>{groupDataModel.totalContributedTokens} tokens</b> this round, resulting in an infrastructure efficiency of <b>{groupDataModel.infrastructureEfficiency}%</b> and a water delivery capacity of <b>{groupDataModel.irrigationCapacity} cubic feet per second</b>. +The amount of water available to pass through your canal is {groupDataModel.actualWaterDeliveryCapacity cubic feet per second}. +</p> +<table border=2 cellspacing=2 cellpadding=3> +<tr> +<th></th></th><th>Infrastructure Efficiency</th><th>Water Delivery Capacity</th><th>Water Availability</th> +</tr> +<tr> +<td>Before Investment</td><td>{groupDataModel.infrastructureEfficiencyBeforeInvestment}%</td><td>{groupDataModel.irrigationCapacityBeforeInvestment} cubic feet per second</td><td>{groupDataModel.actualWaterDeliveryCapacity}</td> +</tr> +<tr> +<td>After Investment</td><td>{groupDataModel.infrastructureEfficiency}%</td><td>{groupDataModel.irrigationCapacity} cubic feet per second</td><td>{groupDataModel.actualWaterDeliveryCapacity}</td> +</tr> +</table> +]]> +</entry></properties> 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. |