virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 61)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <al...@us...> - 2009-10-24 21:20:03
|
Revision: 332 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=332&view=rev Author: alllee Date: 2009-10-24 21:19:51 +0000 (Sat, 24 Oct 2009) Log Message: ----------- updated configuration parameters / instructions Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-23 19:17:09 UTC (rev 331) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-24 21:19:51 UTC (rev 332) @@ -16,9 +16,15 @@ <entry key="round8">round8.xml</entry> <entry key="round9">round9.xml</entry> <entry key="round10">round10.xml</entry> +<entry key="round11">round11.xml</entry> +<entry key="round12">round12.xml</entry> +<entry key="round13">round13.xml</entry> +<entry key="round14">round14.xml</entry> +<entry key="round15">round15.xml</entry> +<entry key="round16">round16.xml</entry> <entry key="wait-for-participants">true</entry> -<entry key="number-of-rounds">11</entry> +<entry key="number-of-rounds">17</entry> <entry key="undisrupted-flow-required">true</entry> @@ -584,11 +590,12 @@ <br><br> To continue to the next page, please answer the following question:<br> <form> -If you invest 7 of the 10 tokens you started with, and you put 202 cf of water on -your field, what is the total number of tokens you will have earned for that round? +If you invest 7 of the 10 tokens you started with, and you put 202 cf of water +on your field, what is the <b>total number of tokens</b> you will have earned +for that round? <br> <input type="radio" name="q8" value="3">3<br> -<input type="radio" name="q8" value="4">4<br> +<input type="radio" name="q8" value="5">5<br> <input type="radio" name="q8" value="7">7<br> <input type="radio" name="q8" value="13">13<br> <br><br> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-10-23 19:17:09 UTC (rev 331) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-10-24 21:19:51 UTC (rev 332) @@ -306,7 +306,7 @@ Given an existing infrastructure efficiency of 20%, if the five participants invest a <b>total of 29 additional tokens</b>, what is the new irrigation infrastructure efficiency? -(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> +(<small><b>Note: only enter a number, you don't need to add the % sign</b></small>)<br> <input type="text" name="q3" value = ""> <br><br> @@ -590,11 +590,12 @@ <br><br> To continue to the next page, please answer the following question:<br> <form> -If you invest 7 of the 10 tokens you started with, and you put 202 cf of water on -your field, what is the total number of tokens you will have earned for that round? +If you invest 7 of the 10 tokens you started with, and you put 202 cf of water +on your field, what is the <b>total number of tokens</b> you will have earned +for that round? <br> <input type="radio" name="q8" value="3">3<br> -<input type="radio" name="q8" value="4">4<br> +<input type="radio" name="q8" value="5">5<br> <input type="radio" name="q8" value="7">7<br> <input type="radio" name="q8" value="13">13<br> <br><br> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml 2009-10-23 19:17:09 UTC (rev 331) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml 2009-10-24 21:19:51 UTC (rev 332) @@ -2,8 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key='max-canal-flow-capacity'>40</entry> -<entry key='max-client-flow-capacity'>25</entry> <entry key="practice-round">true</entry> <entry key="instructions"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-23 19:17:28
|
Revision: 331 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=331&view=rev Author: alllee Date: 2009-10-23 19:17:09 +0000 (Fri, 23 Oct 2009) Log Message: ----------- added begin experimetn button Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-23 18:18:35 UTC (rev 330) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-23 19:17:09 UTC (rev 331) @@ -49,6 +49,8 @@ private JButton displayInvestmentButton; private StringBuilder builder = new StringBuilder(); + + private JButton beginExperimentButton; /** * This is the default constructor */ @@ -70,6 +72,7 @@ buttonPanel.add(getBeginChatButton()); buttonPanel.add(getDisplayInvestmentButton()); buttonPanel.add(getStartRoundButton()); + buttonPanel.add(getBeginExperimentButton()); add(buttonPanel, BorderLayout.NORTH); editorPane = new HtmlEditorPane(); editorPane.setEditable(false); @@ -113,6 +116,19 @@ return beginChatButton; } + private JButton getBeginExperimentButton() { + if (beginExperimentButton == null) { + beginExperimentButton = new JButton("Begin experiment"); + beginExperimentButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + facilitator.sendBeginExperimentRequest(); + } + + }); + } + return beginExperimentButton; + } + private JButton getDisplayInvestmentButton() { if (displayInvestmentButton == null) { displayInvestmentButton = new JButton("Show Investment Screen"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-23 18:18:44
|
Revision: 330 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=330&view=rev Author: alllee Date: 2009-10-23 18:18:35 +0000 (Fri, 23 Oct 2009) Log Message: ----------- adding water supply capacity instructions to label Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-23 16:44:30 UTC (rev 329) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-23 18:18:35 UTC (rev 330) @@ -578,9 +578,11 @@ addCenterComponent(getInvestTokensPanel()); StringBuilder builder = new StringBuilder(); builder.append( - String.format("<h2>The current infrastructure efficiency is %d%%, with an irrigation flow capacity of %d cubic feet per second.</h2>", + String.format( + "<h2>The current infrastructure efficiency is %d%%. The irrigation capacity is %d cubic feet per second and the water supply is %d cubic feet per second.</h2>", infrastructureEfficiency, - group.calculateFlowCapacity(infrastructureEfficiency) + group.calculateFlowCapacity(infrastructureEfficiency), + roundConfiguration.getWaterSupplyCapacity() )); builder.append(getServerConfiguration().getInvestmentInstructions()); tokenInstructionsEditorPane.setText(builder.toString()); @@ -607,11 +609,11 @@ else { instructionsBuilder.append( String.format("<p>The current infrastructure efficiency is %d%% but will be degraded by %d%% during this round." + - "The current irrigation capacity is %d cfps with a maximum canal capacity is %d cfps.</p><hr/>", + "The current irrigation capacity is %d cfps and the available water supply is %d cfps.</p><hr/>", clientDataModel.getGroupDataModel().getInfrastructureEfficiency(), roundConfiguration.getInfrastructureDegradationFactor(), irrigationCapacity, - roundConfiguration.getMaximumCanalFlowCapacity() + roundConfiguration.getWaterSupplyCapacity() )); } setInstructions(instructionsBuilder.toString()); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 16:44:30 UTC (rev 329) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 18:18:35 UTC (rev 330) @@ -43,7 +43,7 @@ return getIntProperty("infrastructure-degradation-factor", 25); } - public int getMaximumCanalFlowCapacity() { + public int getWaterSupplyCapacity() { return getIntProperty("max-canal-flow-capacity", 30); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 16:44:30 UTC (rev 329) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 18:18:35 UTC (rev 330) @@ -156,11 +156,11 @@ } public int getInitialFlowCapacity() { - return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getMaximumCanalFlowCapacity()); + return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); } public int getFlowCapacity() { - return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getMaximumCanalFlowCapacity()); + return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); } public void resetCurrentlyAvailableFlowCapacity() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-23 16:44:45
|
Revision: 329 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=329&view=rev Author: alllee Date: 2009-10-23 16:44:30 +0000 (Fri, 23 Oct 2009) Log Message: ----------- adding variable canal treatment. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java Added Paths: ----------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round1.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round10.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round11.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round12.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round13.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round14.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round15.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round16.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round2.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round3.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round4.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round5.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round6.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round7.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round8.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round9.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-23 04:01:06 UTC (rev 328) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-23 16:44:30 UTC (rev 329) @@ -293,7 +293,8 @@ private JTextField createTextField() { JTextField textField = new JTextField(); textField.setEditable(false); - textField.setBackground(Color.LIGHT_GRAY); +// textField.setBackground(Color.LIGHT_GRAY); + textField.setBackground(Color.YELLOW); return textField; } @@ -424,7 +425,6 @@ getTokensNotInvestedTextField().setText("" + clientData.getUninvestedTokens()); getTokensEarnedTextField().setText("" + clientData.getTokensEarnedFromWaterCollected()); getTotalTokensEarnedTextField().setText("" + clientData.getAllTokensEarnedThisRound()); - // getScoreBoxPanel().update(clientDataModel); getMiddleWindowPanel().update(clientDataModel); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 04:01:06 UTC (rev 328) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 16:44:30 UTC (rev 329) @@ -44,7 +44,7 @@ } public int getMaximumCanalFlowCapacity() { - return getIntProperty("max-canal-flow-capacity", 40); + return getIntProperty("max-canal-flow-capacity", 30); } public int getMaximumTokenInvestment() { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 04:01:06 UTC (rev 328) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 16:44:30 UTC (rev 329) @@ -33,7 +33,7 @@ private int maximumAvailableFlowCapacity = 0; private int infrastructureEfficiency; - + // infrastructure efficiency before investment (but post decline) private int initialInfrastructureEfficiency; private int totalContributedTokens = 0; @@ -156,11 +156,11 @@ } public int getInitialFlowCapacity() { - return calculateFlowCapacity(initialInfrastructureEfficiency); + return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getMaximumCanalFlowCapacity()); } public int getFlowCapacity() { - return calculateFlowCapacity(infrastructureEfficiency); + return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getMaximumCanalFlowCapacity()); } public void resetCurrentlyAvailableFlowCapacity() { Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/irrigation.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,734 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> +<!--<entry key="hostname">localhost</entry>--> +<entry key="hostname">@SERVER_ADDRESS@</entry> +<entry key="port">@PORT_NUMBER@</entry> +<entry key="round0">round0.xml</entry> +<entry key="round1">round1.xml</entry> +<entry key="round2">round2.xml</entry> +<entry key="round3">round3.xml</entry> +<entry key="round4">round4.xml</entry> +<entry key="round5">round5.xml</entry> +<entry key="round6">round6.xml</entry> +<entry key="round7">round7.xml</entry> +<entry key="round8">round8.xml</entry> +<entry key="round9">round9.xml</entry> +<entry key="round10">round10.xml</entry> +<entry key="round11">round11.xml</entry> +<entry key="round12">round12.xml</entry> +<entry key="round13">round13.xml</entry> +<entry key="round14">round14.xml</entry> +<entry key="round15">round15.xml</entry> +<entry key="round16">round16.xml</entry> + +<entry key="wait-for-participants">true</entry> +<entry key="number-of-rounds">17</entry> + +<entry key="undisrupted-flow-required">true</entry> + +<entry key="q1">4</entry> +<entry key="q2">identity</entry> +<entry key="q3">49</entry> +<entry key="q4">76</entry> +<entry key="q5">20</entry> +<entry key="q6">5</entry> +<entry key="q7">25</entry> +<entry key="q8">7</entry> +<entry key="q9">19</entry> +<entry key="q10">1.50</entry> + +<entry key='final-instructions'> +<![CDATA[ +<p> +The experiment is almost over. We have a brief survey for you to fill out while the +facilitator prepares your payments. When the facilitator has finished preparing +payments and you have all completed your surveys your computer number will be +called. You can then go next door to receive your payment. For privacy reasons we +must pay you one at a time. +</p> +<p> +Thanks for participating! +</p> +]]> +</entry> + + +<entry key="initial-instructions"> +<![CDATA[ +<h3>Welcome</h3> +<p> +Please be patient while the experimental environment is set up. +<b>Please do not close this window or open any other windows.</b> +</p> +]]> +</entry> + + +<entry key="facilitator-instructions"> +<![CDATA[ +<h3>Facilitator Instructions</h3> +<p> +Welcome to the facilitator interface. This interface allows you to control +the experiment. You may only modify configuration parameters <b>before</b> +you start the experiment by selecting the Configuration menu. When all the +participants are ready to begin the experiment, you can start the experiment +by selecting Experiment -> Start. After a round has been completed you +will be able to view the statistics for all of the participants. You can +begin the next round by selecting Round -> Start. +</p> +]]> +</entry> + + + +<entry key="general-instructions0"> +<![CDATA[ +<center><h3>Welcome to the experiment. Please do not close this window or open any +other applications.</h3></center> +]]> +</entry> + +<entry key="general-instructions1"> +<![CDATA[ +<h3>General Instructions</h3> +<p>Welcome. You have already earned 5 dollars by showing up for this exercise. +You can earn more, up to an extra 25 dollars, by participating in the exercise +which will last for about one hour. You will participate in this exercise as a +part of a group. Each group has five participants. Your group has been formed +by randomly assigning you to FOUR other participants in the room. The amount +of money you earn will depend on the decisions made by you and the rest of the +group. That is, your earnings will depend on your decisions as well as the +other members of your group. +</p> +<p> +This exercise mimics decisions people make in irrigation systems. In each round you +will receive 10 tokens which you can choose to keep or invest in the irrigation +infrastructure (for example canals and water diversion structures). Depending on the +state of repair of the irrigation infrastructure, it will be capable of directing +water to your field when you use your water diversion structure (called an +irrigation gate). Depending on the amount of water you can get to your field, you +can grow crops. Depending on the number of crops you grow you earn tokens. Each +token is worth 5 cents and you will be paid cash in private at the end of the +experiment based on the number of tokens you earned. +</p> +<p> +The experiment consists of a number of rounds. In each round you will first make a +decision as to how much to invest in the irrigation infrastructure. Without periodic +investment, the irrigation infrastructure will break down over time. Based on the +combined contributions of all 5 participants in your group in each round, as +explained below, your group can maintain the performance of the irrigation +infrastructure. The condition of the irrigation infrastructure determines +its capacity to deliver water which you can use to grow crops. +</p> +]]> +</entry> + +<entry key="general-instructionsq1"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +<form> +How many OTHER people in the room will be in your group?<br> +<input type="radio" name="q1" value="0">0<br> +<input type="radio" name="q1" value="1">1<br> +<input type="radio" name="q1" value="4">4<br> +<input type="radio" name="q1" value="Everybody">Everybody<br> +<br><br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> + +<entry key="general-instructions2"> +<![CDATA[ +<h3>Chat</h3> +<p>Before each round you will have a chat period of 40 seconds 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 +side-payments or threaten them with any consequence after the experiment is +finished. +</li> +<li>You are <b>not allowed to reveal your real identity</b>.</li> +</ol> +<p> +We will be monitoring the chat traffic. If we detect any violation of these rules, +we will have to remove <b>all members of the group where the violation occurred</b> +from the experiment. That group will have to wait until the entire experiment is +finished to receive their payment. +</p> +<p> +You will see a text box appear on your screen when a chat period starts. The amount +of time left in the chat period will be shown at the <b>top left of the screen</b>.<br> +</p> +]]> +</entry> + +<entry key="general-instructionsq2"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +<form> +Which of the following topics are you <b>not allowed</b> to discuss in chat?<br> +<input type="radio" name="q2" value="weather">the weather<br> +<input type="radio" name="q2" value="identity">your real identity<br> +<input type="radio" name="q2" value="experiment">the experiment<br> +<input type="radio" name="q2" value="earnings">what you will do with the money you earn from this experiment<br> +<br><br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> + +<entry key="general-instructions3"> +<![CDATA[ +<h3>Creating Irrigation Infrastructure</h3> +<p> +After the chat period ends you and each other participant will be given 10 tokens. +You must then decide what to do with these tokens. You may decide to invest in the +irrigation infrastructure or to keep the tokens. If you keep the tokens you will +earn at a minimum 10 tokens X 5 cents = $0.50 for each round. If you do this every +round after twenty rounds you will end up with at least $10 (plus any crops that you +may be able to grow as we will discuss later). Your total earnings for +participating in the experiment would then be at least $10 plus your show-up payment +of $5, for a grand total of at least $15. +</p> +<p> +On the other hand, if you invest some of your tokens in the irrigation +infrastructure, you may be able to earn more than this amount by growing crops. If +the irrigation infrastructure is operating at near maximum capacity you can earn +close to $1.50 each round. Thus if you grow crops you can roughly triple your +earnings compared to doing nothing. The actual earnings depend on the decisions you +and the other participants in your group make in terms of investment and when to +grow crops. +</p> +<p> +In each round the condition of the irrigation system declines such that its water +delivery efficiency drops by 25%. Investment is necessary to keep the irrigation +infrastructure from deteriorating. If you decide to invest in irrigation +infrastructure you must decide on the amount to invest out of your initial 10 +tokens. Keep in mind that the irrigation infrastructure must exceed a certain level +before you can grow crops. The tokens invested by all participants in your group +are added together and will total up to an amount 0 and 50 tokens. Each token +invested increases the irrigation infrastructure efficiency by one percentage point, +up to a <b>maximum of 100%</b>. This means that if the irrigation infrastructure +efficiency is at 80% it would not make sense for your group to invest a total of 50 +tokens, as any investment beyond 20 tokens would be wasted. In the table below you +can see the water delivery capacity measured in water units per second as a function +of the condition of the irrigation infrastructure. When the infrastructure is at +100% efficiency, 40 cubic feet of water per second (cfps) will be available. When the +irrigation infrastructure efficiency falls below 45%, there is no capacity left for +transporting water and thus there is no water available for anyone. +</p> +<p> +Your initial irrigation infrastructure will start at 75% efficiency but <b>will +carry over from round to round</b>. As an example, let's say that no one in a +group invests any tokens in the first round. The irrigation infrastructure +efficiency will be set at 75% for that first round. The table below lists the water +delivery in cubic feet per second (cfps) corresponding to the irrigation infrastructure +efficiency. If you look at the second to last row you can see that at 75% +efficiency the irrigation infrastructure will deliver 35 cfps. So in the first +round the group will have 35 cfps of water available to them. +</p> +<p> +Recall that each round the irrigation infrastructure efficiency deteriorates by 25%, +so at the start of the second round the infrastructure efficiency decreases to 50%. +At this point all five members of the group decide to invest 7 tokens each. This +increases the infrastructure efficiency by 35%, resulting in a total infrastructure +efficiency of 85%. If you look at the table again you can see that an +infrastructure efficiency of 85% will deliver 40 cfps. +</p> +<p> +The actual amount of water that is available for the group depends on the amount of +water available. Your group might have created an irrigation infrastructure with a +capacity of 40 cfps, but due to lack of rainfall only 30 cfps is available. On the +other hand, if the infrastructure capacity allows 30 cfps and 40 cfps of water is available +to the system, only 30 cfps can be delivered. +</p> + +<p> +To recap, at the beginning of each round you will be informed of the current +irrigation infrastructure efficiency. You will then decide how many tokens (between +0 and 10) to invest in the irrigation infrastructure. After everybody has made +their decision, you will be notified of the condition of the irrigation +infrastructure and the corresponding water delivery capacity. +</p> + +<b>Table 1:</b> The water delivery capacity as a function of the irrigation +infrastructure condition +<table border="1" cellspacing="2" cellpadding="2"> +<thead> +<th>Infrastructure efficiency (percent)</th> +<th>Water delivery (cubic feet per second)</th> +</thead> +<tr> +<td>≤ 45</td><td>0</td> +</tr> +<tr> +<td>46-51</td><td>5</td> +</tr> +<tr> +<td>52-55</td><td>10</td> +</tr> +<tr> +<td>56-58</td><td>15</td> +</tr> +<tr> +<td>59-61</td><td>20</td> +</tr> +<tr> +<td>62-65</td><td>25</td> +</tr> +<tr> +<td>66-70</td><td>30</td> +</tr> +<tr> +<td>71-80</td><td>35</td> +</tr> +<tr> +<td>81-100</td><td>40</td> +</tr> +</table> + +]]> +</entry> + +<entry key="general-instructionsq3"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following questions:<br> +<form> +Question 1:<br> +Given an existing infrastructure efficiency of 20%, if the five participants invest +a <b>total of 29 additional tokens</b>, what is the new irrigation infrastructure +efficiency? +(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> +<input type="text" name="q3" value = ""> +<br><br> + +Question 2:<br> +Given an existing infrastructure efficiency of 50%, if <b>two participants invest 10 tokens each</b> +while the <b>three other participants invest 2 tokens each</b>, what is the new +irrigation infrastructure efficiency? +(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> +<input type="text" name="q4" value = ""> +<br><br> +<input type="submit" name="submit" value="Submit"><br> +<br> +</form> +]]> +</entry> + +<entry key="general-instructions4"> +<![CDATA[ +<h3>Growing crops</h3> +<p>There are <b>five</b> participants in each group, each of which is randomly assigned to +one of the five positions, A, B, C, D or E. Below is a screenshot of the +graphical interface representation of the irrigation system. Water comes from +the box to the left and the five players are located from upstream (leftmost) +to downstream (rightmost) accordingly. To illustrate, assume you are in +position C. The black lines represent "gates" that you open and close by +clicking on the large button on the lower left corner of the screen. +Each round consists of 50 seconds and the amount of time left in the +experiment is indicated by a bar at the top of the screen. +</p> +<img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> +<br><br> +<p> +You can irrigate your field during the round by opening your gate. Your +earnings depend on the amount of water you can draw onto your fields and will +be explained in more detail on the next page. The speed at which you can grow +a crop depends on the amount of water available to you <b>at the time that you +open your gate</b>. The maximum flow capacity of the main canal shared by A, +B, C, D, and E is forty cubic feet per second. +</p> +<p> +The maximum amount of water that can flow through your gate when it is opened +is 25 cubic feet per second. If other people are using the canal, the water +flow available to you might be less, and it may take longer to get water to +your field since you are also limited by the amount of water that is flowing +through the shared canal. +</p> +]]> +</entry> + +<entry key="general-instructionsq4"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +Question 3:<br> +<form> +What is the minimum time to deliver 500 cubic feet of water to your field when +your maximum water flow capacity is available? +<br> +<input type="radio" name="q5" value="12.5">12.5 seconds<br> +<input type="radio" name="q5" value="20">20 seconds<br> +<input type="radio" name="q5" value="25">25 seconds<br> +<input type="radio" name="q5" value="50">50 seconds<br> +<br><br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> + + +<entry key="general-instructions5"> +<![CDATA[ +<h3>Positions A,B,C,D and E</h3> +<p> +The animation above illustrates how water flows to each player when their gates are +opened and closed. When a player opens their gate, the black line will rotate to a +vertical position, allowing water (represented by white dots) to flow to them. Note +that the water available downstream of a player with an open port is reduced, +illustrated by a narrowing of the canal. +</p> +<p> +Access to water depends on your position as shown in the window. Water originates +in the box at the upper left part of the screen and travels to the right. Thus, +participant A will have first access to the available water. Water not used by +participant A is then available to be used by participant B. Water not used by +participants A and B is then available for C. Water not used by participants A, B +and C is available for D. Finally, water not used by participants A, B, C and D is +available for E. +</p> +<p> +You can only get water to your field if you have water available to your position. +Suppose that the total irrigation capacity available is 40 cfps and 40 cfps of water +is available. If player A opens their gate they will consume 25 cfps of water and 15 +cfps is left for B. Suppose on the other hand, A does not open the gate, then a +total of 40 cfps is left for B, allowing B to extract water at the maximum rate of +25 cfps. +</p> +<p> +As another example, suppose that the canal system has been allowed to deteriorate +so that the total irrigation capacity available is 20 cfps. While player A’s gate is +open, no water is available for B. If A is NOT using water, 20 cfps is available for +B. +</p> +]]> +</entry> + +<entry key="general-instructionsq5"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +<form> +Suppose the irrigation efficiency is between 71 and 80% so that the canal flow +capacity is 30 cfps. If A opens their gate and diverts water at 25 cfps what is the +available water flow for B? +<br> +<input type="radio" name="q6" value="30">30 cfps<br> +<input type="radio" name="q6" value="25">25 cfps<br> +<input type="radio" name="q6" value="15">15 cfps<br> +<input type="radio" name="q6" value="5">5 cfps<br> +<br><br> +If the canal flow capacity available is 25 cfps and A,B,C and D are not using water, +what is the available water for E? +<br> +<input type="radio" name="q7" value="40">40 cfps<br> +<input type="radio" name="q7" value="25">25 cfps<br> +<input type="radio" name="q7" value="15">15 cfps<br> +<input type="radio" name="q7" value="0">0 cfps<br> + +<input type="submit" name="submit" value="Submit"> +<br><br> +</form> +]]> +</entry> + +<entry key="general-instructions6"> +<![CDATA[ +<h3>How to grow crops</h3> +<p> +To start growing crops, click on the yellow button labeled "open gate". +This will open your irrigation gate and allow water to flow to your field if it is +available. The text on the button will change to "close gate" - if +you would like to close the gate and stop extracting water from the canal, just +click on the yellow button again. Your gate will close and the text on the button +will change back to "open gate". +</p> +<p> +The amount of water units (cubic feet) your field has received is shown on the +screen, as well as the resulting amount of tokens earned from growing a crop. +The number of tokens earned in each round depends on how much water you have +diverted to your field. If you receive less than 150 cubic feet (cf) the crop has +not received enough water to grow a crop and you will thus not receive any tokens. +The maximum earnings are received when between 500 cf and 549 cf are diverted to +your field. If more than 549 cf water is diverted to your field, this will +negatively affect the growth of the crop (i.e. overwatering) and less tokens will be +earned. In the table below you can see the amount of tokens earned for amount of +water applied to your field. +</p> +<b>Table 2</b>: Earnings resulting from the amount of water applied to your field. + +<table border="1" cellspacing="2" cellpadding="2"> +<thead> +<th>Water units received (cubic feet)</th> +<th>Tokens earned</th> +</thead> +<tr> +<td>< 150</td><td>0</td> +</tr> +<tr> +<td>150-199</td><td>1</td> +</tr> +<tr> +<td>200-249</td><td>4</td> +</tr> +<tr> +<td>250-299</td><td>10</td> +</tr> +<tr> +<td>300-349</td><td>15</td> +</tr> +<tr> +<td>350-399</td><td>18</td> +</tr> +<tr> +<td>400-499</td><td>19</td> +</tr> +<tr> +<td>500-549</td><td>20</td> +</tr> +<tr> +<td>550-649</td><td>19</td> +</tr> +<tr> +<td>650-699</td><td>18</td> +</tr> +<tr> +<td>700-749</td><td>15</td> +</tr> +<tr> +<td>750-799</td><td>10</td> +</tr> +<tr> +<td>800-849</td><td>4</td> +</tr> +<tr> +<td>850-899</td><td>1</td> +</tr> +<tr> +<td>> 899</td><td>0</td> +</tr> +</table> + +Your earnings at the end of the round depend on your investment and the number of +tokens received for the crop. For example, suppose you invest 6 out of the 10 +tokens you are endowed with at the start of the round and you receive 333 cubic feet +of water. Your total earnings will be the amount of tokens leftover from your +initial endowment (10 - 6) plus the tokens you earned from your crop (15 tokens for +333 cubic feet of water, see Table 2). The total number of tokens earned is 19 +($0.85 since each token is $0.05). + +]]> +</entry> + +<entry key='water-collected-to-tokens-table'> +<![CDATA[ +<table border="1" cellspacing="2" cellpadding="2"> +<thead> +<th>Water applied to your field</th> +<th>Tokens earned</th> +</thead> +<tr> +<td>< 150</td><td>0</td> +</tr> +<tr> +<td>150-199</td><td>1</td> +</tr> +<tr> +<td>200-249</td><td>4</td> +</tr> +<tr> +<td>250-299</td><td>10</td> +</tr> +<tr> +<td>300-349</td><td>15</td> +</tr> +<tr> +<td>350-399</td><td>18</td> +</tr> +<tr> +<td>400-499</td><td>19</td> +</tr> +<tr> +<td>500-549</td><td>20</td> +</tr> +<tr> +<td>550-649</td><td>19</td> +</tr> +<tr> +<td>650-699</td><td>18</td> +</tr> +<tr> +<td>700-749</td><td>15</td> +</tr> +<tr> +<td>750-799</td><td>10</td> +</tr> +<tr> +<td>800-849</td><td>4</td> +</tr> +<tr> +<td>850-899</td><td>1</td> +</tr> +<tr> +<td>> 899</td><td>0</td> +</tr> +</table> +]]> +</entry> + + +<entry key="general-instructionsq6"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +<form> +If you invest 7 of the 10 tokens you started with, and you put 202 cf of water on +your field, what is the total number of tokens you will have earned for that round? +<br> +<input type="radio" name="q8" value="3">3<br> +<input type="radio" name="q8" value="4">4<br> +<input type="radio" name="q8" value="7">7<br> +<input type="radio" name="q8" value="13">13<br> +<br><br> +If you invest all 10 tokens you start with, and you put 555 cf of water on your +field, what is the total number of tokens your will have earned for that round? +<br> +<input type="radio" name="q9" value="10">10<br> +<input type="radio" name="q9" value="19">19<br> +<input type="radio" name="q9" value="20">20<br> +<input type="radio" name="q9" value="29">29<br> +<br><br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> + +<entry key="general-instructions7"> +<![CDATA[ +<h3>Scores</h3> +<p> +The total number of tokens collected during a round is shown on the screen with the +message: +<br><br> +Total tokens earned this round: 0 +<br><br> +This the total of tokens not invested in irrigation structure plus additional +tokens earned by growing a crop. +<br> +You will also see the scores of the other participants summarized on the screen. +Finally, you will see the water flow capacity of each player at any given moment, as +illustrated in the figure below. + +]]> +</entry> + + +<entry key="general-instructionsq7"> +<![CDATA[ +<br><br> +To continue to the next page, please answer the following question:<br> +<form> +Each token is worth 5 cents, thus if you collected 30 tokens in a round you earned: +<br> +<input type="radio" name="q10" value=".15">$0.15<br> +<input type="radio" name="q10" value=".50">$0.50<br> +<input type="radio" name="q10" value="1.50">$1.50<br> +<input type="radio" name="q10" value="2.50">$2.50<br> +<br><br> +<input type="submit" name="submit" value="Submit"> +<br><br> +</form> +]]> +</entry> + +<entry key="general-instructions8"> +<![CDATA[ +<p> +We will now start with two practice rounds. This practice round will not +contribute to your earnings – it is intended to acquaint you with the +functioning of the exercise environment. +</p> +<p> +You will first chat via text with other participants in your group and then +decide how much you wish to invest in irrigation infrastructure maintenance. +After all investment decisions have been made you will begin the actual round +and make real-time decisions on when to open your gates and irrigate your +fields. +</p> +<p> +If you have any questions feel free to raise your hand and to ask your question. +<b>Do you have any questions so far?</b> +</p> +]]> +</entry> + +<entry key="undisrupted-flow-instructions"> +<![CDATA[ +<p> +If the flow of water is disrupted while your gate is open your crop growing progress +will be halted. +</p> +]]> +</entry> + + +<entry key="investment-instructions"> +<![CDATA[ +<h3>Invest tokens in the irrigation infrastructure</h3> +<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 +infrastructure efficiency. +</p> +<table border="1" cellspacing="2" cellpadding="2"> +<thead> +<th>Total Infrastructure Efficiency (percent)</th> +<th>Water delivery (cubic feet per second)</th> +</thead> +<tr> +<td> ≤ 45</td><td>0</td> +</tr> +<tr> +<td>46-51</td><td>5</td> +</tr> +<tr> +<td>52-55</td><td>10</td> +</tr> +<tr> +<td>56-58</td><td>15</td> +</tr> +<tr> +<td>59-61</td><td>20</td> +</tr> +<tr> +<td>62-65</td><td>25</td> +</tr> +<tr> +<td>66-70</td><td>30</td> +</tr> +<tr> +<td>71-80</td><td>35</td> +</tr> +<tr> +<td>81-100</td><td>40</td> +</tr> +</table> +]]> +</entry> + +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round0.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> +<entry key='max-canal-flow-capacity'>40</entry> +<entry key='max-client-flow-capacity'>25</entry> +<entry key="practice-round">true</entry> + +<entry key="instructions"> +<![CDATA[ +<p> +We will now start with two practice rounds. This practice round will not contribute +to your earnings. If you have any questions feel free to raise your hand and to ask +your question. +<br> +<b>Do you have any questions?</b> +</p> +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round1.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round1.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round1.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> +<entry key="practice-round">true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Practice Round 2</h3> +<p> +This is the second practice round of the experiment. If you have any questions +after participating in the first round, please ask them now. +</p> +]]> +</entry> +</properties> + Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round10.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round10.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round10.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>36</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 9 Instructions</h3> +<p> +This round is the same as the previous round. +</p> +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round11.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round11.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round11.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + + +<entry key='max-canal-flow-capacity'>25</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 10 Instructions</h3> +<p> +This round is the same as the previous round. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round12.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round12.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round12.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>32</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 11 Instructions</h3> +<p> +This round is the same as the previous rounds. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round13.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round13.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round13.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>38</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 12 Instructions</h3> +<p> +This round is the same as previous rounds. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round14.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round14.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round14.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>21</entry> + + +<entry key="instructions"> +<![CDATA[ +<h3>Round 13 Instructions</h3> +<p> +This round is the same as previous rounds. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round15.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round15.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round15.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>29</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 14 Instructions</h3> +<p> +This is round 14/20. The infrastructure has been degraded by 10%. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round16.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round16.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round16.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>39</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 15 Instructions</h3> +<p> +This is the final round. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round2.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round2.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round2.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='reset-infrastructure-efficiency'>true</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 1 Instructions</h3> +<p> +This is the first actual round of the experiment. Before this round begins +you will have the opportunity to text chat with the other participant for +forty seconds, then decide on your level of investment in the irrigation +infrastructure. After the total irrigation infrastructure investment has been +determined you will begin the experiment and make decisions on when to open +your irrigation gates and grow crops. +</p> +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round3.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round3.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round3.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 2 Instructions</h3> +<p> +This round is the same as the previous round. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round4.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round4.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round4.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 3 Instructions</h3> +<p> +This round is the same as the previous round. +</p> +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round5.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round5.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round5.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<p> +This round is the same as previous rounds. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round6.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round6.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round6.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 5 Instructions</h3> +<p> +This round is the same as the previous round. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round7.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round7.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round7.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>27</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 6 Instructions</h3> +<p> +In the past rounds the water supply was stable at a level of 30 cubic +feet per second for each round. In the following rounds the average water +supply remains 30 cfps, but the actual water supply varies each round +between 25 cfps and 35 cfps. After you have made your investment decisions, +the infrastructure level is announced as well as the actual water supply for +that round. Please remember that the water supply is independent of your +irrigation capacity. If you develop an irrigation capacity of 30 cfps but the +water supply is only 20 cfps, you are only getting 20 cfps down your canal. +</p> + +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round8.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round8.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round8.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>31</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 7 Instructions</h3> +<p> +This round is the same as the previous round. +</p> +]]> +</entry> +</properties> Added: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round9.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round9.xml (rev 0) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/t4/round9.xml 2009-10-23 16:44:30 UTC (rev 329) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Irrigation experiment round configuration</comment> + +<entry key='max-canal-flow-capacity'>22</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 8 Instructions</h3> +<p> +This round is the same as the previous round. +</p> + +]]> +</entry> +</properties> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-23 04:01:15
|
Revision: 328 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=328&view=rev Author: alllee Date: 2009-10-23 04:01:06 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Final updates before sending first version out to Indiana. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-10-23 04:01:06 UTC (rev 328) @@ -14,7 +14,6 @@ import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JFrame; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; @@ -60,6 +59,9 @@ private JEditorPane chatInstructionsPane; + private JTextField chatField; + + public ChatPanel() { initGuiComponents(); } @@ -71,8 +73,6 @@ private class TextEntryPanel extends JPanel { private JProgressBar timeLeftProgressBar; - private JLabel timeLeftLabel; - private JTextField chatField; private Identifier targetIdentifier = Identifier.ALL; public TextEntryPanel() { @@ -93,13 +93,6 @@ } }); JPanel timeLeftPanel = new JPanel(); -// timeLeftPanel.setLayout(new BoxLayout(timeLeftPanel, BoxLayout.LINE_AXIS)); - -// timeLeftLabel = new JLabel("40"); -// timeLeftLabel.setFont(new Font("Arial", Font.BOLD, 14)); -// timeLeftLabel.setForeground(new Color(0x0000dd)); -// timeLeftPanel.add(new JLabel(" Time left: ")); -// timeLeftPanel.add(timeLeftLabel); timeLeftProgressBar = new JProgressBar(0, 60); timeLeftProgressBar.setStringPainted(true); timeLeftPanel.setLayout(new BorderLayout()); @@ -132,13 +125,6 @@ private final static String HANDLE_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - private final static String CHAT_INSTRUCTIONS = "<h3>Chat Instructions</h3><p>You now have the opportunity to chat for 40 seconds." + - " You can discuss whatever you want related to the experiment with some restrictions. You may not promise the other participant(s) side " + - "payments or threaten them with any consequence (e.g., physical violence) after the experiment is finished. Also, you may not reveal your real identity." + - "We are monitoring chat traffic - if we notice a violation of the rules we will remove the group from the room until the other groups are finished with the experiment.</p>" + - "<p>You can send messages by typing in the text field at the bottom of the screen and then hit return or click send. " + - "The time left for the discussion is displayed above the text field at the bottom of the screen.</p>"; - private static String[] HANDLES; private Map<Identifier, String> chatHandles = new HashMap<Identifier, String>(); @@ -195,7 +181,6 @@ chatInstructionsPane.setEditorKit(new HTMLEditorKit()); chatInstructionsPane.setEditable(false); JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); - chatInstructionsPane.setText(CHAT_INSTRUCTIONS); add(chatInstructionsScrollPane, BorderLayout.PAGE_START); add(messageScrollPane, BorderLayout.CENTER); // add(participantButtonPanel, BorderLayout.EAST); @@ -239,6 +224,7 @@ public void setIrrigationClient(IrrigationClient client) { this.irrigationClient = client; + chatInstructionsPane.setText(irrigationClient.getServerConfiguration().getChatInstructions()); client.getEventChannel().add(this, new EventTypeProcessor<ChatEvent>(ChatEvent.class) { public void handle(final ChatEvent chatEvent) { SwingUtilities.invokeLater(new Runnable() { @@ -252,4 +238,8 @@ }); } + public void setFocusInChatField() { + chatField.requestFocusInWindow(); + } + } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-23 04:01:06 UTC (rev 328) @@ -563,7 +563,7 @@ } - public void updateSubmitTokenScreenDisplay() { + public void updateTokenInstructionsPanel() { Runnable runnable = new Runnable() { public void run() { GroupDataModel group = clientDataModel.getGroupDataModel(); @@ -573,7 +573,6 @@ infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { - System.err.println("group was not null, efficiency is: " + group.getInfrastructureEfficiency() + " degrading by " + clientDataModel.getRoundConfiguration().getInfrastructureDegradationFactor()); infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); } addCenterComponent(getInvestTokensPanel()); @@ -602,12 +601,19 @@ instructionsBuilder.append("<hr/>"); int irrigationCapacity = clientDataModel.getGroupDataModel().getFlowCapacity(); int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); - - instructionsBuilder.append( - String.format("<p><b>The irrigation capacity is %d cfps and the maximum amount of water you can collect per second is %d cfps.</b></p>", - irrigationCapacity, - Math.min(irrigationCapacity, clientCapacity) - )); + if (roundConfiguration.shouldResetInfrastructureEfficiency()) { + instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75%."); + } + else { + instructionsBuilder.append( + String.format("<p>The current infrastructure efficiency is %d%% but will be degraded by %d%% during this round." + + "The current irrigation capacity is %d cfps with a maximum canal capacity is %d cfps.</p><hr/>", + clientDataModel.getGroupDataModel().getInfrastructureEfficiency(), + roundConfiguration.getInfrastructureDegradationFactor(), + irrigationCapacity, + roundConfiguration.getMaximumCanalFlowCapacity() + )); + } setInstructions(instructionsBuilder.toString()); } addCenterComponent(getInstructionsPanel()); @@ -624,11 +630,11 @@ public void initializeChatWindow() { SwingUtilities.invokeLater(new Runnable() { public void run() { - //canalPanelAnimation.stopTimer(); - startTimer(clientDataModel.getRoundConfiguration().getChatDuration() * 1000L); + startTimer(getServerConfiguration().getChatDuration() * 1000L); ChatPanel chatPanel = getChatPanel(); chatPanel.initialize(clientDataModel.getAllClientIdentifiers()); addCenterComponent( chatPanel ); + chatPanel.setFocusInChatField(); } }); } @@ -641,7 +647,7 @@ public void actionPerformed(ActionEvent event) { final long timeRemaining = endTime - System.currentTimeMillis(); if (timeRemaining < 0) { - addCenterComponent(getInvestTokensPanel()); + updateTokenInstructionsPanel(); getInvestedTokensTextField().requestFocusInWindow(); timer.stop(); timer = null; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-23 04:01:06 UTC (rev 328) @@ -109,7 +109,7 @@ IrrigationClient client = new IrrigationClient(); client.initialize(); frame.setTitle("Virtual Commons Experiment Client: " + client.id); - frame.setPreferredSize(new Dimension(1100, 800)); + frame.setPreferredSize(new Dimension(1200, 800)); // frame.setResizable(false); frame.getContentPane().add(client.getExperimentGameWindow()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -201,7 +201,7 @@ }); channel.add(this, new EventTypeProcessor<DisplaySubmitTokenRequest>(DisplaySubmitTokenRequest.class) { public void handle(DisplaySubmitTokenRequest request) { - experimentGameWindow.updateSubmitTokenScreenDisplay(); + experimentGameWindow.updateTokenInstructionsPanel(); } }); channel.add(this, new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-23 04:01:06 UTC (rev 328) @@ -145,9 +145,6 @@ return getBooleanProperty("chat-enabled-before-round", true); } - public int getChatDuration() { - return getIntProperty("chat-duration", 40); - } /** * Returns the duration of the round in seconds. Set to default of 50 seconds per round. Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-23 04:01:06 UTC (rev 328) @@ -161,5 +161,22 @@ public int getNumberOfGeneralInstructionPages() { return assistant.getIntProperty("general-instruction-pages", 8); } + + public int getChatDuration() { + return assistant.getIntProperty("chat-duration", 60); + } + public String getChatInstructions() { + return assistant.getProperty("chat-instructions", + String.format( + "<h3>Chat Instructions</h3><p>You now have the opportunity to chat for %d seconds. You can discuss whatever you want" + + " related to the experiment with some restrictions. You may not promise the other participant(s) side " + + "payments or threaten them with any consequence (e.g., physical violence) after the experiment is finished. Also, you may not reveal your real identity." + + "We are monitoring chat traffic - if we notice a violation of the rules we will remove the group from the room until the other groups are finished with the experiment.</p>" + + "<p>You can send messages by typing in the text field at the bottom of the screen and then hit return or click send. " + + "The time left for the discussion is displayed above the text field at the bottom of the screen.</p>", + getChatDuration()) + ); + } + } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-23 04:01:06 UTC (rev 328) @@ -25,11 +25,8 @@ private final Map<Identifier, ClientData> clients = new LinkedHashMap<Identifier, ClientData>(); - private transient ServerDataModel serverDataModel; - private RoundConfiguration roundConfiguration; - private transient Logger logger = Logger.getLogger(GroupDataModel.class.getName()); private int currentlyAvailableFlowCapacity = 0; @@ -42,7 +39,6 @@ private int totalContributedTokens = 0; public GroupDataModel(ServerDataModel serverDataModel) { - this.serverDataModel = serverDataModel; setRoundConfiguration(serverDataModel.getRoundConfiguration()); } @@ -53,21 +49,6 @@ public Set<Identifier> getClientIdentifiers() { return Collections.unmodifiableSet(clients.keySet()); } - /** Here instead of tokens there would be get in general tokens, or the profit earned - * but at present it would be just currentTokens - * - * @param id - * @return - */ - public int getAward(Identifier id) { - ClientData state = (ClientData) clients.get(id); - if (state == null) { - // FIXME: perhaps we should just return 0 instead. - throw new IllegalArgumentException( - "no client state available for: " + id); - } - return state.getAllTokensEarnedThisRound(); - } public void addClient(ClientData clientData) { clients.put(clientData.getId(), clientData); @@ -90,10 +71,6 @@ clients.clear(); } - public void setServerDataModel(ServerDataModel serverDataModel) { - this.serverDataModel = serverDataModel; - } - public Map<Identifier, ClientData> getClientDataMap() { return Collections.unmodifiableMap(clients); } @@ -118,35 +95,26 @@ for(ClientData clientData : getClientDataMap().values()) { totalContributedTokens += clientData.getInvestedTokens(); } - getLogger().info("total contributed tokens: " + totalContributedTokens); updateInfrastructureEfficiency(totalContributedTokens); - currentlyAvailableFlowCapacity = maximumAvailableFlowCapacity = getFlowCapacity(); - getLogger().info("maximum available flow capacity = "+ maximumAvailableFlowCapacity); } private void updateInfrastructureEfficiency(int totalContributedTokens) { RoundConfiguration roundConfiguration = getRoundConfiguration(); - int currentRoundNumber = roundConfiguration.getRoundNumber(); // initialize infrastructure efficiency - System.err.println("current round number: " + currentRoundNumber); - System.err.println("initial infrastructure efficiency: " + infrastructureEfficiency); if ( roundConfiguration.shouldResetInfrastructureEfficiency() ) { - System.err.println("initializing infrastructure efficiency to default initial value: " + roundConfiguration.getInitialInfrastructureEfficiency()); infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { // degrade by infrastructure-degradation-factor, clamp at 0 - getLogger().info("degrading infrastructure efficiency: " + infrastructureEfficiency); infrastructureEfficiency = Math.max(infrastructureEfficiency - roundConfiguration.getInfrastructureDegradationFactor(), 0); - getLogger().info("New infrastructure efficiency: " + infrastructureEfficiency); } // set original infrastructure efficiency before token contributions + getLogger().info("initial infrastructure efficiency: " + infrastructureEfficiency); initialInfrastructureEfficiency = infrastructureEfficiency; // add total invested tokens to infrastructure efficiency, clamp at // 100 infrastructureEfficiency = Math.min(100, totalContributedTokens + infrastructureEfficiency); - System.err.println("total infrastructure efficiency: " + infrastructureEfficiency); } /** Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -16,21 +16,9 @@ <entry key="round8">round8.xml</entry> <entry key="round9">round9.xml</entry> <entry key="round10">round10.xml</entry> -<entry key="round11">round11.xml</entry> -<entry key="round12">round12.xml</entry> -<entry key="round13">round13.xml</entry> -<entry key="round14">round14.xml</entry> -<entry key="round15">round15.xml</entry> -<entry key="round16">round16.xml</entry> -<entry key="round17">round17.xml</entry> -<entry key="round18">round18.xml</entry> -<entry key="round19">round19.xml</entry> -<entry key="round20">round20.xml</entry> -<entry key="round21">round21.xml</entry> - <entry key="wait-for-participants">true</entry> -<entry key="number-of-rounds">12</entry> +<entry key="number-of-rounds">11</entry> <entry key="undisrupted-flow-required">true</entry> @@ -538,7 +526,7 @@ <![CDATA[ <table border="1" cellspacing="2" cellpadding="2"> <thead> -<th>Water units received (cubic feet)</th> +<th>Water applied to your field</th> <th>Tokens earned</th> </thead> <tr> @@ -658,15 +646,16 @@ <entry key="general-instructions8"> <![CDATA[ <p> -We will now start with two practice rounds. This practice round will not contribute to your earnings – -it is intended to acquaint you with the functioning of the exercise environment. +We will now start with two practice rounds. This practice round will not +contribute to your earnings – it is intended to acquaint you with the +functioning of the exercise environment. </p> <p> -You will first chat via text with other participants in your group for 40 seconds, -then decide how much you wish to invest in irrigation infrastructure -maintenance. After all investment decisions have been made you will begin the -actual round and make real-time decisions on when to open your gates and irrigate -your fields. +You will first chat via text with other participants in your group and then +decide how much you wish to invest in irrigation infrastructure maintenance. +After all investment decisions have been made you will begin the actual round +and make real-time decisions on when to open your gates and irrigate your +fields. </p> <p> If you have any questions feel free to raise your hand and to ask your question. Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -9,8 +9,7 @@ <![CDATA[ <h3>Round 9 Instructions</h3> <p> -This round is the same as the previous round, but the irrigation -infrastructure efficiency has declined by 10%. +This round is the same as the previous round. </p> ]]> </entry> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -21,10 +21,6 @@ you have any questions, please ask them now. </p> -<p> -In this round, the infrastructure has declined by 10%. -</p> - ]]> </entry> </properties> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -3,14 +3,13 @@ <properties> <comment>Irrigation experiment round configuration</comment> -<entry key='infrastructure-degradation-factor'>10</entry> +<entry key='infrastructure-degradation-factor'>85</entry> <entry key="instructions"> <![CDATA[ <h3>Round 5 Instructions</h3> <p> -This round is the same as the previous round. The irrigation infrastructure -efficiency has experienced a decline of 10%. +This round is the same as the previous round. </p> ]]> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -3,14 +3,13 @@ <properties> <comment>Irrigation experiment round configuration</comment> -<entry key='infrastructure-degradation-factor'>85</entry> +<entry key='infrastructure-degradation-factor'>10</entry> <entry key="instructions"> <![CDATA[ <h3>Round 6 Instructions</h3> <p> -This round is the same as the previous round, but the irrigation -infrastructure efficiency has experienced a severe decline of 85%. +This round is the same as the previous round. </p> ]]> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -9,8 +9,7 @@ <![CDATA[ <h3>Round 7 Instructions</h3> <p> -This round is the same as the previous round, but the irrigation -infrastructure efficiency has declined by 30%. +This round is the same as the previous round. </p> ]]> </entry> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml 2009-10-23 00:27:56 UTC (rev 327) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml 2009-10-23 04:01:06 UTC (rev 328) @@ -9,8 +9,7 @@ <![CDATA[ <h3>Round 8 Instructions</h3> <p> -This round is the same as the previous round, but the irrigation -infrastructure efficiency has declined by 10%. +This round is the same as the previous round. </p> ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-23 00:28:06
|
Revision: 327 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=327&view=rev Author: alllee Date: 2009-10-23 00:27:56 +0000 (Fri, 23 Oct 2009) Log Message: ----------- interface improvements, getting rid of timer, not creating new canal panels every time. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-23 00:27:56 UTC (rev 327) @@ -245,6 +245,13 @@ repaint(); } } + + public void stopTimer() { + if (timer != null) { + timer.stop(); + timer = null; + } + } /* * This will process the balls according to their position Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-23 00:27:56 UTC (rev 327) @@ -40,7 +40,7 @@ private Random generator = new Random(); - private boolean enableBallAnimation = true; + private final static boolean enableBallAnimation = true; private int maximumIrrigationCapacity; @@ -61,10 +61,17 @@ public CanalPanel(ClientDataModel clientDataModel) { super(); //when totalContributed bandwidth = 1.0, you dont see the canal line - this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); - this.clientDataModel = clientDataModel; - initialize(); + setClientDataModel(clientDataModel); } + + public void setClientDataModel(ClientDataModel clientDataModel) { + if (timer != null) { + timer.stop(); + } + this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); + this.clientDataModel = clientDataModel; + initialize(); + } /** * @@ -112,25 +119,23 @@ graphics2D.fillRect(gate[5].getX(), gate[5].getY(),10,gate[5].getHeight()); //////////////////////Animation Logic//////////////////////////// - if (enableBallAnimation) { - graphics.setColor(Color.white); - // int ballCounter = 0; - for(int i=0;i<BALLCOUNT;i++){ - if((balls[i].getPosition() == 1)||(balls[i].getPosition() == 2) || (balls[i].getPosition()==3) - || (balls[i].getPosition() == 4) || (balls[i].getPosition() == 5)){ - if(!((!gate[balls[i].getPosition()-1].isOpenGate())&& balls[i].getY() >= (gate[balls[i].getPosition()-1].getY()+gate[balls[i].getPosition()-1].getHeight()))) - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - else{ - if(balls[i].getPosition() != 0){ - if(gate[balls[i].getPosition() - 6].getHeight() != 0) - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - else{ - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - } - } + graphics.setColor(Color.white); + // int ballCounter = 0; + for(int i=0;i<BALLCOUNT;i++){ + if((balls[i].getPosition() == 1)||(balls[i].getPosition() == 2) || (balls[i].getPosition()==3) + || (balls[i].getPosition() == 4) || (balls[i].getPosition() == 5)){ + if(!((!gate[balls[i].getPosition()-1].isOpenGate())&& balls[i].getY() >= (gate[balls[i].getPosition()-1].getY()+gate[balls[i].getPosition()-1].getHeight()))) + graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + } + else{ + if(balls[i].getPosition() != 0){ + if(gate[balls[i].getPosition() - 6].getHeight() != 0) + graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + } + else{ + graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + } + } } } @@ -412,7 +417,10 @@ } public void endRound() { - initializeBalls(); + if (timer != null) { + timer.stop(); + } + timer = null; closeAllGates(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-10-23 00:27:56 UTC (rev 327) @@ -1,9 +1,7 @@ package edu.asu.commons.irrigation.client; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -13,12 +11,12 @@ import java.util.List; import java.util.Map; -import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.JTextPane; @@ -72,6 +70,7 @@ } private class TextEntryPanel extends JPanel { + private JProgressBar timeLeftProgressBar; private JLabel timeLeftLabel; private JTextField chatField; private Identifier targetIdentifier = Identifier.ALL; @@ -94,12 +93,17 @@ } }); JPanel timeLeftPanel = new JPanel(); - timeLeftPanel.setLayout(new BoxLayout(timeLeftPanel, BoxLayout.LINE_AXIS)); - timeLeftLabel = new JLabel("40"); - timeLeftLabel.setFont(new Font("Arial", Font.BOLD, 14)); - timeLeftLabel.setForeground(new Color(0x0000dd)); - timeLeftPanel.add(new JLabel(" Time left: ")); - timeLeftPanel.add(timeLeftLabel); +// timeLeftPanel.setLayout(new BoxLayout(timeLeftPanel, BoxLayout.LINE_AXIS)); + +// timeLeftLabel = new JLabel("40"); +// timeLeftLabel.setFont(new Font("Arial", Font.BOLD, 14)); +// timeLeftLabel.setForeground(new Color(0x0000dd)); +// timeLeftPanel.add(new JLabel(" Time left: ")); +// timeLeftPanel.add(timeLeftLabel); + timeLeftProgressBar = new JProgressBar(0, 60); + timeLeftProgressBar.setStringPainted(true); + timeLeftPanel.setLayout(new BorderLayout()); + timeLeftPanel.add(timeLeftProgressBar, BorderLayout.CENTER); add(timeLeftPanel, BorderLayout.PAGE_START); add(chatField, BorderLayout.CENTER); @@ -118,8 +122,10 @@ chatField.requestFocusInWindow(); } - private void setTimeRemaining(long timeRemaining) { - timeLeftLabel.setText(String.format(" %d s", timeRemaining / 1000L)); + private void setTimeLeft(long timeLeft) { + int timeLeftInSeconds = (int) (timeLeft / 1000L); + timeLeftProgressBar.setValue(timeLeftInSeconds); + timeLeftProgressBar.setString(String.format("%d sec", timeLeftInSeconds)); } } @@ -166,8 +172,8 @@ .addStyle("italic", defaultStyle), true); } - public void setTimeRemaining(long timeRemaining) { - textEntryPanel.setTimeRemaining(timeRemaining); + public void setTimeLeft(long timeLeft) { + textEntryPanel.setTimeLeft(timeLeft); } private String getChatHandle(Identifier identifier) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-23 00:27:56 UTC (rev 327) @@ -40,7 +40,6 @@ * * The root experiment window placed in the client's JFrame. * - * FIXME: refactor this class. * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ @@ -107,8 +106,6 @@ private int numberOfGeneralInstructionPages; - private JLabel infrastructureEfficiencyLabel = new JLabel("Current infrastructure efficiency: "); - public ExperimentGameWindow(IrrigationClient client) { this.client = client; this.clientDataModel = client.getClientDataModel(); @@ -142,30 +139,14 @@ tokenInstructionsEditorPane = createInstructionsEditorPane(); tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); investTokensPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); - tokenInstructionsEditorPane.setText(getServerConfiguration().getInvestmentInstructions()); tokenInstructionsEditorPane.setCaretPosition(0); tokenInstructionsEditorPane.repaint(); investTokensPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); - investTokensPanel.add(infrastructureEfficiencyLabel, BorderLayout.NORTH); investTokensPanel.setBackground(Color.WHITE); } return investTokensPanel; } - public void updateInfrastructureEfficiencyLabel() { - GroupDataModel group = clientDataModel.getGroupDataModel(); - RoundConfiguration roundConfiguration = clientDataModel.getRoundConfiguration(); - int infrastructureEfficiency = 0; - if (roundConfiguration.isPracticeRound() || roundConfiguration.isFirstRound()) { - infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); - } - else { - System.err.println("group was not null, efficiency is: " + group.getInfrastructureEfficiency() + " degrading by " + clientDataModel.getRoundConfiguration().getInfrastructureDegradationFactor()); - infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); - } - infrastructureEfficiencyLabel.setText("Current infrastructure efficiency: " + infrastructureEfficiency); - } - private JPanel getSubmitTokenPanel() { if (submitTokenPanel == null) { submitTokenPanel = new JPanel(); @@ -233,6 +214,7 @@ getInstructionsPanel().add(getCanalAnimationPanel(), BorderLayout.PAGE_START); } else { + getInstructionsPanel().remove(getCanalAnimationPanel()); } getInstructionsPanel().revalidate(); @@ -272,7 +254,7 @@ return nextButton; } - private JPanel getCanalAnimationPanel() { + private CanalAnimationPanel getCanalAnimationPanel() { if (canalAnimationPanel == null) { canalAnimationPanel = new CanalAnimationPanel(40); } @@ -337,7 +319,7 @@ else { investedTokensTextField.setText(""); instructionsBuilder.delete(0, instructionsBuilder.length()); - instructionsBuilder.append("\nPlease enter your tokens within the range 0 - 10"); + instructionsBuilder.append("<h3>Please enter your tokens within the range 0 - 10</h3>"); instructionsBuilder.append(getServerConfiguration().getInvestmentInstructions()); tokenInstructionsEditorPane.setText(instructionsBuilder.toString()); } @@ -345,7 +327,7 @@ catch(NumberFormatException e){ investedTokensTextField.setText(""); instructionsBuilder.delete(0, instructionsBuilder.length()); - instructionsBuilder.append("\nYou only have between 0 and 10 to invest. Please choose a number between 0 and 10 and try again."); + instructionsBuilder.append("<h3>You only have between 0 and 10 to invest. Please choose a number between 0 and 10 and try again.</h3>"); instructionsBuilder.append(getServerConfiguration().getInvestmentInstructions()); tokenInstructionsEditorPane.setText(instructionsBuilder.toString()); } @@ -380,6 +362,7 @@ public void startRound(final RoundConfiguration configuration) { Runnable runnable = new Runnable() { public void run() { + getCanalAnimationPanel().stopTimer(); disableInstructions(); addCenterComponent(irrigationGamePanel); irrigationGamePanel.startRound(); @@ -394,7 +377,7 @@ /* * updates the mainIrrigationGameWindow Panel and adds - * instructionsScrollPane with the debreifing information + * instructionsScrollPane with the debriefing information */ public void endRound(final EndRoundEvent event) { irrigationGamePanel.endRound(); @@ -583,8 +566,25 @@ public void updateSubmitTokenScreenDisplay() { Runnable runnable = new Runnable() { public void run() { + GroupDataModel group = clientDataModel.getGroupDataModel(); + RoundConfiguration roundConfiguration = clientDataModel.getRoundConfiguration(); + int infrastructureEfficiency = 0; + if (roundConfiguration.isPracticeRound() || roundConfiguration.isFirstRound()) { + infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); + } + else { + System.err.println("group was not null, efficiency is: " + group.getInfrastructureEfficiency() + " degrading by " + clientDataModel.getRoundConfiguration().getInfrastructureDegradationFactor()); + infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); + } addCenterComponent(getInvestTokensPanel()); - updateInfrastructureEfficiencyLabel(); + StringBuilder builder = new StringBuilder(); + builder.append( + String.format("<h2>The current infrastructure efficiency is %d%%, with an irrigation flow capacity of %d cubic feet per second.</h2>", + infrastructureEfficiency, + group.calculateFlowCapacity(infrastructureEfficiency) + )); + builder.append(getServerConfiguration().getInvestmentInstructions()); + tokenInstructionsEditorPane.setText(builder.toString()); getInvestedTokensTextField().requestFocusInWindow(); } }; @@ -647,18 +647,9 @@ timer = null; } else { - chatPanel.setTimeRemaining(timeRemaining); + chatPanel.setTimeLeft(timeRemaining); } } - - private void sleep() { - long prevTime = System.currentTimeMillis(); - while((System.currentTimeMillis() - prevTime) < 5000) { - - chatPanel.setEnabled(false); - } - - } }); timer.start(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-23 00:27:56 UTC (rev 327) @@ -8,7 +8,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.BoxLayout; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JLabel; @@ -46,19 +45,10 @@ private JPanel jPanelDownStreamWindow = null; private JPanel downloadScreenPanel = null; - private ScoreBoxPanel scoreBoxPanel; + private IrrigationClient client; - /** - * This is the default constructor - */ - public IrrigationClient client; + private JProgressBar timeLeftProgressBar; - public Dimension screenSize; - - public JProgressBar timeLeftProgressBar; - - public JProgressBar timeRemainingjProgressBar = null; - private JLabel timeRemainingjLabel = null; private JTextField timeRemainingjText; @@ -73,7 +63,7 @@ private MiddleWindowPanel middleWindowPanel; - private JLabel dashBoardLabel = null; + private JLabel gateSwitchLabel = null; private JLabel scoreBoardLabel = null; @@ -158,10 +148,10 @@ scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); scoreBoardLabel.setText("WATER COLLECTED TO TOKENS EARNED TABLE"); - dashBoardLabel = new JLabel(); - dashBoardLabel.setBounds(new Rectangle(13,225+100+35,530,20)); - dashBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - dashBoardLabel.setText("YOUR DASHBOARD"); + gateSwitchLabel = new JLabel(); + gateSwitchLabel.setBounds(new Rectangle(13,225+100+35,530,20)); + gateSwitchLabel.setHorizontalAlignment(SwingConstants.CENTER); + gateSwitchLabel.setText("DASHBOARD"); totalContributedBandwidthTextjLabel = new JLabel(); totalContributedBandwidthTextjLabel.setBounds(new Rectangle(200, 18, 55, 17)); totalContributedBandwidthTextjLabel.setText(""); @@ -174,14 +164,10 @@ downloadScreenPanel = new JPanel(); downloadScreenPanel.setLayout(null); downloadScreenPanel.setName("downloadScreenPanel"); - downloadScreenPanel.setBackground(Color.white); + downloadScreenPanel.setBackground(Color.WHITE); downloadScreenPanel.add(getCenterPanel(),null); downloadScreenPanel.add(getTimeLeftProgressBar(), null); - // downloadScreenPanel.add(timeRemainingjLabel, null); - // downloadScreenPanel.add(timeRemainingjText,null); - // downloadScreenPanel.add(totalContributedBandwidthjLabel, null); - // downloadScreenPanel.add(totalContributedBandwidthTextjLabel, null); - downloadScreenPanel.add(dashBoardLabel, null); + downloadScreenPanel.add(gateSwitchLabel, null); downloadScreenPanel.add(scoreBoardLabel, null); } return downloadScreenPanel; @@ -209,10 +195,14 @@ return centerPanel; } - private JPanel createCanalPanel(ClientDataModel clientDataModel) { - canalPanel = new CanalPanel(clientDataModel); - canalPanel.setSize(new Dimension(1098, 123)); - + private JPanel getCanalPanel(ClientDataModel clientDataModel) { + if (canalPanel == null) { + canalPanel = new CanalPanel(clientDataModel); + canalPanel.setSize(new Dimension(1098, 123)); + } + else { + canalPanel.setClientDataModel(clientDataModel); + } return canalPanel; } @@ -227,26 +217,27 @@ jPanelUpStreamWindow.setLayout(new BorderLayout()); jPanelUpStreamWindow.setBackground(new Color(186, 226, 237)); jPanelUpStreamWindow.setBounds(new Rectangle(13, 225+100+50, 530, 326)); - jPanelUpStreamWindow.add(getGateSwitchButton(), BorderLayout.CENTER); + jPanelUpStreamWindow.add(getGateSwitchButton(), BorderLayout.NORTH); + jPanelUpStreamWindow.add(getControlPanel(), BorderLayout.CENTER); } return jPanelUpStreamWindow; } - private final static String OPEN_GATE_LABEL = "Click here to open your gate"; - private final static String CLOSE_GATE_LABEL = "Click here to close your gate"; + private final static String OPEN_GATE_LABEL = "OPEN YOUR GATE"; + private final static String CLOSE_GATE_LABEL = "CLOSE YOUR GATE"; private JButton getGateSwitchButton() { if (gateSwitchButton == null) { gateSwitchButton = new JButton(OPEN_GATE_LABEL); gateSwitchButton.setFont(new Font("sansserif", Font.TRUETYPE_FONT, 18)); - // gateSwitchButton.setPreferredSize(new Dimension(100, 100)); gateSwitchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { open = !open; - gateSwitchButton.setText( open ? CLOSE_GATE_LABEL : OPEN_GATE_LABEL ); if (open) { client.openGate(); + gateSwitchButton.setText(CLOSE_GATE_LABEL); } else { client.closeGate(); + gateSwitchButton.setText(OPEN_GATE_LABEL); } } }); @@ -255,11 +246,6 @@ } private JPanel getControlPanel() { - JPanel panel = new JPanel(); - panel.setPreferredSize(new Dimension(530, 326)); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - panel.add(getGateSwitchButton()); - JPanel bottomInformationPanel = new JPanel(); GroupLayout layout = new GroupLayout(bottomInformationPanel); bottomInformationPanel.setLayout(layout); @@ -294,8 +280,7 @@ .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); layout.setVerticalGroup(verticalGroup); - panel.add(bottomInformationPanel); - return panel; + return bottomInformationPanel; } private JTextField getWaterCollectedTextField() { @@ -405,11 +390,11 @@ private void setProgressBarColor(int timeLeft) { if (timeLeft < 10) { // timeLeftProgressBar.setForeground( Color.RED ); - timeLeftProgressBar.setBackground( Color.RED ); +// timeLeftProgressBar.setBackground( Color.RED ); // return Color.RED; } else { - timeLeftProgressBar.setBackground( Color.GREEN ); +// timeLeftProgressBar.setBackground( Color.GREEN ); } } /** @@ -422,7 +407,7 @@ String timeLeftString = String.format("%d sec", timeLeft); timeLeftProgressBar.setValue( timeLeft ); timeLeftProgressBar.setString(timeLeftString); - setProgressBarColor(timeLeft); +// setProgressBarColor(timeLeft); for (final ClientData clientData : clientDataModel.getClientDataMap().values()) { if (clientData.isGateOpen()) { canalPanel.openGate(clientData.getPriority()); @@ -555,8 +540,7 @@ * fills in the panels depending on the priority of the client */ public void fillPanels(ClientDataModel clientDataModel) { - // TODO Auto-generated method stub - centerPanel.add(createCanalPanel(clientDataModel)); + centerPanel.add(getCanalPanel(clientDataModel)); //switch(clientGameState.getPriority()){ downloadScreenPanel.add(getJPanelUpStreamWindow(),null); Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 20:12:59 UTC (rev 326) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-23 00:27:56 UTC (rev 327) @@ -312,7 +312,7 @@ Given an existing infrastructure efficiency of 20%, if the five participants invest a <b>total of 29 additional tokens</b>, what is the new irrigation infrastructure efficiency? -<br> +(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> <input type="text" name="q3" value = ""> <br><br> @@ -320,7 +320,7 @@ Given an existing infrastructure efficiency of 50%, if <b>two participants invest 10 tokens each</b> while the <b>three other participants invest 2 tokens each</b>, what is the new irrigation infrastructure efficiency? -<br> +(<b>Note: only enter a number, you don't need to add the % sign</b>)<br> <input type="text" name="q4" value = ""> <br><br> <input type="submit" name="submit" value="Submit"><br> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 20:13:06
|
Revision: 326 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=326&view=rev Author: alllee Date: 2009-10-22 20:12:59 +0000 (Thu, 22 Oct 2009) Log Message: ----------- fixing discrepancy between round degradation and instructions Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 19:32:59 UTC (rev 325) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 20:12:59 UTC (rev 326) @@ -9,8 +9,8 @@ <![CDATA[ <h3>Round 5 Instructions</h3> <p> -This round is the same as the previous round, but the irrigation -infrastructure efficiency has experienced a severe decline of 85%. +This round is the same as the previous round. The irrigation infrastructure +efficiency has experienced a decline of 10%. </p> ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 19:33:08
|
Revision: 325 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=325&view=rev Author: alllee Date: 2009-10-22 19:32:59 +0000 (Thu, 22 Oct 2009) Log Message: ----------- updating pom and build.properties.example for effective jetty:run use. jetty:run should also invoke ant deploy first though... Modified Paths: -------------- irrigation/trunk/build.properties.example irrigation/trunk/pom.xml Modified: irrigation/trunk/build.properties.example =================================================================== --- irrigation/trunk/build.properties.example 2009-10-22 19:16:19 UTC (rev 324) +++ irrigation/trunk/build.properties.example 2009-10-22 19:32:59 UTC (rev 325) @@ -20,7 +20,7 @@ # part of the URL you can just set the server.address and leave this property # blank since the build.xml that loads this properties file sets the codebase # url to the ${server.address} + "/foraging" by default. -codebase.url=http://${server.address}:8080/irrigation +codebase.url=http://${server.address}:8080/ # set to whatever port you want the Java experiment server to run on (this is # *not* the webserver port, this is the experiment server port used to Modified: irrigation/trunk/pom.xml =================================================================== --- irrigation/trunk/pom.xml 2009-10-22 19:16:19 UTC (rev 324) +++ irrigation/trunk/pom.xml 2009-10-22 19:32:59 UTC (rev 325) @@ -9,7 +9,7 @@ <artifactId>irrigation</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> - <name>foraging</name> + <name>irrigation</name> <url>http://commons.asu.edu/irrigation</url> <repositories> <repository> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 19:16:27
|
Revision: 324 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=324&view=rev Author: alllee Date: 2009-10-22 19:16:19 +0000 (Thu, 22 Oct 2009) Log Message: ----------- fixed question 3 Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 18:58:45 UTC (rev 323) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 19:16:19 UTC (rev 324) @@ -38,7 +38,7 @@ <entry key="q2">identity</entry> <entry key="q3">49</entry> <entry key="q4">76</entry> -<entry key="q5">4</entry> +<entry key="q5">20</entry> <entry key="q6">5</entry> <entry key="q7">25</entry> <entry key="q8">7</entry> @@ -366,10 +366,13 @@ <![CDATA[ <br><br> To continue to the next page, please answer the following question:<br> +Question 3:<br> <form> -What is the minimum time to grow a crop when maximum water flow capacity is available?<br> -<input type="radio" name="q5" value="4">4 seconds<br> -<input type="radio" name="q5" value="10">10 seconds<br> +What is the minimum time to deliver 500 cubic feet of water to your field when +your maximum water flow capacity is available? +<br> +<input type="radio" name="q5" value="12.5">12.5 seconds<br> +<input type="radio" name="q5" value="20">20 seconds<br> <input type="radio" name="q5" value="25">25 seconds<br> <input type="radio" name="q5" value="50">50 seconds<br> <br><br> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 18:58:52
|
Revision: 323 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=323&view=rev Author: alllee Date: 2009-10-22 18:58:45 +0000 (Thu, 22 Oct 2009) Log Message: ----------- adding basic web.xml for jetty:run Added Paths: ----------- irrigation/trunk/src/main/resources/web/WEB-INF/ irrigation/trunk/src/main/resources/web/WEB-INF/web.xml Added: irrigation/trunk/src/main/resources/web/WEB-INF/web.xml =================================================================== --- irrigation/trunk/src/main/resources/web/WEB-INF/web.xml (rev 0) +++ irrigation/trunk/src/main/resources/web/WEB-INF/web.xml 2009-10-22 18:58:45 UTC (rev 323) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +vim:sts=2:sw=2 +--> +<web-app> + <display-name>The Virtual Commons Irrigation Experiment</display-name> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> +</web-app> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 18:43:04
|
Revision: 322 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=322&view=rev Author: alllee Date: 2009-10-22 18:42:57 +0000 (Thu, 22 Oct 2009) Log Message: ----------- updated round configuration, starting variable decline at round 3 Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml 2009-10-22 17:08:13 UTC (rev 321) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round5.xml 2009-10-22 18:42:57 UTC (rev 322) @@ -3,14 +3,28 @@ <properties> <comment>Irrigation experiment round configuration</comment> +<entry key='infrastructure-degradation-factor'>10</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 4 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +In the past rounds the infrastructure efficiency declined from one round to +the next at a constant amount of 25%. In the following rounds the <b>average +decline</b> of the infrastructure efficiency will remain the same, but the +<b>actual amount</b> of decline can vary from round to round. This means that +in some rounds the decline will be larger than 25% and some rounds the decline +will be smaller than 25%. Before each round begins you will continue to make a +decision on how much to invest in the irrigation infrastructure. After all of +your investment contributions have been submitted the resulting level of +infrastructure efficiency will be displayed and then the round will begin. If +you have any questions, please ask them now. </p> +<p> +In this round, the infrastructure has declined by 10%. +</p> + ]]> </entry> </properties> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 17:08:13 UTC (rev 321) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 18:42:57 UTC (rev 322) @@ -9,22 +9,10 @@ <![CDATA[ <h3>Round 5 Instructions</h3> <p> -In the past rounds the infrastructure efficiency declined from one round to -the next at a constant amount of 25%. In the following rounds the <b>average -decline</b> of the infrastructure efficiency will remain the same, but the -<b>actual amount</b> of decline can vary from round to round. This means that -in some rounds the decline will be larger than 25% and some rounds the decline -will be smaller than 25%. Before each round begins you will continue to make a -decision on how much to invest in the irrigation infrastructure. After all of -your investment contributions have been submitted the resulting level of -infrastructure efficiency will be displayed and then the round will begin. If -you have any questions, please ask them now. +This round is the same as the previous round, but the irrigation +infrastructure efficiency has experienced a severe decline of 85%. </p> -<p> -In this round, the infrastructure has declined by 10%. -</p> - ]]> </entry> </properties> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 17:08:22
|
Revision: 321 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=321&view=rev Author: alllee Date: 2009-10-22 17:08:13 +0000 (Thu, 22 Oct 2009) Log Message: ----------- updating progress bar color for windows boxes (need to find a cross platform way to do this for both) and updated general instructions Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-22 08:20:12 UTC (rev 320) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-22 17:08:13 UTC (rev 321) @@ -67,7 +67,7 @@ private void initialize() { this.setPreferredSize(new Dimension(1098,150)); this.setLayout(new GridBagLayout()); - this.setBackground(Color.white); + this.setBackground(Color.WHITE); //initializing the constructor for Gates for(int i=0;i<6;i++){ gate[i] = new Gate(totalContributedBandwidth,i); @@ -113,8 +113,8 @@ protected void paintComponent(Graphics graphics){ + super.paintComponent(graphics); // needed! updateGUI(); - super.paintComponent(graphics); // needed! Graphics2D graphics2D = (Graphics2D)graphics; graphics2D.setColor(Color.BLUE); graphics2D.fillRect(0,0,100,100); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 08:20:12 UTC (rev 320) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 17:08:13 UTC (rev 321) @@ -435,8 +435,8 @@ clientData.getMaximumTokenInvestment(), clientData.getInvestedTokens(), clientData.getUninvestedTokens(), + clientData.getTokensEarnedFromWaterCollected(), clientData.getAllTokensEarnedThisRound(), - clientData.getTokensEarnedFromWaterCollected(), clientData.getTotalDollarsEarnedThisRound(), clientData.getTotalDollarsEarned() + showUpBonus )); @@ -604,7 +604,7 @@ int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); instructionsBuilder.append( - String.format("<p><b>The irrigation capacity is %d and the maximum available water to you is %d cfps.</b></p>", + String.format("<p><b>The irrigation capacity is %d cfps and the maximum amount of water you can collect per second is %d cfps.</b></p>", irrigationCapacity, Math.min(irrigationCapacity, clientCapacity) )); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 08:20:12 UTC (rev 320) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 17:08:13 UTC (rev 321) @@ -402,11 +402,15 @@ return waterCollectedToTokensScrollPane; } - private Color getProgressBarColor(int timeLeft) { + private void setProgressBarColor(int timeLeft) { if (timeLeft < 10) { - return Color.RED; +// timeLeftProgressBar.setForeground( Color.RED ); + timeLeftProgressBar.setBackground( Color.RED ); +// return Color.RED; } - return Color.BLACK; + else { + timeLeftProgressBar.setBackground( Color.GREEN ); + } } /** * Should be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. @@ -418,7 +422,7 @@ String timeLeftString = String.format("%d sec", timeLeft); timeLeftProgressBar.setValue( timeLeft ); timeLeftProgressBar.setString(timeLeftString); - timeLeftProgressBar.setForeground( getProgressBarColor(timeLeft) ); + setProgressBarColor(timeLeft); for (final ClientData clientData : clientDataModel.getClientDataMap().values()) { if (clientData.isGateOpen()) { canalPanel.openGate(clientData.getPriority()); Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 08:20:12 UTC (rev 320) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 17:08:13 UTC (rev 321) @@ -332,36 +332,33 @@ <entry key="general-instructions4"> <![CDATA[ <h3>Growing crops</h3> -<p>There are FIVE participants in each group, each of which is randomly assigned to -one of the five positions, A, B, C, D or E. Below is a schematic representing the -irrigation system. Water comes from the box to the left and the five players -are located from upstream (leftmost) to downstream (rightmost) accordingly. To -illustrate the game, assume you are in position B. The black lines represent "gates" -that you control (i.e, open and close). -<p> -<img src="http://dev.commons.asu.edu/irrigation/images/irrigation-example-screenshot.jpg"><br><br> +<p>There are <b>five</b> participants in each group, each of which is randomly assigned to +one of the five positions, A, B, C, D or E. Below is a screenshot of the +graphical interface representation of the irrigation system. Water comes from +the box to the left and the five players are located from upstream (leftmost) +to downstream (rightmost) accordingly. To illustrate, assume you are in +position C. The black lines represent "gates" that you open and close by +clicking on the large button on the lower left corner of the screen. +Each round consists of 50 seconds and the amount of time left in the +experiment is indicated by a bar at the top of the screen. </p> -Each round will take 50 seconds and the amount of time left in the experiment -is indicated at the top of the screen. +<img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> +<br><br> <p> -<img src = "http://dev.commons.asu.edu/irrigation/images/time-remaining-screenshot.jpg"><br> +You can irrigate your field during the round by opening your gate. Your +earnings depend on the amount of water you can draw onto your fields and will +be explained in more detail on the next page. The speed at which you can grow +a crop depends on the amount of water available to you <b>at the time that you +open your gate</b>. The maximum flow capacity of the main canal shared by A, +B, C, D, and E is forty cubic feet per second. </p> <p> -During this round you can irrigate your field. Your earnings depend on the amount -of water you can draw onto your fields and will be explained in more detail in the -next screen. The speed at which you can grow a crop depends on the amount of water -available to you <b>at the time that you open your gate</b>. The maximum flow -capacity of the main canal shared by A, B, C, D, and E is forty cubic feet per second. +The maximum amount of water that can flow through your gate when it is opened +is 25 cubic feet per second. If other people are using the canal, the water +flow available to you might be less, and it may take longer to get water to +your field since you are also limited by the amount of water that is flowing +through the shared canal. </p> -<p> -The maximum capacity that can flow through your gate when it is opened is -twenty-five cubic feet per second. If other people are using the canal, the water -flow available to you might be less, and it may take longer to get water to your -field (you are limited by the flow capacity of the shared canal). -</p> -<p> -The water flow capacity available for your field is shown as a number. -</p> ]]> </entry> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 08:20:19
|
Revision: 320 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=320&view=rev Author: alllee Date: 2009-10-22 08:20:12 +0000 (Thu, 22 Oct 2009) Log Message: ----------- disabling undisrupted flow instructions for the time being Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-22 08:06:27 UTC (rev 319) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-22 08:20:12 UTC (rev 320) @@ -84,9 +84,9 @@ builder.append("Your position: ").append(toPriorityString(clientPosition)); } builder.append(getGeneralInstructions(instructionPageNumber)); - if (isUndisruptedFlowRequired()) { - builder.append(getUndisruptedFlowInstructions()); - } +// if (isUndisruptedFlowRequired()) { +// builder.append(getUndisruptedFlowInstructions()); +// } // if the current instruction page number is greater than the number of pages traversed, then // we need to render the quizzes. Otherwise, we don't. if (instructionPageNumber > pagesTraversed) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 08:06:44
|
Revision: 319 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=319&view=rev Author: alllee Date: 2009-10-22 08:06:27 +0000 (Thu, 22 Oct 2009) Log Message: ----------- - updated configuration for first pretest, 10 actual rounds, 3 normal constant decline 25% and 5 fluctuating between 10 and 85%. - made GroupDataModel hold its own copy of the RoundConfiguration instead of delegating to its transient ServerDataModel which causes NPEs when invoked on the client side. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round0.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round1.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round11.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 08:06:27 UTC (rev 319) @@ -599,6 +599,15 @@ } else { instructionsBuilder.append(roundConfiguration.getInstructions()); + instructionsBuilder.append("<hr/>"); + int irrigationCapacity = clientDataModel.getGroupDataModel().getFlowCapacity(); + int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); + + instructionsBuilder.append( + String.format("<p><b>The irrigation capacity is %d and the maximum available water to you is %d cfps.</b></p>", + irrigationCapacity, + Math.min(irrigationCapacity, clientCapacity) + )); setInstructions(instructionsBuilder.toString()); } addCenterComponent(getInstructionsPanel()); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-22 08:06:27 UTC (rev 319) @@ -101,7 +101,7 @@ } public boolean shouldResetInfrastructureEfficiency() { - return getBooleanProperty("reset-infrastructure-efficiency", false); + return isPracticeRound() || getBooleanProperty("reset-infrastructure-efficiency", false); } public String getInstructions() { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-22 08:06:27 UTC (rev 319) @@ -6,7 +6,6 @@ import java.util.Set; import java.util.logging.Logger; -import edu.asu.commons.event.EventChannel; import edu.asu.commons.experiment.DataModel; import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.net.Identifier; @@ -28,8 +27,11 @@ private transient ServerDataModel serverDataModel; - private transient Logger logger = Logger.getLogger(GroupDataModel.class.getName()); + private RoundConfiguration roundConfiguration; + + private transient Logger logger = Logger.getLogger(GroupDataModel.class.getName()); + private int currentlyAvailableFlowCapacity = 0; private int maximumAvailableFlowCapacity = 0; @@ -41,6 +43,7 @@ public GroupDataModel(ServerDataModel serverDataModel) { this.serverDataModel = serverDataModel; + setRoundConfiguration(serverDataModel.getRoundConfiguration()); } public ClientData getClientData(Identifier id) { @@ -80,27 +83,27 @@ } public boolean isFull() { - return clients.size() == serverDataModel.getRoundConfiguration().getClientsPerGroup(); + return clients.size() == getRoundConfiguration().getClientsPerGroup(); } public void clear() { clients.clear(); } - public void setServerDataModel(ServerDataModel state) { - this.serverDataModel = state; + public void setServerDataModel(ServerDataModel serverDataModel) { + this.serverDataModel = serverDataModel; } public Map<Identifier, ClientData> getClientDataMap() { return Collections.unmodifiableMap(clients); } - public int getAvailableClientFlowCapacity(){ + public int getAvailableClientFlowCapacity() { return Math.min(currentlyAvailableFlowCapacity, getRoundConfiguration().getMaximumClientFlowCapacity()); } public RoundConfiguration getRoundConfiguration() { - return serverDataModel.getRoundConfiguration(); + return roundConfiguration; } public int getTotalContributedTokens() { @@ -213,10 +216,6 @@ public int getMaximumAvailableFlowCapacity() { return maximumAvailableFlowCapacity; } - - public EventChannel getEventChannel() { - return serverDataModel.getEventChannel(); - } public int getInfrastructureEfficiency() { return infrastructureEfficiency; @@ -232,6 +231,11 @@ } return logger; } + + + public void setRoundConfiguration(RoundConfiguration roundConfiguration) { + this.roundConfiguration = roundConfiguration; + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ServerDataModel.java 2009-10-22 08:06:27 UTC (rev 319) @@ -36,6 +36,9 @@ public void setRoundConfiguration(RoundConfiguration roundConfiguration) { this.roundConfiguration = roundConfiguration; + for (GroupDataModel group: clientsToGroups.values()) { + group.setRoundConfiguration(roundConfiguration); + } } public synchronized void addClient(ClientData clientData) { Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -30,7 +30,7 @@ <entry key="wait-for-participants">true</entry> -<entry key="number-of-rounds">22</entry> +<entry key="number-of-rounds">12</entry> <entry key="undisrupted-flow-required">true</entry> @@ -689,15 +689,16 @@ <![CDATA[ <h3>Invest tokens in the irrigation infrastructure</h3> <p> -You have 10 tokens to invest. You must make a decision about how much you wish to -invest [0,10] in the irrigation infrastructure. As a reminder we have included the -table relating irrigation infrastructure and the total available flow capacity in -the figure 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. +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 +infrastructure efficiency. </p> <table border="1" cellspacing="2" cellpadding="2"> <thead> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round0.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round0.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -4,9 +4,7 @@ <comment>Irrigation experiment round configuration</comment> <entry key='max-canal-flow-capacity'>40</entry> <entry key='max-client-flow-capacity'>25</entry> -<entry key="max-total-token-contribution">50</entry> <entry key="practice-round">true</entry> -<entry key="clients-per-group">5</entry> <entry key="instructions"> <![CDATA[ Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round1.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round1.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round1.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -2,7 +2,6 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> <entry key="practice-round">true</entry> <entry key="instructions"> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round10.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -2,16 +2,15 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> -<entry key="practice-round">false</entry> -<entry key="clients-per-group">5</entry> +<entry key='infrastructure-degradation-factor'>10</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 9 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +This round is the same as the previous round, but the irrigation +infrastructure efficiency has declined by 10%. </p> ]]> </entry> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round11.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round11.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round11.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -2,14 +2,15 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> +<entry key='infrastructure-degradation-factor'>85</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 10 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +This round is the same as the previous round, but the infrastructure +irrigation efficiency has experienced a severe decline of 85%. </p> ]]> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -9,12 +9,12 @@ <![CDATA[ <h3>Round 1 Instructions</h3> <p> -This is the first round of twenty. Before this round begins you will have the -opportunity to text chat with the other participant for forty seconds, then -decide on your level of investment in the irrigation infrastructure. After -the total irrigation infrastructure investment has been determined you will -begin the experiment and make decisions on when to open your irrigation gates -and grow crops. +This is the first actual round of the experiment. Before this round begins +you will have the opportunity to text chat with the other participant for +forty seconds, then decide on your level of investment in the irrigation +infrastructure. After the total irrigation infrastructure investment has been +determined you will begin the experiment and make decisions on when to open +your irrigation gates and grow crops. </p> ]]> </entry> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round6.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -3,14 +3,28 @@ <properties> <comment>Irrigation experiment round configuration</comment> +<entry key='infrastructure-degradation-factor'>10</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 5 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +In the past rounds the infrastructure efficiency declined from one round to +the next at a constant amount of 25%. In the following rounds the <b>average +decline</b> of the infrastructure efficiency will remain the same, but the +<b>actual amount</b> of decline can vary from round to round. This means that +in some rounds the decline will be larger than 25% and some rounds the decline +will be smaller than 25%. Before each round begins you will continue to make a +decision on how much to invest in the irrigation infrastructure. After all of +your investment contributions have been submitted the resulting level of +infrastructure efficiency will be displayed and then the round will begin. If +you have any questions, please ask them now. </p> +<p> +In this round, the infrastructure has declined by 10%. +</p> + ]]> </entry> </properties> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round7.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -3,14 +3,14 @@ <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> +<entry key='infrastructure-degradation-factor'>85</entry> <entry key="instructions"> <![CDATA[ <h3>Round 6 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +This round is the same as the previous round, but the irrigation +infrastructure efficiency has experienced a severe decline of 85%. </p> ]]> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round8.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -2,15 +2,15 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> -<entry key="clients-per-group">5</entry> +<entry key='infrastructure-degradation-factor'>30</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 7 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +This round is the same as the previous round, but the irrigation +infrastructure efficiency has declined by 30%. </p> ]]> </entry> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml 2009-10-22 07:02:10 UTC (rev 318) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round9.xml 2009-10-22 08:06:27 UTC (rev 319) @@ -2,15 +2,15 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment round configuration</comment> -<entry key="max-total-token-contribution">50</entry> -<entry key="clients-per-group">5</entry> +<entry key='infrastructure-degradation-factor'>10</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 8 Instructions</h3> <p> -This round is the same as the previous round, but the infrastructure irrigation has -been decreased by 25%. +This round is the same as the previous round, but the irrigation +infrastructure efficiency has declined by 10%. </p> ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 07:02:17
|
Revision: 318 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=318&view=rev Author: alllee Date: 2009-10-22 07:02:10 +0000 (Thu, 22 Oct 2009) Log Message: ----------- updated instructions and added reset-infrastructure parameter to first actual round of experiment. Modified Paths: -------------- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 07:00:32 UTC (rev 317) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/irrigation.xml 2009-10-22 07:02:10 UTC (rev 318) @@ -312,6 +312,7 @@ Given an existing infrastructure efficiency of 20%, if the five participants invest a <b>total of 29 additional tokens</b>, what is the new irrigation infrastructure efficiency? +<br> <input type="text" name="q3" value = ""> <br><br> @@ -533,6 +534,63 @@ ]]> </entry> +<entry key='water-collected-to-tokens-table'> +<![CDATA[ +<table border="1" cellspacing="2" cellpadding="2"> +<thead> +<th>Water units received (cubic feet)</th> +<th>Tokens earned</th> +</thead> +<tr> +<td>< 150</td><td>0</td> +</tr> +<tr> +<td>150-199</td><td>1</td> +</tr> +<tr> +<td>200-249</td><td>4</td> +</tr> +<tr> +<td>250-299</td><td>10</td> +</tr> +<tr> +<td>300-349</td><td>15</td> +</tr> +<tr> +<td>350-399</td><td>18</td> +</tr> +<tr> +<td>400-499</td><td>19</td> +</tr> +<tr> +<td>500-549</td><td>20</td> +</tr> +<tr> +<td>550-649</td><td>19</td> +</tr> +<tr> +<td>650-699</td><td>18</td> +</tr> +<tr> +<td>700-749</td><td>15</td> +</tr> +<tr> +<td>750-799</td><td>10</td> +</tr> +<tr> +<td>800-849</td><td>4</td> +</tr> +<tr> +<td>850-899</td><td>1</td> +</tr> +<tr> +<td>> 899</td><td>0</td> +</tr> +</table> +]]> +</entry> + + <entry key="general-instructionsq6"> <![CDATA[ <br><br> @@ -540,6 +598,7 @@ <form> If you invest 7 of the 10 tokens you started with, and you put 202 cf of water on your field, what is the total number of tokens you will have earned for that round? +<br> <input type="radio" name="q8" value="3">3<br> <input type="radio" name="q8" value="4">4<br> <input type="radio" name="q8" value="7">7<br> @@ -547,6 +606,7 @@ <br><br> If you invest all 10 tokens you start with, and you put 555 cf of water on your field, what is the total number of tokens your will have earned for that round? +<br> <input type="radio" name="q9" value="10">10<br> <input type="radio" name="q9" value="19">19<br> <input type="radio" name="q9" value="20">20<br> Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml 2009-10-22 07:00:32 UTC (rev 317) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/round2.xml 2009-10-22 07:02:10 UTC (rev 318) @@ -3,12 +3,14 @@ <properties> <comment>Irrigation experiment round configuration</comment> +<entry key='reset-infrastructure-efficiency'>true</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 1 Instructions</h3> <p> This is the first round of twenty. Before this round begins you will have the -opportunity to text chat with the other participant for fifty seconds, then +opportunity to text chat with the other participant for forty seconds, then decide on your level of investment in the irrigation infrastructure. After the total irrigation infrastructure investment has been determined you will begin the experiment and make decisions on when to open your irrigation gates This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 07:00:45
|
Revision: 317 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=317&view=rev Author: alllee Date: 2009-10-22 07:00:32 +0000 (Thu, 22 Oct 2009) Log Message: ----------- client interface is pretty much finalized, next up is testing round configurations and server interaction / persistence. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 07:00:32 UTC (rev 317) @@ -555,7 +555,7 @@ graphPanel.setName("Graph panel"); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); graphPanel.add(getPieChartPanel()); - graphPanel.add(Box.createVerticalStrut(10)); + graphPanel.add(Box.createVerticalStrut(15)); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-22 07:00:32 UTC (rev 317) @@ -109,7 +109,7 @@ IrrigationClient client = new IrrigationClient(); client.initialize(); frame.setTitle("Virtual Commons Experiment Client: " + client.id); - frame.setPreferredSize(new Dimension(1024, 768)); + frame.setPreferredSize(new Dimension(1100, 800)); // frame.setResizable(false); frame.getContentPane().add(client.getExperimentGameWindow()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 07:00:32 UTC (rev 317) @@ -231,15 +231,17 @@ } return jPanelUpStreamWindow; } - + private final static String OPEN_GATE_LABEL = "Click here to open your gate"; + private final static String CLOSE_GATE_LABEL = "Click here to close your gate"; private JButton getGateSwitchButton() { if (gateSwitchButton == null) { - gateSwitchButton = new JButton("Open gate"); + gateSwitchButton = new JButton(OPEN_GATE_LABEL); + gateSwitchButton.setFont(new Font("sansserif", Font.TRUETYPE_FONT, 18)); // gateSwitchButton.setPreferredSize(new Dimension(100, 100)); gateSwitchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { open = !open; - gateSwitchButton.setText( open ? "Close gate" : "Open gate"); + gateSwitchButton.setText( open ? CLOSE_GATE_LABEL : OPEN_GATE_LABEL ); if (open) { client.openGate(); } @@ -499,7 +501,7 @@ // controlPanel.endRound(); centerPanel.removeAll(); canalPanel.endRound(); - gateSwitchButton.setText("Open gate"); + gateSwitchButton.setText(OPEN_GATE_LABEL); } }); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-22 07:00:32 UTC (rev 317) @@ -23,11 +23,14 @@ private JLabel positionText; - private JLabel availableFlowCapacityLabel; + private JLabel availableWaterLabel; private JLabel waterCollectedLabel; - private JLabel tokensCollectedLabel; + private JLabel tokensEarnedLabel; + + private JLabel tokensNotInvestedLabel; + private JLabel totalTokensEarnedLabel; private int priority; @@ -46,34 +49,48 @@ this.setPreferredSize(new Dimension(60,200)); this.add(getPositionLabel(),null); this.add(getWaterCollectedLabel(),null); - this.add(getAvailableFlowCapacityLabel(),null); - this.add(getTokensCollectedLabel(),null); - - + this.add(getAvailableWaterLabel(),null); + this.add(getTokensEarnedLabel(),null); +// this.add(getTokensNotInvestedLabel(),null); +// this.add(getTotalTokensEarnedLabel(),null); } + + private JLabel getTotalTokensEarnedLabel() { + if (totalTokensEarnedLabel == null) { + totalTokensEarnedLabel = new JLabel(); + totalTokensEarnedLabel.setBounds(new Rectangle(5,10+32+10+20+10+20+10+20+10+30+30,30,20)); + } + return totalTokensEarnedLabel; + } + + private JLabel getTokensNotInvestedLabel() { + if (tokensNotInvestedLabel == null) { + tokensNotInvestedLabel = new JLabel(String.valueOf(clientData.getUninvestedTokens())); + tokensNotInvestedLabel.setBounds(new Rectangle(5,10+32+10+20+10+20+10+20+10+30,30,20)); + } + return tokensNotInvestedLabel; + } - private JLabel getTokensCollectedLabel() { - if(tokensCollectedLabel == null){ - tokensCollectedLabel = new JLabel(); - tokensCollectedLabel.setBounds(new Rectangle(5,50+32+10+20+10+20+10+20+10,30,20)); - tokensCollectedLabel.setText(""); + private JLabel getTokensEarnedLabel() { + if(tokensEarnedLabel == null){ + tokensEarnedLabel = new JLabel(); + tokensEarnedLabel.setBounds(new Rectangle(5,10+32+10+20+10+20+10+20+10,30,20)); } - return tokensCollectedLabel; + return tokensEarnedLabel; } - private JLabel getAvailableFlowCapacityLabel() { - if(availableFlowCapacityLabel == null){ - availableFlowCapacityLabel = new JLabel(); - availableFlowCapacityLabel.setBounds(new Rectangle(5,50+32+10+20+10,30,20)); - availableFlowCapacityLabel.setText(""); + private JLabel getAvailableWaterLabel() { + if(availableWaterLabel == null){ + availableWaterLabel = new JLabel(); + availableWaterLabel.setBounds(new Rectangle(5,10+32+10+20+10,30,20)); } - return availableFlowCapacityLabel; + return availableWaterLabel; } private JLabel getPositionLabel() { if (positionText == null){ positionText = new JLabel(clientData.getPriorityString()); - positionText.setBounds(new Rectangle(5,50+32+10,30,20)); + positionText.setBounds(new Rectangle(5,10+32+10,30,20)); } return positionText; } @@ -82,16 +99,16 @@ private JLabel getWaterCollectedLabel() { if(waterCollectedLabel == null){ waterCollectedLabel = new JLabel("0"); - waterCollectedLabel.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); + waterCollectedLabel.setBounds(new Rectangle(5,10+32+10+20+10+20+10,30,20)); } return waterCollectedLabel; } public void update(ClientData clientData) { this.clientData = clientData; - availableFlowCapacityLabel.setText("" + clientData.getAvailableFlowCapacity()); + availableWaterLabel.setText("" + clientData.getAvailableFlowCapacity()); waterCollectedLabel.setText("" + clientData.getWaterCollected()); - tokensCollectedLabel.setText("" + clientData.getAllTokensEarnedThisRound()); + tokensEarnedLabel.setText("" + clientData.getTokensEarnedFromWaterCollected()); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { // show that client is actively irrigating Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-22 07:00:32 UTC (rev 317) @@ -36,21 +36,21 @@ this.setBounds(new Rectangle(13,100 + 100 - 50,1093,100+50+50)); this.setSize(new Dimension(1093,200)); - positionLabel = new JLabel(); - positionLabel.setBounds(new Rectangle(30,50+32+10,150,20)); + positionLabel = new JLabel("Position"); + positionLabel.setBounds(new Rectangle(30,10+32+10,200,20)); positionLabel.setText("Position"); - availableWaterLabel = new JLabel(); - availableWaterLabel.setBounds(new Rectangle(30,50+32+10+20+10,200,20)); - availableWaterLabel.setText("Available water per second"); + availableWaterLabel = new JLabel("Available water per second"); + availableWaterLabel.setBounds(new Rectangle(30,10+32+10+20+10,200,20)); - waterCollectedLabel = new JLabel(); - waterCollectedLabel.setBounds(new Rectangle(30,50+32+10+20+10+20+10, 150,20)); - waterCollectedLabel.setText("Water collected"); + waterCollectedLabel = new JLabel("Water collected"); + waterCollectedLabel.setBounds(new Rectangle(30,10+32+10+20+10+20+10, 150,20)); - tokensEarnedLabel = new JLabel(); - tokensEarnedLabel.setBounds(new Rectangle(30,50+32+10+20+10+20+10+20+10, 200,20)); - tokensEarnedLabel.setText("Tokens earned "); + tokensEarnedLabel = new JLabel("Tokens earned"); + tokensEarnedLabel.setBounds(new Rectangle(30,10+32+10+20+10+20+10+20+10, 200,20)); + + totalTokensEarnedLabel = new JLabel("Total tokens earned"); + totalTokensEarnedLabel.setBounds(new Rectangle(30,10+32+10+20+10+20+10+20+10+30, 200,20)); this.add(positionLabel, null); this.add(availableWaterLabel, null); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-22 07:00:32 UTC (rev 317) @@ -99,6 +99,10 @@ public void report() { getProperties().list(System.err); } + + public boolean shouldResetInfrastructureEfficiency() { + return getBooleanProperty("reset-infrastructure-efficiency", false); + } public String getInstructions() { return getStringProperty("instructions", Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-22 06:25:19 UTC (rev 316) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-22 07:00:32 UTC (rev 317) @@ -128,7 +128,7 @@ // initialize infrastructure efficiency System.err.println("current round number: " + currentRoundNumber); System.err.println("initial infrastructure efficiency: " + infrastructureEfficiency); - if (roundConfiguration.isPracticeRound() || roundConfiguration.isFirstRound()) { + if ( roundConfiguration.shouldResetInfrastructureEfficiency() ) { System.err.println("initializing infrastructure efficiency to default initial value: " + roundConfiguration.getInitialInfrastructureEfficiency()); infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 06:25:32
|
Revision: 316 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=316&view=rev Author: alllee Date: 2009-10-22 06:25:19 +0000 (Thu, 22 Oct 2009) Log Message: ----------- revived Sanket's old MainIrrigationGameWindow since there's not enough time to properly re-implement the hard-coded layout that he had set up. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/OpenGateEvent.java Added Paths: ----------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-22 06:25:19 UTC (rev 316) @@ -4,7 +4,7 @@ public class Ball { - private int size = 2; + private int size = 3; public int x; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-22 06:25:19 UTC (rev 316) @@ -116,7 +116,6 @@ updateGUI(); super.paintComponent(graphics); // needed! Graphics2D graphics2D = (Graphics2D)graphics; - graphics2D = graphics2D; graphics2D.setColor(Color.BLUE); graphics2D.fillRect(0,0,100,100); //draw the other gates Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-22 06:25:19 UTC (rev 316) @@ -1,8 +1,10 @@ package edu.asu.commons.irrigation.client; import java.awt.Color; +import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; @@ -69,9 +71,10 @@ * @return void */ private void initialize() { -// this.setPreferredSize(new Dimension(1098,150)); + this.setSize(new Dimension(1098,150)); + setLayout(new GridBagLayout()); this.setBackground(Color.WHITE); - //initializing the constructor for Gates + //initialize each gate for(int i=0;i<numberOfGates ;i++){ gate[i] = new Gate(maximumIrrigationCapacity,i); } @@ -109,8 +112,7 @@ graphics2D.fillRect(gate[5].getX(), gate[5].getY(),10,gate[5].getHeight()); //////////////////////Animation Logic//////////////////////////// - if(enableBallAnimation == true) - { + if (enableBallAnimation) { graphics.setColor(Color.white); // int ballCounter = 0; for(int i=0;i<BALLCOUNT;i++){ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 06:25:19 UTC (rev 316) @@ -15,6 +15,7 @@ import java.util.Map; import java.util.Properties; +import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JLabel; @@ -67,8 +68,10 @@ private InfrastructureEfficiencyChartPanel infrastructureEfficiencyChartPanel = null; private IrrigationClient client; + +// private MainIrrigationGameWindow mainIrrigationGameWindow; - private IrrigationGamePanel irrigationGamePanel; + private MainIrrigationGameWindow irrigationGamePanel; private StringBuilder instructionsBuilder = new StringBuilder(); @@ -119,7 +122,8 @@ setInstructions(getGeneralInstructions(0)); addToCardLayout(getInstructionsPanel()); - irrigationGamePanel = new IrrigationGamePanel(client); +// irrigationGamePanel = new IrrigationGamePanel(client); + irrigationGamePanel = new MainIrrigationGameWindow(client); addToCardLayout(irrigationGamePanel); addToCardLayout(getInvestTokensPanel()); addToCardLayout(getChatPanel()); @@ -549,8 +553,9 @@ if (graphPanel == null) { graphPanel = new JPanel(); graphPanel.setName("Graph panel"); - graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.X_AXIS)); + graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); graphPanel.add(getPieChartPanel()); + graphPanel.add(Box.createVerticalStrut(10)); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); @@ -565,8 +570,8 @@ infrastructureEfficiencyChartPanel = new InfrastructureEfficiencyChartPanel(client); pieChart = new TokenInvestmentPieChartPanel(); GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(2); - gridLayout.setColumns(1); + gridLayout.setRows(1); + gridLayout.setColumns(2); pieChartPanel.setLayout(gridLayout); pieChartPanel.add(infrastructureEfficiencyChartPanel); pieChartPanel.add(pieChart); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-22 06:25:19 UTC (rev 316) @@ -1,5 +1,6 @@ package edu.asu.commons.irrigation.client; +import java.awt.Dimension; import java.util.LinkedHashMap; import java.util.Map; @@ -108,7 +109,8 @@ IrrigationClient client = new IrrigationClient(); client.initialize(); frame.setTitle("Virtual Commons Experiment Client: " + client.id); -// frame.setSize(1130, 600); + frame.setPreferredSize(new Dimension(1024, 768)); +// frame.setResizable(false); frame.getContentPane().add(client.getExperimentGameWindow()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-22 06:25:19 UTC (rev 316) @@ -3,6 +3,8 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException; @@ -19,6 +21,7 @@ import javax.swing.GroupLayout.ParallelGroup; import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.util.HtmlEditorPane; /** * $Id$ @@ -39,7 +42,7 @@ private CanalPanel canalPanel; //this contains the CanalPanel - private JPanel upperPanel; + private JPanel centerPanel; private ScoreBoxPanel scoreBoxPanel; @@ -83,6 +86,8 @@ private JTextField irrigationCapacityTextField; + private HtmlEditorPane waterCollectedToTokensTable; + public IrrigationGamePanel(IrrigationClient client) { setName("Irrigation Game Panel"); this.client = client; @@ -102,18 +107,22 @@ setLayout(new BorderLayout()); add(topmostPanel, BorderLayout.PAGE_START); - add(getUpperPanel(), BorderLayout.CENTER); + add(getCenterPanel(), BorderLayout.CENTER); add(getBottomPanel(), BorderLayout.PAGE_END); } private JPanel getBottomPanel() { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - panel.add(getGateSwitchButton()); + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); + bottomPanel.add(getGateSwitchButton()); + + JPanel bottomMostPanel = new JPanel(); + bottomMostPanel.setLayout(new BoxLayout(bottomMostPanel, BoxLayout.X_AXIS)); + - JPanel bottomPanel = new JPanel(); - GroupLayout layout = new GroupLayout(bottomPanel); - bottomPanel.setLayout(layout); + JPanel bottomInformationPanel = new JPanel(); + GroupLayout layout = new GroupLayout(bottomInformationPanel); + bottomInformationPanel.setLayout(layout); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); @@ -145,19 +154,25 @@ .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); layout.setVerticalGroup(verticalGroup); -// bottomPanel.add(getWaterUsedLabel()); -// bottomPanel.add(getWaterUsedTextField()); -// bottomPanel.add(getTokensNotInvestedLabel()); -// bottomPanel.add(getTokensNotInvestedTextField()); -// bottomPanel.add(getTokensEarnedLabel()); -// bottomPanel.add(getTokensEarnedTextField()); -// bottomPanel.add(getTotalTokensEarnedLabel()); -// bottomPanel.add(getTotalTokensEarnedTextField()); + + bottomMostPanel.add(bottomInformationPanel); + + bottomMostPanel.add(getWaterCollectedToTokensTable()); + + bottomPanel.add(bottomMostPanel); + return bottomPanel; + } - panel.add(bottomPanel); - return panel; + + private HtmlEditorPane getWaterCollectedToTokensTable() { + if (waterCollectedToTokensTable == null) { + waterCollectedToTokensTable = new HtmlEditorPane(); + waterCollectedToTokensTable.setEditable(false); + waterCollectedToTokensTable.setText(client.getServerConfiguration().getWaterCollectedToTokensTable()); + } + return waterCollectedToTokensTable; } - + private JTextField getWaterCollectedTextField() { if (waterCollectedTextField == null) { waterCollectedTextField = createTextField(); @@ -224,6 +239,7 @@ if (irrigationCapacityLabel == null) { irrigationCapacityLabel = new JLabel(); irrigationCapacityLabel.setLabelFor(getIrrigationCapacityTextField()); + irrigationCapacityLabel.setFont(new Font("sansserif", Font.BOLD, 16)); } return irrigationCapacityLabel; } @@ -235,41 +251,22 @@ return irrigationCapacityTextField; } - // private JPanel getMainIrrigationPanel() { - // if (mainIrrigationPanel == null) { - // irrigationCapacityLabel = new JLabel(); - // irrigationCapacityLabel.setText("Irrigation capacity: "); - // mainIrrigationPanel = new JPanel(); - // - // - // mainIrrigationPanel.setName("downloadScreenPanel"); - // mainIrrigationPanel.setBackground(Color.white); - // mainIrrigationPanel.add(getUpperPanel(),null); - // mainIrrigationPanel.add(timeRemainingLabel, null); - // mainIrrigationPanel.add(timeRemainingTextField,null); - // - // mainIrrigationPanel.add(irrigationCapacityLabel, null); - // mainIrrigationPanel.add(maximumAvailableFlowCapacityLabel, null); - // mainIrrigationPanel.add(dashBoardLabel, null); - // mainIrrigationPanel.add(scoreBoardLabel, null); - // } - // return mainIrrigationPanel; - // } - - private JPanel getUpperPanel() { - if (upperPanel == null) { - upperPanel = new JPanel(); - upperPanel.setLayout(new BorderLayout()); - upperPanel.add(getScoreBoxPanel(), BorderLayout.PAGE_END); + private JPanel getCenterPanel() { + if (centerPanel == null) { + centerPanel = new JPanel(); +// centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); +// centerPanel.setLayout(new BorderLayout()); +// centerPanel.add(getMiddleWindowPanel(), BorderLayout.PAGE_END); +// upperPanel.add(getScoreBoxPanel(), BorderLayout.PAGE_END); } - return upperPanel; + return centerPanel; } private JButton getGateSwitchButton() { if (gateSwitchButton == null) { gateSwitchButton = new JButton("Open gate"); - gateSwitchButton.setPreferredSize(new Dimension(100, 100)); +// gateSwitchButton.setPreferredSize(new Dimension(100, 100)); gateSwitchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { open = !open; @@ -287,8 +284,12 @@ } private JPanel createCanalPanel() { + JPanel panel = new JPanel(); canalPanel = new CanalPanel(clientDataModel); - return canalPanel; + canalPanel.setSize(new Dimension(1098, 123)); + panel.add(canalPanel); + panel.setBounds(new Rectangle(13, 64, 1098, 123)); + return panel; } // private IrrigationGameWindow getIrrigationGameWindow() { @@ -364,16 +365,11 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { int timeLeft = clientDataModel.getTimeLeft(); - int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); String timeLeftString = String.format("%d sec", timeLeft); timeLeftProgressBar.setValue( timeLeft ); timeLeftProgressBar.setString(timeLeftString); timeLeftProgressBar.setForeground( getProgressBarColor(timeLeft) ); - irrigationCapacityLabel.setText( - String.format("Irrigation capacity: %d cubic feet per second (cfps)", - irrigationCapacity)); for (final ClientData clientData : clientDataModel.getClientDataMap().values()) { - System.err.println("changing canal gate for client: " + clientData.getPriority() + ":" + clientData.isGateOpen()); if (clientData.isGateOpen()) { canalPanel.openGate(clientData.getPriority()); } @@ -389,8 +385,8 @@ tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); tokensEarnedTextField.setText("" + clientData.getTokensEarnedFromWaterCollected()); totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); - getScoreBoxPanel().update(clientDataModel); -// getMiddleWindowPanel().update(clientDataModel); +// getScoreBoxPanel().update(clientDataModel); + getMiddleWindowPanel().update(clientDataModel); } @@ -411,7 +407,7 @@ gateSwitchButton.setText("Open gate"); if (canalPanel != null) { System.err.println("Removing canal panel"); - upperPanel.remove(canalPanel); + centerPanel.removeAll(); canalPanel.endRound(); } System.err.println("ending round for canal panel"); @@ -437,13 +433,21 @@ /** - * fills in the panels depending on the priority of the client + * Updates all GUI related components that are dependent on the client data model being properly initialized + * with the GroupDataModel, RoundConfiguration, ClientData, etc. */ public void startRound() { open = false; - upperPanel.add(createCanalPanel(), BorderLayout.CENTER); - getScoreBoxPanel().initialize(clientDataModel); + centerPanel.add(createCanalPanel(), null); + centerPanel.add(getMiddleWindowPanel(), null); +// getWaterCollectedToTokensTable().setText(clientDataModel.getServerConfiguration().getWaterCollectedToTokensTable()); +// getScoreBoxPanel().initialize(clientDataModel); getMiddleWindowPanel().initialize(clientDataModel); + int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); + irrigationCapacityLabel.setText( + String.format("Irrigation capacity: %d cubic feet per second (cfps)", + irrigationCapacity)); + revalidate(); // mainIrrigationPanel.add(getJPanelUpStreamWindow(),null); // mainIrrigationPanel.add(getJPanelDownStreamWindow(),null); Added: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-10-22 06:25:19 UTC (rev 316) @@ -0,0 +1,582 @@ +package edu.asu.commons.irrigation.client; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.GroupLayout.Alignment; +import javax.swing.GroupLayout.ParallelGroup; + +import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.util.HtmlEditorPane; + + + +public class MainIrrigationGameWindow extends JPanel { + + //public ChartWindowPanelTokenBandwidth xySeriesDemo; + + public IrrigationGameWindow controlPanel; + + //public ActivitySummaryPanel activitySummaryWindow; + + public CanalPanel canalPanel; + + private static final long serialVersionUID = 1L; + + private JPanel jPanelMain = null; + //this contains the CanalPanel + private JPanel centerPanel = null; + //this contains the upstream and downstream Panel + private JPanel jPanelUpStreamWindow = null; + private JPanel jPanelDownStreamWindow = null; + private JPanel downloadScreenPanel = null; + + private ScoreBoxPanel scoreBoxPanel; + + /** + * This is the default constructor + */ + public IrrigationClient client; + + public Dimension screenSize; + + public JProgressBar timeLeftProgressBar; + + public JProgressBar timeRemainingjProgressBar = null; + + private JLabel timeRemainingjLabel = null; + + private JTextField timeRemainingjText; + + private JLabel priorityjLabel = null; + + private JLabel totalContributedBandwidthjLabel = null; + + private JLabel totalContributedBandwidthTextjLabel = null; + + private ClientDataModel clientDataModel; // @jve:decl-index=0: + + private MiddleWindowPanel middleWindowPanel; + + private JLabel dashBoardLabel = null; + + private JLabel scoreBoardLabel = null; + + private JButton gateSwitchButton; + + protected boolean open; + + private JTextField waterCollectedTextField; + + private JLabel waterCollectedLabel; + + private JTextField tokensNotInvestedTextField; + + private JLabel tokensNotInvestedLabel; + + private JTextField tokensEarnedTextField; + + private JLabel tokensEarnedLabel; + + private JTextField totalTokensEarnedTextField; + + private JLabel totalTokensEarnedLabel; + + private JLabel irrigationCapacityLabel; + + private JTextField irrigationCapacityTextField; + + private HtmlEditorPane waterCollectedToTokensTable; + + private JScrollPane waterCollectedToTokensScrollPane; + + public MainIrrigationGameWindow(IrrigationClient client) { + super(); + this.client = client; + setName("main irrigation game window"); + initialize(); + } + /** + * This method initializes this + * + * @return void + */ + + private void initialize() { + timeRemainingjLabel = new JLabel(); + timeRemainingjLabel.setBounds(new Rectangle(469, 39, 146, 23)); + timeRemainingjLabel.setHorizontalAlignment(SwingConstants.CENTER); + timeRemainingjLabel.setHorizontalTextPosition(SwingConstants.CENTER); + timeRemainingjLabel.setText("TIME REMAINING"); + timeRemainingjText = new JTextField(); + timeRemainingjText.setEditable(false); + timeRemainingjText.setBounds(new Rectangle(620, 39, 61, 23)); + timeRemainingjText.setText("50 sec"); + timeRemainingjText.setBackground(Color.white); + timeRemainingjText.setFont(new Font("serif", Font.BOLD, 14)); + timeRemainingjText.setForeground(new Color(102, 204, 255)); + timeRemainingjText.setHorizontalAlignment(SwingConstants.CENTER); + + this.setLayout(new BorderLayout(4,4)); + this.setSize(1130, 558); + this.add(getJPanelMain(),null); + + } + + private JPanel getJPanelMain() { + // TODO Auto-generated method stub + if(jPanelMain == null){ + jPanelMain = new JPanel(); + jPanelMain.setLayout(new BorderLayout(4,4)); + jPanelMain.setBackground(Color.WHITE); + jPanelMain.setForeground(Color.BLACK); + jPanelMain.add(getIrrigationCapacityLabel(), BorderLayout.NORTH); + jPanelMain.add(getDownloadScreenPanel(), BorderLayout.CENTER); + return jPanelMain; + } + return jPanelMain; + } + + private JPanel getDownloadScreenPanel() { + if(downloadScreenPanel == null){ + scoreBoardLabel = new JLabel(); + scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); + scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); + scoreBoardLabel.setText("WATER COLLECTED TO TOKENS EARNED TABLE"); + dashBoardLabel = new JLabel(); + dashBoardLabel.setBounds(new Rectangle(13,225+100+35,530,20)); + dashBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); + dashBoardLabel.setText("YOUR DASHBOARD"); + totalContributedBandwidthTextjLabel = new JLabel(); + totalContributedBandwidthTextjLabel.setBounds(new Rectangle(200, 18, 55, 17)); + totalContributedBandwidthTextjLabel.setText(""); + totalContributedBandwidthjLabel = new JLabel(); + totalContributedBandwidthjLabel.setBounds(new Rectangle(19, 17, 170, 16)); + totalContributedBandwidthjLabel.setText("Total Water Availability Capacity: "); + priorityjLabel = new JLabel(); + priorityjLabel.setBounds(new Rectangle(780, 16, 44, 16)); + priorityjLabel.setText(""); + downloadScreenPanel = new JPanel(); + downloadScreenPanel.setLayout(null); + downloadScreenPanel.setName("downloadScreenPanel"); + downloadScreenPanel.setBackground(Color.white); + downloadScreenPanel.add(getCenterPanel(),null); + downloadScreenPanel.add(getTimeLeftProgressBar(), null); + // downloadScreenPanel.add(timeRemainingjLabel, null); + // downloadScreenPanel.add(timeRemainingjText,null); + // downloadScreenPanel.add(totalContributedBandwidthjLabel, null); + // downloadScreenPanel.add(totalContributedBandwidthTextjLabel, null); + downloadScreenPanel.add(dashBoardLabel, null); + downloadScreenPanel.add(scoreBoardLabel, null); + } + return downloadScreenPanel; + } + + private JProgressBar getTimeLeftProgressBar() { + if (timeLeftProgressBar == null) { + timeLeftProgressBar = new JProgressBar(0, 50); + timeLeftProgressBar.setBounds(new Rectangle(360, 15, 370, 17)); + timeLeftProgressBar.setStringPainted(true); + } + return timeLeftProgressBar; + } + /** + * This method initializes jPanel + * + * @return javax.swing.JPanel + */ + private JPanel getCenterPanel() { + if (centerPanel == null) { + centerPanel = new JPanel(); + centerPanel.setLayout(null); + centerPanel.setBounds(new Rectangle(13, 64, 1098, 123)); + } + return centerPanel; + } + + private JPanel createCanalPanel(ClientDataModel clientDataModel) { + canalPanel = new CanalPanel(clientDataModel); + canalPanel.setSize(new Dimension(1098, 123)); + + return canalPanel; + } + + /** + * This method initializes jPanel1 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelUpStreamWindow() { + if (jPanelUpStreamWindow == null) { + jPanelUpStreamWindow = new JPanel(); + jPanelUpStreamWindow.setLayout(new BorderLayout()); + jPanelUpStreamWindow.setBackground(new Color(186, 226, 237)); + jPanelUpStreamWindow.setBounds(new Rectangle(13, 225+100+50, 530, 326)); + jPanelUpStreamWindow.add(getGateSwitchButton(), BorderLayout.CENTER); + } + return jPanelUpStreamWindow; + } + + private JButton getGateSwitchButton() { + if (gateSwitchButton == null) { + gateSwitchButton = new JButton("Open gate"); + // gateSwitchButton.setPreferredSize(new Dimension(100, 100)); + gateSwitchButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + open = !open; + gateSwitchButton.setText( open ? "Close gate" : "Open gate"); + if (open) { + client.openGate(); + } + else { + client.closeGate(); + } + } + }); + } + return gateSwitchButton; + } + + private JPanel getControlPanel() { + JPanel panel = new JPanel(); + panel.setPreferredSize(new Dimension(530, 326)); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.add(getGateSwitchButton()); + + JPanel bottomInformationPanel = new JPanel(); + GroupLayout layout = new GroupLayout(bottomInformationPanel); + bottomInformationPanel.setLayout(layout); + layout.setAutoCreateContainerGaps(true); + layout.setAutoCreateGaps(true); + + GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup(); + ParallelGroup labelsGroup = layout.createParallelGroup(); + labelsGroup.addComponent(getWaterCollectedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); + + horizontalGroup.addGroup(labelsGroup); + + ParallelGroup textFieldGroup = layout.createParallelGroup(); + textFieldGroup.addComponent(getWaterCollectedTextField()); + textFieldGroup.addComponent(getTokensNotInvestedTextField()); + textFieldGroup.addComponent(getTokensEarnedTextField()); + textFieldGroup.addComponent(getTotalTokensEarnedTextField()); + horizontalGroup.addGroup(textFieldGroup); + layout.setHorizontalGroup(horizontalGroup); + + GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup(); + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getWaterCollectedLabel()).addComponent(getWaterCollectedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTokensNotInvestedLabel()).addComponent(getTokensNotInvestedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTokensEarnedLabel()).addComponent(getTokensEarnedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); + + layout.setVerticalGroup(verticalGroup); + panel.add(bottomInformationPanel); + return panel; + } + + private JTextField getWaterCollectedTextField() { + if (waterCollectedTextField == null) { + waterCollectedTextField = createTextField(); + } + return waterCollectedTextField; + } + + private JTextField createTextField() { + JTextField textField = new JTextField(); + textField.setEditable(false); + textField.setBackground(Color.LIGHT_GRAY); + return textField; + } + + private JLabel getWaterCollectedLabel() { + if (waterCollectedLabel == null) { + waterCollectedLabel = new JLabel("Total water applied to your field: "); + } + return waterCollectedLabel; + } + + private JTextField getTokensNotInvestedTextField() { + if (tokensNotInvestedTextField == null) { + tokensNotInvestedTextField = createTextField(); + } + return tokensNotInvestedTextField; + } + private JLabel getTokensNotInvestedLabel() { + if (tokensNotInvestedLabel == null) { + tokensNotInvestedLabel = new JLabel("Tokens not invested: "); + } + return tokensNotInvestedLabel; + } + + private JTextField getTokensEarnedTextField() { + if (tokensEarnedTextField == null) { + tokensEarnedTextField = createTextField(); + } + return tokensEarnedTextField; + } + private JLabel getTokensEarnedLabel() { + if (tokensEarnedLabel == null) { + tokensEarnedLabel = new JLabel("Tokens earned by crop production: "); + } + return tokensEarnedLabel; + } + + private JTextField getTotalTokensEarnedTextField() { + if (totalTokensEarnedTextField == null) { + totalTokensEarnedTextField = createTextField(); + } + return totalTokensEarnedTextField; + + } + + private JLabel getTotalTokensEarnedLabel() { + if (totalTokensEarnedLabel == null) { + totalTokensEarnedLabel = new JLabel("Total tokens earned this round: "); + } + return totalTokensEarnedLabel; + } + + private JLabel getIrrigationCapacityLabel() { + if (irrigationCapacityLabel == null) { + irrigationCapacityLabel = new JLabel(); + irrigationCapacityLabel.setLabelFor(getIrrigationCapacityTextField()); + irrigationCapacityLabel.setFont(new Font("sansserif", Font.BOLD, 16)); + } + return irrigationCapacityLabel; + } + + private JTextField getIrrigationCapacityTextField() { + if (irrigationCapacityTextField == null) { + irrigationCapacityTextField = createTextField(); + } + return irrigationCapacityTextField; + } + /** + * This method initializes jPanel3 + * summary scoreboard + * @return javax.swing.JPanel + */ + private JPanel getJPanelDownStreamWindow() { + if (jPanelDownStreamWindow == null) { + jPanelDownStreamWindow = new JPanel(); + jPanelDownStreamWindow.setLayout(new BorderLayout()); + jPanelDownStreamWindow.setBackground(new Color(186, 226, 237)); + jPanelDownStreamWindow.setBounds(new Rectangle(582, 225 + 100+50, 530, 326)); + jPanelDownStreamWindow.add(getWaterCollectedToTokensTable(),BorderLayout.CENTER); + } + return jPanelDownStreamWindow; + } + + private JScrollPane getWaterCollectedToTokensTable() { + if (waterCollectedToTokensTable == null) { + waterCollectedToTokensTable = new HtmlEditorPane(); + waterCollectedToTokensTable.setEditable(false); + waterCollectedToTokensTable.setText(client.getServerConfiguration().getWaterCollectedToTokensTable()); + waterCollectedToTokensScrollPane = new JScrollPane(waterCollectedToTokensTable); + waterCollectedToTokensScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + } + return waterCollectedToTokensScrollPane; + } + + private Color getProgressBarColor(int timeLeft) { + if (timeLeft < 10) { + return Color.RED; + } + return Color.BLACK; + } + /** + * Should be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. + */ + public void updateClientStatus(final ClientDataModel clientDataModel) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + int timeLeft = clientDataModel.getTimeLeft(); + String timeLeftString = String.format("%d sec", timeLeft); + timeLeftProgressBar.setValue( timeLeft ); + timeLeftProgressBar.setString(timeLeftString); + timeLeftProgressBar.setForeground( getProgressBarColor(timeLeft) ); + for (final ClientData clientData : clientDataModel.getClientDataMap().values()) { + if (clientData.isGateOpen()) { + canalPanel.openGate(clientData.getPriority()); + } + else if(clientData.isPaused()){ + canalPanel.closeGate(clientData.getPriority()); + } + else if(clientData.isGateClosed()){ + canalPanel.closeGate(clientData.getPriority()); + } + } + ClientData clientData = clientDataModel.getClientData(); + getWaterCollectedTextField().setText("" + clientData.getWaterCollected()); + getTokensNotInvestedTextField().setText("" + clientData.getUninvestedTokens()); + getTokensEarnedTextField().setText("" + clientData.getTokensEarnedFromWaterCollected()); + getTotalTokensEarnedTextField().setText("" + clientData.getAllTokensEarnedThisRound()); + // getScoreBoxPanel().update(clientDataModel); + getMiddleWindowPanel().update(clientDataModel); + + } + + }); + } + // //this event gets called every second in the experiment. + // public void updateSendFileProgress(final ClientDataModel clientGameState) { + // // TODO Auto-generated method stub + // ////////////new code//////////////////////////////////////////////////////////// + // Runnable createGuiRunnable = new Runnable(){ + // public void run() { + // for(final ClientData clientData : clientGameState.getClientDataMap().values()){ + // timeRemainingjText.setText((new Integer(((int)clientGameState.getTimeLeft()))).toString()+"sec"); + // timeRemainingjProgressBar.setValue((int)clientGameState.getTimeLeft()); + // totalContributedBandwidthTextjLabel.setText((new Double(clientData.getGroupDataModel().getMaximumAvailableFlowCapacity())).toString()+" cubic feet per second (cfps)"); + // middleWindowPanel.update(clientGameState); + // if(clientGameState.getPriority() == clientData.getPriority()){ + // controlPanel.update(clientData); + // //per parameter score panel + //// scoreBoxPanel.update(clientData); + // } + // else{ + //// scoreBoxPanel.update(clientData); + // } + // if(clientData.isDownloading() == true){ + // upperPanel.openGates(clientData.getPriority()); + // + // } + // else if(clientData.isPaused() == true){ + // upperPanel.closeGates(clientData.getPriority()); + // } + // if(clientData.isStopped() == true){ + // upperPanel.closeGates(clientData.getPriority()); + // } + // } + // } + // + // }; + // try { + // SwingUtilities.invokeAndWait(createGuiRunnable); + // } catch (InterruptedException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (InvocationTargetException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + + /** + * changes the file button color to red when started downloading + * @param file + */ + + /* + * updates the irrigation window + */ + public void endRound() { + System.out.println("End of round."); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // controlPanel.endRound(); + centerPanel.removeAll(); + canalPanel.endRound(); + gateSwitchButton.setText("Open gate"); + } + + }); + open = false; + } + + /** + * assigns the priority to the window and prepares the irrigationWindowMap + */ + public void setClientDataModel(final ClientDataModel clientDataModel) { + this.clientDataModel = clientDataModel; + //Here a map is created with the map consisting of the + //irrigation window as the value and the priority value as the key. This is handled here , because + //the event contains the priority for every client, and the priority can act as a unique key for the + //game window. + + //checking the client priority and assigning the activity summary and client panel to the + //doownloadScreenPanel + fillPanels(clientDataModel); + + //This is helpful, if we need to scale the game to more than two users. We can declare + //more panels like middleStream Window, etc and add them in this switch case statement + + //case 2 : irrigationWindowMap.put(new Integer(clientData.getPriority()), middleStreamWindow); + } + + public void startRound() { + open = false; + getMiddleWindowPanel().initialize(clientDataModel); + int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); + irrigationCapacityLabel.setText( + String.format("Irrigation capacity: %d cubic feet per second (cfps)", + irrigationCapacity)); + + revalidate(); + // mainIrrigationPanel.add(getJPanelUpStreamWindow(),null); + // mainIrrigationPanel.add(getJPanelDownStreamWindow(),null); + //adding the in between Panel + // mainIrrigationPanel.add(getJPanelMiddleWindow(),null); + } + + + + + + /** + * fills in the panels depending on the priority of the client + */ + public void fillPanels(ClientDataModel clientDataModel) { + // TODO Auto-generated method stub + centerPanel.add(createCanalPanel(clientDataModel)); + //switch(clientGameState.getPriority()){ + + downloadScreenPanel.add(getJPanelUpStreamWindow(),null); + downloadScreenPanel.add(getJPanelDownStreamWindow(),null); + //adding the in between Panel + downloadScreenPanel.add(getMiddleWindowPanel(),null); + /*case 0 : downloadScreenPanel.add(getJPanelUpStreamWindow(0),null); + downloadScreenPanel.add(getJPanelDownStreamWindow(0),null); + //Assigning the Priorities on the Priority Label + break; + + case 1 : downloadScreenPanel.add(getJPanelUpStreamWindow(1),null); + downloadScreenPanel.add(getJPanelDownStreamWindow(1),null); + //Assigning the Priorities on the Priority Label + break; + */ } + + private MiddleWindowPanel getMiddleWindowPanel() { + // TODO Auto-generated method stub + if(middleWindowPanel == null) { + middleWindowPanel = new MiddleWindowPanel(); + } + return middleWindowPanel; + } + + public ClientDataModel getClientDataModel() { + return clientDataModel; + } +} \ No newline at end of file Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-22 06:25:19 UTC (rev 316) @@ -23,11 +23,11 @@ private JLabel positionText; - private JLabel currentBandwidthText; + private JLabel availableFlowCapacityLabel; - private JLabel waterUsedTextField; + private JLabel waterCollectedLabel; - private JLabel totalTokensEarnedTextField; + private JLabel tokensCollectedLabel; private int priority; @@ -44,33 +44,33 @@ this.clientData = clientData; setBackground( clientData.getPriority() == priority ? Color.GREEN : Color.YELLOW); this.setPreferredSize(new Dimension(60,200)); - this.add(getPositionText(),null); - this.add(getWaterUsedTextField(),null); - this.add(getCurrentBandwidth(),null); - this.add(getTokensCollected(),null); + this.add(getPositionLabel(),null); + this.add(getWaterCollectedLabel(),null); + this.add(getAvailableFlowCapacityLabel(),null); + this.add(getTokensCollectedLabel(),null); } - private JLabel getTokensCollected() { - if(totalTokensEarnedTextField == null){ - totalTokensEarnedTextField = new JLabel(); - totalTokensEarnedTextField.setBounds(new Rectangle(5,50+32+10+20+10+20+10+20+10,30,20)); - totalTokensEarnedTextField.setText(""); + private JLabel getTokensCollectedLabel() { + if(tokensCollectedLabel == null){ + tokensCollectedLabel = new JLabel(); + tokensCollectedLabel.setBounds(new Rectangle(5,50+32+10+20+10+20+10+20+10,30,20)); + tokensCollectedLabel.setText(""); } - return totalTokensEarnedTextField; + return tokensCollectedLabel; } - private JLabel getCurrentBandwidth() { - if(currentBandwidthText == null){ - currentBandwidthText = new JLabel(); - currentBandwidthText.setBounds(new Rectangle(5,50+32+10+20+10,30,20)); - currentBandwidthText.setText(""); + private JLabel getAvailableFlowCapacityLabel() { + if(availableFlowCapacityLabel == null){ + availableFlowCapacityLabel = new JLabel(); + availableFlowCapacityLabel.setBounds(new Rectangle(5,50+32+10+20+10,30,20)); + availableFlowCapacityLabel.setText(""); } - return currentBandwidthText; + return availableFlowCapacityLabel; } - private JLabel getPositionText() { + private JLabel getPositionLabel() { if (positionText == null){ positionText = new JLabel(clientData.getPriorityString()); positionText.setBounds(new Rectangle(5,50+32+10,30,20)); @@ -79,19 +79,19 @@ } - private JLabel getWaterUsedTextField() { - if(waterUsedTextField == null){ - waterUsedTextField = new JLabel("0"); - waterUsedTextField.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); + private JLabel getWaterCollectedLabel() { + if(waterCollectedLabel == null){ + waterCollectedLabel = new JLabel("0"); + waterCollectedLabel.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); } - return waterUsedTextField; + return waterCollectedLabel; } public void update(ClientData clientData) { this.clientData = clientData; - currentBandwidthText.setText("" + clientData.getAvailableFlowCapacity()); - waterUsedTextField.setText("" + clientData.getWaterCollected()); - totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); + availableFlowCapacityLabel.setText("" + clientData.getAvailableFlowCapacity()); + waterCollectedLabel.setText("" + clientData.getWaterCollected()); + tokensCollectedLabel.setText("" + clientData.getAllTokensEarnedThisRound()); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { // show that client is actively irrigating Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-22 06:25:19 UTC (rev 316) @@ -1,15 +1,10 @@ -/** - * - */ package edu.asu.commons.irrigation.client; import java.awt.Dimension; import java.awt.Rectangle; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import javax.swing.JLabel; import javax.swing.JPanel; @@ -17,23 +12,23 @@ import edu.asu.commons.irrigation.server.ClientData; /** - * @author Sanket - * + * $Id$ + * + * + * @author Allen Lee, Sanket Joshi */ public class MiddleWindowPanel extends JPanel { private static final long serialVersionUID = 2892921110280857458L; - //Map<Integer, MiddleScorePanel>middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); - Map<Integer, JLabel>jLabelMap = new LinkedHashMap<Integer, JLabel>(); // @jve:decl-index=0: - -// Map<Integer, MiddleScorePanel> middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); private List<MiddleScorePanel> middleScorePanels = new ArrayList<MiddleScorePanel>(); - JLabel positionLabel; - JLabel availableBandwidthLabel; - JLabel filesDownLoadedLabel; - JLabel tokensCollectedLabel; + private JLabel positionLabel; + private JLabel availableWaterLabel; + private JLabel waterCollectedLabel; + private JLabel tokensEarnedLabel; + private JLabel tokensNotInvestedLabel; + private JLabel totalTokensEarnedLabel; public MiddleWindowPanel() { @@ -42,30 +37,32 @@ this.setSize(new Dimension(1093,200)); positionLabel = new JLabel(); - positionLabel.setBounds(new Rectangle(80,50+32+10,150,20)); + positionLabel.setBounds(new Rectangle(30,50+32+10,150,20)); positionLabel.setText("Position"); - availableBandwidthLabel = new JLabel(); - availableBandwidthLabel.setBounds(new Rectangle(80,50+32+10+20+10,150,20)); - availableBandwidthLabel.setText("Available Flow Capacity"); + availableWaterLabel = new JLabel(); + availableWaterLabel.setBounds(new Rectangle(30,50+32+10+20+10,200,20)); + availableWaterLabel.setText("Available water per second"); - filesDownLoadedLabel = new JLabel(); - filesDownLoadedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10, 150,20)); - filesDownLoadedLabel.setText("Crops Grown"); + waterCollectedLabel = new JLabel(); + waterCollectedLabel.setBounds(new Rectangle(30,50+32+10+20+10+20+10, 150,20)); + waterCollectedLabel.setText("Water collected"); - tokensCollectedLabel = new JLabel(); - tokensCollectedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10+20+10, 150,20)); - tokensCollectedLabel.setText("Tokens Collected"); + tokensEarnedLabel = new JLabel(); + tokensEarnedLabel.setBounds(new Rectangle(30,50+32+10+20+10+20+10+20+10, 200,20)); + tokensEarnedLabel.setText("Tokens earned "); this.add(positionLabel, null); - this.add(availableBandwidthLabel, null); - this.add(filesDownLoadedLabel, null); - this.add(tokensCollectedLabel, null); + this.add(availableWaterLabel, null); + this.add(waterCollectedLabel, null); + this.add(tokensEarnedLabel, null); } public void initialize(ClientDataModel clientDataModel) { - removeAll(); - middleScorePanels.clear(); + for (MiddleScorePanel panel: middleScorePanels) { + remove(panel); + } + middleScorePanels.clear(); for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { int priority = clientData.getPriority(); MiddleScorePanel middleScorePanel = new MiddleScorePanel(clientDataModel.getPriority(), clientData); @@ -76,8 +73,6 @@ } public void update(ClientDataModel clientDataModel) { - // TODO Auto-generated method stub - //jLabelMap.get(new Integer(clientData.getPriority())).setText(new Integer(clientData.getFilesDownloaded()).toString()); for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { middleScorePanels.get(clientData.getPriority()).update(clientData); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-10-22 06:25:19 UTC (rev 316) @@ -145,6 +145,10 @@ "general-instructions"+pageNumber, "<b>No instructions available for this round</b>"); } + + public String getWaterCollectedToTokensTable() { + return assistant.getProperty("water-collected-to-tokens-table"); + } public String getFinalInstructions() { return assistant.getProperty("final-instructions", "<b>The experiment is now over. Thanks for participating!</b>"); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/OpenGateEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/OpenGateEvent.java 2009-10-22 00:04:03 UTC (rev 315) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/OpenGateEvent.java 2009-10-22 06:25:19 UTC (rev 316) @@ -4,8 +4,12 @@ import edu.asu.commons.net.Identifier; /** - * + * $Id$ + * + * Signifies that a client opened a gate. * + * @author Allen Lee + * @revision $Rev$ */ public class OpenGateEvent extends AbstractPersistableEvent { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-22 00:04:17
|
Revision: 315 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=315&view=rev Author: alllee Date: 2009-10-22 00:04:03 +0000 (Thu, 22 Oct 2009) Log Message: ----------- - improved time progressbar and removed time left label/textfields in favor of a unified time left progressbar with text - updated debriefing instructions - testing out different layout packages - using system look and feel instead of crappy java metal look and feel Modified Paths: -------------- irrigation/trunk/pom.xml irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java Modified: irrigation/trunk/pom.xml =================================================================== --- irrigation/trunk/pom.xml 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/pom.xml 2009-10-22 00:04:03 UTC (rev 315) @@ -57,6 +57,11 @@ <version>1.0.13</version> </dependency> <dependency> + <groupId>com.miglayout</groupId> + <artifactId>miglayout</artifactId> + <version>3.7.1</version> + </dependency> + <dependency> <groupId>jgoodies</groupId> <artifactId>looks</artifactId> <version>1.2.2</version> Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-22 00:04:03 UTC (rev 315) @@ -65,7 +65,6 @@ } /** - * This method initializes this * * @return void */ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-22 00:04:03 UTC (rev 315) @@ -4,14 +4,12 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -114,23 +112,14 @@ this.numberOfGeneralInstructionPages = getServerConfiguration().getNumberOfGeneralInstructionPages(); } - void initialize(Dimension screenSize) { - initGuiComponents(screenSize); - } - - private void initGuiComponents(Dimension screenSize) { + void initialize() { cardLayout = new CardLayout(); setLayout(cardLayout); - instructionsScrollPane = new JScrollPane(getInstructionsEditorPane()); - instructionsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - instructionsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - // create a quiz listener and then initialize the instructions. - instructionsEditorPane.setActionListener(createQuizListener(getServerConfiguration())); - instructionsEditorPane.setCaretPosition(0); + setInstructions(getGeneralInstructions(0)); addToCardLayout(getInstructionsPanel()); - irrigationGamePanel = new IrrigationGamePanel(screenSize, client); + irrigationGamePanel = new IrrigationGamePanel(client); addToCardLayout(irrigationGamePanel); addToCardLayout(getInvestTokensPanel()); addToCardLayout(getChatPanel()); @@ -183,13 +172,22 @@ } return submitTokenPanel; } + + private JScrollPane getInstructionsScrollPane() { + if (instructionsScrollPane == null) { + instructionsScrollPane = new JScrollPane(getInstructionsEditorPane()); + instructionsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + instructionsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } + return instructionsScrollPane; + } private JPanel getInstructionsPanel() { if (instructionsPanel == null) { instructionsPanel = new JPanel(); - instructionsPanel.setName("General instructions panel"); + instructionsPanel.setName("Instructions panel"); instructionsPanel.setLayout(new BorderLayout()); - instructionsPanel.add(instructionsScrollPane, BorderLayout.CENTER); + instructionsPanel.add(getInstructionsScrollPane(), BorderLayout.CENTER); instructionsPanel.add(getInstructionsNavigationPanel(), BorderLayout.PAGE_END); } return instructionsPanel; @@ -353,6 +351,10 @@ if (instructionsEditorPane == null) { instructionsEditorPane = createInstructionsEditorPane(); instructionsEditorPane.setName("Instructions editor pane"); + // create a quiz listener and then initialize the instructions. + instructionsEditorPane.setActionListener(createQuizListener(getServerConfiguration())); + instructionsEditorPane.setCaretPosition(0); + instructionsEditorPane.setBackground(Color.WHITE); } return instructionsEditorPane; } @@ -360,7 +362,7 @@ private HtmlEditorPane createInstructionsEditorPane() { HtmlEditorPane htmlEditorPane = new HtmlEditorPane(); htmlEditorPane.setEditable(false); - htmlEditorPane.setFont(new Font("serif", Font.PLAIN, 12)); + htmlEditorPane.setFont(new Font("sansserif", Font.TRUETYPE_FONT, 14)); return htmlEditorPane; } @@ -392,22 +394,13 @@ */ public void endRound(final EndRoundEvent event) { irrigationGamePanel.endRound(); - Runnable runnable = new Runnable() { + SwingUtilities.invokeLater(new Runnable() { public void run() { investedTokensTextField.setText(""); addDebriefingText(event); addCenterComponent(getInstructionsPanel()); } - }; - try { - SwingUtilities.invokeAndWait(runnable); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } + }); info("ExperimentGameWindow finished cleanup, ending round completed."); } @@ -421,17 +414,20 @@ */ private void addDebriefingText(EndRoundEvent event) { instructionsBuilder.delete(0, instructionsBuilder.length()); - instructionsBuilder.append("<b>You were in position " + clientDataModel.getPriorityString()); + instructionsBuilder.append("<b>You are at position " + clientDataModel.getPriorityString()); instructionsBuilder.append( - "<table><thead><th>Position</th><th>Initial token endowment</th><th>Tokens invested</th><th>Tokens not invested</th>" + + "<table border='3' cellpadding='5'><thead><th>Position</th><th>Initial token endowment</th><th>Tokens invested</th><th>Tokens not invested</th>" + "<th>Tokens earned from growing crops</th><th>Total tokens earned during this round</th>" + "<th>Dollars earned during this round</th><th>Total dollars earned (including show-up bonus)</th></thead>" + "<tbody>"); double showUpBonus = clientDataModel.getServerConfiguration().getShowUpPayment(); + RoundConfiguration roundConfiguration = clientDataModel.getRoundConfiguration(); for(ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + String backgroundColor = clientData.getPriority() == clientDataModel.getPriority() ? "#FFFFCC" : "CCCCCC"; instructionsBuilder.append( - String.format("<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>$%3.2f</td><td>$%3.2f</td></tr>", - clientData.getPriorityString(), + String.format("<tr align='center' bgcolor='%s'><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>$%3.2f</td><td>$%3.2f</td></tr>", + backgroundColor, + clientData.getPriorityString(), clientData.getMaximumTokenInvestment(), clientData.getInvestedTokens(), clientData.getUninvestedTokens(), @@ -443,81 +439,28 @@ } ClientData clientData = clientDataModel.getClientData(); - RoundConfiguration configuration = clientDataModel.getRoundConfiguration(); - instructionsBuilder.append("</tbody></table><hr/>"); instructionsBuilder.append(String.format("<h3>You received $%3.2f this past round. Your total earnings are $%3.2f, including the $%3.2f show up bonus.</h3>", clientData.getTotalDollarsEarnedThisRound(), clientData.getTotalDollarsEarned()+showUpBonus, showUpBonus)); - // FIXME: wow. change this. -// instructionsBuilder.append(String.format( -// positionString + -// -// allClientData[0].getInvestedTokens(), -// allClientData[1].getInvestedTokens(), -// allClientData[2].getInvestedTokens(), -// allClientData[3].getInvestedTokens(), -// allClientData[4].getInvestedTokens(), -// -// allClientData[0].getUninvestedTokens(), -// allClientData[1].getUninvestedTokens(), -// allClientData[2].getUninvestedTokens(), -// allClientData[3].getUninvestedTokens(), -// allClientData[4].getUninvestedTokens(), -// -// allClientData[0].getTotalTokensEarned() - allClientData[0].getUninvestedTokens(), -// allClientData[1].getTotalTokensEarned() - allClientData[1].getUninvestedTokens(), -// allClientData[2].getTotalTokensEarned() - allClientData[2].getUninvestedTokens(), -// allClientData[3].getTotalTokensEarned() - allClientData[3].getUninvestedTokens(), -// allClientData[4].getTotalTokensEarned() - allClientData[4].getUninvestedTokens(), -// -// allClientData[0].getTotalTokensEarned(), -// allClientData[1].getTotalTokensEarned(), -// allClientData[2].getTotalTokensEarned(), -// allClientData[3].getTotalTokensEarned(), -// allClientData[4].getTotalTokensEarned(), -// -// (float)dollarsPerToken*allClientData[0].getTotalTokensEarned(), -// (float)dollarsPerToken*allClientData[1].getTotalTokensEarned(), -// (float)dollarsPerToken*allClientData[2].getTotalTokensEarned(), -// (float)dollarsPerToken*allClientData[3].getTotalTokensEarned(), -// (float)dollarsPerToken*allClientData[4].getTotalTokensEarned() -// -// /* -// event.getClientData().getContributedTokens(),otherClientData.getContributedTokens(), -// 10 - event.getClientData().getContributedTokens(),10 - otherClientData.getContributedTokens(), -// event.getClientData().getAward()-(10 - event.getClientData().getContributedTokens()), -// otherClientData.getAward()-(10 - otherClientData.getContributedTokens()), -// event.getClientData().getAward(),otherClientData.getAward(), -// (float)event.getClientData().getRoundConfiguration().getDollarsPerToken()*event.getClientData().getAward(), -// (float)otherClientData.getRoundConfiguration().getDollarsPerToken()*otherClientData.getAward()*/ -// )); -// instructionsBuilder.append("</tbody></table><hr>"); -// instructionsBuilder.append(String.format("Summary: You received $1.00 at the beginning of the round and had " + -// "$%3.2f at the end of the round. Your earnings in the experiments so far are $%3.2f plus the $5.00 " + -// "showup fee, for a grand total of $%3.2f", -// (float)dollarsPerToken*clientData.getAllTokensEarnedThisRound(), -// (float)dollarsPerToken*clientData.getTotalTokens(), -// (float)dollarsPerToken*clientData.getTotalTokens() + getServerConfiguration().getShowUpPayment() -// )); //append the added practice round instructions - if(clientDataModel.getRoundConfiguration().isPracticeRound()) { - instructionsBuilder.append(" However, this is a practice round and the earnings mentioned are only for illustrative purposes " + - "and will not count towards your actual payments"); + + if (roundConfiguration.isPracticeRound() || roundConfiguration.isSecondPracticeRound()) { + instructionsBuilder.append(roundConfiguration.getPracticeRoundPaymentInstructions()); } else if (event.isLastRound()) { instructionsBuilder.append(getServerConfiguration().getFinalInstructions()); } + instructionsBuilder.append("<hr/>"); setInstructions(instructionsBuilder.toString()); } // adding the instructions into the instruction Panel private void setInstructions(final String instructions) { -// System.err.println("Setting instructions: " + instructions); SwingUtilities.invokeLater(new Runnable() { public void run() { - instructionsEditorPane.setText(instructions); - instructionsEditorPane.setCaretPosition(0); - instructionsScrollPane.revalidate(); + getInstructionsEditorPane().setText(instructions); + getInstructionsEditorPane().setCaretPosition(0); + getInstructionsScrollPane().revalidate(); } }); } @@ -526,7 +469,6 @@ return new ActionListener() { private Map<String, String> quizAnswers = configuration.getQuizAnswers(); public void actionPerformed(ActionEvent e){ - // System.err.println("In action performed with event: " + e); FormActionEvent formEvent = (FormActionEvent) e; Properties responses = formEvent.getData(); List<String> incorrectAnswers = new ArrayList<String>(); @@ -575,7 +517,7 @@ public void displayTokenContributions(final ClientData clientData) { GroupDataModel groupDataModel = clientData.getGroupDataModel(); - int totalContributedTokensPerGroup = groupDataModel.getTotalContributedTokens(); + int totalContributedTokens = groupDataModel.getTotalContributedTokens(); final StringBuilder builder = new StringBuilder(); builder.append("Infrastructure efficiency before investment: ") .append(groupDataModel.getInitialInfrastructureEfficiency()) @@ -584,14 +526,14 @@ builder.append( String.format( "Your group invested a total of %d tokens, increasing the infrastructure efficiency to %d%%.\n", - groupDataModel.getTotalContributedTokens(), groupDataModel.getInfrastructureEfficiency())); + totalContributedTokens, groupDataModel.getInfrastructureEfficiency())); if (groupDataModel.getFlowCapacity() > groupDataModel.getInitialFlowCapacity()) { builder.append("Your group's investment has increased the irrigation capacity to "); } else { - builder.append("Your group's irrigation capacity after investment is "); + builder.append("Your group's investment was not enough to increase the irrigation capacity. Your group's irrigation capacity is still "); } - builder.append(groupDataModel.getFlowCapacity()).append('.'); + builder.append(groupDataModel.getFlowCapacity()).append(" cubic feet of water per second."); SwingUtilities.invokeLater(new Runnable() { public void run() { contributionInformationTextArea.setText(builder.toString()); @@ -645,7 +587,7 @@ } public void updateRoundInstructions(RoundConfiguration roundConfiguration) { - System.err.println("Updating round instructions: " + roundConfiguration.getInstructions()); + info("Updating round instructions: " + roundConfiguration.getInstructions()); // if this is the first round, show the general instructions. if (roundConfiguration.isFirstRound()) { @@ -685,7 +627,6 @@ public void actionPerformed(ActionEvent event) { final long timeRemaining = endTime - System.currentTimeMillis(); if (timeRemaining < 0) { - sleep(); addCenterComponent(getInvestTokensPanel()); getInvestedTokensTextField().requestFocusInWindow(); timer.stop(); @@ -699,8 +640,7 @@ private void sleep() { long prevTime = System.currentTimeMillis(); while((System.currentTimeMillis() - prevTime) < 5000) { - //System.out.println("Prev "+prevTime); - //System.out.println("Current "+System.currentTimeMillis()); + chatPanel.setEnabled(false); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-22 00:04:03 UTC (rev 315) @@ -1,11 +1,11 @@ package edu.asu.commons.irrigation.client; -import java.awt.Dimension; import java.util.LinkedHashMap; import java.util.Map; import javax.swing.JFrame; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import edu.asu.commons.event.Event; import edu.asu.commons.event.EventChannel; @@ -74,10 +74,10 @@ initEventProcessors(); } - private void initialize(Dimension screenSize) { + private void initialize() { clientDataModel = new ClientDataModel(channel, this); experimentGameWindow = new ExperimentGameWindow(this); - experimentGameWindow.initialize(screenSize); + experimentGameWindow.initialize(); connect(); } @@ -96,14 +96,19 @@ } public static void main(String[] args) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (Exception exception) { + exception.printStackTrace(); + } Runnable createGuiRunnable = new Runnable() { public void run() { - Dimension defaultDimension = new Dimension(500, 500); JFrame frame = new JFrame(); IrrigationClient client = new IrrigationClient(); - client.initialize(defaultDimension); + client.initialize(); frame.setTitle("Virtual Commons Experiment Client: " + client.id); - frame.setSize(1130, 600); +// frame.setSize(1130, 600); frame.getContentPane().add(client.getExperimentGameWindow()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-22 00:04:03 UTC (rev 315) @@ -3,8 +3,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; -import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException; @@ -16,7 +14,6 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JTextField; -import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.ParallelGroup; @@ -37,29 +34,21 @@ private static final long serialVersionUID = -3878952269498777014L; - public IrrigationGameWindow irrigationGameWindow; +// private IrrigationGameWindow irrigationGameWindow; - public CanalPanel canalPanel; + private CanalPanel canalPanel; //this contains the CanalPanel - private JPanel upperPanel = null; - //this contains the upstream and downstream Panel - private JPanel jPanelUpStreamWindow = null; - private JPanel jPanelDownStreamWindow = null; -// private JPanel mainIrrigationPanel = null; + private JPanel upperPanel; private ScoreBoxPanel scoreBoxPanel; - public IrrigationClient client; + private IrrigationClient client; - public Dimension screenSize; +// private Dimension screenSize; - public JProgressBar timeRemainingProgressBar; + private JProgressBar timeLeftProgressBar; - private JLabel timeRemainingLabel; - - private JTextField timeRemainingTextField; - private JButton gateSwitchButton; private JLabel irrigationCapacityLabel; @@ -80,9 +69,9 @@ private JLabel tokensNotInvestedLabel; - private JLabel waterUsedLabel; + private JLabel waterCollectedLabel; - private JTextField waterUsedTextField; + private JTextField waterCollectedTextField; private JTextField tokensNotInvestedTextField; @@ -92,9 +81,10 @@ private boolean open; - public IrrigationGamePanel(Dimension screenSize, IrrigationClient client) { + private JTextField irrigationCapacityTextField; + + public IrrigationGamePanel(IrrigationClient client) { setName("Irrigation Game Panel"); - this.screenSize = screenSize; this.client = client; initGuiComponents(); } @@ -106,17 +96,10 @@ JPanel topmostPanel = new JPanel(); - topmostPanel.setLayout(new BoxLayout(topmostPanel, BoxLayout.X_AXIS)); + topmostPanel.setLayout(new BoxLayout(topmostPanel, BoxLayout.Y_AXIS)); topmostPanel.add(getIrrigationCapacityLabel()); + topmostPanel.add(getTimeLeftProgressBar()); - JPanel timeRemainingPanel = new JPanel(); - timeRemainingPanel.setLayout(new BoxLayout(timeRemainingPanel, BoxLayout.Y_AXIS)); - timeRemainingPanel.add(getTimeRemainingProgressBar()); - timeRemainingPanel.add(getTimeRemainingPanel()); - - topmostPanel.add(timeRemainingPanel); - - setLayout(new BorderLayout()); add(topmostPanel, BorderLayout.PAGE_START); add(getUpperPanel(), BorderLayout.CENTER); @@ -136,12 +119,12 @@ GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup(); ParallelGroup labelsGroup = layout.createParallelGroup(); - labelsGroup.addComponent(getWaterUsedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); + labelsGroup.addComponent(getWaterCollectedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); horizontalGroup.addGroup(labelsGroup); ParallelGroup textFieldGroup = layout.createParallelGroup(); - textFieldGroup.addComponent(getWaterUsedTextField()); + textFieldGroup.addComponent(getWaterCollectedTextField()); textFieldGroup.addComponent(getTokensNotInvestedTextField()); textFieldGroup.addComponent(getTokensEarnedTextField()); textFieldGroup.addComponent(getTotalTokensEarnedTextField()); @@ -150,7 +133,7 @@ GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup(); verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(getWaterUsedLabel()).addComponent(getWaterUsedTextField())); + .addComponent(getWaterCollectedLabel()).addComponent(getWaterCollectedTextField())); verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getTokensNotInvestedLabel()).addComponent(getTokensNotInvestedTextField())); @@ -175,11 +158,11 @@ return panel; } - private JTextField getWaterUsedTextField() { - if (waterUsedTextField == null) { - waterUsedTextField = createTextField(); + private JTextField getWaterCollectedTextField() { + if (waterCollectedTextField == null) { + waterCollectedTextField = createTextField(); } - return waterUsedTextField; + return waterCollectedTextField; } private JTextField createTextField() { @@ -189,11 +172,11 @@ return textField; } - private JLabel getWaterUsedLabel() { - if (waterUsedLabel == null) { - waterUsedLabel = new JLabel("Water units collected: "); + private JLabel getWaterCollectedLabel() { + if (waterCollectedLabel == null) { + waterCollectedLabel = new JLabel("Total water applied to your field: "); } - return waterUsedLabel; + return waterCollectedLabel; } private JTextField getTokensNotInvestedTextField() { @@ -237,30 +220,20 @@ return totalTokensEarnedLabel; } - private JPanel getTimeRemainingPanel() { - timeRemainingLabel = new JLabel("Time left: "); - timeRemainingLabel.setHorizontalAlignment(SwingConstants.CENTER); - timeRemainingLabel.setHorizontalTextPosition(SwingConstants.CENTER); - timeRemainingTextField = new JTextField("50 sec"); - timeRemainingTextField.setEditable(false); - timeRemainingTextField.setBackground(Color.white); - timeRemainingTextField.setFont(new Font("serif", Font.BOLD, 14)); - timeRemainingTextField.setForeground(new Color(102, 204, 255)); - timeRemainingTextField.setHorizontalAlignment(SwingConstants.CENTER); - - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - panel.add(timeRemainingLabel); - panel.add(timeRemainingTextField); - return panel; - } - private JLabel getIrrigationCapacityLabel() { if (irrigationCapacityLabel == null) { - irrigationCapacityLabel = new JLabel("Irrigation capacity: "); + irrigationCapacityLabel = new JLabel(); + irrigationCapacityLabel.setLabelFor(getIrrigationCapacityTextField()); } return irrigationCapacityLabel; } + + private JTextField getIrrigationCapacityTextField() { + if (irrigationCapacityTextField == null) { + irrigationCapacityTextField = createTextField(); + } + return irrigationCapacityTextField; + } // private JPanel getMainIrrigationPanel() { // if (mainIrrigationPanel == null) { @@ -313,49 +286,49 @@ return gateSwitchButton; } - private JPanel getCanalPanel() { + private JPanel createCanalPanel() { canalPanel = new CanalPanel(clientDataModel); return canalPanel; } - /** - * This method initializes jPanel1 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelUpStreamWindow() { - if (jPanelUpStreamWindow == null) { - jPanelUpStreamWindow = new JPanel(); - jPanelUpStreamWindow.setLayout(null); - jPanelUpStreamWindow.setBackground(new Color(186, 226, 237)); - jPanelUpStreamWindow.setBounds(new Rectangle(13, 225+100+50, 530, 326)); - jPanelUpStreamWindow.add(getControlPanel(), null); - } - return jPanelUpStreamWindow; - } +// private IrrigationGameWindow getIrrigationGameWindow() { +// if(irrigationGameWindow == null) { +// irrigationGameWindow = new IrrigationGameWindow(screenSize,client,this); +// } +// return irrigationGameWindow; +// } + +// /** +// * This method initializes jPanel1 +// * +// * @return javax.swing.JPanel +// */ +// private JPanel getJPanelUpStreamWindow() { +// if (jPanelUpStreamWindow == null) { +// jPanelUpStreamWindow = new JPanel(); +// jPanelUpStreamWindow.setLayout(null); +// jPanelUpStreamWindow.setBackground(new Color(186, 226, 237)); +// jPanelUpStreamWindow.setBounds(new Rectangle(13, 225+100+50, 530, 326)); +// jPanelUpStreamWindow.add(getIrrigationGameWindow(), null); +// } +// return jPanelUpStreamWindow; +// } +// /** +// * This method initializes jPanel3 +// * +// * @return javax.swing.JPanel +// */ +// private JPanel getJPanelDownStreamWindow() { +// if (jPanelDownStreamWindow == null) { +// jPanelDownStreamWindow = new JPanel(); +// jPanelDownStreamWindow.setLayout(null); +// jPanelDownStreamWindow.setBackground(new Color(186, 226, 237)); +// jPanelDownStreamWindow.setBounds(new Rectangle(582, 225 + 100+50, 530, 326)); +// jPanelDownStreamWindow.add(getScoreBoxPanel(),null); +// } +// return jPanelDownStreamWindow; +// } - private IrrigationGameWindow getControlPanel() { - if(irrigationGameWindow == null) { - irrigationGameWindow = new IrrigationGameWindow(screenSize,client,this); - } - return irrigationGameWindow; - } - /** - * This method initializes jPanel3 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelDownStreamWindow() { - if (jPanelDownStreamWindow == null) { - jPanelDownStreamWindow = new JPanel(); - jPanelDownStreamWindow.setLayout(null); - jPanelDownStreamWindow.setBackground(new Color(186, 226, 237)); - jPanelDownStreamWindow.setBounds(new Rectangle(582, 225 + 100+50, 530, 326)); - jPanelDownStreamWindow.add(getScoreBoxPanel(),null); - } - return jPanelDownStreamWindow; - } - private ScoreBoxPanel getScoreBoxPanel() { if(scoreBoxPanel == null){ scoreBoxPanel = new ScoreBoxPanel(); @@ -369,25 +342,33 @@ * * @return javax.swing.JProgressBar */ - private JProgressBar getTimeRemainingProgressBar() { - if (timeRemainingProgressBar == null) { - timeRemainingProgressBar = new JProgressBar(0, 50); - timeRemainingProgressBar.setBackground(Color.white); - timeRemainingProgressBar.setForeground(new Color(51, 153, 255)); + private JProgressBar getTimeLeftProgressBar() { + if (timeLeftProgressBar == null) { + timeLeftProgressBar = new JProgressBar(0, 50); + timeLeftProgressBar.setStringPainted(true); } - return timeRemainingProgressBar; + return timeLeftProgressBar; } - + + private Color getProgressBarColor(int timeLeft) { + if (timeLeft < 10) { + return Color.RED; + } + return Color.BLACK; + } + /** * Should be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. */ public void updateClientStatus(final ClientDataModel clientDataModel) { - Runnable createGuiRunnable = new Runnable(){ + SwingUtilities.invokeLater(new Runnable() { public void run() { int timeLeft = clientDataModel.getTimeLeft(); int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); - timeRemainingTextField.setText( timeLeft + " sec"); - timeRemainingProgressBar.setValue( timeLeft ); + String timeLeftString = String.format("%d sec", timeLeft); + timeLeftProgressBar.setValue( timeLeft ); + timeLeftProgressBar.setString(timeLeftString); + timeLeftProgressBar.setForeground( getProgressBarColor(timeLeft) ); irrigationCapacityLabel.setText( String.format("Irrigation capacity: %d cubic feet per second (cfps)", irrigationCapacity)); @@ -404,7 +385,7 @@ } } ClientData clientData = clientDataModel.getClientData(); - waterUsedTextField.setText("" + clientData.getWaterUsed()); + waterCollectedTextField.setText("" + clientData.getWaterCollected()); tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); tokensEarnedTextField.setText("" + clientData.getTokensEarnedFromWaterCollected()); totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); @@ -413,16 +394,7 @@ } - }; - try { - SwingUtilities.invokeAndWait(createGuiRunnable); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } + }); } /** @@ -469,7 +441,7 @@ */ public void startRound() { open = false; - upperPanel.add(getCanalPanel(), BorderLayout.CENTER); + upperPanel.add(createCanalPanel(), BorderLayout.CENTER); getScoreBoxPanel().initialize(clientDataModel); getMiddleWindowPanel().initialize(clientDataModel); revalidate(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-22 00:04:03 UTC (rev 315) @@ -90,7 +90,7 @@ public void update(ClientData clientData) { this.clientData = clientData; currentBandwidthText.setText("" + clientData.getAvailableFlowCapacity()); - waterUsedTextField.setText("" + clientData.getWaterUsed()); + waterUsedTextField.setText("" + clientData.getWaterCollected()); totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-22 00:04:03 UTC (rev 315) @@ -52,10 +52,10 @@ availableWaterLabels.add(availableWaterLabel); add(availableWaterLabel); } - // water used + // water collected add(new JLabel("Water collected:")); for (ClientData clientData : clientDataList) { - JLabel waterUsedLabel = new JLabel("" + clientData.getWaterUsed()); + JLabel waterUsedLabel = new JLabel("" + clientData.getWaterCollected()); waterUsedLabels.add(waterUsedLabel); add(waterUsedLabel); } @@ -68,7 +68,7 @@ JLabel availableWaterLabel = availableWaterLabels.get(index); availableWaterLabel.setText("" + clientData.getAvailableFlowCapacity()); JLabel waterUsedLabel = waterUsedLabels.get(index); - waterUsedLabel.setText("" + clientData.getWaterUsed()); + waterUsedLabel.setText("" + clientData.getWaterCollected()); } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-22 00:04:03 UTC (rev 315) @@ -66,6 +66,11 @@ public boolean isPracticeRound() { return getBooleanProperty("practice-round"); } + + public String getPracticeRoundPaymentInstructions() { + return getProperty("practice-round-payment-instructions", + "This is a practice round so the earnings mentioned are only for illustrative purposes and <b>will not count towards your actual earnings</b>."); + } // FIXME: horrible hack.. figure out why this is here again. public boolean isSecondPracticeRound(){ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-22 00:04:03 UTC (rev 315) @@ -256,7 +256,7 @@ waterCollected += availableFlowCapacity; } - public int getWaterUsed(){ + public int getWaterCollected(){ return waterCollected; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 16:52:30 UTC (rev 314) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-22 00:04:03 UTC (rev 315) @@ -390,8 +390,8 @@ sendEndRoundEvents(); persistRound(); cleanupRound(); - // FIXME: have to wait for .... some reason. - try { Thread.sleep(2000); } catch (InterruptedException ignored) {} + // FIXME: have to wait for .... some reason? + Utils.sleep(2000); advanceToNextRound(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-21 16:52:38
|
Revision: 314 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=314&view=rev Author: alllee Date: 2009-10-21 16:52:30 +0000 (Wed, 21 Oct 2009) Log Message: ----------- fixing duplicate info in debriefing text Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 07:35:00 UTC (rev 313) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 16:52:30 UTC (rev 314) @@ -33,7 +33,6 @@ import edu.asu.commons.irrigation.events.QuizCompletedEvent; import edu.asu.commons.irrigation.server.ClientData; import edu.asu.commons.irrigation.server.GroupDataModel; -import edu.asu.commons.net.Identifier; import edu.asu.commons.util.HtmlEditorPane; import edu.asu.commons.util.HtmlEditorPane.FormActionEvent; @@ -417,7 +416,7 @@ } /** - * FIXME: needs serious refactoring + * * @param event */ private void addDebriefingText(EndRoundEvent event) { @@ -431,14 +430,13 @@ double showUpBonus = clientDataModel.getServerConfiguration().getShowUpPayment(); for(ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { instructionsBuilder.append( - String.format("<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>$%3.2f</td><td>$%3.2f</td></tr>", + String.format("<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>$%3.2f</td><td>$%3.2f</td></tr>", clientData.getPriorityString(), clientData.getMaximumTokenInvestment(), clientData.getInvestedTokens(), clientData.getUninvestedTokens(), clientData.getAllTokensEarnedThisRound(), clientData.getTokensEarnedFromWaterCollected(), - clientData.getAllTokensEarnedThisRound(), clientData.getTotalDollarsEarnedThisRound(), clientData.getTotalDollarsEarned() + showUpBonus )); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-21 07:35:07
|
Revision: 313 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=313&view=rev Author: alllee Date: 2009-10-21 07:35:00 +0000 (Wed, 21 Oct 2009) Log Message: ----------- fixed debriefing table for arbitrary numbers of clients instead of hard coded 5 clients by transposing it. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -45,6 +45,11 @@ public ClientData getClientData() { return groupDataModel.getClientData( getId() ); } + + public String getPriorityString() { + return getClientData().getPriorityString(); + } + public Identifier getId() { return client.getId(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 07:35:00 UTC (rev 313) @@ -402,14 +402,14 @@ }; try { SwingUtilities.invokeAndWait(runnable); - } catch (InterruptedException e) { - // TODO Auto-generated catch block + } + catch (InterruptedException e) { e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block + } + catch (InvocationTargetException e) { e.printStackTrace(); } - info("IrrigationGameWindow finished cleanup, ending round completed."); + info("ExperimentGameWindow finished cleanup, ending round completed."); } private void info(String message) { @@ -422,74 +422,85 @@ */ private void addDebriefingText(EndRoundEvent event) { instructionsBuilder.delete(0, instructionsBuilder.length()); - - Map<Identifier,ClientData> clientDataMap = event.getClientDataMap(); - - String positionString = "Your position is: " + event.getClientData().getPriorityAsString(); - ClientData[] allClientData = new ClientData[clientDataMap.size()]; - for(ClientData clientData : clientDataMap.values()) { - allClientData[clientData.getPriority()] = clientData; + instructionsBuilder.append("<b>You were in position " + clientDataModel.getPriorityString()); + instructionsBuilder.append( + "<table><thead><th>Position</th><th>Initial token endowment</th><th>Tokens invested</th><th>Tokens not invested</th>" + + "<th>Tokens earned from growing crops</th><th>Total tokens earned during this round</th>" + + "<th>Dollars earned during this round</th><th>Total dollars earned (including show-up bonus)</th></thead>" + + "<tbody>"); + double showUpBonus = clientDataModel.getServerConfiguration().getShowUpPayment(); + for(ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + instructionsBuilder.append( + String.format("<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>$%3.2f</td><td>$%3.2f</td></tr>", + clientData.getPriorityString(), + clientData.getMaximumTokenInvestment(), + clientData.getInvestedTokens(), + clientData.getUninvestedTokens(), + clientData.getAllTokensEarnedThisRound(), + clientData.getTokensEarnedFromWaterCollected(), + clientData.getAllTokensEarnedThisRound(), + clientData.getTotalDollarsEarnedThisRound(), + clientData.getTotalDollarsEarned() + showUpBonus + )); } - ClientData clientData = event.getClientData(); - RoundConfiguration roundConfiguration = clientData.getRoundConfiguration(); - double dollarsPerToken = roundConfiguration.getDollarsPerToken(); - // FIXME: wow - instructionsBuilder.append(String.format( - positionString + - "<table><thead><th></th><th></th><th>A</th><th></th><th>B</th><th></th><th>C</th><th></th><th>D</th><th></th><th>E</th></thead><tbody>"+ - "<tr><td>A Initial endowment</td><td></td><td>10</td><td></td><td>10</td><td></td><td>10</td><td></td><td>10</td><td></td><td>10</td></tr>"+ - "<tr><td>B Infrastructure investment</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td></tr>"+ - "<tr><td>C Kept endowment (A - B)</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td></tr>"+ - "<tr><td>D Return from growing crops</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td></tr>"+ - "<tr><td>E Total tokens earned in last round(D+C)</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td><td></td><td>%d</td></tr>"+ - "<tr><td>F Total dollars earned in this round (E*0.1$)</td><td></td><td>%3.2f</td><td></td><td>%3.2f</td><td></td><td>%3.2f</td><td></td><td>%3.2f</td><td></td><td>%3.2f</td></tr>", - allClientData[0].getInvestedTokens(), - allClientData[1].getInvestedTokens(), - allClientData[2].getInvestedTokens(), - allClientData[3].getInvestedTokens(), - allClientData[4].getInvestedTokens(), - - allClientData[0].getUninvestedTokens(), - allClientData[1].getUninvestedTokens(), - allClientData[2].getUninvestedTokens(), - allClientData[3].getUninvestedTokens(), - allClientData[4].getUninvestedTokens(), + + ClientData clientData = clientDataModel.getClientData(); + RoundConfiguration configuration = clientDataModel.getRoundConfiguration(); - allClientData[0].getTotalTokensEarned() - allClientData[0].getUninvestedTokens(), - allClientData[1].getTotalTokensEarned() - allClientData[1].getUninvestedTokens(), - allClientData[2].getTotalTokensEarned() - allClientData[2].getUninvestedTokens(), - allClientData[3].getTotalTokensEarned() - allClientData[3].getUninvestedTokens(), - allClientData[4].getTotalTokensEarned() - allClientData[4].getUninvestedTokens(), - - allClientData[0].getTotalTokensEarned(), - allClientData[1].getTotalTokensEarned(), - allClientData[2].getTotalTokensEarned(), - allClientData[3].getTotalTokensEarned(), - allClientData[4].getTotalTokensEarned(), - - (float)dollarsPerToken*allClientData[0].getTotalTokensEarned(), - (float)dollarsPerToken*allClientData[1].getTotalTokensEarned(), - (float)dollarsPerToken*allClientData[2].getTotalTokensEarned(), - (float)dollarsPerToken*allClientData[3].getTotalTokensEarned(), - (float)dollarsPerToken*allClientData[4].getTotalTokensEarned() - - /* - event.getClientData().getContributedTokens(),otherClientData.getContributedTokens(), - 10 - event.getClientData().getContributedTokens(),10 - otherClientData.getContributedTokens(), - event.getClientData().getAward()-(10 - event.getClientData().getContributedTokens()), - otherClientData.getAward()-(10 - otherClientData.getContributedTokens()), - event.getClientData().getAward(),otherClientData.getAward(), - (float)event.getClientData().getRoundConfiguration().getDollarsPerToken()*event.getClientData().getAward(), - (float)otherClientData.getRoundConfiguration().getDollarsPerToken()*otherClientData.getAward()*/ - )); - instructionsBuilder.append("</tbody></table><hr>"); - instructionsBuilder.append(String.format("Summary: You received $1.00 at the beginning of the round and had " + - "$%3.2f at the end of the round. Your earnings in the experiments so far are $%3.2f plus the $5.00 " + - "showup fee, for a grand total of $%3.2f", - (float)dollarsPerToken*clientData.getTotalTokensEarned(), - (float)dollarsPerToken*clientData.getTotalTokens(), - (float)dollarsPerToken*clientData.getTotalTokens() + getServerConfiguration().getShowUpPayment() - )); + instructionsBuilder.append("</tbody></table><hr/>"); + instructionsBuilder.append(String.format("<h3>You received $%3.2f this past round. Your total earnings are $%3.2f, including the $%3.2f show up bonus.</h3>", + clientData.getTotalDollarsEarnedThisRound(), clientData.getTotalDollarsEarned()+showUpBonus, showUpBonus)); + // FIXME: wow. change this. +// instructionsBuilder.append(String.format( +// positionString + +// +// allClientData[0].getInvestedTokens(), +// allClientData[1].getInvestedTokens(), +// allClientData[2].getInvestedTokens(), +// allClientData[3].getInvestedTokens(), +// allClientData[4].getInvestedTokens(), +// +// allClientData[0].getUninvestedTokens(), +// allClientData[1].getUninvestedTokens(), +// allClientData[2].getUninvestedTokens(), +// allClientData[3].getUninvestedTokens(), +// allClientData[4].getUninvestedTokens(), +// +// allClientData[0].getTotalTokensEarned() - allClientData[0].getUninvestedTokens(), +// allClientData[1].getTotalTokensEarned() - allClientData[1].getUninvestedTokens(), +// allClientData[2].getTotalTokensEarned() - allClientData[2].getUninvestedTokens(), +// allClientData[3].getTotalTokensEarned() - allClientData[3].getUninvestedTokens(), +// allClientData[4].getTotalTokensEarned() - allClientData[4].getUninvestedTokens(), +// +// allClientData[0].getTotalTokensEarned(), +// allClientData[1].getTotalTokensEarned(), +// allClientData[2].getTotalTokensEarned(), +// allClientData[3].getTotalTokensEarned(), +// allClientData[4].getTotalTokensEarned(), +// +// (float)dollarsPerToken*allClientData[0].getTotalTokensEarned(), +// (float)dollarsPerToken*allClientData[1].getTotalTokensEarned(), +// (float)dollarsPerToken*allClientData[2].getTotalTokensEarned(), +// (float)dollarsPerToken*allClientData[3].getTotalTokensEarned(), +// (float)dollarsPerToken*allClientData[4].getTotalTokensEarned() +// +// /* +// event.getClientData().getContributedTokens(),otherClientData.getContributedTokens(), +// 10 - event.getClientData().getContributedTokens(),10 - otherClientData.getContributedTokens(), +// event.getClientData().getAward()-(10 - event.getClientData().getContributedTokens()), +// otherClientData.getAward()-(10 - otherClientData.getContributedTokens()), +// event.getClientData().getAward(),otherClientData.getAward(), +// (float)event.getClientData().getRoundConfiguration().getDollarsPerToken()*event.getClientData().getAward(), +// (float)otherClientData.getRoundConfiguration().getDollarsPerToken()*otherClientData.getAward()*/ +// )); +// instructionsBuilder.append("</tbody></table><hr>"); +// instructionsBuilder.append(String.format("Summary: You received $1.00 at the beginning of the round and had " + +// "$%3.2f at the end of the round. Your earnings in the experiments so far are $%3.2f plus the $5.00 " + +// "showup fee, for a grand total of $%3.2f", +// (float)dollarsPerToken*clientData.getAllTokensEarnedThisRound(), +// (float)dollarsPerToken*clientData.getTotalTokens(), +// (float)dollarsPerToken*clientData.getTotalTokens() + getServerConfiguration().getShowUpPayment() +// )); //append the added practice round instructions if(clientDataModel.getRoundConfiguration().isPracticeRound()) { instructionsBuilder.append(" However, this is a practice round and the earnings mentioned are only for illustrative purposes " + Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 07:35:00 UTC (rev 313) @@ -181,6 +181,7 @@ }); channel.add(this, new EventTypeProcessor<EndRoundEvent>(EndRoundEvent.class) { public void handle(EndRoundEvent event) { + clientDataModel.setGroupDataModel(event.getClientData().getGroupDataModel()); experimentGameWindow.endRound(event); } }); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -177,12 +177,17 @@ private JTextField getWaterUsedTextField() { if (waterUsedTextField == null) { - waterUsedTextField = new JTextField(); - waterUsedTextField.setEditable(false); - waterUsedTextField.setBackground(Color.GRAY); + waterUsedTextField = createTextField(); } return waterUsedTextField; } + + private JTextField createTextField() { + JTextField textField = new JTextField(); + textField.setEditable(false); + textField.setBackground(Color.LIGHT_GRAY); + return textField; + } private JLabel getWaterUsedLabel() { if (waterUsedLabel == null) { @@ -193,8 +198,7 @@ private JTextField getTokensNotInvestedTextField() { if (tokensNotInvestedTextField == null) { - tokensNotInvestedTextField = new JTextField(); - tokensNotInvestedTextField.setEditable(false); + tokensNotInvestedTextField = createTextField(); } return tokensNotInvestedTextField; } @@ -207,8 +211,7 @@ private JTextField getTokensEarnedTextField() { if (tokensEarnedTextField == null) { - tokensEarnedTextField = new JTextField(); - tokensEarnedTextField.setEditable(false); + tokensEarnedTextField = createTextField(); } return tokensEarnedTextField; } @@ -221,8 +224,7 @@ private JTextField getTotalTokensEarnedTextField() { if (totalTokensEarnedTextField == null) { - totalTokensEarnedTextField = new JTextField(); - totalTokensEarnedTextField.setEditable(false); + totalTokensEarnedTextField = createTextField(); } return totalTokensEarnedTextField; @@ -404,8 +406,8 @@ ClientData clientData = clientDataModel.getClientData(); waterUsedTextField.setText("" + clientData.getWaterUsed()); tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); - tokensEarnedTextField.setText("" + clientData.waterToTokenFunction()); - totalTokensEarnedTextField.setText("" + clientData.getTotalTokensEarned()); + tokensEarnedTextField.setText("" + clientData.getTokensEarnedFromWaterCollected()); + totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); getScoreBoxPanel().update(clientDataModel); // getMiddleWindowPanel().update(clientDataModel); @@ -434,22 +436,24 @@ public void endRound() { Runnable createGuiRunnable = new Runnable(){ public void run() { + gateSwitchButton.setText("Open gate"); if (canalPanel != null) { System.err.println("Removing canal panel"); upperPanel.remove(canalPanel); + canalPanel.endRound(); } System.err.println("ending round for canal panel"); - canalPanel.endRound(); + canalPanel = null; } }; open = false; - gateSwitchButton.setText("Open gate"); - try { SwingUtilities.invokeAndWait(createGuiRunnable); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { e.printStackTrace(); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) { e.printStackTrace(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-21 07:35:00 UTC (rev 313) @@ -544,7 +544,7 @@ if (moneyEarnedTextField == null) { moneyEarnedTextField = new JTextField(); moneyEarnedTextField.setText(new Integer(mainIrrigationWindow - .getClientDataModel().getClientData().getTotalTokensEarned()) + .getClientDataModel().getClientData().getAllTokensEarnedThisRound()) .toString()); moneyEarnedTextField.setBounds(new Rectangle(161, 17, 86, 21)); moneyEarnedTextField.setFont(new Font("Dialog", Font.PLAIN, 14)); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -72,7 +72,7 @@ private JLabel getPositionText() { if (positionText == null){ - positionText = new JLabel(clientData.getPriorityAsString()); + positionText = new JLabel(clientData.getPriorityString()); positionText.setBounds(new Rectangle(5,50+32+10,30,20)); } return positionText; @@ -91,7 +91,7 @@ this.clientData = clientData; currentBandwidthText.setText("" + clientData.getAvailableFlowCapacity()); waterUsedTextField.setText("" + clientData.getWaterUsed()); - totalTokensEarnedTextField.setText("" + clientData.getTotalTokensEarned()); + totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { // show that client is actively irrigating Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -43,7 +43,7 @@ add(new JLabel("Position:")); List<ClientData> clientDataList = clientDataModel.getClientDataSortedByPriority(); for (ClientData clientData : clientDataList) { - add(new JLabel(clientData.getPriorityAsString())); + add(new JLabel(clientData.getPriorityString())); } // available water per second add(new JLabel("Available water per second:")); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -55,7 +55,7 @@ labelBuilder.append("You"); } else { - labelBuilder.append(currentClientData.getPriorityAsString()); + labelBuilder.append(currentClientData.getPriorityString()); } labelBuilder.append(" invested ").append(currentClientData.getInvestedTokens()).append(" token(s)"); defaultPieDataset.setValue(labelBuilder.toString(), currentClientData.getInvestedTokens()); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-21 07:35:00 UTC (rev 313) @@ -47,8 +47,8 @@ return getIntProperty("max-canal-flow-capacity", 40); } - public int getMaximumInvestedTokens() { - return getIntProperty("max-invested-tokens", 10); + public int getMaximumTokenInvestment() { + return getIntProperty("max-token-investment", 10); } /** @@ -56,7 +56,7 @@ * @return */ public int getMaximumTotalInvestedTokens() { - return getMaximumInvestedTokens() * getClientsPerGroup(); + return getMaximumTokenInvestment() * getClientsPerGroup(); } public int getMaximumInfrastructureEfficiency() { @@ -79,6 +79,8 @@ /** * Returns the dollars/token exchange rate. $1 = 1, 50 cents = $.50, 1 penny per token = .01, etc. * + * FIXME: this should be a ServerConfiguration parameter unless we change it so + * the client keeps track of total dollars earned per round instead of total tokens earned per round. * * @return */ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-21 07:35:00 UTC (rev 313) @@ -186,8 +186,8 @@ "<td align='center'>$%3.2f</td>" + "<td align='center'>$%3.2f</td></tr>", clientId.toString(), - data.getTotalTokensEarned(), - data.getTotalTokensEarned() * model.getRoundConfiguration().getDollarsPerToken(), + data.getAllTokensEarnedThisRound(), + data.getAllTokensEarnedThisRound() * model.getRoundConfiguration().getDollarsPerToken(), data.getTotalTokens() * model.getRoundConfiguration().getDollarsPerToken()+ facilitator.getConfiguration().getShowUpPayment())); } builder.append("</tbody></table><hr>"); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 07:35:00 UTC (rev 313) @@ -27,7 +27,7 @@ private GroupDataModel groupDataModel; - private int waterUsed = 0; + private int waterCollected = 0; private int availableFlowCapacity; @@ -76,7 +76,7 @@ private final static String[] PRIORITY_STRINGS = { "A", "B", "C", "D", "E" }; - public String getPriorityAsString() { + public String getPriorityString() { // bounds check int priority = getPriority(); if (priority >= 0 && priority < PRIORITY_STRINGS.length) { @@ -125,7 +125,7 @@ } public int getUninvestedTokens() { - return roundConfiguration.getMaximumInvestedTokens() - investedTokens; + return roundConfiguration.getMaximumTokenInvestment() - investedTokens; } public GroupDataModel getGroupDataModel() { @@ -149,7 +149,7 @@ closeGate(); investedTokens = 0; //adding number of files to be downloaded = 0 per round - waterUsed = 0; + waterCollected = 0; } public void resetAllTokens() { @@ -182,17 +182,21 @@ setAvailableFlowCapacity(availableFlowCapacity); } - public void award() { - totalTokens += getTotalTokensEarned(); + public void addTokensEarnedThisRoundToTotal() { + totalTokens += getAllTokensEarnedThisRound(); } /** * Returns the current number of tokens given to this participant. * @return */ - public int getTotalTokensEarned(){ - return waterToTokenFunction() + getUninvestedTokens(); + public int getAllTokensEarnedThisRound(){ + return getTokensEarnedFromWaterCollected() + getUninvestedTokens(); } + + public double getTotalDollarsEarnedThisRound() { + return roundConfiguration.getDollarsPerToken() * getAllTokensEarnedThisRound(); + } /** * Reward function table correlating water usage to tokens earned. @@ -200,47 +204,47 @@ * @param value * @return */ - public int waterToTokenFunction() { - if (waterUsed < 150) { + public int getTokensEarnedFromWaterCollected() { + if (waterCollected < 150) { return 0; } - else if (waterUsed < 200) { + else if (waterCollected < 200) { return 1; } - else if (waterUsed < 250) { + else if (waterCollected < 250) { return 4; } - else if (waterUsed < 300) { + else if (waterCollected < 300) { return 10; } - else if (waterUsed < 350) { + else if (waterCollected < 350) { return 15; } - else if (waterUsed < 400) { + else if (waterCollected < 400) { return 18; } - else if (waterUsed < 500) { + else if (waterCollected < 500) { return 19; } - else if (waterUsed < 550) { + else if (waterCollected < 550) { return 20; } - else if (waterUsed < 650) { + else if (waterCollected < 650) { return 19; } - else if (waterUsed < 700) { + else if (waterCollected < 700) { return 18; } - else if (waterUsed < 750) { + else if (waterCollected < 750) { return 15; } - else if (waterUsed < 800) { + else if (waterCollected < 800) { return 10; } - else if (waterUsed < 850) { + else if (waterCollected < 850) { return 4; } - else if (waterUsed < 900) { + else if (waterCollected < 900) { return 1; } else { @@ -249,13 +253,21 @@ } public void collectWater() { - waterUsed += availableFlowCapacity; + waterCollected += availableFlowCapacity; } public int getWaterUsed(){ - return waterUsed; + return waterCollected; } + public int getMaximumTokenInvestment() { + return getRoundConfiguration().getMaximumTokenInvestment(); + } + + public double getTotalDollarsEarned() { + return roundConfiguration.getDollarsPerToken() * totalTokens; + } + } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 07:35:00 UTC (rev 313) @@ -63,7 +63,7 @@ throw new IllegalArgumentException( "no client state available for: " + id); } - return state.getTotalTokensEarned(); + return state.getAllTokensEarnedThisRound(); } public void addClient(ClientData clientData) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 05:59:23 UTC (rev 312) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 07:35:00 UTC (rev 313) @@ -401,7 +401,7 @@ //Send the end round event to all the clients synchronized (clients) { for (ClientData data : clients.values()) { - data.award(); + data.addTokensEarnedThisRoundToTotal(); transmit(new EndRoundEvent(data.getId(), data.getGroupDataModel(), getConfiguration().isLastRound())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-21 06:50:56
|
Revision: 312 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=312&view=rev Author: alllee Date: 2009-10-21 05:59:23 +0000 (Wed, 21 Oct 2009) Log Message: ----------- updated contribution text area and continuing to refine game interface layout. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-21 05:59:23 UTC (rev 312) @@ -2,14 +2,8 @@ import java.util.Random; -public class Ball{ +public class Ball { - public boolean isInServer; - - public boolean isInFirstCanal; - - public boolean isInSecondCanal; - private int size = 2; public int x; @@ -19,10 +13,10 @@ public int moveX; public int moveY; - public int xBOUNDSUPPER; - public int xBOUNDSLOWER; - public int yBOUNDSUPPER; - public int yBOUNDSLOWER; + public int xUpperBound; + public int xLowerBound; + public int yUpperBound; + public int yLowerBound; //just one global variable speciying the ten potential positions of the balls private int position; @@ -31,10 +25,10 @@ this.x = generator.nextInt(100); this.y = generator.nextInt(100); - this.xBOUNDSUPPER = 100; - this.yBOUNDSUPPER = 100; - this.xBOUNDSLOWER = 0; - this.yBOUNDSLOWER = 0; + this.xUpperBound = 100; + this.yUpperBound = 100; + this.xLowerBound = 0; + this.yLowerBound = 0; this.moveX = generator.nextInt(15); this.moveY = generator.nextInt(10); /*this.moveX = 3; @@ -44,30 +38,13 @@ } public void setPosition(int position) { - // TODO Auto-generated method stub - - //System.out.println("Setting the position :"+position); - this.position = position; - } public int getBallSize(){ return size; } - public boolean getIsInServer(){ - return isInServer; - } - - public boolean getIsInFirstCanal(){ - return isInFirstCanal; - } - - public boolean getIsInSecondCanal(){ - return isInSecondCanal; - } - public void setX(int x){ this.x = x; } @@ -77,25 +54,14 @@ } public int getPosition() { - // TODO Auto-generated method stub return position; } public int getX() { - // TODO Auto-generated method stub return x; } - /* - * will set the upper and the lower bounds for a ball depending on its position - */ - /*public void setBounds(int position) { - // TODO Auto-generated method stub - - }*/ - public int getY() { - // TODO Auto-generated method stub return y; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -264,10 +264,10 @@ //still in server else { setBounds(i); - if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ + if(balls[i].x <= balls[i].xUpperBound || balls[i].x >= balls[i].xUpperBound-balls[i].getBallSize()){ balls[i].moveX = balls[i].moveX * -1; } - if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) + if(balls[i].y <= balls[i].yLowerBound || balls[i].y >= balls[i].yUpperBound-balls[i].getBallSize()) balls[i].moveY = balls[i].moveY * -1; } break; @@ -280,9 +280,9 @@ //directly pass in the information setBounds(i); /*System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - +" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER);*/ + +" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER);*/ /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -291,12 +291,12 @@ else{ setBounds(i); /*System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - +" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER); + +" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER); */ - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(2); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -309,7 +309,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -317,10 +317,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(3); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -333,7 +333,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -341,10 +341,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(4); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -356,7 +356,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -364,10 +364,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(5); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -379,7 +379,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -387,17 +387,17 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(6); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } break; case 6: setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ /*balls[i].setX(generator.nextInt(100)); balls[i].setY(100 - gate[0].getHeight()+ generator.nextInt(gate[0].getHeight())); balls[i].setPosition(0); @@ -405,7 +405,7 @@ setBallInTank(i); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } break; @@ -425,7 +425,7 @@ else{ setBounds(i); //System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - //+" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER); + //+" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER); } } } @@ -448,10 +448,10 @@ private void setBounds(int ballIndex) { // ball is in the server if(balls[ballIndex].getPosition() == 0){ - balls[ballIndex].xBOUNDSUPPER = 100; - balls[ballIndex].xBOUNDSLOWER = 0; - balls[ballIndex].yBOUNDSUPPER = 100; - balls[ballIndex].yBOUNDSLOWER = 0; + balls[ballIndex].xUpperBound = 100; + balls[ballIndex].xLowerBound = 0; + balls[ballIndex].yUpperBound = 100; + balls[ballIndex].yLowerBound = 0; //balls[ballIndex].moveX = generator.nextInt(6); //balls[ballIndex].moveY = generator.nextInt(6); //balls[ballIndex].moveX = 3; @@ -461,20 +461,20 @@ if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 1].getY(); //balls[ballIndex].moveX = 3; //balls[ballIndex].moveY = 3; } //the ball is in one of the openings else{ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); balls[ballIndex].moveX = 0; balls[ballIndex].moveY = 3; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -86,8 +86,8 @@ } protected void paintComponent(Graphics graphics){ + super.paintComponent(graphics); // needed! updateGUI(); - super.paintComponent(graphics); // needed! Graphics2D graphics2D = (Graphics2D) graphics; graphics2D.setColor(Color.BLUE); graphics2D.fillRect(0,0,serverHeight,serverWidth); @@ -213,7 +213,7 @@ * This will process the balls according to their position */ private void process(int i){ - switch(balls[i].getPosition()){ + switch(balls[i].getPosition()) { case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(maximumIrrigationCapacity*bandWidthCanalHeightMapping) && balls[i].y <= serverHeight)){ @@ -223,10 +223,10 @@ //still in server else{ setBounds(i); - if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ + if(balls[i].x <= balls[i].xLowerBound || balls[i].x >= balls[i].xUpperBound-balls[i].getBallSize()){ balls[i].moveX = balls[i].moveX * -1; } - if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) + if(balls[i].y <= balls[i].yLowerBound || balls[i].y >= balls[i].yUpperBound-balls[i].getBallSize()) balls[i].moveY = balls[i].moveY * -1; } break; @@ -239,10 +239,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(2); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -257,10 +257,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(3); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -273,7 +273,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -281,10 +281,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(4); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -298,10 +298,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(5); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -313,23 +313,23 @@ //directly pass in the information setBounds(i); } - else{ + else { setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(6); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } break; case 6: setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ setBallInServer(i); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } break; @@ -362,10 +362,10 @@ // TODO Auto-generated method stub //ball is in the server if(balls[ballIndex].getPosition() == 0){ - balls[ballIndex].xBOUNDSUPPER = serverWidth; - balls[ballIndex].xBOUNDSLOWER = 0; - balls[ballIndex].yBOUNDSUPPER = serverHeight; - balls[ballIndex].yBOUNDSLOWER = 0; + balls[ballIndex].xUpperBound = serverWidth; + balls[ballIndex].xLowerBound = 0; + balls[ballIndex].yUpperBound = serverHeight; + balls[ballIndex].yLowerBound = 0; //balls[ballIndex].moveX = generator.nextInt(6); //balls[ballIndex].moveY = generator.nextInt(6); //balls[ballIndex].moveX = 3; @@ -375,17 +375,17 @@ if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 1].getY(); } //the ball is in one of the openings else{ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); //X change in motion balls[ballIndex].moveX = 0; //Y change in motion Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 05:59:23 UTC (rev 312) @@ -12,7 +12,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.lang.reflect.InvocationTargetException; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -76,8 +75,6 @@ private StringBuilder instructionsBuilder = new StringBuilder(); - private int totalContributedTokensPerGroup; - private JTextArea contributionInformationTextArea; private JButton nextButton; @@ -567,36 +564,34 @@ } - public void updateGraphDisplay(final ClientData clientData) { - totalContributedTokensPerGroup = clientData.getGroupDataModel().getTotalContributedTokens(); - DecimalFormat df = new DecimalFormat("#.##"); - final String contributionInformation = - "Initial infrastructure efficiency: " + clientData.getGroupDataModel().getInitialInfrastructureEfficiency() + "%" - + "\n\nInitial flow capacity: " + clientData.getGroupDataModel().getInitialFlowCapacity() + " cubic feet per second " - + "\n\nActual infrastructure efficiency: " + clientData.getGroupDataModel().getInfrastructureEfficiency() + "%" - + "\n\nActual total flow capacity: " - + df.format(clientData.getGroupDataModel().getMaximumAvailableFlowCapacity()) + " cubic feet per second \n\n" - + "\n\nMaximum tokens that could have been contributed: " - + clientDataModel.getRoundConfiguration().getMaximumTotalInvestedTokens() - + "\n\nTotal tokens contributed: " - + totalContributedTokensPerGroup - + "\n\nYour token contribution: " - + clientData.getInvestedTokens() - + "\n\nTotal flow capacity that could have been generated: " - + clientDataModel.getRoundConfiguration().getMaximumCanalFlowCapacity() - + " cubic feet per second"; - - - + public void displayTokenContributions(final ClientData clientData) { + GroupDataModel groupDataModel = clientData.getGroupDataModel(); + int totalContributedTokensPerGroup = groupDataModel.getTotalContributedTokens(); + final StringBuilder builder = new StringBuilder(); + builder.append("Infrastructure efficiency before investment: ") + .append(groupDataModel.getInitialInfrastructureEfficiency()) + .append("%\n"); + builder.append("Irrigation capacity before investment: ").append(groupDataModel.getInitialFlowCapacity()).append(" cubic feet per second\n\n"); + builder.append( + String.format( + "Your group invested a total of %d tokens, increasing the infrastructure efficiency to %d%%.\n", + groupDataModel.getTotalContributedTokens(), groupDataModel.getInfrastructureEfficiency())); + if (groupDataModel.getFlowCapacity() > groupDataModel.getInitialFlowCapacity()) { + builder.append("Your group's investment has increased the irrigation capacity to "); + } + else { + builder.append("Your group's irrigation capacity after investment is "); + } + builder.append(groupDataModel.getFlowCapacity()).append('.'); SwingUtilities.invokeLater(new Runnable() { public void run() { - contributionInformationTextArea.setText(contributionInformation); + contributionInformationTextArea.setText(builder.toString()); infrastructureEfficiencyChartPanel.initialize(); pieChart.setClientData(clientData); addCenterComponent(getGraphPanel()); } }); - irrigationGamePanel.updateContributions(clientDataModel); + irrigationGamePanel.setClientDataModel(clientDataModel); } public JPanel getGraphPanel() { @@ -607,6 +602,7 @@ graphPanel.add(getPieChartPanel()); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); + graphPanel.add(contributionInformationTextArea); } return graphPanel; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 05:59:23 UTC (rev 312) @@ -170,7 +170,7 @@ public void handle(InfrastructureUpdateEvent event) { System.err.println("Received group update event: " + event); clientDataModel.setGroupDataModel(event.getGroupDataModel()); - experimentGameWindow.updateGraphDisplay(event.getClientData()); + experimentGameWindow.displayTokenContributions(event.getClientData()); } }); channel.add(this, new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -46,7 +46,7 @@ //this contains the upstream and downstream Panel private JPanel jPanelUpStreamWindow = null; private JPanel jPanelDownStreamWindow = null; - private JPanel mainIrrigationPanel = null; +// private JPanel mainIrrigationPanel = null; private ScoreBoxPanel scoreBoxPanel; @@ -186,7 +186,7 @@ private JLabel getWaterUsedLabel() { if (waterUsedLabel == null) { - waterUsedLabel = new JLabel("Water units used: "); + waterUsedLabel = new JLabel("Water units collected: "); } return waterUsedLabel; } @@ -293,8 +293,8 @@ private JButton getGateSwitchButton() { if (gateSwitchButton == null) { - gateSwitchButton = new JButton("Open Gate"); - gateSwitchButton.setPreferredSize(new Dimension(60, 60)); + gateSwitchButton = new JButton("Open gate"); + gateSwitchButton.setPreferredSize(new Dimension(100, 100)); gateSwitchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { open = !open; @@ -375,9 +375,9 @@ } return timeRemainingProgressBar; } - //this event gets called every second in the experiment. + /** - * Shoudl be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. + * Should be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. */ public void updateClientStatus(final ClientDataModel clientDataModel) { Runnable createGuiRunnable = new Runnable(){ @@ -442,6 +442,8 @@ canalPanel.endRound(); } }; + open = false; + gateSwitchButton.setText("Open gate"); try { SwingUtilities.invokeAndWait(createGuiRunnable); @@ -453,15 +455,8 @@ } - /** - * assigns the priority to the window and prepares the irrigationWindowMap - */ - public void updateContributions(final ClientDataModel clientDataModel) { + public void setClientDataModel(final ClientDataModel clientDataModel) { this.clientDataModel = clientDataModel; - //Here a map is created with the map consisting of the - //irrigation window as the value and the priority value as the key. This is handled here , because - //the event contains the priority for every client, and the priority can act as a unique key for the - //game window. } @@ -469,8 +464,8 @@ * fills in the panels depending on the priority of the client */ public void startRound() { - upperPanel.add(getCanalPanel(), BorderLayout.CENTER); open = false; + upperPanel.add(getCanalPanel(), BorderLayout.CENTER); getScoreBoxPanel().initialize(clientDataModel); getMiddleWindowPanel().initialize(clientDataModel); revalidate(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -29,6 +29,7 @@ private void clear() { availableWaterLabels.clear(); waterUsedLabels.clear(); + removeAll(); } public void initialize(ClientDataModel clientDataModel) { @@ -39,20 +40,20 @@ GridLayout gridLayout = new GridLayout(3, columns); setLayout(gridLayout); - add(new JLabel("Position")); + add(new JLabel("Position:")); List<ClientData> clientDataList = clientDataModel.getClientDataSortedByPriority(); for (ClientData clientData : clientDataList) { add(new JLabel(clientData.getPriorityAsString())); } // available water per second - add(new JLabel("Available water per second")); + add(new JLabel("Available water per second:")); for (ClientData clientData: clientDataList) { JLabel availableWaterLabel = new JLabel("" + clientData.getAvailableFlowCapacity()); availableWaterLabels.add(availableWaterLabel); add(availableWaterLabel); } // water used - add(new JLabel("Water used")); + add(new JLabel("Water collected:")); for (ClientData clientData : clientDataList) { JLabel waterUsedLabel = new JLabel("" + clientData.getWaterUsed()); waterUsedLabels.add(waterUsedLabel); Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -1,33 +0,0 @@ -package edu.asu.commons.irrigation.client; - -import javax.swing.JPanel; - -import edu.asu.commons.irrigation.server.ClientData; - - -/** - * $Id$ - * - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class SummaryPanel extends JPanel { - - private static final long serialVersionUID = 2393688647176774993L; - - private IrrigationClient client; - - - public SummaryPanel(int parameterIndex, IrrigationClient client) { - super(); - this.client = client; - } - - - - public void update(ClientData clientData) { - - } - -} Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 05:59:23 UTC (rev 312) @@ -1,11 +1,8 @@ package edu.asu.commons.irrigation.server; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.events.FileDownloadedEvent; import edu.asu.commons.net.Identifier; /** @@ -18,7 +15,7 @@ * minus tokens subtracted by others * minus tokens subtracted by sanctioning others * - * @author <a href='ano...@gm...'>Allen Lee</a>, Deepali Bhagvat + * @author <a href='mailto:all...@as...'>Allen Lee</a>, Deepali Bhagvat * @version $Revision$ */ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -95,8 +95,8 @@ return Collections.unmodifiableMap(clients); } - public int getCurrentlyAvailableFlowCapacity(){ - return currentlyAvailableFlowCapacity; + public int getAvailableClientFlowCapacity(){ + return Math.min(currentlyAvailableFlowCapacity, getRoundConfiguration().getMaximumClientFlowCapacity()); } public RoundConfiguration getRoundConfiguration() { @@ -197,8 +197,7 @@ } public void allocateFlowCapacity(ClientData clientData) { - RoundConfiguration roundConfiguration = getRoundConfiguration(); - int maximumClientFlowCapacity = roundConfiguration.getMaximumClientFlowCapacity(); + int maximumClientFlowCapacity = getRoundConfiguration().getMaximumClientFlowCapacity(); if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; clientData.setAvailableFlowCapacity(maximumClientFlowCapacity); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 05:59:23 UTC (rev 312) @@ -316,7 +316,7 @@ group.allocateFlowCapacity(clientData); } else if (clientData.isGateClosed()) { - clientData.init(group.getCurrentlyAvailableFlowCapacity()); + clientData.init(group.getAvailableClientFlowCapacity()); } // right now the clients cannot be paused. else if (clientData.isPaused()) { @@ -341,7 +341,7 @@ private IrrigationServerState state; - private long lastTime; +// private long lastTime; private Duration secondTick = Duration.create(1000L); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-21 00:29:27
|
Revision: 311 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=311&view=rev Author: alllee Date: 2009-10-21 00:29:19 +0000 (Wed, 21 Oct 2009) Log Message: ----------- fixed canalpanel flickering, adding jfreechart and jcommon dependencies to client.jnlp Modified Paths: -------------- irrigation/trunk/pom.xml irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java irrigation/trunk/src/main/resources/web/client.jnlp Modified: irrigation/trunk/pom.xml =================================================================== --- irrigation/trunk/pom.xml 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/pom.xml 2009-10-21 00:29:19 UTC (rev 311) @@ -56,6 +56,16 @@ <artifactId>jfreechart</artifactId> <version>1.0.13</version> </dependency> + <dependency> + <groupId>jgoodies</groupId> + <artifactId>looks</artifactId> + <version>1.2.2</version> + </dependency> + <dependency> + <groupId>jgoodies</groupId> + <artifactId>forms</artifactId> + <version>1.0.5</version> + </dependency> </dependencies> <build> <finalName>irrigation</finalName> Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 00:29:19 UTC (rev 311) @@ -1,7 +1,6 @@ package edu.asu.commons.irrigation.client; import java.awt.Color; -import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; @@ -11,6 +10,8 @@ import javax.swing.JPanel; import javax.swing.Timer; +import edu.asu.commons.irrigation.server.ClientData; + /** * $Id$ * @@ -35,15 +36,15 @@ private int gateHeight = 20; - Random generator = new Random(); + private Random generator = new Random(); private boolean enableBallAnimation = true; - private double totalContributedBandwidth; + private int maximumIrrigationCapacity; - private ClientDataModel clientGameState; + private ClientDataModel clientDataModel; - private int numberofGates = 6; + private int numberOfGates = 6; private int serverHeight = 100; @@ -55,15 +56,11 @@ //////////////////////////////////////////////////////////////////////////// - public CanalPanel(ClientDataModel clientGameState) { + public CanalPanel(ClientDataModel clientDataModel) { super(); //when totalContributed bandwidth = 1.0, you dont see the canal line - this.totalContributedBandwidth = clientGameState.getGroupDataModel().getMaximumAvailableFlowCapacity(); - this.clientGameState = clientGameState; - if(totalContributedBandwidth == 1.0){ - totalContributedBandwidth = 2.0; - } - + this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); + this.clientDataModel = clientDataModel; initialize(); } @@ -73,12 +70,11 @@ * @return void */ private void initialize() { - this.setPreferredSize(new Dimension(1098,150)); - this.setBackground(Color.white); +// this.setPreferredSize(new Dimension(1098,150)); + this.setBackground(Color.WHITE); //initializing the constructor for Gates - for(int i=0;i<numberofGates ;i++){ - gate[i] = new Gate(totalContributedBandwidth,i); - //System.out.println("Gate "+i+"x : "+gate[i].getX()+"y : "+gate[i].getY()); + for(int i=0;i<numberOfGates ;i++){ + gate[i] = new Gate(maximumIrrigationCapacity,i); } initializeBalls(); @@ -96,12 +92,12 @@ graphics2D.setColor(Color.BLUE); graphics2D.fillRect(0,0,serverHeight,serverWidth); //draw the other gates - for(int i=0;i<numberofGates-1;i++){ + for(int i=0;i<numberOfGates-1;i++){ graphics2D.setColor(Color.BLUE); graphics2D.fillRect(gate[i].getX(), gate[i].getY(), gate[i].getWidth(),gate[i].getHeight()); } - int numClients = clientGameState.getAllClientIdentifiers().size(); + int numClients = clientDataModel.getAllClientIdentifiers().size(); for(int i=0;i<numClients;i++) { graphics2D.setColor(Color.BLUE); graphics2D.fillRect(gate[i].getOpeningsX(), gate[i].getOpeningsY(),gate[i].getOpeningsWidth(), @@ -157,7 +153,7 @@ } //order matters here if(!(i == 5)){ - gate[i].setOpeningsHeight((totalContributedBandwidth*bandWidthCanalHeightMapping) + gate[i].setOpeningsHeight((maximumIrrigationCapacity*bandWidthCanalHeightMapping) - gate[i].getHeight()); gate[i].setOpeningsY(gate[i].getOpeningsHeight() - 50); @@ -195,13 +191,8 @@ */ private void initializeBalls() { balls = new Ball[BALLCOUNT]; - if(balls == null){ - System.out.println("Ball is null"); - } - for(int i=0;i<BALLCOUNT;i++){ balls[i] = new Ball(generator); - } } @@ -222,11 +213,9 @@ * This will process the balls according to their position */ private void process(int i){ - // TODO Auto-generated method stub - switch(balls[i].getPosition()){ - case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(totalContributedBandwidth*bandWidthCanalHeightMapping) && + case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(maximumIrrigationCapacity*bandWidthCanalHeightMapping) && balls[i].y <= serverHeight)){ balls[i].setPosition(1); setBounds(i); @@ -337,7 +326,7 @@ case 6: setBounds(i); if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - setBallinServer(i); + setBallInServer(i); } if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ @@ -350,7 +339,7 @@ if((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) || (balls[i].getPosition() == 8) || (balls[i].getPosition() == 9) || (balls[i].getPosition() == 10)){ if(balls[i].getY() >= 150){ - setBallinServer(i); + setBallInServer(i); } else{ setBounds(i); @@ -359,8 +348,7 @@ } - private void setBallinServer(int i) { - // TODO Auto-generated method stub + private void setBallInServer(int i) { generator.setSeed(i*(i+1)); balls[i].setX(generator.nextInt(serverWidth)); balls[i].setY(generator.nextInt(serverHeight)); @@ -406,14 +394,14 @@ } } - public void openGates(int priority) { + public void openGate(int priority) { gate[priority].setGateOpen(true); // paintComponent(graphics2D); repaint(); } - public void closeGates(int priority) { + public void closeGate(int priority) { gate[priority].setGateOpen(false); gate[priority].setx1(gate[priority].getdefaultx1()); gate[priority].sety1(gate[priority].getdefaulty1()); @@ -424,6 +412,13 @@ public void endRound() { initializeBalls(); + closeAllGates(); } + + private void closeAllGates() { + for (ClientData clientData: clientDataModel.getClientDataMap().values()) { + closeGate(clientData.getPriority()); + } + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 00:29:19 UTC (rev 311) @@ -125,7 +125,6 @@ private void initGuiComponents(Dimension screenSize) { cardLayout = new CardLayout(); setLayout(cardLayout); - instructionsScrollPane = new JScrollPane(getInstructionsEditorPane()); instructionsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); instructionsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -230,8 +229,8 @@ nextButton.setEnabled(true); setInstructions(getGeneralInstructions(instructionNumber,pagesTraversed)); // FIXME: get rid of hardcoded animation on page 5. Should instead - // just be an animated gif or something like that. - // should be more like "if instructions.hasAnimation()" + // just be an animated gif or something more like + // if instructions.hasAnimation() if (instructionNumber == 5) { getInstructionsPanel().add(getCanalAnimationPanel(), BorderLayout.PAGE_START); } @@ -261,9 +260,6 @@ instructionNumber++; setInstructions(getGeneralInstructions(instructionNumber,pagesTraversed)); } -// else { -// setInstructions(clientDataModel.getRoundConfiguration().getInstructions()); -// } if(instructionNumber == 5) { getInstructionsPanel().add(getCanalAnimationPanel(), BorderLayout.PAGE_START); } @@ -382,6 +378,7 @@ public void startRound(final RoundConfiguration configuration) { Runnable runnable = new Runnable() { public void run() { + disableInstructions(); addCenterComponent(irrigationGamePanel); irrigationGamePanel.startRound(); } @@ -397,15 +394,12 @@ * updates the mainIrrigationGameWindow Panel and adds * instructionsScrollPane with the debreifing information */ - public void updateEndRoundEvent(final EndRoundEvent event) { + public void endRound(final EndRoundEvent event) { irrigationGamePanel.endRound(); Runnable runnable = new Runnable() { public void run() { investedTokensTextField.setText(""); addDebriefingText(event); - // generate debriefing text from data culled from the Event -// addCenterComponent(instructionsEditorPane); - // FIXME: this is probably wrong. addCenterComponent(getInstructionsPanel()); } }; @@ -710,10 +704,14 @@ timer.start(); } } + + private void disableInstructions() { + quizMessageLabel.setText(""); + getInstructionsPanel().remove(getInstructionsNavigationPanel()); + } public void enableInstructions() { setInstructions(getGeneralInstructions(1,pagesTraversed)); addCenterComponent(getInstructionsPanel()); - } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 00:29:19 UTC (rev 311) @@ -181,7 +181,7 @@ }); channel.add(this, new EventTypeProcessor<EndRoundEvent>(EndRoundEvent.class) { public void handle(EndRoundEvent event) { - experimentGameWindow.updateEndRoundEvent(event); + experimentGameWindow.endRound(event); } }); channel.add(this, new EventTypeProcessor<ClientUpdateEvent>(ClientUpdateEvent.class) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 00:29:19 UTC (rev 311) @@ -4,13 +4,13 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; -import java.awt.GridLayout; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException; import javax.swing.BoxLayout; +import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -18,6 +18,8 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; +import javax.swing.GroupLayout.Alignment; +import javax.swing.GroupLayout.ParallelGroup; import edu.asu.commons.irrigation.server.ClientData; @@ -127,16 +129,48 @@ panel.add(getGateSwitchButton()); JPanel bottomPanel = new JPanel(); - bottomPanel.setLayout(new GridLayout(4, 2)); - bottomPanel.add(getWaterUsedLabel()); - bottomPanel.add(getWaterUsedTextField()); - bottomPanel.add(getTokensNotInvestedLabel()); - bottomPanel.add(getTokensNotInvestedTextField()); - bottomPanel.add(getTokensEarnedLabel()); - bottomPanel.add(getTokensEarnedTextField()); - bottomPanel.add(getTotalTokensEarnedLabel()); - bottomPanel.add(getTotalTokensEarnedTextField()); + GroupLayout layout = new GroupLayout(bottomPanel); + bottomPanel.setLayout(layout); + layout.setAutoCreateContainerGaps(true); + layout.setAutoCreateGaps(true); + + GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup(); + ParallelGroup labelsGroup = layout.createParallelGroup(); + labelsGroup.addComponent(getWaterUsedLabel()).addComponent(getTokensNotInvestedLabel()).addComponent(getTokensEarnedLabel()).addComponent(getTotalTokensEarnedLabel()); + + horizontalGroup.addGroup(labelsGroup); + ParallelGroup textFieldGroup = layout.createParallelGroup(); + textFieldGroup.addComponent(getWaterUsedTextField()); + textFieldGroup.addComponent(getTokensNotInvestedTextField()); + textFieldGroup.addComponent(getTokensEarnedTextField()); + textFieldGroup.addComponent(getTotalTokensEarnedTextField()); + horizontalGroup.addGroup(textFieldGroup); + layout.setHorizontalGroup(horizontalGroup); + + GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup(); + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getWaterUsedLabel()).addComponent(getWaterUsedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTokensNotInvestedLabel()).addComponent(getTokensNotInvestedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTokensEarnedLabel()).addComponent(getTokensEarnedTextField())); + + verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(getTotalTokensEarnedLabel()).addComponent(getTotalTokensEarnedTextField())); + + layout.setVerticalGroup(verticalGroup); +// bottomPanel.add(getWaterUsedLabel()); +// bottomPanel.add(getWaterUsedTextField()); +// bottomPanel.add(getTokensNotInvestedLabel()); +// bottomPanel.add(getTokensNotInvestedTextField()); +// bottomPanel.add(getTokensEarnedLabel()); +// bottomPanel.add(getTokensEarnedTextField()); +// bottomPanel.add(getTotalTokensEarnedLabel()); +// bottomPanel.add(getTotalTokensEarnedTextField()); + panel.add(bottomPanel); return panel; } @@ -145,6 +179,7 @@ if (waterUsedTextField == null) { waterUsedTextField = new JTextField(); waterUsedTextField.setEditable(false); + waterUsedTextField.setBackground(Color.GRAY); } return waterUsedTextField; } @@ -354,15 +389,16 @@ irrigationCapacityLabel.setText( String.format("Irrigation capacity: %d cubic feet per second (cfps)", irrigationCapacity)); - for(final ClientData clientData : clientDataModel.getClientDataMap().values()){ + for (final ClientData clientData : clientDataModel.getClientDataMap().values()) { + System.err.println("changing canal gate for client: " + clientData.getPriority() + ":" + clientData.isGateOpen()); if (clientData.isGateOpen()) { - canalPanel.openGates(clientData.getPriority()); + canalPanel.openGate(clientData.getPriority()); } else if(clientData.isPaused()){ - canalPanel.closeGates(clientData.getPriority()); + canalPanel.closeGate(clientData.getPriority()); } else if(clientData.isGateClosed()){ - canalPanel.closeGates(clientData.getPriority()); + canalPanel.closeGate(clientData.getPriority()); } } ClientData clientData = clientDataModel.getClientData(); @@ -370,7 +406,9 @@ tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); tokensEarnedTextField.setText("" + clientData.waterToTokenFunction()); totalTokensEarnedTextField.setText("" + clientData.getTotalTokensEarned()); - scoreBoxPanel.update(clientDataModel); + getScoreBoxPanel().update(clientDataModel); +// getMiddleWindowPanel().update(clientDataModel); + } }; @@ -396,10 +434,11 @@ public void endRound() { Runnable createGuiRunnable = new Runnable(){ public void run() { - //Refreshing the screen and preparing the main Irrigation Window for the next round - //provided we have already got the updatedClientDataMap - irrigationGameWindow.endRound(); - upperPanel.removeAll(); + if (canalPanel != null) { + System.err.println("Removing canal panel"); + upperPanel.remove(canalPanel); + } + System.err.println("ending round for canal panel"); canalPanel.endRound(); } }; @@ -432,7 +471,8 @@ public void startRound() { upperPanel.add(getCanalPanel(), BorderLayout.CENTER); open = false; - scoreBoxPanel.initialize(clientDataModel); + getScoreBoxPanel().initialize(clientDataModel); + getMiddleWindowPanel().initialize(clientDataModel); revalidate(); // mainIrrigationPanel.add(getJPanelUpStreamWindow(),null); // mainIrrigationPanel.add(getJPanelDownStreamWindow(),null); @@ -440,12 +480,9 @@ // mainIrrigationPanel.add(getJPanelMiddleWindow(),null); } - private JPanel getJPanelMiddleWindow() { + private MiddleWindowPanel getMiddleWindowPanel() { if(middleWindowPanel == null){ - if(clientDataModel != null){ - System.out.println("Main Irrigation Window clientGameState is not null"); - } - middleWindowPanel = new MiddleWindowPanel(clientDataModel); + middleWindowPanel = new MiddleWindowPanel(); } return middleWindowPanel; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-21 00:29:19 UTC (rev 311) @@ -19,140 +19,83 @@ */ public class MiddleScorePanel extends JPanel { - private static final long serialVersionUID = -1329890496417714604L; - - private JLabel positionText; - - private JLabel currentBandwidthText; - - private JLabel filesDownloadedText; - - private JLabel tokensText; - - private JLabel fileLabel; - - private int priority; - - private ClientData clientData; // @jve:decl-index=0: + private static final long serialVersionUID = -1329890496417714604L; - private ClientDataModel clientGameState; // @jve:decl-index=0: - - public MiddleScorePanel(int priority,ClientDataModel clientGameState){ - super(); - this.priority = priority; - /*this.clientGameState = clientGameState; - */ - initialize(clientGameState); - } + private JLabel positionText; - private void initialize(ClientDataModel clientGameState) { - // TODO Auto-generated method stub - /*GridLayout gridLayout = new GridLayout(); - gridLayout.setColumns(1); - gridLayout.setRows(4); - this.setLayout(gridLayout); - */ - this.setLayout(null); - this.clientGameState = clientGameState; - /*if(this.clientGameState == null) - System.out.println("client GameState is null in MiddleScorePanel initialize"); - */ - if(clientGameState.getPriority() == priority) - this.setBackground(Color.GREEN); - else - this.setBackground(Color.YELLOW); - this.setSize(new Dimension(60,200)); -// this.add(getFileLabel()); - this.add(getPositionText(priority),null); - this.add(getFilesDownLoadedText(priority),null); - this.add(getCurrentBandwidth(),null); - this.add(getTokensCollected(),null); - - - } + private JLabel currentBandwidthText; -// private JLabel getFileLabel() { -// if(fileLabel == null){ -// URL fileUrl = ResourceLoader.getResourceAsUrl("images/file.gif"); -// fileLabel = new JLabel(); -// fileLabel.setBounds(new Rectangle(10,50,30,32)); -// fileLabel.setIcon(new ImageIcon(fileUrl)); -// fileLabel.setVisible(false); -// } -// return fileLabel; -// } + private JLabel waterUsedTextField; - private JLabel getTokensCollected() { - // TODO Auto-generated method stub - if(tokensText == null){ - tokensText = new JLabel(); - tokensText.setBounds(new Rectangle(5,50+32+10+20+10+20+10+20+10,30,20)); - tokensText.setText(""); - } - return tokensText; - } + private JLabel totalTokensEarnedTextField; - private JLabel getCurrentBandwidth() { - // TODO Auto-generated method stub - if(currentBandwidthText == null){ - currentBandwidthText = new JLabel(); - currentBandwidthText.setBounds(new Rectangle(5,50+32+10+20+10,30,20)); - currentBandwidthText.setText(""); - } - return currentBandwidthText; - } + private int priority; - private JLabel getPositionText(int priority) { - // TODO Auto-generated method stub - if(positionText == null){ - positionText = new JLabel(); - positionText.setBounds(new Rectangle(5,50+32+10,30,20)); - switch(priority){ - case 0: positionText.setText("A"); - break; - - case 1: positionText.setText("B"); - break; - - case 2: positionText.setText("C"); - break; - - case 3: positionText.setText("D"); - break; - - case 4: positionText.setText("E"); - break; - - } - } - - return positionText; - } - + private ClientData clientData; - private JLabel getFilesDownLoadedText(int priority) { - if(filesDownloadedText == null){ - filesDownloadedText = new JLabel(); - filesDownloadedText.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); - filesDownloadedText.setText(new Integer(priority).toString()); - } - return filesDownloadedText; - } + public MiddleScorePanel(int priority, ClientData clientData){ + super(); + this.priority = priority; + initialize(clientData); + } - public void update(ClientData clientData) { - this.clientData = clientData; - - if(clientData.getAvailableFlowCapacity() > 25){ - currentBandwidthText.setText(new Double(25).toString()); - } - else - currentBandwidthText.setText(new Double(clientData.getAvailableFlowCapacity()).toString()); - - filesDownloadedText.setText(new Integer(clientData.getWaterUsed()).toString()); - tokensText.setText(new Integer(clientData.getTotalTokensEarned()).toString()); - - if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { - // show that client is actively irrigating - } - } + private void initialize(ClientData clientData) { + this.setLayout(null); + this.clientData = clientData; + setBackground( clientData.getPriority() == priority ? Color.GREEN : Color.YELLOW); + this.setPreferredSize(new Dimension(60,200)); + this.add(getPositionText(),null); + this.add(getWaterUsedTextField(),null); + this.add(getCurrentBandwidth(),null); + this.add(getTokensCollected(),null); + + + } + + private JLabel getTokensCollected() { + if(totalTokensEarnedTextField == null){ + totalTokensEarnedTextField = new JLabel(); + totalTokensEarnedTextField.setBounds(new Rectangle(5,50+32+10+20+10+20+10+20+10,30,20)); + totalTokensEarnedTextField.setText(""); + } + return totalTokensEarnedTextField; + } + + private JLabel getCurrentBandwidth() { + if(currentBandwidthText == null){ + currentBandwidthText = new JLabel(); + currentBandwidthText.setBounds(new Rectangle(5,50+32+10+20+10,30,20)); + currentBandwidthText.setText(""); + } + return currentBandwidthText; + } + + private JLabel getPositionText() { + if (positionText == null){ + positionText = new JLabel(clientData.getPriorityAsString()); + positionText.setBounds(new Rectangle(5,50+32+10,30,20)); + } + return positionText; + } + + + private JLabel getWaterUsedTextField() { + if(waterUsedTextField == null){ + waterUsedTextField = new JLabel("0"); + waterUsedTextField.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); + } + return waterUsedTextField; + } + + public void update(ClientData clientData) { + this.clientData = clientData; + currentBandwidthText.setText("" + clientData.getAvailableFlowCapacity()); + waterUsedTextField.setText("" + clientData.getWaterUsed()); + totalTokensEarnedTextField.setText("" + clientData.getTotalTokensEarned()); + + if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { + // show that client is actively irrigating + + } + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-10-21 00:29:19 UTC (rev 311) @@ -6,7 +6,9 @@ import java.awt.Dimension; import java.awt.Rectangle; +import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import javax.swing.JLabel; @@ -20,82 +22,65 @@ */ public class MiddleWindowPanel extends JPanel { - /** - * - */ - private static final long serialVersionUID = 2892921110280857458L; + private static final long serialVersionUID = 2892921110280857458L; - //Map<Integer, MiddleScorePanel>middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); - Map<Integer, JLabel>jLabelMap = new LinkedHashMap<Integer, JLabel>(); // @jve:decl-index=0: - - Map<Integer, MiddleScorePanel> middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); + //Map<Integer, MiddleScorePanel>middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); + Map<Integer, JLabel>jLabelMap = new LinkedHashMap<Integer, JLabel>(); // @jve:decl-index=0: - JLabel positionLabel; - JLabel availableBandwidthLabel; - JLabel filesDownLoadedLabel; - JLabel tokensCollectedLabel; - - - private ClientDataModel clientGameState; +// Map<Integer, MiddleScorePanel> middleScorePanelMap = new LinkedHashMap<Integer, MiddleScorePanel>(); + private List<MiddleScorePanel> middleScorePanels = new ArrayList<MiddleScorePanel>(); - public MiddleWindowPanel(ClientDataModel clientGameState){ - super(); - this.clientGameState = clientGameState; - initialize(); - - - } + JLabel positionLabel; + JLabel availableBandwidthLabel; + JLabel filesDownLoadedLabel; + JLabel tokensCollectedLabel; - private void initialize() { - // TODO Auto-generated method stub - //this.setLayout(null); - - this.setLayout(null); - this.setBounds(new Rectangle(13,100 + 100 - 50,1093,100+50+50)); - this.setSize(new Dimension(1093,200)); - - positionLabel = new JLabel(); - positionLabel.setBounds(new Rectangle(80,50+32+10,150,20)); - positionLabel.setText("Position"); - - availableBandwidthLabel = new JLabel(); - availableBandwidthLabel.setBounds(new Rectangle(80,50+32+10+20+10,150,20)); - availableBandwidthLabel.setText("Available Flow Capacity"); - - filesDownLoadedLabel = new JLabel(); - filesDownLoadedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10, 150,20)); - filesDownLoadedLabel.setText("Crops Grown"); - - tokensCollectedLabel = new JLabel(); - tokensCollectedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10+20+10, 150,20)); - tokensCollectedLabel.setText("Tokens Collected"); - - this.add(positionLabel, null); - this.add(availableBandwidthLabel, null); - this.add(filesDownLoadedLabel, null); - this.add(tokensCollectedLabel, null); - - for(int i=0;i<clientGameState.getRoundConfiguration().getClientsPerGroup();i++){ - /*JLabel jTextLabel = new JLabel(); - jLabelMap.put(new Integer(i), jTextLabel); - jTextLabel.setBounds(new Rectangle((258 + 20 + i*198),35,60,50)); - this.add(jTextLabel,null); - */ - if(this.clientGameState != null) - System.out.println("Middle Window clientGameState is not null"); - MiddleScorePanel middleScorePanel = new MiddleScorePanel(i,this.clientGameState); - middleScorePanel.setBounds(new Rectangle((258 + 20 + i*198)-20,0,60,100+50+50)); - middleScorePanelMap.put(new Integer(i), middleScorePanel); - this.add(middleScorePanel, null); - - } - } + public MiddleWindowPanel() { + this.setLayout(null); + this.setBounds(new Rectangle(13,100 + 100 - 50,1093,100+50+50)); + this.setSize(new Dimension(1093,200)); - public void update(ClientData clientData) { - // TODO Auto-generated method stub - //jLabelMap.get(new Integer(clientData.getPriority())).setText(new Integer(clientData.getFilesDownloaded()).toString()); - middleScorePanelMap.get(new Integer(clientData.getPriority())).update(clientData); - } - + positionLabel = new JLabel(); + positionLabel.setBounds(new Rectangle(80,50+32+10,150,20)); + positionLabel.setText("Position"); + + availableBandwidthLabel = new JLabel(); + availableBandwidthLabel.setBounds(new Rectangle(80,50+32+10+20+10,150,20)); + availableBandwidthLabel.setText("Available Flow Capacity"); + + filesDownLoadedLabel = new JLabel(); + filesDownLoadedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10, 150,20)); + filesDownLoadedLabel.setText("Crops Grown"); + + tokensCollectedLabel = new JLabel(); + tokensCollectedLabel.setBounds(new Rectangle(80,50+32+10+20+10+20+10+20+10, 150,20)); + tokensCollectedLabel.setText("Tokens Collected"); + + this.add(positionLabel, null); + this.add(availableBandwidthLabel, null); + this.add(filesDownLoadedLabel, null); + this.add(tokensCollectedLabel, null); + } + + public void initialize(ClientDataModel clientDataModel) { + removeAll(); + middleScorePanels.clear(); + for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + int priority = clientData.getPriority(); + MiddleScorePanel middleScorePanel = new MiddleScorePanel(clientDataModel.getPriority(), clientData); + middleScorePanel.setBounds(new Rectangle((258 + 20 + priority*198)-20,0,60,100+50+50)); + middleScorePanels.add(middleScorePanel); + add(middleScorePanel, null); + } + } + + public void update(ClientDataModel clientDataModel) { + // TODO Auto-generated method stub + //jLabelMap.get(new Integer(clientData.getPriority())).setText(new Integer(clientData.getFilesDownloaded()).toString()); + for (ClientData clientData : clientDataModel.getClientDataSortedByPriority()) { + middleScorePanels.get(clientData.getPriority()).update(clientData); + } + } + } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java 2009-10-21 00:29:19 UTC (rev 311) @@ -60,7 +60,7 @@ private void initializeEventProcessors() { channel.add(this, new EventTypeProcessor<RegistrationEvent>(RegistrationEvent.class) { public void handle(RegistrationEvent registrationEvent) { - facilitatorWindow.setText(registrationEvent.getRoundConfiguration().getInstructions()); + facilitatorWindow.addInstructions(registrationEvent.getRoundConfiguration().getInstructions()); } }); channel.add(this, new EventTypeProcessor<FacilitatorEndRoundEvent>(FacilitatorEndRoundEvent.class) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-21 00:29:19 UTC (rev 311) @@ -47,6 +47,8 @@ private JButton showInstructionsButton; private JButton displayInvestmentButton; + + private StringBuilder builder = new StringBuilder(); /** * This is the default constructor */ @@ -165,8 +167,8 @@ * @return javax.swing.JButton */ public void endRound(FacilitatorEndRoundEvent event) { + builder = new StringBuilder(); ServerDataModel model = event.getServerDataModel(); - StringBuilder builder = new StringBuilder(); builder.append("<h3>Facilitator Debriefing:</h3>"); builder.append("<table><thead><th>Participant</th><th>Current tokens</th><th>Current Income</th><th>Total Income</th></thead><tbody>"); Map<Identifier, ClientData> clientDataMap = new HashMap<Identifier, ClientData>(); @@ -195,5 +197,10 @@ } setText(builder.toString()); } + + public void addInstructions(String instructions) { + builder.append(instructions); + setText(builder.toString()); + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 00:29:19 UTC (rev 311) @@ -51,7 +51,7 @@ private final Map<Identifier, ClientData> clients = new LinkedHashMap<Identifier, ClientData>(); - private final static int SERVER_SLEEP_INTERVAL = 333; + private final static int SERVER_SLEEP_INTERVAL = 100; private final Object roundSignal = new Object(); @@ -194,6 +194,11 @@ public void handle(DisconnectionRequest request) { getLogger().warning("irrigation server handling disconnection request: " + request); Identifier disconnectedClientId = request.getId(); + if (disconnectedClientId.equals(facilitatorId)) { + getLogger().warning("Disconnecting facilitator."); + facilitatorId = null; + return; + } synchronized (clients) { clients.remove(disconnectedClientId); serverDataModel.removeClient(disconnectedClientId); @@ -303,14 +308,11 @@ int timeLeft = (int) (currentRoundDuration.getTimeLeft() / 1000); // allocate bandwidth to each client for (ClientData clientData : group.getClientDataMap().values()) { - /** - * undisrupted bandwith extensions - */ - if(clientData.getAvailableFlowCapacity() <= 0 && getConfiguration().isUndisruptedFlowRequired()){ - clientData.init(group.getCurrentlyAvailableFlowCapacity()); - } + // for undisrupted flow extensions, disabled for the time being. +// if (clientData.getAvailableFlowCapacity() <= 0 && getConfiguration().isUndisruptedFlowRequired()){ +// clientData.init(group.getCurrentlyAvailableFlowCapacity()); +// } if (clientData.isGateOpen()) { - //System.out.println("Downloading file"+clientData.getFileNumber()+"Current time"+System.currentTimeMillis()/1000); group.allocateFlowCapacity(clientData); } else if (clientData.isGateClosed()) { @@ -338,9 +340,11 @@ private class IrrigationServerStateMachine implements StateMachine { private IrrigationServerState state; + + private long lastTime; + + private Duration secondTick = Duration.create(1000L); - private final Duration secondTick = Duration.create(1000L); - public void initialize() { // FIXME: may want to change this as we add more states. state = IrrigationServerState.WAITING; @@ -357,11 +361,13 @@ // start timers currentRoundDuration = getRoundConfiguration().getRoundDuration(); currentRoundDuration.start(); + state = IrrigationServerState.ROUND_IN_PROGRESS; secondTick.start(); - state = IrrigationServerState.ROUND_IN_PROGRESS; +// lastTime = System.currentTimeMillis(); } private void processRound() { +// if ((System.currentTimeMillis() - lastTime) / 1000 > 1) { if (secondTick.hasExpired()) { for (GroupDataModel group: serverDataModel.getAllGroupDataModels()) { // reset available bandwidth for this group to calculate new allocations for the group @@ -374,6 +380,7 @@ getLogger().throwing(IrrigationServerStateMachine.class.getName(), "processRound", exception); } } +// lastTime = System.currentTimeMillis(); secondTick.restart(); } } Modified: irrigation/trunk/src/main/resources/web/client.jnlp =================================================================== --- irrigation/trunk/src/main/resources/web/client.jnlp 2009-10-20 09:58:30 UTC (rev 310) +++ irrigation/trunk/src/main/resources/web/client.jnlp 2009-10-21 00:29:19 UTC (rev 311) @@ -10,7 +10,9 @@ <resources> <j2se version="1.6+"/> <jar href="client.jar"/> - <jar href='@FRAMEWORK_JAR@'/> + <jar href='csidex.jar'/> + <jar href='jcommon.jar'/> + <jar href='jfreechart.jar'/> </resources> <application-desc main-class="@MAIN_CLASS@"/> </jnlp> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-20 09:58:38
|
Revision: 310 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=310&view=rev Author: alllee Date: 2009-10-20 09:58:30 +0000 (Tue, 20 Oct 2009) Log Message: ----------- irrigation game panel is almost complete. It's ugly as hell though, layout needs a lot of work. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -1,9 +1,9 @@ package edu.asu.commons.irrigation.client; import java.awt.Color; +import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; @@ -73,8 +73,7 @@ * @return void */ private void initialize() { - this.setSize(1098,150); - this.setLayout(new GridBagLayout()); + this.setPreferredSize(new Dimension(1098,150)); this.setBackground(Color.white); //initializing the constructor for Gates for(int i=0;i<numberofGates ;i++){ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -1,6 +1,8 @@ package edu.asu.commons.irrigation.client; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; @@ -98,6 +100,17 @@ public Map<Identifier, ClientData> getClientDataMap() { return groupDataModel.getClientDataMap(); } + + public List<ClientData> getClientDataSortedByPriority() { + ArrayList<ClientData> clientDataList = new ArrayList<ClientData>(getGroupDataModel().getClientDataMap().values()); + // sort by position. + Collections.sort(clientDataList, new Comparator<ClientData>() { + public int compare(ClientData a, ClientData b) { + return new Integer(a.getPriority()).compareTo(b.getPriority()); + } + }); + return clientDataList; + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-20 09:58:30 UTC (rev 310) @@ -383,7 +383,7 @@ Runnable runnable = new Runnable() { public void run() { addCenterComponent(irrigationGamePanel); - requestFocusInWindow(); + irrigationGamePanel.startRound(); } }; SwingUtilities.invokeLater(runnable); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-20 09:58:30 UTC (rev 310) @@ -137,9 +137,8 @@ transmit(openGateEvent); } - public void closeGate(String fileNo) { + public void closeGate() { CloseGateEvent closeGateEvent = new CloseGateEvent(getId()); - closeGateEvent.setFileNumber(fileNo); transmit(closeGateEvent); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -4,9 +4,14 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.GridLayout; import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException; +import javax.swing.BoxLayout; +import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; @@ -39,7 +44,7 @@ //this contains the upstream and downstream Panel private JPanel jPanelUpStreamWindow = null; private JPanel jPanelDownStreamWindow = null; - private JPanel downloadScreenPanel = null; + private JPanel mainIrrigationPanel = null; private ScoreBoxPanel scoreBoxPanel; @@ -47,26 +52,44 @@ public Dimension screenSize; - public JProgressBar timeRemainingProgressBar = null; + public JProgressBar timeRemainingProgressBar; - private JLabel timeRemainingLabel = null; + private JLabel timeRemainingLabel; private JTextField timeRemainingTextField; - private JLabel priorityjLabel = null; + private JButton gateSwitchButton; - private JLabel totalAvailableFlowCapacityLabel = null; + private JLabel irrigationCapacityLabel; - private JLabel maximumAvailableFlowCapacityLabel = null; + // private JLabel maximumAvailableFlowCapacityLabel = null; private ClientDataModel clientDataModel; // @jve:decl-index=0: private MiddleWindowPanel middleWindowPanel; - private JLabel dashBoardLabel = null; + // private JLabel dashBoardLabel = null; - private JLabel scoreBoardLabel = null; + // private JLabel scoreBoardLabel = null; + private JLabel totalTokensEarnedLabel; + + private JLabel tokensEarnedLabel; + + private JLabel tokensNotInvestedLabel; + + private JLabel waterUsedLabel; + + private JTextField waterUsedTextField; + + private JTextField tokensNotInvestedTextField; + + private JTextField tokensEarnedTextField; + + private JTextField totalTokensEarnedTextField; + + private boolean open; + public IrrigationGamePanel(Dimension screenSize, IrrigationClient client) { setName("Irrigation Game Panel"); this.screenSize = screenSize; @@ -78,68 +101,181 @@ * @return */ private void initGuiComponents() { - timeRemainingLabel = new JLabel(); - timeRemainingLabel.setBounds(new Rectangle(469, 39, 146, 23)); + + + JPanel topmostPanel = new JPanel(); + topmostPanel.setLayout(new BoxLayout(topmostPanel, BoxLayout.X_AXIS)); + topmostPanel.add(getIrrigationCapacityLabel()); + + JPanel timeRemainingPanel = new JPanel(); + timeRemainingPanel.setLayout(new BoxLayout(timeRemainingPanel, BoxLayout.Y_AXIS)); + timeRemainingPanel.add(getTimeRemainingProgressBar()); + timeRemainingPanel.add(getTimeRemainingPanel()); + + topmostPanel.add(timeRemainingPanel); + + + setLayout(new BorderLayout()); + add(topmostPanel, BorderLayout.PAGE_START); + add(getUpperPanel(), BorderLayout.CENTER); + add(getBottomPanel(), BorderLayout.PAGE_END); + } + + private JPanel getBottomPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.add(getGateSwitchButton()); + + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new GridLayout(4, 2)); + bottomPanel.add(getWaterUsedLabel()); + bottomPanel.add(getWaterUsedTextField()); + bottomPanel.add(getTokensNotInvestedLabel()); + bottomPanel.add(getTokensNotInvestedTextField()); + bottomPanel.add(getTokensEarnedLabel()); + bottomPanel.add(getTokensEarnedTextField()); + bottomPanel.add(getTotalTokensEarnedLabel()); + bottomPanel.add(getTotalTokensEarnedTextField()); + + panel.add(bottomPanel); + return panel; + } + + private JTextField getWaterUsedTextField() { + if (waterUsedTextField == null) { + waterUsedTextField = new JTextField(); + waterUsedTextField.setEditable(false); + } + return waterUsedTextField; + } + + private JLabel getWaterUsedLabel() { + if (waterUsedLabel == null) { + waterUsedLabel = new JLabel("Water units used: "); + } + return waterUsedLabel; + } + + private JTextField getTokensNotInvestedTextField() { + if (tokensNotInvestedTextField == null) { + tokensNotInvestedTextField = new JTextField(); + tokensNotInvestedTextField.setEditable(false); + } + return tokensNotInvestedTextField; + } + private JLabel getTokensNotInvestedLabel() { + if (tokensNotInvestedLabel == null) { + tokensNotInvestedLabel = new JLabel("Tokens not invested: "); + } + return tokensNotInvestedLabel; + } + + private JTextField getTokensEarnedTextField() { + if (tokensEarnedTextField == null) { + tokensEarnedTextField = new JTextField(); + tokensEarnedTextField.setEditable(false); + } + return tokensEarnedTextField; + } + private JLabel getTokensEarnedLabel() { + if (tokensEarnedLabel == null) { + tokensEarnedLabel = new JLabel("Tokens earned by crop production: "); + } + return tokensEarnedLabel; + } + + private JTextField getTotalTokensEarnedTextField() { + if (totalTokensEarnedTextField == null) { + totalTokensEarnedTextField = new JTextField(); + totalTokensEarnedTextField.setEditable(false); + } + return totalTokensEarnedTextField; + + } + + private JLabel getTotalTokensEarnedLabel() { + if (totalTokensEarnedLabel == null) { + totalTokensEarnedLabel = new JLabel("Total tokens earned this round: "); + } + return totalTokensEarnedLabel; + } + + private JPanel getTimeRemainingPanel() { + timeRemainingLabel = new JLabel("Time left: "); timeRemainingLabel.setHorizontalAlignment(SwingConstants.CENTER); timeRemainingLabel.setHorizontalTextPosition(SwingConstants.CENTER); - timeRemainingLabel.setText("Time Left"); - timeRemainingTextField = new JTextField(); + timeRemainingTextField = new JTextField("50 sec"); timeRemainingTextField.setEditable(false); - // timeRemainingTextField.setBounds(new Rectangle(620, 39, 61); - timeRemainingTextField.setText("50 sec"); timeRemainingTextField.setBackground(Color.white); timeRemainingTextField.setFont(new Font("serif", Font.BOLD, 14)); timeRemainingTextField.setForeground(new Color(102, 204, 255)); timeRemainingTextField.setHorizontalAlignment(SwingConstants.CENTER); - setLayout(new BorderLayout()); - add(getDownloadScreenPanel(), BorderLayout.CENTER); + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + panel.add(timeRemainingLabel); + panel.add(timeRemainingTextField); + return panel; } - private JPanel getDownloadScreenPanel() { - if(downloadScreenPanel == null){ - scoreBoardLabel = new JLabel(); - scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); - scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - scoreBoardLabel.setText("SUMMARY SCOREBOARD FOR YOU AND OTHER PLAYERS"); - dashBoardLabel = new JLabel(); - dashBoardLabel.setBounds(new Rectangle(13,225+100+35,530,20)); - dashBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - dashBoardLabel.setText("YOUR DASHBOARD"); - maximumAvailableFlowCapacityLabel = new JLabel(); - maximumAvailableFlowCapacityLabel.setBounds(new Rectangle(200, 18, 55, 17)); - maximumAvailableFlowCapacityLabel.setText(""); - totalAvailableFlowCapacityLabel = new JLabel(); - totalAvailableFlowCapacityLabel.setBounds(new Rectangle(19, 17, 170, 16)); - totalAvailableFlowCapacityLabel.setText("Irrigation capacity: "); - priorityjLabel = new JLabel(); - priorityjLabel.setBounds(new Rectangle(780, 16, 44, 16)); - priorityjLabel.setText(""); - downloadScreenPanel = new JPanel(); - downloadScreenPanel.setLayout(null); - downloadScreenPanel.setName("downloadScreenPanel"); - downloadScreenPanel.setBackground(Color.white); - downloadScreenPanel.add(getUpperPanel(),null); - downloadScreenPanel.add(getTimeRemainingProgressBar(), null); - downloadScreenPanel.add(timeRemainingLabel, null); - downloadScreenPanel.add(timeRemainingTextField,null); - - downloadScreenPanel.add(totalAvailableFlowCapacityLabel, null); - downloadScreenPanel.add(maximumAvailableFlowCapacityLabel, null); - downloadScreenPanel.add(dashBoardLabel, null); - downloadScreenPanel.add(scoreBoardLabel, null); + private JLabel getIrrigationCapacityLabel() { + if (irrigationCapacityLabel == null) { + irrigationCapacityLabel = new JLabel("Irrigation capacity: "); } - return downloadScreenPanel; + return irrigationCapacityLabel; } + // private JPanel getMainIrrigationPanel() { + // if (mainIrrigationPanel == null) { + // irrigationCapacityLabel = new JLabel(); + // irrigationCapacityLabel.setText("Irrigation capacity: "); + // mainIrrigationPanel = new JPanel(); + // + // + // mainIrrigationPanel.setName("downloadScreenPanel"); + // mainIrrigationPanel.setBackground(Color.white); + // mainIrrigationPanel.add(getUpperPanel(),null); + // mainIrrigationPanel.add(timeRemainingLabel, null); + // mainIrrigationPanel.add(timeRemainingTextField,null); + // + // mainIrrigationPanel.add(irrigationCapacityLabel, null); + // mainIrrigationPanel.add(maximumAvailableFlowCapacityLabel, null); + // mainIrrigationPanel.add(dashBoardLabel, null); + // mainIrrigationPanel.add(scoreBoardLabel, null); + // } + // return mainIrrigationPanel; + // } + private JPanel getUpperPanel() { if (upperPanel == null) { upperPanel = new JPanel(); upperPanel.setLayout(new BorderLayout()); + upperPanel.add(getScoreBoxPanel(), BorderLayout.PAGE_END); } return upperPanel; } + + private JButton getGateSwitchButton() { + if (gateSwitchButton == null) { + gateSwitchButton = new JButton("Open Gate"); + gateSwitchButton.setPreferredSize(new Dimension(60, 60)); + gateSwitchButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + open = !open; + gateSwitchButton.setText( open ? "Close gate" : "Open gate"); + if (open) { + client.openGate(); + } + else { + client.closeGate(); + } + } + }); + } + return gateSwitchButton; + } + private JPanel getCanalPanel() { canalPanel = new CanalPanel(clientDataModel); return canalPanel; @@ -185,9 +321,7 @@ private ScoreBoxPanel getScoreBoxPanel() { if(scoreBoxPanel == null){ - scoreBoxPanel = new ScoreBoxPanel(client); - - return scoreBoxPanel; + scoreBoxPanel = new ScoreBoxPanel(); } return scoreBoxPanel; } @@ -201,7 +335,6 @@ private JProgressBar getTimeRemainingProgressBar() { if (timeRemainingProgressBar == null) { timeRemainingProgressBar = new JProgressBar(0, 50); - timeRemainingProgressBar.setBounds(new Rectangle(360, 15, 370, 17)); timeRemainingProgressBar.setBackground(Color.white); timeRemainingProgressBar.setForeground(new Color(51, 153, 255)); } @@ -212,35 +345,32 @@ * Shoudl be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. */ public void updateClientStatus(final ClientDataModel clientDataModel) { - ////////////new code//////////////////////////////////////////////////////////// Runnable createGuiRunnable = new Runnable(){ public void run() { + int timeLeft = clientDataModel.getTimeLeft(); + int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableFlowCapacity(); + timeRemainingTextField.setText( timeLeft + " sec"); + timeRemainingProgressBar.setValue( timeLeft ); + irrigationCapacityLabel.setText( + String.format("Irrigation capacity: %d cubic feet per second (cfps)", + irrigationCapacity)); for(final ClientData clientData : clientDataModel.getClientDataMap().values()){ - timeRemainingTextField.setText( clientDataModel.getTimeLeft() +" second(s)" ); - timeRemainingProgressBar.setValue( (clientDataModel.getTimeLeft() / 1000) ); - maximumAvailableFlowCapacityLabel.setText( - clientData.getGroupDataModel().getMaximumAvailableFlowCapacity() +" cubic feet per second (cfps)" - ); - middleWindowPanel.update(clientData); - if (clientDataModel.getPriority() == clientData.getPriority()) { - irrigationGameWindow.update(clientData); - //per parameter score panel - scoreBoxPanel.update(clientData); - } - else{ - scoreBoxPanel.update(clientData); - } - if(clientData.isGateOpen()){ + if (clientData.isGateOpen()) { canalPanel.openGates(clientData.getPriority()); - } else if(clientData.isPaused()){ canalPanel.closeGates(clientData.getPriority()); } - if(clientData.isGateClosed()){ + else if(clientData.isGateClosed()){ canalPanel.closeGates(clientData.getPriority()); } } + ClientData clientData = clientDataModel.getClientData(); + waterUsedTextField.setText("" + clientData.getWaterUsed()); + tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); + tokensEarnedTextField.setText("" + clientData.waterToTokenFunction()); + totalTokensEarnedTextField.setText("" + clientData.getTotalTokensEarned()); + scoreBoxPanel.update(clientDataModel); } }; @@ -293,21 +423,21 @@ //irrigation window as the value and the priority value as the key. This is handled here , because //the event contains the priority for every client, and the priority can act as a unique key for the //game window. - fillPanels(); - } - /** * fills in the panels depending on the priority of the client */ - private void fillPanels() { + public void startRound() { upperPanel.add(getCanalPanel(), BorderLayout.CENTER); - downloadScreenPanel.add(getJPanelUpStreamWindow(),null); - downloadScreenPanel.add(getJPanelDownStreamWindow(),null); + open = false; + scoreBoxPanel.initialize(clientDataModel); + revalidate(); + // mainIrrigationPanel.add(getJPanelUpStreamWindow(),null); + // mainIrrigationPanel.add(getJPanelDownStreamWindow(),null); //adding the in between Panel - downloadScreenPanel.add(getJPanelMiddleWindow(),null); + // mainIrrigationPanel.add(getJPanelMiddleWindow(),null); } private JPanel getJPanelMiddleWindow() { @@ -320,9 +450,8 @@ return middleWindowPanel; } - public ClientDataModel getClientGameState() { + public ClientDataModel getClientDataModel() { return clientDataModel; } } -// @jve:decl-index=0:visual-constraint="10,-43" Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-20 09:58:30 UTC (rev 310) @@ -544,7 +544,7 @@ if (moneyEarnedTextField == null) { moneyEarnedTextField = new JTextField(); moneyEarnedTextField.setText(new Integer(mainIrrigationWindow - .getClientGameState().getClientData().getTotalTokensEarned()) + .getClientDataModel().getClientData().getTotalTokensEarned()) .toString()); moneyEarnedTextField.setBounds(new Rectangle(161, 17, 86, 21)); moneyEarnedTextField.setFont(new Font("Dialog", Font.PLAIN, 14)); @@ -635,8 +635,9 @@ * clientData.getAvailableBandwidth()).toString()); } */ - fileDownloadedProgressBar.setValue((int) clientData.getPercentFileDownload()); +// fileDownloadedProgressBar.setValue((int) clientData.getPercentFileDownload()); // checks whether the file has been downlaoded + /* if (clientData.isFileDownloaded()) { moneyEarnedTextField.setText(new Integer(clientData.getTotalTokensEarned()) Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -148,7 +148,7 @@ else currentBandwidthText.setText(new Double(clientData.getAvailableFlowCapacity()).toString()); - filesDownloadedText.setText(new Integer(clientData.getCropsGrown()).toString()); + filesDownloadedText.setText(new Integer(clientData.getWaterUsed()).toString()); tokensText.setText(new Integer(clientData.getTotalTokensEarned()).toString()); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -1,17 +1,19 @@ package edu.asu.commons.irrigation.client; -import java.awt.Dimension; import java.awt.GridLayout; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JLabel; import javax.swing.JPanel; import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.server.GroupDataModel; /** * $Id$ - * + * + * Panel displaying data for all participants. * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ @@ -19,42 +21,54 @@ public class ScoreBoxPanel extends JPanel { private static final long serialVersionUID = 4724679308719540371L; - //creating a Linked Hash Map for the activity Panel Screens - //Map<Integer, ActivitySummaryPanel>activitySummaryPanelMap = new LinkedHashMap<Integer, ActivitySummaryPanel>(); - Map<Integer, SummaryPanel>activitySummaryPanelMap = new LinkedHashMap<Integer, SummaryPanel>(); - - IrrigationClient client; - int NUMBER_PARAMETERS = 3; + private List<JLabel> availableWaterLabels = new ArrayList<JLabel>(); - public ScoreBoxPanel(IrrigationClient client){ - super(); - this.client = client; - initialize(); + private List<JLabel> waterUsedLabels = new ArrayList<JLabel>(); + + private void clear() { + availableWaterLabels.clear(); + waterUsedLabels.clear(); } - - private void initialize() { - // TODO Auto-generated method stub - GridLayout gridLayout = new GridLayout(); - gridLayout.setColumns(2); - gridLayout.setRows(2); - this.setSize(new Dimension(530,326)); - this.setLayout(gridLayout); - - //add the new activity panel that gives information per Parameter - for(int i=0;i<NUMBER_PARAMETERS;i++){ - //get the activity panels per parameter - SummaryPanel activitySummaryPanelNew = new SummaryPanel(i,client); - activitySummaryPanelMap.put(new Integer(i), activitySummaryPanelNew); - this.add(activitySummaryPanelNew); + + public void initialize(ClientDataModel clientDataModel) { + clear(); + // number of clients + 1 for the labels + GroupDataModel groupDataModel = clientDataModel.getGroupDataModel(); + int columns = groupDataModel.size() + 1; + GridLayout gridLayout = new GridLayout(3, columns); + setLayout(gridLayout); + + add(new JLabel("Position")); + List<ClientData> clientDataList = clientDataModel.getClientDataSortedByPriority(); + for (ClientData clientData : clientDataList) { + add(new JLabel(clientData.getPriorityAsString())); } + // available water per second + add(new JLabel("Available water per second")); + for (ClientData clientData: clientDataList) { + JLabel availableWaterLabel = new JLabel("" + clientData.getAvailableFlowCapacity()); + availableWaterLabels.add(availableWaterLabel); + add(availableWaterLabel); + } + // water used + add(new JLabel("Water used")); + for (ClientData clientData : clientDataList) { + JLabel waterUsedLabel = new JLabel("" + clientData.getWaterUsed()); + waterUsedLabels.add(waterUsedLabel); + add(waterUsedLabel); + } } - public void update(ClientData clientData){ - //update specific panel if activity Summary panel is being used, else update all the panels. - //activitySummaryPanelMap.get(new Integer(clientData.getPriority())).update(clientData); - for(int i=0;i<NUMBER_PARAMETERS;i++){ - activitySummaryPanelMap.get(new Integer(i)).update(clientData); + public void update(ClientDataModel clientDataModel) { + List<ClientData> clientDataList = clientDataModel.getClientDataSortedByPriority(); + for (int index = 0; index < clientDataList.size(); index++) { + ClientData clientData = clientDataList.get(index); + JLabel availableWaterLabel = availableWaterLabels.get(index); + availableWaterLabel.setText("" + clientData.getAvailableFlowCapacity()); + JLabel waterUsedLabel = waterUsedLabels.get(index); + waterUsedLabel.setText("" + clientData.getWaterUsed()); } + } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-20 09:58:30 UTC (rev 310) @@ -63,10 +63,6 @@ return getIntProperty("max-infrastructure-efficiency", 100); } - public double getMaximumIndividualFlowCapacity() { - return getDoubleProperty("max-individual-flow-capacity", 20.0d); - } - public boolean isPracticeRound() { return getBooleanProperty("practice-round"); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-20 09:58:30 UTC (rev 310) @@ -30,27 +30,10 @@ private GroupDataModel groupDataModel; - private String fileNumber; - - private List<String> filesDownloadedList = new ArrayList<String>(); - - private boolean fileDownloaded = false; + private int waterUsed = 0; - private int fileSize; + private int availableFlowCapacity; - private double percentFileDownloaded = 0; - - private double downloadedFileSize = 0; - - private int cropsGrown = 0; - - // maximum available bandwidth - private double maximumIndividualFlowCapacity; - /** - * current download speed - */ - private double availableFlowCapacity = 25.0d; - private int investedTokens; private int assignedNumber; @@ -59,8 +42,6 @@ private int totalTokens; - private int tokensCollectedLastRound; - private boolean paused = false; private boolean gateOpen = false; @@ -80,29 +61,15 @@ public boolean isGateOpen(){ return gateOpen; } - - // cap on the size of the entire stream (e.g,. 50 kbps) - public double getMaximumAvailableBandwidth(){ - return groupDataModel.getMaximumAvailableFlowCapacity(); - } - // cap on the size of the stream that can be delivered to the client (e.g., 25 kbps) - public void setMaximumIndividualFlowCapacity(double deliveryBandwidth){ - this.maximumIndividualFlowCapacity = deliveryBandwidth; - } - - public double getMaximumIndividualFlowCapacity(){ - return maximumIndividualFlowCapacity; - } - /** * The actual bandwidth allocated to this client. */ - public void setAvailableFlowCapacity(double availableFlowCapacity){ + public void setAvailableFlowCapacity(int availableFlowCapacity) { this.availableFlowCapacity = availableFlowCapacity; } - public double getAvailableFlowCapacity(){ + public int getAvailableFlowCapacity(){ return availableFlowCapacity; } @@ -120,23 +87,7 @@ } return "Position not found"; } - - /** - * set and get the current file_no from the client.The corresponding file sizes and their numbers - * are listed down in the configuration file. Thus I can get their sizes. - * - */ - public void setFileNumber(String fileNumber){ - this.fileNumber = fileNumber; - } - public String getFileNumber() { - return fileNumber; - } - - public double getPercentFileDownload(){ - return percentFileDownloaded; - } /** * here the parameters isPaused, isStopped and isStartDownload would change. * The server every time would check the clients queue. It would be a queue of clients requests. @@ -149,7 +100,7 @@ paused = false; } - public void setPaused(){ + public void pause(){ paused = true; gateOpen = false; } @@ -197,17 +148,15 @@ * clearing the clientData at the end of each round * */ - public void reset() { - resetFileInformation(); + public void endRound() { closeGate(); investedTokens = 0; //adding number of files to be downloaded = 0 per round - cropsGrown = 0; - filesDownloadedList.clear(); + waterUsed = 0; } public void resetAllTokens() { - reset(); + endRound(); totalTokens = 0; } @@ -223,9 +172,6 @@ return totalTokens; } - public int getTokensCollectedLastRound() { - return tokensCollectedLastRound; - } public RoundConfiguration getRoundConfiguration(){ return roundConfiguration; @@ -234,21 +180,11 @@ * This would initialize the clientData before the start of each download. * */ - public void init(double availableFlowCapacity) { - resetFileInformation(); - maximumIndividualFlowCapacity = getRoundConfiguration().getMaximumIndividualFlowCapacity(); - //currentBandwidth = totalContributedBandwidth; - this.availableFlowCapacity = availableFlowCapacity; + public void init(int availableFlowCapacity) { + closeGate(); + setAvailableFlowCapacity(availableFlowCapacity); } - private void resetFileInformation() { - fileSize = 0; - fileNumber = ""; - downloadedFileSize = 0; - percentFileDownloaded = 0; - closeGate(); - } - public void award() { totalTokens += getTotalTokensEarned(); } @@ -258,102 +194,71 @@ * @return */ public int getTotalTokensEarned(){ - return calculateTokensEarned() + (getRoundConfiguration().getMaximumInvestedTokens() - investedTokens); + return waterToTokenFunction() + getUninvestedTokens(); } /** - * complex functions can be defined here + * Reward function table correlating water usage to tokens earned. + * * @param value * @return */ - - private int calculateTokensEarned() { - switch (cropsGrown) { - case 0: case 1: + public int waterToTokenFunction() { + if (waterUsed < 150) { return 0; - case 2: - return 6; - case 3: - return 22; - case 4: - return 28; - case 5: - return 30; - default: - throw new IllegalStateException("Should be a number between 0-5, was " + cropsGrown + " instead."); } -// double alpha,b,a,num,deno; -// /** -// * This would be taken by a proper configuration file -// */ -// alpha = getRoundConfiguration().getAlphaAward(); -// a = getRoundConfiguration().getA_award(); -// b = getRoundConfiguration().getB_award(); -// num = alpha * Math.pow((double)filesDownloaded,b); -// deno = Math.pow(a,b)+Math.pow(filesDownloaded,b); -// -// /** -// * until u get the final equation, you can go ahead with -// * these values.. -// */ -// return (int)(Math.round(num/deno)); - //return no_fileDownloaded; + else if (waterUsed < 200) { + return 1; + } + else if (waterUsed < 250) { + return 4; + } + else if (waterUsed < 300) { + return 10; + } + else if (waterUsed < 350) { + return 15; + } + else if (waterUsed < 400) { + return 18; + } + else if (waterUsed < 500) { + return 19; + } + else if (waterUsed < 550) { + return 20; + } + else if (waterUsed < 650) { + return 19; + } + else if (waterUsed < 700) { + return 18; + } + else if (waterUsed < 750) { + return 15; + } + else if (waterUsed < 800) { + return 10; + } + else if (waterUsed < 850) { + return 4; + } + else if (waterUsed < 900) { + return 1; + } + else { + return 0; + } } - /** - * calculates the percent of the file downloaded - * - */ - /** - *Here check whether the percentageFile > 100, then init the file download - *else simply increment the filesize. If we increment the file size and then - *check whether the filesize > 100 and then invoke completedownload, that information - *is not send to the client, as the sending file progress events are in the same loop - *as processDownload function - */ - public void allocateFlowCapacity(double availableBandwidth) { - assert gateOpen; - fileDownloaded = false; - incrementFileDownloadSize(); + + public void collectWater() { + waterUsed += availableFlowCapacity; } - private void completeFileDownload() { - cropsGrown++; - fileDownloaded = true; - filesDownloadedList.add(fileNumber); - groupDataModel.getEventChannel().handle(new FileDownloadedEvent(id, fileNumber)); - resetFileInformation(); - //init(availableBandwidth); + public int getWaterUsed(){ + return waterUsed; } - - /** - * This would increament the percentage of the file downloaded - * by Bi - * - */ - public void incrementFileDownloadSize(){ - downloadedFileSize += availableFlowCapacity; - percentFileDownloaded = (downloadedFileSize/fileSize)*100; - if (percentFileDownloaded >= 100) { - //filesDownloaded++; - percentFileDownloaded = 100; - completeFileDownload(); - } - - } - public int getCropsGrown(){ - return cropsGrown; - } - - public boolean isFileDownloaded() { - return fileDownloaded; - } - - public List<String> getDownloadListArray() { - return filesDownloadedList; - } - - } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-20 09:58:30 UTC (rev 310) @@ -70,6 +70,10 @@ clients.put(clientData.getId(), clientData); clientData.setAssignedNumber(clients.size()); } + + public int size() { + return clients.size(); + } public void removeClient(Identifier id) { clients.remove(id); @@ -99,14 +103,13 @@ return serverDataModel.getRoundConfiguration(); } - //get totalContributed tokens for this round public int getTotalContributedTokens() { return totalContributedTokens; } public void calculateTotalFlowCapacity() { // for practice round and first round, initialize to initial infrastructure efficiency - //setting the total contributed Bandwidth = 0 , so thatfor every round, + //setting the total contributed Bandwidth = 0 , so that for every round, // fresh totalContributed tokens are calculated totalContributedTokens = 0; for(ClientData clientData : getClientDataMap().values()) { @@ -194,16 +197,17 @@ } public void allocateFlowCapacity(ClientData clientData) { - if (currentlyAvailableFlowCapacity >= clientData.getMaximumIndividualFlowCapacity()) { - currentlyAvailableFlowCapacity -= clientData.getMaximumIndividualFlowCapacity(); -// setAvailableBandwidth(clientData.getTotalContributedBandwidth() - clientData.getDeliveryBandwidth()); - clientData.setAvailableFlowCapacity(clientData.getMaximumIndividualFlowCapacity()); + RoundConfiguration roundConfiguration = getRoundConfiguration(); + int maximumClientFlowCapacity = roundConfiguration.getMaximumClientFlowCapacity(); + if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { + currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; + clientData.setAvailableFlowCapacity(maximumClientFlowCapacity); } else { clientData.setAvailableFlowCapacity(currentlyAvailableFlowCapacity); currentlyAvailableFlowCapacity = 0; } - clientData.allocateFlowCapacity(currentlyAvailableFlowCapacity); + clientData.collectWater(); } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-20 06:07:13 UTC (rev 309) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-20 09:58:30 UTC (rev 310) @@ -259,7 +259,7 @@ }); addEventProcessor(new EventTypeProcessor<PauseRequest>(PauseRequest.class) { public void handle(PauseRequest event) { - clients.get(event.getId()).setPaused(); + clients.get(event.getId()).pause(); } }); } @@ -414,7 +414,7 @@ clientData.resetAllTokens(); } else { - clientData.reset(); + clientData.endRound(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-20 06:07:21
|
Revision: 309 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=309&view=rev Author: alllee Date: 2009-10-20 06:07:13 +0000 (Tue, 20 Oct 2009) Log Message: ----------- starting to refactor the game interface now. continuing to remove unnecessary nested JPanels (what were you thinking Sanket?!?). Next up is to continue merging all primary interface elements into IrrigationGamePanel. fixed a bug in RegistrationEvent where the facilitator would receive RegistrationEvents with a null RoundConfiguration. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-20 04:41:30 UTC (rev 308) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-20 06:07:13 UTC (rev 309) @@ -12,59 +12,35 @@ import javax.swing.Timer; /** - * @author Sanket - * + * $Id$ + * + * @author Allen Lee, Sanket Joshi */ public class CanalPanel extends JPanel { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -6178860067928578812L; - /** - * This is the default constructor - */ - private int x1UpStream; +// private Graphics2D graphics2D; - private int y1UpStream; + //////////////////animation logic parameters////////////////////////////// + private Timer timer; - private int x2UpStream = 420; + private final static int DELAY = 20; - private int y2UpStream = 100; + private Ball balls[]; - private int y2DownStream = 100; + private final static int BALLCOUNT = 500; - private int x2DownStream = 950; + private Gate gate[] = new Gate[6]; - private int y1DownStream; - - private int x1DownStream; - - private Graphics2D graphics2D; - - private boolean flagDownStream = false; - - private boolean flagUpStream = false; - - //private IrrigationClientGameState clientGameState; - - //////////////////animation logic parameters////////////////////////////// - private Timer timer; - - private final int DELAY = 20; - - private Ball balls[]; - - private int BALLCOUNT = 500; - - private Gate gate[] = new Gate[6]; - private int gateHeight = 20; - + Random generator = new Random(); private boolean enableBallAnimation = true; private double totalContributedBandwidth; - + private ClientDataModel clientGameState; private int numberofGates = 6; @@ -87,7 +63,7 @@ if(totalContributedBandwidth == 1.0){ totalContributedBandwidth = 2.0; } - + initialize(); } @@ -105,67 +81,66 @@ gate[i] = new Gate(totalContributedBandwidth,i); //System.out.println("Gate "+i+"x : "+gate[i].getX()+"y : "+gate[i].getY()); } - - initializexy(); - - timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an action - // every DELAY times. - timer.start(); // starts the timer. - - } + initializeBalls(); + + timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an action + // every DELAY times. + timer.start(); // starts the timer. + + } + protected void paintComponent(Graphics graphics){ updateGUI(); super.paintComponent(graphics); // needed! - Graphics2D graphics2D = (Graphics2D)graphics; - this.graphics2D = graphics2D; - this.graphics2D.setColor(Color.BLUE); - this.graphics2D.fillRect(0,0,serverHeight,serverWidth); + Graphics2D graphics2D = (Graphics2D) graphics; + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(0,0,serverHeight,serverWidth); //draw the other gates for(int i=0;i<numberofGates-1;i++){ - this.graphics2D.setColor(Color.BLUE); - this.graphics2D.fillRect(gate[i].getX(), gate[i].getY(), gate[i].getWidth(),gate[i].getHeight()); + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gate[i].getX(), gate[i].getY(), gate[i].getWidth(),gate[i].getHeight()); } - + int numClients = clientGameState.getAllClientIdentifiers().size(); - for(int i=0;i<numClients;i++){ - this.graphics2D.setColor(Color.BLUE); - this.graphics2D.fillRect(gate[i].getOpeningsX(), gate[i].getOpeningsY(),gate[i].getOpeningsWidth(), + for(int i=0;i<numClients;i++) { + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gate[i].getOpeningsX(), gate[i].getOpeningsY(),gate[i].getOpeningsWidth(), gate[i].getOpeningsHeight()); - this.graphics2D.setColor(Color.BLACK); - this.graphics2D.drawLine(gate[i].getx1(),gate[i].gety1(),gate[i].getx2(),gate[i].gety2()); + graphics2D.setColor(Color.BLACK); + graphics2D.drawLine(gate[i].getx1(),gate[i].gety1(),gate[i].getx2(),gate[i].gety2()); } - this.graphics2D.setColor(Color.BLUE); - this.graphics2D.fillRect(gate[5].getX(), gate[5].getY(),10,gate[5].getHeight()); - + graphics2D.setColor(Color.BLUE); + graphics2D.fillRect(gate[5].getX(), gate[5].getY(),10,gate[5].getHeight()); + //////////////////////Animation Logic//////////////////////////// - if(enableBallAnimation == true) - { - graphics.setColor(Color.white); -// int ballCounter = 0; - for(int i=0;i<BALLCOUNT;i++){ - if((balls[i].getPosition() == 1)||(balls[i].getPosition() == 2) || (balls[i].getPosition()==3) - || (balls[i].getPosition() == 4) || (balls[i].getPosition() == 5)){ - if(!((!gate[balls[i].getPosition()-1].isOpenGate())&& balls[i].getY() >= (gate[balls[i].getPosition()-1].getY()+gate[balls[i].getPosition()-1].getHeight()))) - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); - } - else{ - if(balls[i].getPosition() != 0){ - if(gate[balls[i].getPosition() - 6].getHeight() != 0) + if(enableBallAnimation == true) + { + graphics.setColor(Color.white); + // int ballCounter = 0; + for(int i=0;i<BALLCOUNT;i++){ + if((balls[i].getPosition() == 1)||(balls[i].getPosition() == 2) || (balls[i].getPosition()==3) + || (balls[i].getPosition() == 4) || (balls[i].getPosition() == 5)){ + if(!((!gate[balls[i].getPosition()-1].isOpenGate())&& balls[i].getY() >= (gate[balls[i].getPosition()-1].getY()+gate[balls[i].getPosition()-1].getHeight()))) graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); } else{ - graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + if(balls[i].getPosition() != 0){ + if(gate[balls[i].getPosition() - 6].getHeight() != 0) + graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + } + else{ + graphics.fillOval(balls[i].x,balls[i].y,balls[i].getBallSize(), balls[i].getBallSize()); + } } } - } - } - + } + } - - - + + + private void updateGUI() { for(int i=1;i<6;i++){ if(gate[i-1].isOpenGate()){ @@ -179,19 +154,19 @@ } else{ gate[i].setHeight(gate[i-1].getHeight()); - + } //order matters here if(!(i == 5)){ gate[i].setOpeningsHeight((totalContributedBandwidth*bandWidthCanalHeightMapping) - gate[i].getHeight()); gate[i].setOpeningsY(gate[i].getOpeningsHeight() - 50); - + //opening the lid logic if(gate[i].isOpenGate()){ gate[i].setx1(gate[i].getx2()); if(!(gate[i].gety2()- gate[i].getGateWidth() < gate[i].getY())) - gate[i].sety1(gate[i].gety2()- gate[i].getGateWidth()); + gate[i].sety1(gate[i].gety2()- gate[i].getGateWidth()); else gate[i].sety1(gate[i].getOpeningsY()); } @@ -199,49 +174,47 @@ gate[i].setx1(gate[i].getdefaultx1()); gate[i].sety1(gate[i].getdefaulty1()); } - - if(gate[0].isOpenGate()){ - gate[0].setx1(gate[0].getx2()); - if(!(gate[0].gety2()- gate[0].getGateWidth() < gate[0].getY())) - gate[0].sety1(gate[0].gety2()- gate[0].getGateWidth()); - else - gate[0].sety1(gate[0].getY()); + + if(gate[0].isOpenGate()){ + gate[0].setx1(gate[0].getx2()); + if(!(gate[0].gety2()- gate[0].getGateWidth() < gate[0].getY())) + gate[0].sety1(gate[0].gety2()- gate[0].getGateWidth()); + else + gate[0].sety1(gate[0].getY()); + } + else{ + gate[0].setx1(gate[0].getdefaultx1()); + gate[0].sety1(gate[0].getdefaulty1()); + } + } - else{ - gate[0].setx1(gate[0].getdefaultx1()); - gate[0].sety1(gate[0].getdefaulty1()); - } - } - } } /* * initialize the Balls */ - private void initializexy() { - // TODO Auto-generated method stub + private void initializeBalls() { balls = new Ball[BALLCOUNT]; if(balls == null){ System.out.println("Ball is null"); } - + for(int i=0;i<BALLCOUNT;i++){ balls[i] = new Ball(generator); - + } } // this is the private class the Timer will look at every DELAY seconds private class Rebound implements ActionListener{ - Random generator = new Random(); public void actionPerformed(ActionEvent e) { for(int i=0;i<BALLCOUNT;i++){ - //updateGUI(); - balls[i].x += balls[i].moveX; - balls[i].y += balls[i].moveY; - process(i); - } + //updateGUI(); + balls[i].x += balls[i].moveX; + balls[i].y += balls[i].moveY; + process(i); + } repaint(); } } @@ -251,151 +224,151 @@ */ private void process(int i){ // TODO Auto-generated method stub - + switch(balls[i].getPosition()){ - + case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(totalContributedBandwidth*bandWidthCanalHeightMapping) && balls[i].y <= serverHeight)){ - balls[i].setPosition(1); - setBounds(i); - } - //still in server - else{ - setBounds(i); - if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ - balls[i].moveX = balls[i].moveX * -1; - } - if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) - balls[i].moveY = balls[i].moveY * -1; - } - break; - + balls[i].setPosition(1); + setBounds(i); + } + //still in server + else{ + setBounds(i); + if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ + balls[i].moveX = balls[i].moveX * -1; + } + if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) + balls[i].moveY = balls[i].moveY * -1; + } + break; + case 1: if(gate[0].isOpenGate() && (balls[i].x >= gate[0].getOpeningsX() && balls[i].x <= (gate[0].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(7); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - balls[i].setPosition(2); - } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - } - - break; - + && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ + balls[i].setPosition(7); + //directly pass in the information + setBounds(i); + } + else{ + setBounds(i); + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + balls[i].setPosition(2); + } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + } + + break; + case 2: if(gate[1].isOpenGate() && (balls[i].x >= gate[1].getOpeningsX() && balls[i].x <= (gate[1].getOpeningsX()+gateBuffer)) && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(8); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - balls[i].setPosition(3); - } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - - + balls[i].setPosition(8); + //directly pass in the information + setBounds(i); + } + else{ + setBounds(i); + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + balls[i].setPosition(3); + } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + } + break; + + case 3: if(gate[2].isOpenGate() && (balls[i].x >= gate[2].getOpeningsX() && balls[i].x <= (gate[2].getOpeningsX()+gateBuffer)) && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(9); - //directly pass in the information - setBounds(i); - /* balls[i].xBOUNDSUPPER = 420; + balls[i].setPosition(9); + //directly pass in the information + setBounds(i); + /* balls[i].xBOUNDSUPPER = 420; balls[i].xBOUNDSLOWER = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; balls[i].moveY = 3;*/ - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - balls[i].setPosition(4); - } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - + } + else{ + setBounds(i); + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + balls[i].setPosition(4); + } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + } + break; + case 4: if(gate[3].isOpenGate() && (balls[i].x >= gate[3].getOpeningsX() && balls[i].x <= (gate[3].getOpeningsX()+gateBuffer)) && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(10); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - balls[i].setPosition(5); - } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - + balls[i].setPosition(10); + //directly pass in the information + setBounds(i); + } + else{ + setBounds(i); + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + balls[i].setPosition(5); + } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + } + break; + case 5: if(gate[4].isOpenGate() && (balls[i].x >= gate[4].getOpeningsX() && balls[i].x <= (gate[4].getOpeningsX()+gateBuffer)) - && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ - balls[i].setPosition(11); - //directly pass in the information - setBounds(i); - } - else{ - setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - balls[i].setPosition(6); - } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - } - break; - + && (balls[i].y >= serverHeight - gateBuffer && balls[i].y <= serverHeight)){ + balls[i].setPosition(11); + //directly pass in the information + setBounds(i); + } + else{ + setBounds(i); + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + balls[i].setPosition(6); + } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + } + break; + case 6: setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ - setBallinServer(i); - } - - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ - balls[i].moveY = balls[i].moveY*-1; - } - break; + if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + setBallinServer(i); } - - //set balls back to the server when they complete their flow in the gates - if((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) || (balls[i].getPosition() == 8) - || (balls[i].getPosition() == 9) || (balls[i].getPosition() == 10)){ - if(balls[i].getY() >= 150){ - setBallinServer(i); - } - else{ - setBounds(i); - } - } - } + if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + balls[i].moveY = balls[i].moveY*-1; + } + break; + } + //set balls back to the server when they complete their flow in the gates + if((balls[i].getPosition() == 11) || (balls[i].getPosition() == 7) || (balls[i].getPosition() == 8) + || (balls[i].getPosition() == 9) || (balls[i].getPosition() == 10)){ + if(balls[i].getY() >= 150){ + setBallinServer(i); + } + else{ + setBounds(i); + } + } + } + + private void setBallinServer(int i) { // TODO Auto-generated method stub - generator.setSeed(i*(i+1)); - balls[i].setX(generator.nextInt(serverWidth)); - balls[i].setY(generator.nextInt(serverHeight)); - balls[i].setPosition(0); - if(balls[i].moveX == 0) - balls[i].moveX = generator.nextInt(15); - setBounds(i); + generator.setSeed(i*(i+1)); + balls[i].setX(generator.nextInt(serverWidth)); + balls[i].setY(generator.nextInt(serverHeight)); + balls[i].setPosition(0); + if(balls[i].moveX == 0) + balls[i].moveX = generator.nextInt(15); + setBounds(i); } private void setBounds(int ballIndex) { @@ -414,7 +387,7 @@ else{ if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ - + balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getX(); balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; @@ -435,38 +408,23 @@ } public void openGates(int priority) { - // TODO Auto-generated method stub - gate[priority].setGateOpen(true); +// paintComponent(graphics2D); + repaint(); - //set the height of all the canal panls depending on the state of the game - paintComponent(graphics2D); } public void closeGates(int priority) { - // TODO Auto-generated method stub gate[priority].setGateOpen(false); gate[priority].setx1(gate[priority].getdefaultx1()); gate[priority].sety1(gate[priority].getdefaulty1()); /*if(!(priority == 0)) gate[priority].setHeight(gate[priority-1].getHeight());*/ - paintComponent(graphics2D); + repaint(); } public void endRound() { - // TODO Auto-generated method stub - flagDownStream = false; - flagDownStream = false; - - x2UpStream = 420; - - y2UpStream = 100; - - y2DownStream = 100; - - x2DownStream = 950; - - initializexy(); + initializeBalls(); } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-20 04:41:30 UTC (rev 308) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-20 06:07:13 UTC (rev 309) @@ -19,27 +19,28 @@ /** * $Id$ * - * Displays the canal animation and so on. + * The game interface screen shown during the round. * + * FIXME: needs refactoring, should merge IrrigationGameWindow functionality into this panel as well. + * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ public class IrrigationGamePanel extends JPanel { - private static final long serialVersionUID = -3878952269498777014L; + private static final long serialVersionUID = -3878952269498777014L; - public IrrigationGameWindow controlPanel; - - public CanalPanel upperPanel; - - private JPanel jPanelMain = null; + public IrrigationGameWindow irrigationGameWindow; + + public CanalPanel canalPanel; + //this contains the CanalPanel - private JPanel jPanelUpperWindow = null; + private JPanel upperPanel = null; //this contains the upstream and downstream Panel private JPanel jPanelUpStreamWindow = null; private JPanel jPanelDownStreamWindow = null; private JPanel downloadScreenPanel = null; - + private ScoreBoxPanel scoreBoxPanel; public IrrigationClient client; @@ -58,7 +59,7 @@ private JLabel maximumAvailableFlowCapacityLabel = null; - private ClientDataModel clientGameState; // @jve:decl-index=0: + private ClientDataModel clientDataModel; // @jve:decl-index=0: private MiddleWindowPanel middleWindowPanel; @@ -84,31 +85,17 @@ timeRemainingLabel.setText("Time Left"); timeRemainingTextField = new JTextField(); timeRemainingTextField.setEditable(false); -// timeRemainingTextField.setBounds(new Rectangle(620, 39, 61); + // timeRemainingTextField.setBounds(new Rectangle(620, 39, 61); timeRemainingTextField.setText("50 sec"); timeRemainingTextField.setBackground(Color.white); timeRemainingTextField.setFont(new Font("serif", Font.BOLD, 14)); timeRemainingTextField.setForeground(new Color(102, 204, 255)); timeRemainingTextField.setHorizontalAlignment(SwingConstants.CENTER); - this.setLayout(new BorderLayout(4,4)); - this.setPreferredSize(new Dimension(1130, 558)); - this.add(getJPanelMain(),null); - + setLayout(new BorderLayout()); + add(getDownloadScreenPanel(), BorderLayout.CENTER); } - private JPanel getJPanelMain() { - if(jPanelMain == null){ - jPanelMain = new JPanel(); - jPanelMain.setLayout(new BorderLayout(4,4)); - jPanelMain.setBackground(Color.WHITE); - jPanelMain.setForeground(Color.BLACK); - jPanelMain.add(getDownloadScreenPanel(), BorderLayout.CENTER); - return jPanelMain; - } - return jPanelMain; - } - private JPanel getDownloadScreenPanel() { if(downloadScreenPanel == null){ scoreBoardLabel = new JLabel(); @@ -132,7 +119,7 @@ downloadScreenPanel.setLayout(null); downloadScreenPanel.setName("downloadScreenPanel"); downloadScreenPanel.setBackground(Color.white); - downloadScreenPanel.add(getJPanelUpperWindow(),null); + downloadScreenPanel.add(getUpperPanel(),null); downloadScreenPanel.add(getTimeRemainingProgressBar(), null); downloadScreenPanel.add(timeRemainingLabel, null); downloadScreenPanel.add(timeRemainingTextField,null); @@ -145,26 +132,17 @@ return downloadScreenPanel; } - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelUpperWindow() { - if (jPanelUpperWindow == null) { - jPanelUpperWindow = new JPanel(); - jPanelUpperWindow.setLayout(null); - jPanelUpperWindow.setBounds(new Rectangle(13, 64, 1098, 123)); + private JPanel getUpperPanel() { + if (upperPanel == null) { + upperPanel = new JPanel(); + upperPanel.setLayout(new BorderLayout()); } - return jPanelUpperWindow; + return upperPanel; } - private JPanel getUpperPanel(ClientDataModel clientGameState) { - // TODO Auto-generated method stub - upperPanel = new CanalPanel(clientGameState); - upperPanel.setSize(new Dimension(1098, 123)); - - return upperPanel; + private JPanel getCanalPanel() { + canalPanel = new CanalPanel(clientDataModel); + return canalPanel; } /** @@ -184,12 +162,10 @@ } private IrrigationGameWindow getControlPanel() { - // TODO Auto-generated method stub - if(controlPanel == null){ - controlPanel = new IrrigationGameWindow(screenSize,client,this); - return controlPanel; + if(irrigationGameWindow == null) { + irrigationGameWindow = new IrrigationGameWindow(screenSize,client,this); } - return controlPanel; + return irrigationGameWindow; } /** * This method initializes jPanel3 @@ -202,22 +178,21 @@ jPanelDownStreamWindow.setLayout(null); jPanelDownStreamWindow.setBackground(new Color(186, 226, 237)); jPanelDownStreamWindow.setBounds(new Rectangle(582, 225 + 100+50, 530, 326)); - jPanelDownStreamWindow.add(getScoreBoxPanel(),null); + jPanelDownStreamWindow.add(getScoreBoxPanel(),null); } return jPanelDownStreamWindow; } private ScoreBoxPanel getScoreBoxPanel() { - // TODO Auto-generated method stub if(scoreBoxPanel == null){ scoreBoxPanel = new ScoreBoxPanel(client); - + return scoreBoxPanel; } return scoreBoxPanel; } - - + + /** * This method initializes TimeRemainingjProgressBar * @@ -236,48 +211,46 @@ /** * Shoudl be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. */ - public void updateClientStatus(final ClientDataModel clientGameState) { - ////////////new code//////////////////////////////////////////////////////////// - Runnable createGuiRunnable = new Runnable(){ - public void run() { - for(final ClientData clientData : clientGameState.getClientDataMap().values()){ - timeRemainingTextField.setText( clientGameState.getTimeLeft() +" second(s)" ); - timeRemainingProgressBar.setValue( (clientGameState.getTimeLeft() / 1000) ); - maximumAvailableFlowCapacityLabel.setText( - clientData.getGroupDataModel().getMaximumAvailableFlowCapacity() +" cubic feet per second (cfps)" - ); - middleWindowPanel.update(clientData); - if (clientGameState.getPriority() == clientData.getPriority()) { - controlPanel.update(clientData); - //per parameter score panel - scoreBoxPanel.update(clientData); - } - else{ - scoreBoxPanel.update(clientData); - } - if(clientData.isGateOpen()){ - upperPanel.openGates(clientData.getPriority()); + public void updateClientStatus(final ClientDataModel clientDataModel) { + ////////////new code//////////////////////////////////////////////////////////// + Runnable createGuiRunnable = new Runnable(){ + public void run() { + for(final ClientData clientData : clientDataModel.getClientDataMap().values()){ + timeRemainingTextField.setText( clientDataModel.getTimeLeft() +" second(s)" ); + timeRemainingProgressBar.setValue( (clientDataModel.getTimeLeft() / 1000) ); + maximumAvailableFlowCapacityLabel.setText( + clientData.getGroupDataModel().getMaximumAvailableFlowCapacity() +" cubic feet per second (cfps)" + ); + middleWindowPanel.update(clientData); + if (clientDataModel.getPriority() == clientData.getPriority()) { + irrigationGameWindow.update(clientData); + //per parameter score panel + scoreBoxPanel.update(clientData); + } + else{ + scoreBoxPanel.update(clientData); + } + if(clientData.isGateOpen()){ + canalPanel.openGates(clientData.getPriority()); - } - else if(clientData.isPaused()){ - upperPanel.closeGates(clientData.getPriority()); - } - if(clientData.isGateClosed()){ - upperPanel.closeGates(clientData.getPriority()); - } - } - } + } + else if(clientData.isPaused()){ + canalPanel.closeGates(clientData.getPriority()); + } + if(clientData.isGateClosed()){ + canalPanel.closeGates(clientData.getPriority()); + } + } + } - }; + }; try { SwingUtilities.invokeAndWait(createGuiRunnable); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -293,87 +266,63 @@ public void endRound() { Runnable createGuiRunnable = new Runnable(){ public void run() { - //TODO Auto-generated method stub - //Refreshing the screen and preparing the main Irrigation Window for the next round - //provided we have already got the updatedClientDataMap - controlPanel.endRound(); - jPanelUpperWindow.removeAll(); - upperPanel.endRound(); + //Refreshing the screen and preparing the main Irrigation Window for the next round + //provided we have already got the updatedClientDataMap + irrigationGameWindow.endRound(); + upperPanel.removeAll(); + canalPanel.endRound(); } }; - - try { - SwingUtilities.invokeAndWait(createGuiRunnable); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + + try { + SwingUtilities.invokeAndWait(createGuiRunnable); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } /** * assigns the priority to the window and prepares the irrigationWindowMap */ - public void updateContributions(final ClientDataModel clientGameState) { - this.clientGameState = clientGameState; + public void updateContributions(final ClientDataModel clientDataModel) { + this.clientDataModel = clientDataModel; //Here a map is created with the map consisting of the - //irrigation window as the value and the priority value as the key. This is handled here , because - //the event contains the priority for every client, and the priority can act as a unique key for the - //game window. - - //checking the client priority and assigning the activity summary and client panel to the - //doownloadScreenPanel - fillPanels(clientGameState); - - //This is helpful, if we need to scale the game to more than two users. We can declare - //more panels like middleStream Window, etc and add them in this switch case statement + //irrigation window as the value and the priority value as the key. This is handled here , because + //the event contains the priority for every client, and the priority can act as a unique key for the + //game window. + fillPanels(); - //case 2 : irrigationWindowMap.put(new Integer(clientData.getPriority()), middleStreamWindow); - } - - - + } + + + /** * fills in the panels depending on the priority of the client */ - public void fillPanels(ClientDataModel clientDataModel) { - // TODO Auto-generated method stub - jPanelUpperWindow.add(getUpperPanel(clientDataModel)); - //switch(clientGameState.getPriority()){ - + private void fillPanels() { + upperPanel.add(getCanalPanel(), BorderLayout.CENTER); downloadScreenPanel.add(getJPanelUpStreamWindow(),null); - downloadScreenPanel.add(getJPanelDownStreamWindow(),null); + downloadScreenPanel.add(getJPanelDownStreamWindow(),null); //adding the in between Panel - downloadScreenPanel.add(getJPanelMiddleWindow(),null); - /*case 0 : downloadScreenPanel.add(getJPanelUpStreamWindow(0),null); - downloadScreenPanel.add(getJPanelDownStreamWindow(0),null); - //Assigning the Priorities on the Priority Label - break; + downloadScreenPanel.add(getJPanelMiddleWindow(),null); + } - case 1 : downloadScreenPanel.add(getJPanelUpStreamWindow(1),null); - downloadScreenPanel.add(getJPanelDownStreamWindow(1),null); - //Assigning the Priorities on the Priority Label - break; -*/ } - private JPanel getJPanelMiddleWindow() { - // TODO Auto-generated method stub if(middleWindowPanel == null){ - if(clientGameState != null){ + if(clientDataModel != null){ System.out.println("Main Irrigation Window clientGameState is not null"); } - middleWindowPanel = new MiddleWindowPanel(clientGameState); + middleWindowPanel = new MiddleWindowPanel(clientDataModel); } return middleWindowPanel; } - + public ClientDataModel getClientGameState() { - // TODO Auto-generated method stub - return clientGameState; + return clientDataModel; } } - // @jve:decl-index=0:visual-constraint="10,-43" +// @jve:decl-index=0:visual-constraint="10,-43" Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-20 04:41:30 UTC (rev 308) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-10-20 06:07:13 UTC (rev 309) @@ -21,8 +21,8 @@ /** * $Id$ * - * Primary JPanel used to display the active interface for the experiment. - * Organizes and contains all other components. + * Contains the primary open gate button, etc. + * * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ @@ -72,7 +72,7 @@ private JLabel profitEarned = null; - public JTextField profitEarnedtxt = null; + public JTextField moneyEarnedTextField = null; private JLabel fileDownloadedtxt = null; @@ -125,7 +125,7 @@ * here the end code and debreifing logic should be written */ refreshButtons(); - profitEarnedtxt.setText("0"); + moneyEarnedTextField.setText("0"); } /** @@ -169,7 +169,7 @@ } public void updateProfitEarned(final int award) { - profitEarnedtxt.setText(new Integer(award).toString()); + moneyEarnedTextField.setText(new Integer(award).toString()); } @@ -541,16 +541,16 @@ * @return javax.swing.JTextField */ private JTextField getProfitEarnedTextField() { - if (profitEarnedtxt == null) { - profitEarnedtxt = new JTextField(); - profitEarnedtxt.setText(new Integer(mainIrrigationWindow + if (moneyEarnedTextField == null) { + moneyEarnedTextField = new JTextField(); + moneyEarnedTextField.setText(new Integer(mainIrrigationWindow .getClientGameState().getClientData().getTotalTokensEarned()) .toString()); - profitEarnedtxt.setBounds(new Rectangle(161, 17, 86, 21)); - profitEarnedtxt.setFont(new Font("Dialog", Font.PLAIN, 14)); - profitEarnedtxt.setEditable(false); + moneyEarnedTextField.setBounds(new Rectangle(161, 17, 86, 21)); + moneyEarnedTextField.setFont(new Font("Dialog", Font.PLAIN, 14)); + moneyEarnedTextField.setEditable(false); } - return profitEarnedtxt; + return moneyEarnedTextField; } /** @@ -639,7 +639,7 @@ // checks whether the file has been downlaoded if (clientData.isFileDownloaded()) { - profitEarnedtxt.setText(new Integer(clientData.getTotalTokensEarned()) + moneyEarnedTextField.setText(new Integer(clientData.getTotalTokensEarned()) .toString()); // StopDownload.setEnabled(false); pauseDownload.setEnabled(false); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-20 04:41:30 UTC (rev 308) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-10-20 06:07:13 UTC (rev 309) @@ -131,7 +131,6 @@ private JLabel getFilesDownLoadedText(int priority) { - // TODO Auto-generated method stub if(filesDownloadedText == null){ filesDownloadedText = new JLabel(); filesDownloadedText.setBounds(new Rectangle(5,50+32+10+20+10+20+10,30,20)); @@ -141,8 +140,6 @@ } public void update(ClientData clientData) { - // TODO Auto-generated method stub - this.clientData = clientData; if(clientData.getAvailableFlowCapacity() > 25){ @@ -154,9 +151,8 @@ filesDownloadedText.setText(new Integer(clientData.getCropsGrown()).toString()); tokensText.setText(new Integer(clientData.getTotalTokensEarned()).toString()); - if(clientData.isGateOpen() == true && clientData.getAvailableFlowCapacity() > 0) - fileLabel.setVisible(true); - else - fileLabel.setVisible(false); + if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { + // show that client is actively irrigating + } } } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java 2009-10-20 04:41:30 UTC (rev 308) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/RegistrationEvent.java 2009-10-20 06:07:13 UTC (rev 309) @@ -30,11 +30,11 @@ public RegistrationEvent(Identifier id, RoundConfiguration roundConfiguration, ClientData clientData) { super(id, roundConfiguration.getInstructions()); this.clientData = clientData; + this.roundConfiguration = roundConfiguration; } public RegistrationEvent(ClientData clientData, RoundConfiguration roundConfiguration) { this(clientData.getId(), roundConfiguration, clientData); - this.roundConfiguration = roundConfiguration; } public RoundConfiguration getRoundConfiguration() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-10-20 04:41:39
|
Revision: 308 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=308&view=rev Author: alllee Date: 2009-10-20 04:41:30 +0000 (Tue, 20 Oct 2009) Log Message: ----------- infrastructure efficiency graph and pie chart are now properly displayed. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java Added Paths: ----------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/PieChart.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-20 04:07:18 UTC (rev 307) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-20 04:41:30 UTC (rev 308) @@ -18,6 +18,7 @@ import java.util.Map; import java.util.Properties; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -67,7 +68,7 @@ private JButton submitTokensButton; - private InfrastructureEfficiencyChartPanel xySeriesDemo = null; + private InfrastructureEfficiencyChartPanel infrastructureEfficiencyChartPanel = null; private IrrigationClient client; @@ -101,7 +102,7 @@ private JPanel pieChartPanel; - private PieChart pieChart; + private TokenInvestmentPieChartPanel pieChart; private CanalAnimationPanel canalAnimationPanel; @@ -356,8 +357,6 @@ } } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////// - private HtmlEditorPane getInstructionsEditorPane() { if (instructionsEditorPane == null) { instructionsEditorPane = createInstructionsEditorPane(); @@ -595,15 +594,14 @@ - Runnable runnable = new Runnable() { + SwingUtilities.invokeLater(new Runnable() { public void run() { contributionInformationTextArea.setText(contributionInformation); + infrastructureEfficiencyChartPanel.initialize(); pieChart.setClientData(clientData); addCenterComponent(getGraphPanel()); } - }; - - SwingUtilities.invokeLater(runnable); + }); irrigationGamePanel.updateContributions(clientDataModel); } @@ -611,13 +609,11 @@ if (graphPanel == null) { graphPanel = new JPanel(); graphPanel.setName("Graph panel"); - GridLayout gridLayout = new GridLayout(); - gridLayout.setColumns(2); - graphPanel.setLayout(gridLayout); - graphPanel.add(getPieChartPanel(), null); + graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.X_AXIS)); + graphPanel.add(getPieChartPanel()); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); - graphPanel.add(contributionInformationTextArea,null); + graphPanel.add(contributionInformationTextArea); } return graphPanel; } @@ -625,14 +621,13 @@ private JPanel getPieChartPanel() { if (pieChartPanel == null) { pieChartPanel = new JPanel(); - xySeriesDemo = new InfrastructureEfficiencyChartPanel(client); - xySeriesDemo.setVisible(true); - pieChart = new PieChart(); + infrastructureEfficiencyChartPanel = new InfrastructureEfficiencyChartPanel(client); + pieChart = new TokenInvestmentPieChartPanel(); GridLayout gridLayout = new GridLayout(); gridLayout.setRows(2); gridLayout.setColumns(1); pieChartPanel.setLayout(gridLayout); - pieChartPanel.add(xySeriesDemo); + pieChartPanel.add(infrastructureEfficiencyChartPanel); pieChartPanel.add(pieChart); } return pieChartPanel; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-10-20 04:07:18 UTC (rev 307) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-10-20 04:41:30 UTC (rev 308) @@ -27,10 +27,9 @@ private static final long serialVersionUID = 5555080117985336199L; private IrrigationClient client; - /** - * - * @param title the frame title. - */ + + private ChartPanel chartPanel; + public InfrastructureEfficiencyChartPanel(IrrigationClient client) { this.client = client; setPreferredSize(new Dimension(530/2, 326/2)); @@ -40,7 +39,11 @@ } public void initialize() { - add(createChartPanel(), BorderLayout.CENTER); + if (chartPanel != null) { + remove(chartPanel); + } + chartPanel = createChartPanel(); + add(chartPanel, BorderLayout.CENTER); } private ChartPanel createChartPanel() { Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/PieChart.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/PieChart.java 2009-10-20 04:07:18 UTC (rev 307) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/PieChart.java 2009-10-20 04:41:30 UTC (rev 308) @@ -1,105 +0,0 @@ -package edu.asu.commons.irrigation.client; - -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Rectangle; -import java.util.Map; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PiePlot; -import org.jfree.data.general.DefaultPieDataset; -import org.jfree.data.general.PieDataset; - -import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.irrigation.server.GroupDataModel; -import edu.asu.commons.net.Identifier; - -/** - * Presents the group contributions as a pie chart. - */ -public class PieChart extends JPanel { - - private static final long serialVersionUID = -5382293105043214105L; - - private ChartPanel chartPanel; - - public void setClientData(final ClientData clientData) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - final PieDataset dataset = createDataset(clientData); - final JFreeChart chart = createChart(dataset); - remove(chartPanel); - chartPanel = new ChartPanel(chart); - chartPanel.setPreferredSize(new Dimension(500, 270)); - add(chartPanel); - setBounds(new Rectangle(0,0,500,270)); - } - }); - } - - /** - * Creates a pie dataset out of the client - * @return a sample dataset. - */ - private PieDataset createDataset(ClientData clientData) { - final DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); - GroupDataModel groupDataModel = clientData.getGroupDataModel(); - Map<Identifier,ClientData>clientDataMap = groupDataModel.getClientDataMap(); - for (ClientData currentClientData : clientDataMap.values()) { - StringBuilder labelBuilder = new StringBuilder(); - if (currentClientData.getId().equals(clientData.getId())) { - labelBuilder.append("You"); - } - else { - labelBuilder.append(currentClientData.getPriorityAsString()); - } - labelBuilder.append(" invested ").append(currentClientData.getInvestedTokens()).append(" token(s)"); - defaultPieDataset.setValue(labelBuilder.toString(), currentClientData.getInvestedTokens()); - } - return defaultPieDataset; - } - - // **************************************************************************** - // * JFREECHART DEVELOPER GUIDE * - // * The JFreeChart Developer Guide, written by David Gilbert, is available * - // * to purchase from Object Refinery Limited: * - // * * - // * http://www.object-refinery.com/jfreechart/guide.html * - // * * - // * Sales are used to provide funding for the JFreeChart project - please * - // * support us so that we can continue developing free software. * - // **************************************************************************** - - /** - * Creates a chart. - * - * @param dataset the dataset. - * - * @return a chart. - */ - private JFreeChart createChart(final PieDataset dataset) { - - final JFreeChart chart = ChartFactory.createPieChart( - "Tokens Contributed", // chart title - dataset, // data - false, // include legend - true, - false - ); - - final PiePlot plot = (PiePlot) chart.getPlot(); - //plot.setLabelGenerator(new CustomLabelGenerator()); - plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); - plot.setNoDataMessage("No data available"); - plot.setCircular(false); - plot.setLabelGap(0.02); - return chart; - - } - -} Copied: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java (from rev 306, irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/PieChart.java) =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java 2009-10-20 04:41:30 UTC (rev 308) @@ -0,0 +1,104 @@ +package edu.asu.commons.irrigation.client; + +import java.awt.BorderLayout; +import java.awt.Font; +import java.util.Map; + +import javax.swing.JPanel; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PiePlot; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; + +import edu.asu.commons.irrigation.server.ClientData; +import edu.asu.commons.irrigation.server.GroupDataModel; +import edu.asu.commons.net.Identifier; + +/** + * Presents the group contributions as a pie chart. + */ +public class TokenInvestmentPieChartPanel extends JPanel { + + private static final long serialVersionUID = -5382293105043214105L; + + private ChartPanel chartPanel; + + public TokenInvestmentPieChartPanel() { + setLayout(new BorderLayout()); + } + + public void setClientData(final ClientData clientData) { + final PieDataset dataset = createPieDataset(clientData); + final JFreeChart chart = createChart(dataset); + if (chartPanel != null) { + remove(chartPanel); + } + chartPanel = new ChartPanel(chart); + add(chartPanel, BorderLayout.CENTER); + revalidate(); + } + + /** + * Creates a pie dataset out of the client + * @return a sample dataset. + */ + private PieDataset createPieDataset(ClientData clientData) { + final DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); + GroupDataModel groupDataModel = clientData.getGroupDataModel(); + Map<Identifier,ClientData>clientDataMap = groupDataModel.getClientDataMap(); + for (ClientData currentClientData : clientDataMap.values()) { + StringBuilder labelBuilder = new StringBuilder(); + if (currentClientData.getId().equals(clientData.getId())) { + labelBuilder.append("You"); + } + else { + labelBuilder.append(currentClientData.getPriorityAsString()); + } + labelBuilder.append(" invested ").append(currentClientData.getInvestedTokens()).append(" token(s)"); + defaultPieDataset.setValue(labelBuilder.toString(), currentClientData.getInvestedTokens()); + } + return defaultPieDataset; + } + + // **************************************************************************** + // * JFREECHART DEVELOPER GUIDE * + // * The JFreeChart Developer Guide, written by David Gilbert, is available * + // * to purchase from Object Refinery Limited: * + // * * + // * http://www.object-refinery.com/jfreechart/guide.html * + // * * + // * Sales are used to provide funding for the JFreeChart project - please * + // * support us so that we can continue developing free software. * + // **************************************************************************** + + /** + * Creates a chart. + * + * @param dataset the dataset. + * + * @return a chart. + */ + private JFreeChart createChart(final PieDataset dataset) { + + final JFreeChart chart = ChartFactory.createPieChart( + "Tokens Contributed", // chart title + dataset, // data + false, // include legend + true, + false + ); + + final PiePlot plot = (PiePlot) chart.getPlot(); + //plot.setLabelGenerator(new CustomLabelGenerator()); + plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); + plot.setNoDataMessage("No data available"); + plot.setCircular(false); + plot.setLabelGap(0.02); + return chart; + + } + +} Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-20 04:07:18 UTC (rev 307) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-10-20 04:41:30 UTC (rev 308) @@ -139,7 +139,7 @@ } public int getChatDuration() { - return getIntProperty("communication-duration", 40); + return getIntProperty("chat-duration", 40); } /** Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-20 04:07:18 UTC (rev 307) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-10-20 04:41:30 UTC (rev 308) @@ -8,7 +8,6 @@ import java.util.TreeSet; import javax.swing.BoxLayout; -import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JScrollPane; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |