virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 59)
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-11-17 00:42:42
|
Revision: 365 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=365&view=rev Author: alllee Date: 2009-11-17 00:42:32 +0000 (Tue, 17 Nov 2009) Log Message: ----------- refactoring / interface cleanup Modified Paths: -------------- irrigation/trunk/pom.xml 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/client/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java Modified: irrigation/trunk/pom.xml =================================================================== --- irrigation/trunk/pom.xml 2009-11-16 20:39:30 UTC (rev 364) +++ irrigation/trunk/pom.xml 2009-11-17 00:42:32 UTC (rev 365) @@ -108,7 +108,7 @@ <tasks> <!-- can be invoked via - mdeployvn -P ant -D target= + mvn -P ant -D target= --> <property name="compile.classpath" refid="maven.compile.classpath"/> <property name="runtime.classpath" refid="maven.runtime.classpath"/> @@ -130,6 +130,5 @@ </dependency> </dependencies> </profile> - </profiles> </project> 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-11-16 20:39:30 UTC (rev 364) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-17 00:42:32 UTC (rev 365) @@ -20,12 +20,13 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.Timer; +import javax.swing.text.html.HTMLEditorKit; import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.irrigation.conf.ServerConfiguration; @@ -52,29 +53,22 @@ private ChatPanel chatPanel; - private JScrollPane instructionsScrollPane; - private HtmlEditorPane instructionsEditorPane; private JPanel tokenInvestmentPanel; - private JPanel contributionInformationPanel; private JTextField investedTokensTextField; - private JButton submitTokensButton; - private InfrastructureEfficiencyChartPanel infrastructureEfficiencyChartPanel; private IrrigationClient client; -// private MainIrrigationGameWindow mainIrrigationGameWindow; - private MainIrrigationGameWindow irrigationGamePanel; private StringBuilder instructionsBuilder = new StringBuilder(); - private JTextArea contributionInformationTextArea; + private JEditorPane contributionInformationEditorPane; private JButton nextButton; @@ -90,27 +84,19 @@ private HtmlEditorPane tokenInstructionsEditorPane; - private JScrollPane tokenInstructionsScrollPane; - private int quizzesAnswered = 0; - private JPanel pieChartPanel; - private TokenInvestmentPieChartPanel pieChart; // private CanalAnimationPanel canalAnimationPanel; private CardLayout cardLayout; - private int numberOfQuestionPages; - private Map<Integer, String> quizPageResponses = new HashMap<Integer, String>(); - public ExperimentGameWindow(IrrigationClient client) { this.client = client; this.clientDataModel = client.getClientDataModel(); - this.numberOfQuestionPages = getServerConfiguration().getNumberOfQuestionPages(); } void initialize() { @@ -137,9 +123,8 @@ tokenInvestmentPanel.setLayout(new BorderLayout()); tokenInstructionsEditorPane = createInstructionsEditorPane(); tokenInstructionsEditorPane.setCaretPosition(0); - tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); + JScrollPane tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); tokenInvestmentPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); - tokenInvestmentPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); tokenInvestmentPanel.setBackground(Color.WHITE); } @@ -151,28 +136,29 @@ submitTokenPanel = new JPanel(); submitTokenPanel.setLayout(new BorderLayout()); submitTokenPanel.add(getInvestedTokensTextField(), BorderLayout.CENTER); - submitTokenPanel.add(getSubmitTokensButton(), BorderLayout.EAST); + JButton submitTokensButton = new JButton("Invest"); + submitTokensButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + submitInvestedTokens(); + } + }); + submitTokenPanel.add(submitTokensButton, BorderLayout.SOUTH); return submitTokenPanel; } 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("Instructions panel"); instructionsPanel.setLayout(new BorderLayout()); - instructionsPanel.add(getInstructionsScrollPane(), BorderLayout.CENTER); - instructionsPanel.add(getQuizNavigationPanel(), BorderLayout.PAGE_END); + JScrollPane instructionsScrollPane = new JScrollPane(getInstructionsEditorPane()); + instructionsScrollPane = new JScrollPane(getInstructionsEditorPane()); + instructionsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + instructionsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + instructionsPanel.add(instructionsScrollPane, BorderLayout.CENTER); +// instructionsPanel.add(getQuizNavigationPanel(), BorderLayout.PAGE_END); } return instructionsPanel; } @@ -218,7 +204,7 @@ if (currentQuizPageNumber >= quizzesAnswered){ nextButton.setEnabled(false); } - if (currentQuizPageNumber < numberOfQuestionPages) { + if (currentQuizPageNumber < getServerConfiguration().getNumberOfQuestionPages()) { currentQuizPageNumber++; setInstructions(getQuizPage()); } @@ -248,10 +234,8 @@ } else { quizPage = quizPage.replace("<input type=\"submit\" name=\"submit\" value=\"Submit\">", ""); - builder.append(quizPage).append(quizPageResponse); } - return builder.toString(); } @@ -273,19 +257,6 @@ return investedTokensTextField; } - private JButton getSubmitTokensButton() { - if (submitTokensButton == null) { - submitTokensButton = new JButton(); - submitTokensButton.setText("Invest"); - submitTokensButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - submitInvestedTokens(); - } - }); - } - return submitTokensButton; - } - private void submitInvestedTokens() { try { int token = Integer.parseInt(investedTokensTextField.getText()); @@ -413,17 +384,24 @@ instructionsBuilder.append(getServerConfiguration().getFinalInstructions()); } instructionsBuilder.append("<hr/>"); - setInstructions(instructionsBuilder.toString()); + displayInstructions(instructionsBuilder.toString()); } // adding the instructions into the instruction Panel private void setInstructions(final String instructions) { + setInstructions(instructions, false); + } + + private void setInstructions(String instructions, boolean caretToEnd) { + instructionsEditorPane.setText(instructions); + instructionsEditorPane.setCaretPosition(caretToEnd ? instructions.length() : 0); + } + + private void displayInstructions(final String instructions) { SwingUtilities.invokeLater(new Runnable() { public void run() { - instructionsEditorPane.setText(instructions); - instructionsEditorPane.setCaretPosition(0); + setInstructions(instructions); addCenterComponent(getInstructionsPanel()); - getInstructionsScrollPane().revalidate(); } }); } @@ -434,6 +412,7 @@ public synchronized void actionPerformed(ActionEvent e) { if (quizPageResponses.containsKey(currentQuizPageNumber)) { // this form has already been submit. + // shouldn't happen // FIXME: report to user? return; } @@ -453,6 +432,11 @@ if (questionNumber.charAt(0) == 'q') { String number = questionNumber.substring(1, questionNumber.length()); String response = (String) entry.getValue(); + if (response == null || response.trim().isEmpty()) { + // if any responses are empty, abort. + + return; + } String correctAnswer = quizAnswers.get(questionNumber); builder.append(String.format("<p><b>Question %s</b><br/>", number)); String color = "blue"; @@ -475,12 +459,12 @@ quizPageResponses.put(currentQuizPageNumber, builder.toString()); // no matter what we move on to the next question page // tell them what was right and what was wrong. - if (currentQuizPageNumber <= numberOfQuestionPages) { + if (currentQuizPageNumber <= getServerConfiguration().getNumberOfQuestionPages()) { nextButton.setEnabled(true); } quizzesAnswered++; client.transmit(new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers)); - setInstructions(getQuizPage()); + setInstructions(getQuizPage(), true); } }; @@ -490,27 +474,27 @@ GroupDataModel groupDataModel = clientData.getGroupDataModel(); int totalContributedTokens = groupDataModel.getTotalContributedTokens(); final StringBuilder builder = new StringBuilder(); - builder.append("Infrastructure efficiency before investment: ") + builder.append("<ul><li>Infrastructure efficiency before investment: ") .append(groupDataModel.getInfrastructureEfficiencyBeforeInvestment()) - .append("%\n"); - builder.append("Irrigation capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second\n\n"); + .append("%</li>"); + builder.append("<li>Irrigation capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second</li>"); builder.append( String.format( - "Your group invested a total of %d tokens, increasing the infrastructure efficiency to %d%%.\n", + "<li>Total group investment: %d tokens, increasing the infrastructure efficiency to %d%%</li>", totalContributedTokens, groupDataModel.getInfrastructureEfficiency())); if (groupDataModel.getIrrigationCapacity() > groupDataModel.getIrrigationCapacityBeforeInvestment()) { - builder.append("Your group's investment has increased the irrigation capacity to "); + builder.append("<li><b>Your group's investment has increased the irrigation capacity to "); } else { - builder.append("Your group's investment was not enough to increase the irrigation capacity. Your group's irrigation capacity is still "); + builder.append("<li>Your group's investment was not enough to increase the irrigation capacity. Your group's irrigation capacity is still "); } - builder.append(groupDataModel.getIrrigationCapacity()).append(" cubic feet of water per second. The amount of water available to pass through your irrigation canal is ") - .append(groupDataModel.getActualFlowCapacity()); + builder.append(groupDataModel.getIrrigationCapacity()).append(" cubic feet of water per second.</li><li>The amount of water available to pass through your irrigation canal is ") + .append(groupDataModel.getActualFlowCapacity()).append(" cubic feet per second</li>"); SwingUtilities.invokeLater(new Runnable() { public void run() { - contributionInformationTextArea.setText(builder.toString()); + contributionInformationEditorPane.setText(builder.toString()); infrastructureEfficiencyChartPanel.initialize(); - pieChart.setClientData(clientData); + pieChart.initialize(clientData); addCenterComponent(getContributionInformationPanel()); } }); @@ -522,28 +506,29 @@ contributionInformationPanel = new JPanel(); contributionInformationPanel.setName("Graph panel"); contributionInformationPanel.setLayout(new BoxLayout(contributionInformationPanel, BoxLayout.Y_AXIS)); - contributionInformationPanel.add(getPieChartPanel()); + contributionInformationPanel.add(createPieChartPanel()); contributionInformationPanel.add(Box.createVerticalStrut(15)); - contributionInformationTextArea = new JTextArea(); - contributionInformationTextArea.setEditable(false); - contributionInformationPanel.add(contributionInformationTextArea); + contributionInformationEditorPane = new JEditorPane(); + contributionInformationEditorPane.setContentType("text/html"); + contributionInformationEditorPane.setEditorKit(new HTMLEditorKit()); + contributionInformationEditorPane.setEditable(false); + contributionInformationEditorPane.setBackground(Color.WHITE); + contributionInformationPanel.add(contributionInformationEditorPane); } return contributionInformationPanel; } - private JPanel getPieChartPanel() { - if (pieChartPanel == null) { - pieChartPanel = new JPanel(); - infrastructureEfficiencyChartPanel = new InfrastructureEfficiencyChartPanel(client); - pieChart = new TokenInvestmentPieChartPanel(); - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(1); - gridLayout.setColumns(2); - pieChartPanel.setLayout(gridLayout); - pieChartPanel.add(infrastructureEfficiencyChartPanel); - pieChartPanel.add(pieChart); - } - return pieChartPanel; + private JPanel createPieChartPanel() { + JPanel panel = new JPanel(); + infrastructureEfficiencyChartPanel = new InfrastructureEfficiencyChartPanel(client); + pieChart = new TokenInvestmentPieChartPanel(); + GridLayout gridLayout = new GridLayout(); + gridLayout.setRows(1); + gridLayout.setColumns(2); + panel.setLayout(gridLayout); + panel.add(infrastructureEfficiencyChartPanel); + panel.add(pieChart); + return panel; } @@ -597,7 +582,7 @@ roundConfiguration.getWaterSupplyCapacity() )); } - setInstructions(instructionsBuilder.toString()); + displayInstructions(instructionsBuilder.toString()); } } @@ -646,11 +631,11 @@ public void showQuiz() { SwingUtilities.invokeLater(new Runnable() { public void run() { + setInstructions(getQuizPage()); getInstructionsPanel().add(getQuizNavigationPanel(), BorderLayout.PAGE_END); getInstructionsPanel().revalidate(); } }); - setInstructions(getQuizPage()); } /** @@ -667,13 +652,13 @@ } public void showGameScreenshot() { - setInstructions(getServerConfiguration().getGameScreenshotInstructions()); + displayInstructions(getServerConfiguration().getGameScreenshotInstructions()); } /** * Invoked when the show instructions button is pressed. */ public void showInstructions() { - setInstructions(getServerConfiguration().getInitialInstructions()); + displayInstructions(getServerConfiguration().getInitialInstructions()); } } 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-11-16 20:39:30 UTC (rev 364) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-17 00:42:32 UTC (rev 365) @@ -12,6 +12,7 @@ import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; +import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.irrigation.server.GroupDataModel; /** @@ -51,30 +52,34 @@ final XYSeries potentialFlowCapacitySeries = new XYSeries("Potential"); // final XYSeries actualFlowCapacitySeriesY = new XYSeries("Actual"); final XYSeries initialInfrastructureEfficiencySeries = new XYSeries("Initial"); - int x,y; + final XYSeries waterSupplySeries = new XYSeries("Available water supply"); GroupDataModel group = client.getClientDataModel().getGroupDataModel(); - final int infrastructureEfficiency = group.getInfrastructureEfficiency(); + final int actualInfrastructureEfficiency = group.getInfrastructureEfficiency(); final int actualFlowCapacity = group.getIrrigationCapacity(); - for (y = 0; y <= actualFlowCapacity; y++) { - actualFlowCapacitySeries.add(infrastructureEfficiency, y); + for (int y = 0; y <= actualFlowCapacity; y++) { + actualFlowCapacitySeries.add(actualInfrastructureEfficiency, y); } - for(x =0; x<=client.getRoundConfiguration().getMaximumInfrastructureEfficiency();x++){ - y = group.calculateFlowCapacity(x); - potentialFlowCapacitySeries.add(x,y); + RoundConfiguration roundConfiguration = client.getRoundConfiguration(); + int maximumInfrastructureEfficiency = roundConfiguration.getMaximumInfrastructureEfficiency(); + int waterSupplyCapacity = roundConfiguration.getWaterSupplyCapacity(); + for(int x = 0; x <= maximumInfrastructureEfficiency; x++){ + int flowCapacity = group.calculateFlowCapacity(x); + potentialFlowCapacitySeries.add(x,flowCapacity); + waterSupplySeries.add(x, waterSupplyCapacity); } final int infrastructureEfficiencyBeforeInvestment = group.getInfrastructureEfficiencyBeforeInvestment(); final int irrigationCapacityBeforeInvestment = group.getIrrigationCapacityBeforeInvestment(); - for (y = 0; y <= irrigationCapacityBeforeInvestment; y++) { + for (int y = 0; y <= irrigationCapacityBeforeInvestment; y++) { initialInfrastructureEfficiencySeries.add(infrastructureEfficiencyBeforeInvestment, y); } + final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(initialInfrastructureEfficiencySeries); data.addSeries(actualFlowCapacitySeries); data.addSeries(potentialFlowCapacitySeries); + data.addSeries(waterSupplySeries); - // data.addSeries(actualFlowCapacitySeriesY); - final JFreeChart chart = ChartFactory.createXYLineChart( "Water Delivery Capacity vs. Infrastructure Efficiency", "Infrastructure Efficiency", 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-11-16 20:39:30 UTC (rev 364) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-17 00:42:32 UTC (rev 365) @@ -373,7 +373,6 @@ tokensEarnedSeries.add(waterApplied, tokensEarned); } - XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(tokensEarnedSeries); data.addSeries(currentWaterAppliedSeries); @@ -387,6 +386,7 @@ true, false ); + chart.setAntiAlias(true); return new ChartPanel(chart); } 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-11-16 20:39:30 UTC (rev 364) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/TokenInvestmentPieChartPanel.java 2009-11-17 00:42:32 UTC (rev 365) @@ -18,7 +18,12 @@ import edu.asu.commons.net.Identifier; /** + * $Id$ + * * Presents the group contributions as a pie chart. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ */ public class TokenInvestmentPieChartPanel extends JPanel { @@ -30,7 +35,7 @@ setLayout(new BorderLayout()); } - public void setClientData(final ClientData clientData) { + public void initialize(final ClientData clientData) { final PieDataset dataset = createPieDataset(clientData); final JFreeChart chart = createChart(dataset); if (chartPanel != null) { @@ -45,42 +50,22 @@ * Creates a pie dataset out of the client * @return a sample dataset. */ - private PieDataset createPieDataset(ClientData clientData) { + private PieDataset createPieDataset(ClientData thisClientData) { final DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); - GroupDataModel groupDataModel = clientData.getGroupDataModel(); + GroupDataModel groupDataModel = thisClientData.getGroupDataModel(); Map<Identifier,ClientData>clientDataMap = groupDataModel.getClientDataMap(); - for (ClientData currentClientData : clientDataMap.values()) { + for (ClientData clientData : clientDataMap.values()) { StringBuilder labelBuilder = new StringBuilder(); - if (currentClientData.getId().equals(clientData.getId())) { - labelBuilder.append("You"); + labelBuilder.append(clientData.getPriorityString()); + if (clientData.getId().equals(thisClientData.getId())) { + labelBuilder.append(" (You)"); } - else { - labelBuilder.append(currentClientData.getPriorityString()); - } - labelBuilder.append(" invested ").append(currentClientData.getInvestedTokens()).append(" token(s)"); - defaultPieDataset.setValue(labelBuilder.toString(), currentClientData.getInvestedTokens()); + labelBuilder.append(" invested ").append(clientData.getInvestedTokens()).append(" token(s)"); + defaultPieDataset.setValue(labelBuilder.toString(), clientData.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( @@ -94,11 +79,10 @@ final PiePlot plot = (PiePlot) chart.getPlot(); //plot.setLabelGenerator(new CustomLabelGenerator()); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); - plot.setNoDataMessage("No data available"); + plot.setNoDataMessage("No contributions were made."); plot.setCircular(false); plot.setLabelGap(0.02); return chart; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-16 21:02:59
|
Leaving today at 14:00 (2.75hr) I have modified the code to accept game objects, instead of just blocks. This should fix the problem of getting the round from the server (in strategyDesign) I will test this next time I work On Mon, Nov 16, 2009 at 11:57 AM, Kalin Jonas <kj...@as...> wrote: > Today I came in at 11:15 to begin working. > I have been reading the document that seema sent me, and updating my code. > I'll be working on trying to test seema's new methods. > |
From: <see...@us...> - 2009-11-16 20:39:40
|
Revision: 364 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=364&view=rev Author: seematalele Date: 2009-11-16 20:39:30 +0000 (Mon, 16 Nov 2009) Log Message: ----------- Changed the code to send game which is a new state of the game rather than block, so that it will be easy for client to extract current block and current round. Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-13 21:02:56 UTC (rev 363) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-16 20:39:30 UTC (rev 364) @@ -16,6 +16,7 @@ import edu.asu.commons.mme.dao.HibernateGroupLocationDao; import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.dao.HibernateStudentDao; +import edu.asu.commons.mme.dao.HibernateStudentStrategyDao; import edu.asu.commons.mme.entity.DayByDayDecisions; import edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions; import edu.asu.commons.mme.entity.Game; @@ -23,6 +24,7 @@ import edu.asu.commons.mme.entity.GroupLocation; import edu.asu.commons.mme.entity.Location; import edu.asu.commons.mme.entity.Student; +import edu.asu.commons.mme.entity.StudentStrategy; /*** 1) Harvesting - Find out the amount of fish per agent and calculate the current population after harvesting @@ -82,13 +84,14 @@ private HibernateGroupLocationDao groupLocationDao; private HibernateGroupDao groupDao; private HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao; - + private HibernateStudentStrategyDao studentStrategyDao; private double totalFishLeaving; static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; static final String getgroupLocation = "SELECT g FROM GroupLocation g where g.group =:group and g.location =:location"; + static final String getStudentStrategy = "SELECT ss FROM StudentStrategy ss,Student s where s.game =: game and s=d.student"; public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; @@ -320,7 +323,7 @@ //set money student.setMoney(game.getMoney() * amountPerAgent); studentDao.save(student); - + //set other students //List<Student> otherStudents = new ArrayList<Student>(); @@ -441,4 +444,87 @@ } + /*public void executeStrategy(Game game) + { + //get student Strategies + List<StudentStrategy> studentStrategies = new ArrayList<StudentStrategy>(); + + Query studentStrategiesQuery = studentStrategyDao.getCurrentSession().createQuery(getStudentStrategy); + + studentStrategiesQuery.setEntity("game", game); + + Iterator studentStrategyIterator = studentStrategiesQuery.list().iterator(); + try + { + while(studentStrategyIterator.hasNext()) + { + StudentStrategy strategy = (StudentStrategy)studentStrategyIterator.next(); + for(int i = 0; i < strategy.getDays();i++) + studentStrategies.add(strategy); + } + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + + queryforGroups.setLong("current_game_id", game.getId()); + Iterator groups = queryforGroups.list().iterator(); + List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); + List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + /** For every group find out the groupLocations objects. + * find out the student decisions for current group. + * Separate the students for each bay + * find out the population for every bay + */ + + /* getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + while(groups.hasNext()) + { + Group currentGroup = (Group) groups.next(); + getLogger().debug("group id in executeStrategy is: " + currentGroup.getId()); + + groupLocations = groupLocationDao.findAllByProperty("group",currentGroup); + + //List<StudentDayByDayDecisions> studentDecisionForCurrentGroup = new ArrayList<DayByDayDecisions>(); + for(DayByDayDecisions tempStudentDecision:studentDecisions) + { + + if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) + { + //studentDecisionForCurrentGroup.add(tempStudentDecision); + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { + bay1Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) + { + bay2Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) + { + bay3Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harborStudents.add(tempStudentDecision); + } + + } + + } + calculateHarvest(bay1Students,"Bay1",currentGroup,game); + calculateHarvest(bay2Students,"Bay2",currentGroup,game); + calculateHarvest(bay3Students,"Bay3",currentGroup,game); + calculateNewPopulation(currentGroup); + } + }catch(Exception e) + { + e.printStackTrace(); + } + + }*/ + + public void setStudentStrategyDao(HibernateStudentStrategyDao studentStrategyDao) { + this.studentStrategyDao = studentStrategyDao; + } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-13 21:02:56 UTC (rev 363) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-16 20:39:30 UTC (rev 364) @@ -150,7 +150,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - //pushBlock(game); + pushBlock(game); flag = true; } else @@ -191,14 +191,14 @@ if(newGameState == null) { getLogger().debug("game state is null..."); - msgHandler.sendBlock(null, null); + msgHandler.sendBlock(null); } else { getLogger().debug("game state is NOT null..."); block = newGameState.getCurrentBlock(); - initializeCurrentBlock(block); - msgHandler.sendBlock(block,newGameState); + initializeGame(newGameState); + msgHandler.sendBlock(newGameState); } }catch (Exception e) { @@ -1076,16 +1076,20 @@ }*/ - /*public Round getCurrentRound() { + public Round getCurrentRound(Game currentGame) { getLogger().debug("in get current round funciton"); Round round = currentGame.getCurrentRound(); //Round round = getDao().find(getCurrentRound().getId()); - initializeRound(round); - getLogger().debug("round no is " + currentRound.getRoundNo() + " " + currentRound.getId()); - return currentRound; - }*/ + return round; + } + private void initializeRound(Round round) { + // TODO Auto-generated method stub + Hibernate.initialize(round); + + } + public void setBlockSeqNo(int blockSeqNo) { this.blockSeqNo = blockSeqNo; } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-13 21:02:56 UTC (rev 363) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-16 20:39:30 UTC (rev 364) @@ -62,7 +62,7 @@ /*logger.info("Ack received from client for message " + msg + "is : " + ack);*/ } - public void sendBlock(Block block, Game game) + public void sendBlock(Game game) { MessageBroker msgBroker = MessageBroker.getMessageBroker("_messageBroker"); @@ -73,11 +73,12 @@ msg.setClientId(clientID); msg.setMessageId(UUIDUtils.createUUID()); msg.setTimestamp(System.currentTimeMillis()); - msg.setBody(block); + + msg.setBody(game); AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); - if(block!=null) + if(game!=null) { - //int duration = block.getDuration(); + //int duration = game.getBlock().getDuration(); int duration = 20; Timer timer = new Timer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-16 18:57:40
|
Today I came in at 11:15 to begin working. I have been reading the document that seema sent me, and updating my code. I'll be working on trying to test seema's new methods. |
From: <al...@us...> - 2009-11-13 21:03:05
|
Revision: 363 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=363&view=rev Author: alllee Date: 2009-11-13 21:02:56 +0000 (Fri, 13 Nov 2009) Log Message: ----------- updated configuration instructions, simplifying / cleaning up logic for canal panel Modified Paths: -------------- 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/ClientDataModel.java 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/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/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -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.GridBagLayout; @@ -60,37 +59,35 @@ super(); //when totalContributed bandwidth = 1.0, you dont see the canal line setClientDataModel(clientDataModel); + initialize(); } public void setClientDataModel(ClientDataModel clientDataModel) { - if (timer != null) { - timer.stop(); - } this.maximumIrrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); this.clientDataModel = clientDataModel; - initialize(); } /** - * - * @return void + * */ private void initialize() { - this.setSize(new Dimension(1098,150)); +// this.setSize(new Dimension(1098,150)); setLayout(new GridBagLayout()); - this.setBackground(Color.WHITE); + setBackground(Color.WHITE); //initialize each gate - for(int i=0;i<numberOfGates ;i++){ - gate[i] = new Gate(maximumIrrigationCapacity,i); - } - + initializeGates(); initializeBalls(); - timer = new Timer(DELAY, new Rebound()); // setup the Timer to do an action // every DELAY times. timer.start(); // starts the timer. } + + private void initializeGates() { + for(int i=0;i<numberOfGates ;i++){ + gate[i] = new Gate(maximumIrrigationCapacity,i); + } + } protected void paintComponent(Graphics graphics){ super.paintComponent(graphics); // needed! @@ -201,7 +198,7 @@ } // this is the private class the Timer will look at every DELAY seconds - private class Rebound implements ActionListener{ + private class Rebound implements ActionListener { public void actionPerformed(ActionEvent e) { for(int i=0;i<BALLCOUNT;i++){ //updateGUI(); @@ -413,12 +410,14 @@ gate[priority].setHeight(gate[priority-1].getHeight());*/ repaint(); } + + public void startRound() { + initializeGates(); + timer.start(); + } public void endRound() { - if (timer != null) { - timer.stop(); - } - timer = null; + timer.stop(); 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -1,6 +1,7 @@ package edu.asu.commons.irrigation.client; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -96,7 +97,7 @@ private void sendMessage() { String message = chatField.getText(); if (message != null && ! message.isEmpty() && targetIdentifier != null) { - displayMessage(String.format("%s -> %s : ", getChatHandle(getClientId()), getChatHandle(targetIdentifier)), + displayMessage(String.format("%s : ", getChatHandle(getClientId())), message); chatField.setText(""); irrigationClient.transmit(new ChatRequest(getClientId(), message, targetIdentifier)); @@ -147,6 +148,7 @@ setLayout(new BorderLayout(4, 4)); messageWindow = new JTextPane(); messageWindow.setEditable(false); + messageWindow.setBackground(Color.WHITE); messageScrollPane = new JScrollPane(messageWindow); addStylesToMessageWindow(); textEntryPanel = new TextEntryPanel(); @@ -154,6 +156,7 @@ chatInstructionsPane.setContentType("text/html"); chatInstructionsPane.setEditorKit(new HTMLEditorKit()); chatInstructionsPane.setEditable(false); + chatInstructionsPane.setBackground(Color.WHITE); JScrollPane chatInstructionsScrollPane = new JScrollPane(chatInstructionsPane); add(chatInstructionsScrollPane, BorderLayout.PAGE_START); add(messageScrollPane, BorderLayout.CENTER); @@ -198,7 +201,7 @@ public void handle(final ChatEvent chatEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { - displayMessage(String.format("%s -> %s : ", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), + displayMessage(String.format("%s : ", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), chatEvent.toString()); } }); 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -62,7 +62,7 @@ public synchronized void initialize(RoundStartedEvent event) { groupDataModel.clear(); setGroupDataModel(event.getGroupDataModel()); - setTimeLeft( (int) (getRoundConfiguration().getRoundDuration().getDelta() / 1000L) ); + setTimeLeft( getRoundConfiguration().getRoundDurationInSeconds() ); } public int 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-13 21:02:56 UTC (rev 363) @@ -136,10 +136,10 @@ tokenInvestmentPanel.setName("Token investment panel"); tokenInvestmentPanel.setLayout(new BorderLayout()); tokenInstructionsEditorPane = createInstructionsEditorPane(); + tokenInstructionsEditorPane.setCaretPosition(0); tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); tokenInvestmentPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); - tokenInstructionsEditorPane.setCaretPosition(0); - tokenInstructionsEditorPane.repaint(); + tokenInvestmentPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); tokenInvestmentPanel.setBackground(Color.WHITE); } @@ -222,6 +222,9 @@ currentQuizPageNumber++; setInstructions(getQuizPage()); } + else { + setInstructions(instructionsBuilder.toString()); + } } }); @@ -236,7 +239,6 @@ // return canalAnimationPanel; // } - private String getQuizPage() { StringBuilder builder = new StringBuilder(); String quizPage = getServerConfiguration().getQuizPage(currentQuizPageNumber); @@ -317,7 +319,6 @@ // create a quiz listener and then initialize the instructions. instructionsEditorPane.setActionListener(createQuizListener(getServerConfiguration())); instructionsEditorPane.setCaretPosition(0); - instructionsEditorPane.setBackground(Color.WHITE); } return instructionsEditorPane; } @@ -325,7 +326,8 @@ private HtmlEditorPane createInstructionsEditorPane() { HtmlEditorPane htmlEditorPane = new HtmlEditorPane(); htmlEditorPane.setEditable(false); - htmlEditorPane.setFont(new Font("sansserif", Font.TRUETYPE_FONT, 14)); + htmlEditorPane.setFont(new Font("sansserif", Font.TRUETYPE_FONT, 16)); + htmlEditorPane.setBackground(Color.WHITE); return htmlEditorPane; } @@ -335,7 +337,7 @@ revalidate(); } - public void startRound(final RoundConfiguration configuration) { + public void startRound() { SwingUtilities.invokeLater(new Runnable() { public void run() { addCenterComponent(irrigationGamePanel); @@ -404,7 +406,7 @@ clientData.getTotalDollarsEarnedThisRound(), clientData.getTotalDollarsEarned()+showUpBonus, showUpBonus)); //append the added practice round instructions - if (roundConfiguration.isPracticeRound() || roundConfiguration.isSecondPracticeRound()) { + if (roundConfiguration.isPracticeRound()) { instructionsBuilder.append(roundConfiguration.getPracticeRoundPaymentInstructions()); } else if (event.isLastRound()) { @@ -587,8 +589,8 @@ } 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 and the available water supply is %d cfps.</p><hr/>", + String.format("<p>The <b>current infrastructure efficiency is %d%%</b> but will <b>decline by %d%%</b> during this round." + + "The <b>current irrigation capacity is %d cfps</b> and the <b>available water supply is %d cfps</b>.</p><hr/>", clientDataModel.getGroupDataModel().getInfrastructureEfficiency(), roundConfiguration.getInfrastructureDegradationFactor(), irrigationCapacity, 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -76,9 +76,9 @@ // data.addSeries(actualFlowCapacitySeriesY); final JFreeChart chart = ChartFactory.createXYLineChart( - "Total Flow Capacity", + "Water Delivery Capacity vs. Infrastructure Efficiency", "Infrastructure Efficiency", - "Actual Flow Capacity", + "Water Delivery Capacity", data, PlotOrientation.VERTICAL, true, 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-11-13 21:02:56 UTC (rev 363) @@ -177,7 +177,7 @@ channel.add(this, new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { public void handle(RoundStartedEvent event) { clientDataModel.initialize(event); - experimentGameWindow.startRound(getRoundConfiguration()); + experimentGameWindow.startRound(); } }); channel.add(this, new EventTypeProcessor<EndRoundEvent>(EndRoundEvent.class) { Deleted: 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -1,421 +0,0 @@ -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 java.lang.reflect.InvocationTargetException; - -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.JTextField; -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; - -/** - * $Id$ - * - * 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 IrrigationGameWindow irrigationGameWindow; - - private CanalPanel canalPanel; - - //this contains the CanalPanel - private JPanel centerPanel; - - private IrrigationClient client; - -// private Dimension screenSize; - - private JProgressBar timeLeftProgressBar; - - private JButton gateSwitchButton; - - private JLabel irrigationCapacityLabel; - - // private JLabel maximumAvailableFlowCapacityLabel = null; - - private ClientDataModel clientDataModel; // @jve:decl-index=0: - - private MiddleWindowPanel middleWindowPanel; - - // private JLabel dashBoardLabel = null; - - // private JLabel scoreBoardLabel = null; - - private JLabel totalTokensEarnedLabel; - - private JLabel tokensEarnedLabel; - - private JLabel tokensNotInvestedLabel; - - private JLabel waterCollectedLabel; - - private JTextField waterCollectedTextField; - - private JTextField tokensNotInvestedTextField; - - private JTextField tokensEarnedTextField; - - private JTextField totalTokensEarnedTextField; - - private boolean open; - - private JTextField irrigationCapacityTextField; - - private HtmlEditorPane waterCollectedToTokensTable; - - public IrrigationGamePanel(IrrigationClient client) { - setName("Irrigation Game Panel"); - this.client = client; - initGuiComponents(); - } - /** - * Initializes the main game window. - * @return - */ - private void initGuiComponents() { - - - JPanel topmostPanel = new JPanel(); - topmostPanel.setLayout(new BoxLayout(topmostPanel, BoxLayout.Y_AXIS)); - topmostPanel.add(getIrrigationCapacityLabel()); - topmostPanel.add(getTimeLeftProgressBar()); - - setLayout(new BorderLayout()); - add(topmostPanel, BorderLayout.PAGE_START); - add(getCenterPanel(), BorderLayout.CENTER); - add(getBottomPanel(), BorderLayout.PAGE_END); - } - - private JPanel getBottomPanel() { - 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 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); - - bottomMostPanel.add(bottomInformationPanel); - - bottomMostPanel.add(getWaterCollectedToTokensTable()); - - bottomPanel.add(bottomMostPanel); - return bottomPanel; - } - - - 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(); - } - 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; - } - - 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 centerPanel; - } - - - 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 createCanalPanel() { - JPanel panel = new JPanel(); - canalPanel = new CanalPanel(clientDataModel); - canalPanel.setSize(new Dimension(1098, 123)); - panel.add(canalPanel); - panel.setBounds(new Rectangle(13, 64, 1098, 123)); - return panel; - } - - /** - * The time left progress bar. - * - * @return javax.swing.JProgressBar - */ - private JProgressBar getTimeLeftProgressBar() { - if (timeLeftProgressBar == null) { - timeLeftProgressBar = new JProgressBar(0, 50); - timeLeftProgressBar.setStringPainted(true); - } - 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) { - 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(); - waterCollectedTextField.setText("" + clientData.getWaterCollected()); - tokensNotInvestedTextField.setText("" + clientData.getUninvestedTokens()); - tokensEarnedTextField.setText("" + clientData.getTokensEarnedFromWaterCollected()); - totalTokensEarnedTextField.setText("" + clientData.getAllTokensEarnedThisRound()); -// getScoreBoxPanel().update(clientDataModel); - getMiddleWindowPanel().update(clientDataModel); - - } - - }); - } - - /** - * changes the file button color to red when started downloading - * @param file - */ - - /* - * updates the irrigation window - */ - public void endRound() { - Runnable createGuiRunnable = new Runnable(){ - public void run() { - gateSwitchButton.setText("Open gate"); - if (canalPanel != null) { - System.err.println("Removing canal panel"); - centerPanel.removeAll(); - canalPanel.endRound(); - } - System.err.println("ending round for canal panel"); - canalPanel = null; - } - }; - open = false; - try { - SwingUtilities.invokeAndWait(createGuiRunnable); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - - } - - public void setClientDataModel(final ClientDataModel clientDataModel) { - this.clientDataModel = clientDataModel; - } - - - /** - * 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; - centerPanel.add(createCanalPanel(), null); - centerPanel.add(getMiddleWindowPanel(), null); -// getWaterCollectedToTokensTable().setText(clientDataModel.getServerConfiguration().getWaterCollectedToTokensTable()); -// getScoreBoxPanel().initialize(clientDataModel); - getMiddleWindowPanel().initialize(clientDataModel); - int irrigationCapacity = clientDataModel.getGroupDataModel().getMaximumAvailableWaterFlow(); - 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); - } - - private MiddleWindowPanel getMiddleWindowPanel() { - if(middleWindowPanel == null){ - middleWindowPanel = new MiddleWindowPanel(); - } - return middleWindowPanel; - } - - public ClientDataModel getClientDataModel() { - return clientDataModel; - } -} - 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-13 21:02:56 UTC (rev 363) @@ -449,12 +449,17 @@ */ public void setClientDataModel(final ClientDataModel clientDataModel) { this.clientDataModel = clientDataModel; - fillPanels(clientDataModel); + } public void startRound() { open = false; getMiddleWindowPanel().initialize(clientDataModel); + centerPanel.add(getCanalPanel(clientDataModel)); + mainInterfacePanel.add(getJPanelUpStreamWindow(),null); + mainInterfacePanel.add(getJPanelDownStreamWindow(),null); + mainInterfacePanel.add(getMiddleWindowPanel(),null); + canalPanel.startRound(); int irrigationCapacity = clientDataModel.getIrrigationCapacity(); int waterSupply = clientDataModel.getWaterSupplyCapacity(); irrigationCapacityLabel.setText( @@ -463,21 +468,9 @@ waterSupplyLabel.setText( String.format("Water supply: %d cubic feet per second (cfps)", waterSupply)); - revalidate(); } - /** - * fills in the panels depending on the priority of the client - */ - public void fillPanels(ClientDataModel clientDataModel) { - centerPanel.add(getCanalPanel(clientDataModel)); - mainInterfacePanel.add(getJPanelUpStreamWindow(),null); - mainInterfacePanel.add(getJPanelDownStreamWindow(),null); - mainInterfacePanel.add(getMiddleWindowPanel(),null); - } - - private MiddleWindowPanel getMiddleWindowPanel() { if(middleWindowPanel == null) { middleWindowPanel = new 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-11-13 21:02:56 UTC (rev 363) @@ -106,8 +106,8 @@ public void update(ClientData clientData) { this.clientData = clientData; - availableWaterLabel.setText(clientData.getAvailableFlowCapacity() + " cfps"); - waterCollectedLabel.setText(clientData.getWaterCollected() + " cf"); + availableWaterLabel.setText(clientData.getAvailableFlowCapacity() + ""); + waterCollectedLabel.setText(clientData.getWaterCollected() + ""); tokensEarnedLabel.setText(String.valueOf(clientData.getTokensEarnedFromWaterCollected())); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-11-13 21:02:56 UTC (rev 363) @@ -23,10 +23,6 @@ private static final float DEFAULT_DOLLARS_PER_TOKEN = .05f; - public RoundConfiguration() { - super(); - } - public static int getTokensEarned(int waterCollected) { if (waterCollected < 150) { return 0; @@ -75,8 +71,6 @@ } } - - public RoundConfiguration(String resource) { super(resource); } @@ -121,12 +115,7 @@ 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(){ - return getBooleanProperty("second-practice-round",false); - } - + public int getClientsPerGroup() { return getIntProperty("clients-per-group", 5); } @@ -151,7 +140,7 @@ } public boolean shouldResetInfrastructureEfficiency() { - return getBooleanProperty("reset-infrastructure-efficiency", false); + return isFirstRound() || getBooleanProperty("reset-infrastructure-efficiency", false); } public String getInstructions() { @@ -167,8 +156,8 @@ return getBooleanProperty("quiz"); } - public String getQuizInstructions() { - return getStringProperty("quiz-instructions"); + public String getQuizPage() { + return getStringProperty("quiz-page"); } public Map<String, String> getQuizAnswers() { @@ -201,8 +190,12 @@ */ @Override public Duration getRoundDuration() { - return Duration.create(getIntProperty("round-duration", 50)); + return Duration.create(getRoundDurationInSeconds()); } + + public int getRoundDurationInSeconds() { + return getIntProperty("round-duration", 50); + } public boolean shouldRandomizeGroup() { return getBooleanProperty("randomize-groups", false); 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-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-13 21:02:56 UTC (rev 363) @@ -267,11 +267,9 @@ addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { @Override public void handle(QuizResponseEvent event) { - numberOfCompletedQuizzes++; getLogger().info("Completed quizzes: " + numberOfCompletedQuizzes); - if(numberOfCompletedQuizzes == clients.size()*8){ - getLogger().info("Everyone has finished reading the general instructions successfully"); - } + numberOfCompletedQuizzes++; + persister.store(event); } }); addEventProcessor(new EventTypeProcessor<OpenGateEvent>(OpenGateEvent.class) { Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 15:14:42 UTC (rev 362) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 21:02:56 UTC (rev 363) @@ -118,7 +118,7 @@ </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> +of time left in the chat period will be displayed <b>below the chat messages window</b>.<br> </p> ]]> </entry> @@ -126,62 +126,6 @@ <entry key='game-screenshot-instructions'> <![CDATA[ <img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> - -<p> -<b>Table 2</b>: Number of tokens earned from the water applied to your field. -</p> -<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> @@ -214,46 +158,9 @@ <entry key="quiz-page1"> <![CDATA[ <p> -The first two questions deal with irrigation infrastructure investment using Table -1. +The first two questions deal with irrigation infrastructure investment. +<b>Please refer to Table 1 of your handout</b>. </p> -<p> -<b>Table 1</b>: The water delivery capacity as a function of irrigation -infrastructure efficiency -</p> -<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> <form> Question 1:<br> @@ -301,68 +208,8 @@ <![CDATA[ <p> The final two questions cover the number of tokens you can earn in within a round. +<b>Please refer to table 2 of your handout</b>. </p> -<b>Table 2</b>: Tokens earned 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> -<p> -Your earnings at the end of the round depend on your investment and the number of -tokens you receive from applying water to your fields and growing a crop. As an -example, suppose you invest 6 tokens out of the 10 tokens you are endowed with at -the start of each round. If you receive 333 cubic feet of water you would receive a -grand total of 19 tokens (4 tokens left over from your 10 token endowment + 15 -tokens for growing a crop with 333 cubic feet of water). Since each token is worth -$0.05, you would have an actual earnings of $0.85 for that round. - <form> Question 5:<br> If you invest 7 of the 10 tokens you start with and you apply 202 cubic feet of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-13 15:14:51
|
Revision: 362 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=362&view=rev Author: alllee Date: 2009-11-13 15:14:42 +0000 (Fri, 13 Nov 2009) Log Message: ----------- minor code hygiene, removing unused code etc. 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/Gate.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/FacilitatorWindow.java 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-11-13 15:14:42 UTC (rev 362) @@ -139,7 +139,7 @@ //get the position information of the ball. and then recheck the condition for height. 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()))) + if(!((!gate[balls[i].getPosition()-1].isGateOpen())&& 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 { @@ -161,7 +161,7 @@ private void updateGUI() { for(int i=1;i<6;i++){ - if(gate[i-1].isOpenGate()){ + if(gate[i-1].isGateOpen()){ if(!(gate[i-1].getHeight() - gateHeight < 0)){ gate[i].setHeight(gate[i-1].getHeight() - gateHeight ); @@ -181,7 +181,7 @@ gate[i].setOpeningsY(gate[i].getOpeningsHeight() - 50); //opening the lid logic - if(gate[i].isOpenGate()){ + if(gate[i].isGateOpen()){ 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()); @@ -193,7 +193,7 @@ gate[i].sety1(gate[i].getdefaulty1()); } - if(gate[0].isOpenGate()){ + if(gate[0].isGateOpen()){ 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()); @@ -280,7 +280,7 @@ case 1: /*if(gate[0].isOpenGate() && (balls[i].x >= 400 && balls[i].x <= 420) && (balls[i].y >= 80 && balls[i].y <= 100)){ - */ if(gate[0].isOpenGate() && (balls[i].x >= gate[0].getOpeningsX() && balls[i].x <= (gate[0].getOpeningsX()+20)) + */ if(gate[0].isGateOpen() && (balls[i].x >= gate[0].getOpeningsX() && balls[i].x <= (gate[0].getOpeningsX()+20)) && (balls[i].y >= 80 && balls[i].y <= 100)){ balls[i].setPosition(7); //directly pass in the information @@ -309,7 +309,7 @@ break; - case 2: if(gate[1].isOpenGate() && (balls[i].x >= gate[1].getOpeningsX() && balls[i].x <= (gate[1].getOpeningsX()+20)) + case 2: if(gate[1].isGateOpen() && (balls[i].x >= gate[1].getOpeningsX() && balls[i].x <= (gate[1].getOpeningsX()+20)) && (balls[i].y >= 80 && balls[i].y <= 100)){ balls[i].setPosition(8); //directly pass in the information @@ -333,7 +333,7 @@ break; - case 3: if(gate[2].isOpenGate() && (balls[i].x >= gate[2].getOpeningsX() && balls[i].x <= (gate[2].getOpeningsX()+20)) + case 3: if(gate[2].isGateOpen() && (balls[i].x >= gate[2].getOpeningsX() && balls[i].x <= (gate[2].getOpeningsX()+20)) && (balls[i].y >= 80 && balls[i].y <= 100)){ balls[i].setPosition(9); //directly pass in the information @@ -356,7 +356,7 @@ } break; - case 4: if(gate[3].isOpenGate() && (balls[i].x >= gate[3].getOpeningsX() && balls[i].x <= (gate[3].getOpeningsX()+20)) + case 4: if(gate[3].isGateOpen() && (balls[i].x >= gate[3].getOpeningsX() && balls[i].x <= (gate[3].getOpeningsX()+20)) && (balls[i].y >= 80 && balls[i].y <= 100)){ balls[i].setPosition(10); //directly pass in the information @@ -379,7 +379,7 @@ } break; - case 5: if(gate[4].isOpenGate() && (balls[i].x >= gate[4].getOpeningsX() && balls[i].x <= (gate[4].getOpeningsX()+20)) + case 5: if(gate[4].isGateOpen() && (balls[i].x >= gate[4].getOpeningsX() && balls[i].x <= (gate[4].getOpeningsX()+20)) && (balls[i].y >= 80 && balls[i].y <= 100)){ balls[i].setPosition(11); //directly pass in the information 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-11-13 15:14:42 UTC (rev 362) @@ -40,8 +40,6 @@ private Random generator = new Random(); - private final static boolean enableBallAnimation = true; - private int maximumIrrigationCapacity; private ClientDataModel clientDataModel; @@ -124,7 +122,7 @@ 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()))) + if(!((!gate[balls[i].getPosition()-1].isGateOpen())&& 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{ @@ -144,7 +142,7 @@ private void updateGUI() { for(int i=1;i<6;i++){ - if(gate[i-1].isOpenGate()){ + if(gate[i-1].isGateOpen()){ if(!(gate[i-1].getHeight() - gateHeight < 0)){ gate[i].setHeight(gate[i-1].getHeight() - gateHeight ); @@ -164,7 +162,7 @@ gate[i].setOpeningsY(gate[i].getOpeningsHeight() - 50); //opening the lid logic - if(gate[i].isOpenGate()){ + if(gate[i].isGateOpen()){ 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()); @@ -176,7 +174,7 @@ gate[i].sety1(gate[i].getdefaulty1()); } - if(gate[0].isOpenGate()){ + if(gate[0].isGateOpen()){ 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()); @@ -237,7 +235,7 @@ } break; - case 1: if(gate[0].isOpenGate() && (balls[i].x >= gate[0].getOpeningsX() && balls[i].x <= (gate[0].getOpeningsX()+gateBuffer)) + case 1: if(gate[0].isGateOpen() && (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 @@ -255,7 +253,7 @@ break; - case 2: if(gate[1].isOpenGate() && (balls[i].x >= gate[1].getOpeningsX() && balls[i].x <= (gate[1].getOpeningsX()+gateBuffer)) + case 2: if(gate[1].isGateOpen() && (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 @@ -273,7 +271,7 @@ break; - case 3: if(gate[2].isOpenGate() && (balls[i].x >= gate[2].getOpeningsX() && balls[i].x <= (gate[2].getOpeningsX()+gateBuffer)) + case 3: if(gate[2].isGateOpen() && (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 @@ -296,7 +294,7 @@ } break; - case 4: if(gate[3].isOpenGate() && (balls[i].x >= gate[3].getOpeningsX() && balls[i].x <= (gate[3].getOpeningsX()+gateBuffer)) + case 4: if(gate[3].isGateOpen() && (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 @@ -313,7 +311,7 @@ } break; - case 5: if(gate[4].isOpenGate() && (balls[i].x >= gate[4].getOpeningsX() && balls[i].x <= (gate[4].getOpeningsX()+gateBuffer)) + case 5: if(gate[4].isGateOpen() && (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 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-13 15:14:42 UTC (rev 362) @@ -1,19 +1,16 @@ package edu.asu.commons.irrigation.client; import java.awt.BorderLayout; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.JButton; import javax.swing.JEditorPane; -import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Gate.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Gate.java 2009-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Gate.java 2009-11-13 15:14:42 UTC (rev 362) @@ -6,7 +6,7 @@ */ public class Gate { - private boolean openGate = false; + private boolean gateOpen = false; private int height; @@ -40,13 +40,7 @@ private int y2; - private int priority; - - private double totalContributedBandwidth; - public Gate(double totalContributedBandwidth, int priority){ - this.totalContributedBandwidth = totalContributedBandwidth; - this.priority = priority; setWidth(198); setHeight(totalContributedBandwidth*0.8); setOpeningsWidth(gateWidth); @@ -62,7 +56,6 @@ } public void setOpeningsY(int openingsY) { - // TODO Auto-generated method stub this.openingsy = 100 - openingsY; this.y1 = 100 - openingsY; this.y2 = 100 - openingsY; @@ -70,22 +63,18 @@ } public void setOpeningsWidth(int gateWidth) { - // TODO Auto-generated method stub openingsWidth = gateWidth; } public void setOpeningsHeight(double gateHeight) { - // TODO Auto-generated method stub openingsHeight = (int)(gateHeight)+this.gateHeight; } public void setY(int y) { - // TODO Auto-generated method stub this.y = y; } public void setWidth(int width) { - // TODO Auto-generated method stub this.width = width; } @@ -132,106 +121,84 @@ } public int getHeight() { - // TODO Auto-generated method stub return height; } public int getWidth() { - // TODO Auto-generated method stub return width; } public int getY() { - // TODO Auto-generated method stub + return y; } public int getX() { - // TODO Auto-generated method stub return x; } - public boolean isOpenGate(){ - if(openGate == true) - return true; - else - return false; + public boolean isGateOpen(){ + return gateOpen; } - public void setGateOpen(boolean openGate) { - // TODO Auto-generated method stub - this.openGate = openGate; + public void setGateOpen(boolean gateOpen) { + this.gateOpen = gateOpen; } public int getOpeningsHeight() { - // TODO Auto-generated method stub return openingsHeight; } public int getOpeningsX() { - // TODO Auto-generated method stub return openingsx; } public int getOpeningsY() { - // TODO Auto-generated method stub return openingsy; } public int getOpeningsWidth() { - // TODO Auto-generated method stub return openingsWidth; } public int gety2() { - // TODO Auto-generated method stub return y2; } public int gety1() { - // TODO Auto-generated method stub return y1; } public int getx1() { - // TODO Auto-generated method stub return x1; } public int getx2() { - // TODO Auto-generated method stub return x2; } public void setx1(int x1) { - // TODO Auto-generated method stub this.x1 = x1; } public int getGateWidth() { - // TODO Auto-generated method stub return gateWidth; } public void sety1(int y1) { - // TODO Auto-generated method stub this.y1 = y1; } public int getdefaultx1() { - // TODO Auto-generated method stub return defaultx1; } public int getdefaulty1() { - // TODO Auto-generated method stub return defaulty1; } public void sety2(int y2) { - // TODO Auto-generated method stub this.y2 = y2; } - } 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleScorePanel.java 2009-11-13 15:14:42 UTC (rev 362) @@ -29,8 +29,8 @@ private JLabel tokensEarnedLabel; - private JLabel tokensNotInvestedLabel; - private JLabel totalTokensEarnedLabel; +// private JLabel tokensNotInvestedLabel; +// private JLabel totalTokensEarnedLabel; private int priority; @@ -55,21 +55,21 @@ // 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 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 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 getTokensEarnedLabel() { if(tokensEarnedLabel == null){ @@ -106,12 +106,12 @@ public void update(ClientData clientData) { this.clientData = clientData; - availableWaterLabel.setText("" + clientData.getAvailableFlowCapacity()); - waterCollectedLabel.setText("" + clientData.getWaterCollected()); - tokensEarnedLabel.setText("" + clientData.getTokensEarnedFromWaterCollected()); + availableWaterLabel.setText(clientData.getAvailableFlowCapacity() + " cfps"); + waterCollectedLabel.setText(clientData.getWaterCollected() + " cf"); + tokensEarnedLabel.setText(String.valueOf(clientData.getTokensEarnedFromWaterCollected())); if(clientData.isGateOpen() && clientData.getAvailableFlowCapacity() > 0) { - // show that client is actively irrigating + // animation displaying active crop growing? } } 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MiddleWindowPanel.java 2009-11-13 15:14:42 UTC (rev 362) @@ -1,6 +1,5 @@ package edu.asu.commons.irrigation.client; - import java.awt.Dimension; import java.awt.Rectangle; import java.util.ArrayList; @@ -27,7 +26,7 @@ private JLabel availableWaterLabel; private JLabel waterCollectedLabel; private JLabel tokensEarnedLabel; - private JLabel tokensNotInvestedLabel; +// private JLabel tokensNotInvestedLabel; private JLabel totalTokensEarnedLabel; 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-11-13 06:56:43 UTC (rev 361) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-13 15:14:42 UTC (rev 362) @@ -14,11 +14,11 @@ import javax.swing.SwingUtilities; import edu.asu.commons.irrigation.events.BeginChatRoundRequest; +import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; +import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.events.ShowQuizRequest; import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; -import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; -import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.server.ClientData; import edu.asu.commons.irrigation.server.GroupDataModel; import edu.asu.commons.irrigation.server.ServerDataModel; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-13 06:56:52
|
Revision: 361 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=361&view=rev Author: alllee Date: 2009-11-13 06:56:43 +0000 (Fri, 13 Nov 2009) Log Message: ----------- - adding JFreeChart to bottom right hand corner for dynamic display of tokens earned - shuffling participants in the first round when chat begins - extracted tokens earned function to static method in RoundConfiguration for the time being 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/MainIrrigationGameWindow.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/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-13 06:56:43 UTC (rev 361) @@ -49,8 +49,6 @@ private IrrigationClient irrigationClient; - private Identifier clientId; - private JScrollPane messageScrollPane; private JTextPane messageWindow; @@ -61,13 +59,8 @@ private JTextField chatField; - - public ChatPanel() { - initGuiComponents(); - } - public ChatPanel(IrrigationClient irrigationClient) { - this(); + initGuiComponents(); setIrrigationClient(irrigationClient); } @@ -106,7 +99,7 @@ private void sendMessage() { String message = chatField.getText(); if (message != null && ! message.isEmpty() && targetIdentifier != null) { - displayMessage(String.format("%s -> %s", getChatHandle(getClientId()), getChatHandle(targetIdentifier)), + displayMessage(String.format("%s -> %s : ", getChatHandle(getClientId()), getChatHandle(targetIdentifier)), message); chatField.setText(""); irrigationClient.transmit(new ChatRequest(getClientId(), message, targetIdentifier)); @@ -129,20 +122,6 @@ private Map<Identifier, String> chatHandles = new HashMap<Identifier, String>(); - public static void main(String[] args) { - JFrame frame = new JFrame(); - ChatPanel chatPanel = new ChatPanel(); - Identifier selfId = new Identifier(){}; - chatPanel.clientId = selfId; - chatPanel.initialize(Arrays.asList(new Identifier[] { - new Identifier(){}, new Identifier(){}, - new Identifier(){}, selfId })); - frame.add(chatPanel); - frame.setSize(new Dimension(400, 400)); - frame.setVisible(true); - } - - private void addStylesToMessageWindow() { StyledDocument styledDocument = messageWindow.getStyledDocument(); // and why not have something like... StyleContext.getDefaultStyle() to @@ -152,10 +131,8 @@ // Style regularStyle = styledDocument.addStyle("regular", // defaultStyle); StyleConstants.setFontFamily(defaultStyle, "Helvetica"); - StyleConstants.setBold(styledDocument.addStyle("bold", defaultStyle), - true); - StyleConstants.setItalic(styledDocument - .addStyle("italic", defaultStyle), true); + StyleConstants.setBold(styledDocument.addStyle("bold", defaultStyle), true); + StyleConstants.setItalic(styledDocument.addStyle("italic", defaultStyle), true); } public void setTimeLeft(long timeLeft) { @@ -189,11 +166,10 @@ private void displayMessage(String chatHandle, String message) { // String chatHandle = getChatHandle(source); - StyledDocument document = messageWindow.getStyledDocument(); + final StyledDocument document = messageWindow.getStyledDocument(); try { - document.insertString(document.getLength(), chatHandle + " : ", - document.getStyle("bold")); - document.insertString(document.getLength(), message + "\n", null); + document.insertString(document.getLength(), chatHandle, document.getStyle("bold")); + document.insertString(document.getLength(), message + "\n", document.getStyle("italic")); messageWindow.setCaretPosition(document.getLength()); } catch (BadLocationException e) { @@ -215,10 +191,7 @@ } public Identifier getClientId() { - if (clientId == null) { - clientId = irrigationClient.getId(); - } - return clientId; + return irrigationClient.getId(); } public void setIrrigationClient(IrrigationClient client) { @@ -228,7 +201,7 @@ public void handle(final ChatEvent chatEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { - displayMessage(String.format("%s -> %s", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), + displayMessage(String.format("%s -> %s : ", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), chatEvent.toString()); } }); 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-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-13 06:56:43 UTC (rev 361) @@ -463,10 +463,17 @@ builder.append(quizAnswers.get( "explanation" + number )).append("</p>"); } } + if (incorrectAnswers.isEmpty()) { + builder.append("<p>Congratulations, you got all of the questions correct.</p>"); + } + else { + builder.append(String.format("<p>You answered %d questions incorrectly. Please review the correct answers to make sure you understand.</p>", incorrectAnswers.size())); + } + builder.append("<p><b>Please click the 'Next' button at the bottom right of the screen to continue.</b></p>"); quizPageResponses.put(currentQuizPageNumber, builder.toString()); // no matter what we move on to the next question page // tell them what was right and what was wrong. - if (currentQuizPageNumber < numberOfQuestionPages) { + if (currentQuizPageNumber <= numberOfQuestionPages) { nextButton.setEnabled(true); } quizzesAnswered++; 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-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-13 06:56:43 UTC (rev 361) @@ -11,7 +11,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.GroupLayout; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -22,6 +21,14 @@ import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.ParallelGroup; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.irrigation.server.ClientData; /** * $Id$ @@ -355,9 +362,32 @@ } return jPanelDownStreamWindow; } + + private XYSeries currentWaterAppliedSeries = new XYSeries("Current water applied"); - private JLabel getWaterCollectedToTokensTable() { - return new JLabel(new ImageIcon("images/payoff-structure.jpg")); + private ChartPanel getWaterCollectedToTokensTable() { + final XYSeries tokensEarnedSeries = new XYSeries("Tokens earned from water applied"); + + for (int waterApplied = 0; waterApplied < 1000; waterApplied++) { + int tokensEarned = RoundConfiguration.getTokensEarned(waterApplied); + tokensEarnedSeries.add(waterApplied, tokensEarned); + } + + + XYSeriesCollection data = new XYSeriesCollection(); + data.addSeries(tokensEarnedSeries); + data.addSeries(currentWaterAppliedSeries); + JFreeChart chart = ChartFactory.createXYLineChart( + "Water applied to tokens earned", + "Cubic feet of water applied to your field", + "Tokens earned", + data, + PlotOrientation.VERTICAL, + true, + true, + false + ); + return new ChartPanel(chart); } /** @@ -389,7 +419,11 @@ getTokensEarnedTextField().setText("" + clientData.getTokensEarnedFromWaterCollected()); getTotalTokensEarnedTextField().setText("" + clientData.getAllTokensEarnedThisRound()); getMiddleWindowPanel().update(clientDataModel); - + + currentWaterAppliedSeries.clear(); + for (int i = 0; i <= clientData.getTokensEarnedFromWaterCollected(); i++) { + currentWaterAppliedSeries.add(clientData.getWaterCollected(), i); + } } }); 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-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-11-13 06:56:43 UTC (rev 361) @@ -27,6 +27,56 @@ super(); } + public static int getTokensEarned(int waterCollected) { + if (waterCollected < 150) { + return 0; + } + else if (waterCollected < 200) { + return 1; + } + else if (waterCollected < 250) { + return 4; + } + else if (waterCollected < 300) { + return 10; + } + else if (waterCollected < 350) { + return 15; + } + else if (waterCollected < 400) { + return 18; + } + else if (waterCollected < 500) { + return 19; + } + else if (waterCollected < 550) { + return 20; + } + else if (waterCollected < 650) { + return 19; + } + else if (waterCollected < 700) { + return 18; + } + else if (waterCollected < 750) { + return 15; + } + else if (waterCollected < 800) { + return 10; + } + else if (waterCollected < 850) { + return 4; + } + else if (waterCollected < 900) { + return 1; + } + else { + return 0; + } + } + + + public RoundConfiguration(String resource) { super(resource); } 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-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-11-13 06:56:43 UTC (rev 361) @@ -206,53 +206,10 @@ * @return */ public int getTokensEarnedFromWaterCollected() { - if (waterCollected < 150) { - return 0; - } - else if (waterCollected < 200) { - return 1; - } - else if (waterCollected < 250) { - return 4; - } - else if (waterCollected < 300) { - return 10; - } - else if (waterCollected < 350) { - return 15; - } - else if (waterCollected < 400) { - return 18; - } - else if (waterCollected < 500) { - return 19; - } - else if (waterCollected < 550) { - return 20; - } - else if (waterCollected < 650) { - return 19; - } - else if (waterCollected < 700) { - return 18; - } - else if (waterCollected < 750) { - return 15; - } - else if (waterCollected < 800) { - return 10; - } - else if (waterCollected < 850) { - return 4; - } - else if (waterCollected < 900) { - return 1; - } - else { - return 0; - } + return RoundConfiguration.getTokensEarned(waterCollected); } + public void collectWater() { waterCollected += availableFlowCapacity; } 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-11-13 05:32:07 UTC (rev 360) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-13 06:56:43 UTC (rev 361) @@ -160,6 +160,9 @@ addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { @Override public void handle(BeginChatRoundRequest request) { + if (getRoundConfiguration().isFirstRound()) { + shuffleParticipants(); + } persister.clearChatData(); // pass it on to all the clients synchronized (clients) { @@ -355,6 +358,18 @@ server.repl(); } + private void shuffleParticipants() { + serverDataModel.clear(); + List<ClientData> clientDataList = new ArrayList<ClientData>(clients.values()); + // randomize the client data list + Collections.shuffle(clientDataList); + // re-add each the clients to the server data model + for (ClientData data: clientDataList) { + serverDataModel.addClient(data); + } + } + + enum IrrigationServerState { WAITING, ROUND_IN_PROGRESS }; private class IrrigationServerStateMachine implements StateMachine { @@ -448,6 +463,8 @@ submittedClients = 0; persister.clear(); } + + private void advanceToNextRound() { if (getConfiguration().isLastRound()) { state = IrrigationServerState.WAITING; @@ -458,14 +475,8 @@ // set up the next round synchronized (clients) { if (nextRoundConfiguration.shouldRandomizeGroup()) { - serverDataModel.clear(); - List<ClientData> clientDataList = new ArrayList<ClientData>(clients.values()); - // randomize the client data list - Collections.shuffle(clientDataList); - // re-add each the clients to the server data model - for (ClientData data: clientDataList) { - serverDataModel.addClient(data); - } + shuffleParticipants(); + } // send registration events to all participants. for (ClientData data: clients.values()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-13 05:32:16
|
Revision: 360 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=360&view=rev Author: alllee Date: 2009-11-13 05:32:07 +0000 (Fri, 13 Nov 2009) Log Message: ----------- updating quiz display / configuration parameters 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/conf/ServerConfiguration.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round2.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-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-13 05:32:07 UTC (rev 360) @@ -459,8 +459,8 @@ color = "red"; } builder.append(String.format("Your answer: <font color='%s'>%s</font><br/>", color, response)); - builder.append(String.format("Correct answer: %s<br/>", correctAnswer)); - builder.append(quizAnswers.get( "qDescriptiveAnswer" + number )).append("</p>"); + builder.append(String.format("Correct answer: %s<br/>", quizAnswers.get("a" + number))); + builder.append(quizAnswers.get( "explanation" + number )).append("</p>"); } } quizPageResponses.put(currentQuizPageNumber, builder.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-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-11-13 05:32:07 UTC (rev 360) @@ -101,7 +101,7 @@ } public boolean shouldResetInfrastructureEfficiency() { - return isPracticeRound() || getBooleanProperty("reset-infrastructure-efficiency", false); + return getBooleanProperty("reset-infrastructure-efficiency", false); } public String getInstructions() { 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-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-13 05:32:07 UTC (rev 360) @@ -101,9 +101,11 @@ String key = "q" + i; String answer = properties.getProperty(key); answers.put(key, answer); - String quizDescriptiveAnswerKey = "qDescriptiveAnswer" + i; - String quizDescriptiveAnswer = properties.getProperty(quizDescriptiveAnswerKey); - answers.put(quizDescriptiveAnswerKey, quizDescriptiveAnswer); + String quizExplanationKey = "explanation" + i; + String quizExplanation = properties.getProperty(quizExplanationKey); + answers.put(quizExplanationKey, quizExplanation); + String descriptiveAnswerKey = "a" + i; + answers.put(descriptiveAnswerKey, properties.getProperty(descriptiveAnswerKey)); } return answers; } Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 05:32:07 UTC (rev 360) @@ -26,16 +26,39 @@ <entry key="wait-for-participants">true</entry> <entry key="number-of-rounds">17</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="q1">49</entry> +<entry key="a1">49%</entry> +<entry key="explanation1">An existing infrastructure efficiency of 20% + 29 tokens invested = 49% infrastructure efficiency.</entry> +<entry key="q2">5</entry> +<entry key="a2">5 cubic feet per second</entry> +<entry key="explanation2"> +<![CDATA[ +An existing infrastructure efficiency of 35% + 15 tokens invested = 50% infrastructure efficiency for the current round. +An infrastructure efficiency of 50% corresponds to a water delivery capacity +of 5 cubic feet per second. +]]> +</entry> +<entry key="q3">5</entry> +<entry key='a3'>5 cubic feet per second</entry> +<entry key="explanation3">Since there is only 30 cubic feet per second of water +available, the irrigation infrastructure capacity of 35 cubic feet per +second will not be fully used. When A opens their gate, they take 25 of the +30 cubic feet per second out of the canal, leaving 5 cubic feet per second for +B. +</entry> +<entry key="q4">25</entry> +<entry key="a4">25 cubic feet per second</entry> +<entry key="explanation4">If A has 25 cfps available and does not take any +water, the same amount is available for the people downstream. Since B, C and +D do not take water, 25 cfps is available for E.</entry> +<entry key="q5">7</entry> +<entry key="a5">7 tokens</entry> +<entry key="explanation5">If you invest 7 out of 10 tokens, you keep 3 tokens for yourself. If you apply 202 cubic feet of water to your field you will earn 4 tokens. 3 + 4 = 7 tokens </entry> +<entry key="q6">19</entry> +<entry key="a6">19 tokens</entry> +<entry key="explanation6">If you invest all 10 tokens, you keep 0 tokens from +your initial endowment. If you apply 555 cubic feet of water to your field +you will earn 19 tokens. 0 + 19 = 19 tokens.</entry> <entry key='final-instructions'> <![CDATA[ Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml 2009-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round0.xml 2009-11-13 05:32:07 UTC (rev 360) @@ -4,6 +4,7 @@ <comment>Irrigation experiment round configuration</comment> <entry key="practice-round">true</entry> +<entry key='reset-infrastructure-efficiency'>true</entry> <entry key="instructions"> <![CDATA[ Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round2.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round2.xml 2009-11-13 04:17:26 UTC (rev 359) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/round2.xml 2009-11-13 05:32:07 UTC (rev 360) @@ -11,7 +11,7 @@ <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 +sixty 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 was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-13 04:17:36
|
Revision: 359 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=359&view=rev Author: alllee Date: 2009-11-13 04:17:26 +0000 (Fri, 13 Nov 2009) Log Message: ----------- - updated build.xml build.dir to reflect maven src structure - added payoff image to interface - wired up facilitator / server events - added quiz questions to server configuration file Modified Paths: -------------- irrigation/trunk/build.xml 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/java/edu/asu/commons/irrigation/conf/ServerConfiguration.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/configuration/asu-fall-2009/mixed-pretest/irrigation.xml Added Paths: ----------- irrigation/trunk/src/main/resources/images/ irrigation/trunk/src/main/resources/images/payoff-structure.jpg Modified: irrigation/trunk/build.xml =================================================================== --- irrigation/trunk/build.xml 2009-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/build.xml 2009-11-13 04:17:26 UTC (rev 359) @@ -51,7 +51,7 @@ <property file="build.properties" /> <!-- default compilation properties --> <property name='src.dir' value='src/main/java'/> - <property name='build.dir' value='target'/> + <property name='build.dir' value='target/classes'/> <!-- default web & deployment properties --> <property name='web.dir' value='src/main/webapp'/> 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-13 04:17:26 UTC (rev 359) @@ -106,11 +106,11 @@ private void sendMessage() { String message = chatField.getText(); if (message != null && ! message.isEmpty() && targetIdentifier != null) { + displayMessage(String.format("%s -> %s", getChatHandle(getClientId()), getChatHandle(targetIdentifier)), + message); chatField.setText(""); irrigationClient.transmit(new ChatRequest(getClientId(), message, targetIdentifier)); - displayMessage( - String.format("%s -> %s", getChatHandle(getClientId()), getChatHandle(targetIdentifier)), - message); + } chatField.requestFocusInWindow(); } @@ -198,7 +198,6 @@ } catch (BadLocationException e) { e.printStackTrace(); - throw new RuntimeException(e); } } @@ -229,8 +228,8 @@ public void handle(final ChatEvent chatEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { - displayMessage(getChatHandle(chatEvent.getSource()) + " -> " - + getChatHandle(chatEvent.getTarget()), chatEvent.toString()); + displayMessage(String.format("%s -> %s", getChatHandle(chatEvent.getSource()), getChatHandle(chatEvent.getTarget())), + chatEvent.toString()); } }); } 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-13 04:17:26 UTC (rev 359) @@ -238,11 +238,18 @@ private String getQuizPage() { - StringBuilder builder = new StringBuilder(getServerConfiguration().getQuizPage(currentQuizPageNumber)); + StringBuilder builder = new StringBuilder(); + String quizPage = getServerConfiguration().getQuizPage(currentQuizPageNumber); String quizPageResponse = quizPageResponses.get(currentQuizPageNumber); - if (quizPageResponse != null) { - builder.append(quizPageResponse); + if (quizPageResponse == null) { + builder.append(quizPage); } + else { + quizPage = quizPage.replace("<input type=\"submit\" name=\"submit\" value=\"Submit\">", ""); + + builder.append(quizPage).append(quizPageResponse); + } + return builder.toString(); } @@ -438,8 +445,7 @@ for (Map.Entry<Object, Object> entry : responses.entrySet()) { sortedResponses.put((String) entry.getKey(), (String) entry.getValue()); } - - builder.append("<h3>Results</h3>"); + builder.append("<hr/><h2>Results</h2>"); for (Map.Entry<String, String> entry : sortedResponses.entrySet()) { String questionNumber = (String) entry.getKey(); if (questionNumber.charAt(0) == 'q') { @@ -456,9 +462,6 @@ builder.append(String.format("Correct answer: %s<br/>", correctAnswer)); builder.append(quizAnswers.get( "qDescriptiveAnswer" + number )).append("</p>"); } - else { - System.err.println("weird stuff in form data: " + questionNumber + ":" + entry.getValue()); - } } quizPageResponses.put(currentQuizPageNumber, builder.toString()); // no matter what we move on to the next question page @@ -468,6 +471,7 @@ } quizzesAnswered++; client.transmit(new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers)); + setInstructions(getQuizPage()); } }; @@ -550,7 +554,9 @@ StringBuilder builder = new StringBuilder(); builder.append( 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>", + "<h2>Current infrastructure efficiency: %d%%</h2>" + + "<h2>Current irrigation capacity: %d cubic feet per second</h2>" + + "<h2>Available water supply: %d cubic feet per second</h2>", infrastructureEfficiency, group.calculateFlowCapacity(infrastructureEfficiency), roundConfiguration.getWaterSupplyCapacity() 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-13 04:17:26 UTC (rev 359) @@ -11,11 +11,11 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.GroupLayout; +import javax.swing.ImageIcon; 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; @@ -23,7 +23,6 @@ import javax.swing.GroupLayout.ParallelGroup; import edu.asu.commons.irrigation.server.ClientData; -import edu.asu.commons.util.HtmlEditorPane; /** * $Id$ * @@ -84,10 +83,6 @@ private JTextField irrigationCapacityTextField; private JTextField waterSupplyTextField; - private HtmlEditorPane waterCollectedToTokensTable; - - private JScrollPane waterCollectedToTokensScrollPane; - public MainIrrigationGameWindow(IrrigationClient client) { super(); this.client = client; @@ -361,15 +356,8 @@ 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 JLabel getWaterCollectedToTokensTable() { + return new JLabel(new ImageIcon("images/payoff-structure.jpg")); } /** 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-13 04:17:26 UTC (rev 359) @@ -129,7 +129,7 @@ } public int getNumberOfQuestionPages() { - return assistant.getIntProperty("question-pages", 8); + return assistant.getIntProperty("question-pages", 2); } public int getChatDuration() { 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/Facilitator.java 2009-11-13 04:17:26 UTC (rev 359) @@ -32,20 +32,16 @@ */ public class Facilitator { - private final static Facilitator INSTANCE = new Facilitator(); + private Identifier id; - private Identifier id; // @jve:decl-index=0: - private ClientDispatcher dispatcher; private ServerConfiguration configuration; - private ServerDataModel serverGameState; // @jve:decl-index=0: + private ServerDataModel serverDataModel; // @jve:decl-index=0: private FacilitatorWindow facilitatorWindow; - private boolean experimentRunning = false; - private final EventChannel channel = EventChannelFactory.create(); private Facilitator() { @@ -71,10 +67,6 @@ }); } - public static Facilitator getInstance(){ - return INSTANCE; - } - public void setConfiguration(ServerConfiguration configuration) { if (configuration == null) { System.err.println("attempt to setConfiguration with null, ignoring"); @@ -85,10 +77,6 @@ } } - /** - * @param args - */ - /* * Connects facilitator to the server and registers with the server as a facilitator. * @@ -121,8 +109,8 @@ public static void main(String[] args) { Runnable createGuiRunnable = new Runnable() { public void run() { - Dimension dimension = new Dimension(600, 600); - Facilitator facilitator = Facilitator.getInstance(); + Dimension dimension = new Dimension(800, 600); + Facilitator facilitator = new Facilitator(); facilitator.initialize(); facilitator.connect(); JFrame frame = new JFrame(); @@ -161,23 +149,19 @@ return id; } - public ServerDataModel getServerGameState(){ - return serverGameState; + public ServerDataModel getServerDataModel(){ + return serverDataModel; } public ServerConfiguration getConfiguration(){ return configuration; } - public boolean isExperimentRunning(){ - return experimentRunning; - } - public RoundConfiguration getCurrentRoundConfiguration() { return configuration.getCurrentParameters(); } - public void setServerGameState(ServerDataModel serverGameState) { - this.serverGameState = serverGameState; + public void setServerDataModel(ServerDataModel serverGameState) { + this.serverDataModel = serverGameState; } } 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-13 04:17:26 UTC (rev 359) @@ -14,6 +14,8 @@ import javax.swing.SwingUtilities; import edu.asu.commons.irrigation.events.BeginChatRoundRequest; +import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; +import edu.asu.commons.irrigation.events.ShowQuizRequest; import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; @@ -46,6 +48,10 @@ private JButton showInstructionsButton; + private JButton showQuizButton; + + private JButton showScreenshotButton; + private JButton displayInvestmentButton; private StringBuilder builder = new StringBuilder(); @@ -71,7 +77,9 @@ buttonPanel.add(getShowInstructionsButton()); buttonPanel.add(getBeginChatButton()); buttonPanel.add(getDisplayInvestmentButton()); + buttonPanel.add(getShowScreenshotButton()); buttonPanel.add(getStartRoundButton()); + buttonPanel.add(getShowQuizButton()); buttonPanel.add(getStartRoundOverrideButton()); add(buttonPanel, BorderLayout.NORTH); editorPane = new HtmlEditorPane(); @@ -144,20 +152,9 @@ return facilitator; } - /** - * This method initializes Stop - * - * @return javax.swing.JButton - */ - /** - * This method initializes Start_Round_Button - * - * @return javax.swing.JButton - */ - private JButton getStartRoundButton() { + private JButton getStartRoundButton() { if (startRoundButton == null) { - startRoundButton = new JButton(); - startRoundButton.setText("Start Round"); + startRoundButton = new JButton("Start round"); startRoundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { facilitator.sendBeginRoundRequest(); @@ -167,6 +164,18 @@ return startRoundButton; } + private JButton getShowQuizButton() { + if (showQuizButton == null) { + showQuizButton = new JButton("Show quiz"); + showQuizButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.transmit(new ShowQuizRequest(facilitator.getId())); + } + }); + } + return showQuizButton; + } + public void setText(final String text) { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -218,4 +227,16 @@ setText(builder.toString()); } + private JButton getShowScreenshotButton() { + if (showScreenshotButton == null) { + showScreenshotButton = new JButton("Show screenshot"); + showScreenshotButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + facilitator.transmit(new ShowGameScreenshotRequest(facilitator.getId())); + } + }); + } + return showScreenshotButton; + } + } 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-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-13 04:17:26 UTC (rev 359) @@ -21,7 +21,6 @@ import edu.asu.commons.irrigation.events.BeginChatRoundRequest; import edu.asu.commons.irrigation.events.ClientUpdateEvent; import edu.asu.commons.irrigation.events.CloseGateEvent; -import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.irrigation.events.EndRoundEvent; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.InfrastructureUpdateEvent; @@ -31,7 +30,10 @@ import edu.asu.commons.irrigation.events.QuizResponseEvent; import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; +import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; +import edu.asu.commons.irrigation.events.ShowQuizRequest; +import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.net.Dispatcher; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.event.ConnectionEvent; @@ -93,6 +95,26 @@ } private void initializeFacilitatorHandlers() { + addEventProcessor(new EventTypeProcessor<ShowGameScreenshotRequest>(ShowGameScreenshotRequest.class) { + public void handle(ShowGameScreenshotRequest request) { + // FIXME: check request id against facilitator id? + synchronized (clients) { + for (Identifier id: clients.keySet()) { + transmit(new ShowGameScreenshotRequest(id)); + } + } + } + }); + addEventProcessor(new EventTypeProcessor<ShowQuizRequest>(ShowQuizRequest.class) { + public void handle(ShowQuizRequest request) { + // FIXME: check request id against facilitator id? + synchronized (clients) { + for (Identifier id: clients.keySet()) { + transmit(new ShowQuizRequest(id)); + } + } + } + }); addEventProcessor(new EventTypeProcessor<FacilitatorRegistrationRequest>(FacilitatorRegistrationRequest.class) { @Override public void handle(FacilitatorRegistrationRequest event) { Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 00:23:33 UTC (rev 358) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 04:17:26 UTC (rev 359) @@ -104,8 +104,9 @@ <![CDATA[ <img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> -<b>Table 2</b>: Earnings resulting from the amount of water applied to your field. - +<p> +<b>Table 2</b>: Number of tokens earned from the water applied to your field. +</p> <table border="1" cellspacing="2" cellpadding="2"> <thead> <th>Water units received (cubic feet)</th> @@ -189,173 +190,96 @@ <entry key="quiz-page1"> <![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> +<p> +The first two questions deal with irrigation infrastructure investment using Table +1. +</p> +<p> +<b>Table 1</b>: The water delivery capacity as a function of irrigation +infrastructure efficiency +</p> +<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 key="quiz-page2"> -<![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="quiz-page3"> -<![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? -(<small><b>Note: only enter a number, you don't need to add the % sign</b></small>)<br> -<input type="text" name="q3" value = ""> +efficiency?<br> +<input type="text" name="q1" 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 = ""> +Suppose the infrastructure efficiency in the last round was 60%. For the current +round, the efficiency will decline by an amount of 25% for a resulting +infrastructure efficiency of 35%. If the members of your group invest a total of 15 +tokens, what will be your group's resulting water delivery capacity?<br> + +<input type="text" name="q2" value = ""> cubic feet per second <br><br> -<input type="submit" name="submit" value="Submit"><br> -<br> -</form> -]]> -</entry> - -<entry key="quiz-page4"> -<![CDATA[ +<b>The next two questions deal with the capacity of the irrigation system in relation +to the actual amount of water available.</b> <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? +If the irrigation efficiency is between 71 and 80%, the water delivery capacity of +the irrigation system is 35 cubic feet per second. Suppose the water supply +available to your group is 30 cubic feet per second and A opens their gate, +diverting water at 25 cubic feet per second. What is the available water flow for +B? <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> +<input type='text' name='q3' value=''> cubic feet per second <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[ +Question 4: +If the available water delivery capacity is 25 cubic feet per second and A, B, C, +and D are not using water, how much cubic feet of water per second is available for +E?<br> +<input type='text' name='q4' value=''> cubic feet per second <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? + +<input type="submit" name="submit" value="Submit"><br> <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"> +<entry key="quiz-page2"> <![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". +The final two questions cover the number of tokens you can earn in within a round. </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. - +<b>Table 2</b>: Tokens earned from the amount of water applied to your field. <table border="1" cellspacing="2" cellpadding="2"> <thead> <th>Water units received (cubic feet)</th> @@ -407,15 +331,30 @@ <td>> 899</td><td>0</td> </tr> </table> - +<p> 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). +tokens you receive from applying water to your fields and growing a crop. As an +example, suppose you invest 6 tokens out of the 10 tokens you are endowed with at +the start of each round. If you receive 333 cubic feet of water you would receive a +grand total of 19 tokens (4 tokens left over from your 10 token endowment + 15 +tokens for growing a crop with 333 cubic feet of water). Since each token is worth +$0.05, you would have an actual earnings of $0.85 for that round. +<form> +Question 5:<br> +If you invest 7 of the 10 tokens you start with and you apply 202 cubic feet of +water to your fields, what is the total number of tokens you will have earned at the +end of the round?<br> +<input type="text" name="q5" value="">tokens +<br><br> +Question 6:<br> +If you invest all 10 tokens you start with and you apply 555 cubic feet of water to +your fields, what is the total number of tokens you will have earned at the end of +the round?<br> +<input type="text" name="q6" value="">tokens +<br><br> +<input type="submit" name="submit" value="Submit"> +</form> ]]> </entry> @@ -475,93 +414,6 @@ ]]> </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 <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="5">5<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="investment-instructions"> <![CDATA[ <h3>Invest tokens in the irrigation infrastructure</h3> Added: irrigation/trunk/src/main/resources/images/payoff-structure.jpg =================================================================== (Binary files differ) Property changes on: irrigation/trunk/src/main/resources/images/payoff-structure.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-13 00:50:32
|
Revision: 358 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=358&view=rev Author: alllee Date: 2009-11-13 00:23:33 +0000 (Fri, 13 Nov 2009) Log Message: ----------- removing unused events + other code hygiene / cleanup. Added quiz logic and display logic / events for facilitator to perform new data flow. Still need to implement facilitator sending the appropriate requests to the server and have the server dispatch those requests to all clients. 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/conf/RoundConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/CloseGateEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.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/IrrigationServer.java irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml Added Paths: ----------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/DisplaySubmitTokenRequest.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ExperimentDurationEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadCompleteEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadedEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizCompletedEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ServerGameStateEvent.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/StartDownload.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/TransferFileInformationEvent.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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-13 00:23:33 UTC (rev 358) @@ -11,14 +11,15 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.TreeMap; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; @@ -29,7 +30,7 @@ import edu.asu.commons.irrigation.conf.RoundConfiguration; import edu.asu.commons.irrigation.conf.ServerConfiguration; import edu.asu.commons.irrigation.events.EndRoundEvent; -import edu.asu.commons.irrigation.events.QuizCompletedEvent; +import edu.asu.commons.irrigation.events.QuizResponseEvent; import edu.asu.commons.irrigation.server.ClientData; import edu.asu.commons.irrigation.server.GroupDataModel; import edu.asu.commons.util.HtmlEditorPane; @@ -39,7 +40,6 @@ * $Id$ * * The root experiment window placed in the client's JFrame. - * * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ @@ -56,15 +56,15 @@ private HtmlEditorPane instructionsEditorPane; - private JPanel investTokensPanel = null; + private JPanel tokenInvestmentPanel; - private JPanel graphPanel; + private JPanel contributionInformationPanel; private JTextField investedTokensTextField; private JButton submitTokensButton; - private InfrastructureEfficiencyChartPanel infrastructureEfficiencyChartPanel = null; + private InfrastructureEfficiencyChartPanel infrastructureEfficiencyChartPanel; private IrrigationClient client; @@ -84,7 +84,7 @@ private JPanel instructionsPanel; - private int instructionNumber = 1; + private int currentQuizPageNumber = 1; private JPanel submitTokenPanel; @@ -92,59 +92,58 @@ private JScrollPane tokenInstructionsScrollPane; - private JLabel quizMessageLabel; + private int quizzesAnswered = 0; - private int pagesTraversed = 0; - private JPanel pieChartPanel; private TokenInvestmentPieChartPanel pieChart; - private CanalAnimationPanel canalAnimationPanel; +// private CanalAnimationPanel canalAnimationPanel; private CardLayout cardLayout; - private int numberOfGeneralInstructionPages; + private int numberOfQuestionPages; + + private Map<Integer, String> quizPageResponses = new HashMap<Integer, String>(); + public ExperimentGameWindow(IrrigationClient client) { this.client = client; this.clientDataModel = client.getClientDataModel(); - this.numberOfGeneralInstructionPages = getServerConfiguration().getNumberOfGeneralInstructionPages(); + this.numberOfQuestionPages = getServerConfiguration().getNumberOfQuestionPages(); } void initialize() { cardLayout = new CardLayout(); setLayout(cardLayout); - - setInstructions(getGeneralInstructions(0)); - + setInstructions(getServerConfiguration().getWelcomeInstructions()); addToCardLayout(getInstructionsPanel()); // irrigationGamePanel = new IrrigationGamePanel(client); irrigationGamePanel = new MainIrrigationGameWindow(client); addToCardLayout(irrigationGamePanel); - addToCardLayout(getInvestTokensPanel()); + addToCardLayout(getTokenInvestmentPanel()); addToCardLayout(getChatPanel()); - addToCardLayout(getGraphPanel()); + addToCardLayout(getContributionInformationPanel()); } private void addToCardLayout(Component component) { add(component, component.getName()); } - private JPanel getInvestTokensPanel() { - if (investTokensPanel == null) { - investTokensPanel = new JPanel(); - investTokensPanel.setName("Invest tokens panel"); - investTokensPanel.setLayout(new BorderLayout()); + private JPanel getTokenInvestmentPanel() { + if (tokenInvestmentPanel == null) { + tokenInvestmentPanel = new JPanel(); + tokenInvestmentPanel.setName("Token investment panel"); + tokenInvestmentPanel.setLayout(new BorderLayout()); tokenInstructionsEditorPane = createInstructionsEditorPane(); tokenInstructionsScrollPane = new JScrollPane(tokenInstructionsEditorPane); - investTokensPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); + tokenInvestmentPanel.add(tokenInstructionsScrollPane, BorderLayout.CENTER); tokenInstructionsEditorPane.setCaretPosition(0); tokenInstructionsEditorPane.repaint(); - investTokensPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); - investTokensPanel.setBackground(Color.WHITE); + tokenInvestmentPanel.add(getSubmitTokenPanel(), BorderLayout.SOUTH); + tokenInvestmentPanel.setBackground(Color.WHITE); } - return investTokensPanel; + return tokenInvestmentPanel; } private JPanel getSubmitTokenPanel() { @@ -173,21 +172,17 @@ instructionsPanel.setName("Instructions panel"); instructionsPanel.setLayout(new BorderLayout()); instructionsPanel.add(getInstructionsScrollPane(), BorderLayout.CENTER); - instructionsPanel.add(getInstructionsNavigationPanel(), BorderLayout.PAGE_END); + instructionsPanel.add(getQuizNavigationPanel(), BorderLayout.PAGE_END); } return instructionsPanel; } - private JPanel getInstructionsNavigationPanel() { + private JPanel getQuizNavigationPanel() { if (instructionsNavigationPanel == null) { instructionsNavigationPanel = new JPanel(); instructionsNavigationPanel.setLayout(new BorderLayout()); instructionsNavigationPanel.add(getPreviousButton(), BorderLayout.LINE_START); instructionsNavigationPanel.add(getNextButton(), BorderLayout.LINE_END); - // displays quiz messages (correct/incorrect answer). - quizMessageLabel = new JLabel(); - quizMessageLabel.setHorizontalAlignment(JLabel.CENTER); - instructionsNavigationPanel.add(quizMessageLabel, BorderLayout.CENTER); } return instructionsNavigationPanel; } @@ -199,25 +194,13 @@ previousButton.setEnabled(false); previousButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - quizMessageLabel.setText(""); // getting the next instruction Number - if (instructionNumber > 1) { - instructionNumber--; + if (currentQuizPageNumber > 1) { + currentQuizPageNumber--; + setInstructions(getQuizPage()); } - previousButton.setEnabled(instructionNumber > 1); + previousButton.setEnabled(currentQuizPageNumber > 1); 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 more like - // if instructions.hasAnimation() - if (instructionNumber == 5) { - getInstructionsPanel().add(getCanalAnimationPanel(), BorderLayout.PAGE_START); - } - else { - - getInstructionsPanel().remove(getCanalAnimationPanel()); - } - getInstructionsPanel().revalidate(); } }); } @@ -231,22 +214,14 @@ nextButton.setEnabled(false); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - quizMessageLabel.setText(""); previousButton.setEnabled(true); - if (instructionNumber >= pagesTraversed){ + if (currentQuizPageNumber >= quizzesAnswered){ nextButton.setEnabled(false); } - if (instructionNumber < numberOfGeneralInstructionPages) { - instructionNumber++; - setInstructions(getGeneralInstructions(instructionNumber,pagesTraversed)); + if (currentQuizPageNumber < numberOfQuestionPages) { + currentQuizPageNumber++; + setInstructions(getQuizPage()); } - if(instructionNumber == 5) { - getInstructionsPanel().add(getCanalAnimationPanel(), BorderLayout.PAGE_START); - } - else { - getInstructionsPanel().remove(getCanalAnimationPanel()); - } - getInstructionsPanel().revalidate(); } }); @@ -254,26 +229,21 @@ return nextButton; } - private CanalAnimationPanel getCanalAnimationPanel() { - if (canalAnimationPanel == null) { - canalAnimationPanel = new CanalAnimationPanel(40); - } - return canalAnimationPanel; - } +// private CanalAnimationPanel getCanalAnimationPanel() { +// if (canalAnimationPanel == null) { +// canalAnimationPanel = new CanalAnimationPanel(40); +// } +// return canalAnimationPanel; +// } - /** - * This returns the string of general instructions from the irrigation.xml file - * where the general instructions are stored - * @param pagesTraversed - * - * @return - */ - private String getGeneralInstructions(int pageNumber, int pagesTraversed) { - return getServerConfiguration().getGeneralInstructions(pageNumber, pagesTraversed, clientDataModel.getPriority()); - } - private String getGeneralInstructions(int pageNumber) { - return getServerConfiguration().getGeneralInstructions(pageNumber); + private String getQuizPage() { + StringBuilder builder = new StringBuilder(getServerConfiguration().getQuizPage(currentQuizPageNumber)); + String quizPageResponse = quizPageResponses.get(currentQuizPageNumber); + if (quizPageResponse != null) { + builder.append(quizPageResponse); + } + return builder.toString(); } private ServerConfiguration getServerConfiguration() { @@ -356,19 +326,15 @@ private void addCenterComponent(Component newCenterComponent) { cardLayout.show(this, newCenterComponent.getName()); revalidate(); - repaint(); } public void startRound(final RoundConfiguration configuration) { - Runnable runnable = new Runnable() { + SwingUtilities.invokeLater(new Runnable() { public void run() { - getCanalAnimationPanel().stopTimer(); - disableInstructions(); addCenterComponent(irrigationGamePanel); irrigationGamePanel.startRound(); } - }; - SwingUtilities.invokeLater(runnable); + }); } public void update() { @@ -445,64 +411,69 @@ private void setInstructions(final String instructions) { SwingUtilities.invokeLater(new Runnable() { public void run() { - getInstructionsEditorPane().setText(instructions); - getInstructionsEditorPane().setCaretPosition(0); + instructionsEditorPane.setText(instructions); + instructionsEditorPane.setCaretPosition(0); + addCenterComponent(getInstructionsPanel()); getInstructionsScrollPane().revalidate(); } }); } - + private ActionListener createQuizListener(final ServerConfiguration configuration) { return new ActionListener() { private Map<String, String> quizAnswers = configuration.getQuizAnswers(); - public void actionPerformed(ActionEvent e){ + public synchronized void actionPerformed(ActionEvent e) { + if (quizPageResponses.containsKey(currentQuizPageNumber)) { + // this form has already been submit. + // FIXME: report to user? + return; + } FormActionEvent formEvent = (FormActionEvent) e; Properties responses = formEvent.getData(); List<String> incorrectAnswers = new ArrayList<String>(); responses.list(System.err); + StringBuilder builder = new StringBuilder(); + TreeMap<String, String> sortedResponses = new TreeMap<String, String>(); + // sort responses so we can put them in order. for (Map.Entry<Object, Object> entry : responses.entrySet()) { + sortedResponses.put((String) entry.getKey(), (String) entry.getValue()); + } + + builder.append("<h3>Results</h3>"); + for (Map.Entry<String, String> entry : sortedResponses.entrySet()) { String questionNumber = (String) entry.getKey(); if (questionNumber.charAt(0) == 'q') { + String number = questionNumber.substring(1, questionNumber.length()); String response = (String) entry.getValue(); String correctAnswer = quizAnswers.get(questionNumber); + builder.append(String.format("<p><b>Question %s</b><br/>", number)); + String color = "blue"; if (! response.equals(correctAnswer)) { incorrectAnswers.add(questionNumber); + color = "red"; } + builder.append(String.format("Your answer: <font color='%s'>%s</font><br/>", color, response)); + builder.append(String.format("Correct answer: %s<br/>", correctAnswer)); + builder.append(quizAnswers.get( "qDescriptiveAnswer" + number )).append("</p>"); } + else { + System.err.println("weird stuff in form data: " + questionNumber + ":" + entry.getValue()); + } } - printIncorrectAnswerList(incorrectAnswers); - if (incorrectAnswers.isEmpty()) { + quizPageResponses.put(currentQuizPageNumber, builder.toString()); + // no matter what we move on to the next question page + // tell them what was right and what was wrong. + if (currentQuizPageNumber < numberOfQuestionPages) { nextButton.setEnabled(true); - pagesTraversed++; - //System.out.println("quiz :instruction number : "+instructionNumber+" pages traversed"+pagesTraversed); - setInstructions(getGeneralInstructions(instructionNumber,pagesTraversed)); - addCenterComponent(getInstructionsPanel()); - quizMessageLabel.setForeground(Color.BLUE); - quizMessageLabel.setText("You answered the question(s) correctly. Please continue to the next page by clicking 'Next'"); - // notify the server and also notify the participant. - //StringBuilder builder = new StringBuilder(configuration.getInstructions()); - //builder.append("<br><b>Congratulations!</b> You have answered all questions correctly."); - //setInstructions(builder.toString()); - client.transmit(new QuizCompletedEvent(client.getId(),instructionNumber)); } - else { - nextButton.setEnabled(false); - quizMessageLabel.setForeground(Color.RED); - quizMessageLabel.setText("You did not answer the question(s) correctly. Please try again."); - } + quizzesAnswered++; + client.transmit(new QuizResponseEvent(client.getId(), currentQuizPageNumber, responses, incorrectAnswers)); } - - private void printIncorrectAnswerList(List<String> incorrectAnswers) { - System.out.println("Size of the incorrect answers is :"+incorrectAnswers.size()); - for(int i=0;i<incorrectAnswers.size();i++){ - System.out.println("Incorrect Answers :"+incorrectAnswers.get(i)); - } - } }; } - public void displayTokenContributions(final ClientData clientData) { + public void displayContributionInformation(final ClientData clientData) { GroupDataModel groupDataModel = clientData.getGroupDataModel(); int totalContributedTokens = groupDataModel.getTotalContributedTokens(); final StringBuilder builder = new StringBuilder(); @@ -527,25 +498,24 @@ contributionInformationTextArea.setText(builder.toString()); infrastructureEfficiencyChartPanel.initialize(); pieChart.setClientData(clientData); - addCenterComponent(getGraphPanel()); + addCenterComponent(getContributionInformationPanel()); } }); irrigationGamePanel.setClientDataModel(clientDataModel); } - public JPanel getGraphPanel() { - if (graphPanel == null) { - graphPanel = new JPanel(); - graphPanel.setName("Graph panel"); - graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); - graphPanel.add(getPieChartPanel()); - graphPanel.add(Box.createVerticalStrut(15)); + public JPanel getContributionInformationPanel() { + if (contributionInformationPanel == null) { + contributionInformationPanel = new JPanel(); + contributionInformationPanel.setName("Graph panel"); + contributionInformationPanel.setLayout(new BoxLayout(contributionInformationPanel, BoxLayout.Y_AXIS)); + contributionInformationPanel.add(getPieChartPanel()); + contributionInformationPanel.add(Box.createVerticalStrut(15)); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); - - graphPanel.add(contributionInformationTextArea); + contributionInformationPanel.add(contributionInformationTextArea); } - return graphPanel; + return contributionInformationPanel; } private JPanel getPieChartPanel() { @@ -564,19 +534,19 @@ } - public void updateTokenInstructionsPanel() { + public void showTokenInvestmentScreen() { Runnable runnable = new Runnable() { public void run() { GroupDataModel group = clientDataModel.getGroupDataModel(); RoundConfiguration roundConfiguration = clientDataModel.getRoundConfiguration(); int infrastructureEfficiency = 0; - if (roundConfiguration.isPracticeRound() || roundConfiguration.isFirstRound()) { + if (roundConfiguration.shouldResetInfrastructureEfficiency()) { infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); } - addCenterComponent(getInvestTokensPanel()); + addCenterComponent(getTokenInvestmentPanel()); StringBuilder builder = new StringBuilder(); builder.append( String.format( @@ -594,16 +564,11 @@ } public void updateRoundInstructions(RoundConfiguration roundConfiguration) { - info("Updating round instructions: " + roundConfiguration.getInstructions()); - // if this is the first round, show the general instructions. - if (roundConfiguration.isFirstRound()) { - - } - else { + if (! roundConfiguration.isFirstRound()) { instructionsBuilder.append(roundConfiguration.getInstructions()); instructionsBuilder.append("<hr/>"); int irrigationCapacity = clientDataModel.getGroupDataModel().getIrrigationCapacity(); - int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); +// int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); if (roundConfiguration.shouldResetInfrastructureEfficiency()) { instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75%."); } @@ -619,7 +584,6 @@ } setInstructions(instructionsBuilder.toString()); } - addCenterComponent(getInstructionsPanel()); } private ChatPanel getChatPanel() { @@ -650,7 +614,7 @@ public void actionPerformed(ActionEvent event) { final long timeRemaining = endTime - System.currentTimeMillis(); if (timeRemaining < 0) { - updateTokenInstructionsPanel(); + showTokenInvestmentScreen(); getInvestedTokensTextField().requestFocusInWindow(); timer.stop(); timer = null; @@ -664,13 +628,37 @@ } } - private void disableInstructions() { - quizMessageLabel.setText(""); - getInstructionsPanel().remove(getInstructionsNavigationPanel()); + public void showQuiz() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + getInstructionsPanel().add(getQuizNavigationPanel(), BorderLayout.PAGE_END); + getInstructionsPanel().revalidate(); + } + }); + setInstructions(getQuizPage()); } + + /** + * Should only be invoked when the instructions navigation panel is done. + * How do we know when it's done? When the user adds a new + */ + public void disableQuiz() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + getInstructionsPanel().remove(getQuizNavigationPanel()); + getInstructionsPanel().revalidate(); + } + }); + } + + public void showGameScreenshot() { + setInstructions(getServerConfiguration().getGameScreenshotInstructions()); + } - public void enableInstructions() { - setInstructions(getGeneralInstructions(1,pagesTraversed)); - addCenterComponent(getInstructionsPanel()); + /** + * Invoked when the show instructions button is pressed. + */ + public void showInstructions() { + setInstructions(getServerConfiguration().getInitialInstructions()); } } 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-11-13 00:23:33 UTC (rev 358) @@ -15,7 +15,6 @@ import edu.asu.commons.irrigation.events.BeginChatRoundRequest; import edu.asu.commons.irrigation.events.ClientUpdateEvent; import edu.asu.commons.irrigation.events.CloseGateEvent; -import edu.asu.commons.irrigation.events.DisplaySubmitTokenRequest; import edu.asu.commons.irrigation.events.EndRoundEvent; import edu.asu.commons.irrigation.events.InfrastructureUpdateEvent; import edu.asu.commons.irrigation.events.InvestedTokensEvent; @@ -23,7 +22,10 @@ import edu.asu.commons.irrigation.events.PauseRequest; import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; +import edu.asu.commons.irrigation.events.ShowGameScreenshotRequest; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; +import edu.asu.commons.irrigation.events.ShowQuizRequest; +import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.net.ClientDispatcher; import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; @@ -169,7 +171,7 @@ public void handle(InfrastructureUpdateEvent event) { System.err.println("Received group update event: " + event); clientDataModel.setGroupDataModel(event.getGroupDataModel()); - experimentGameWindow.displayTokenContributions(event.getClientData()); + experimentGameWindow.displayContributionInformation(event.getClientData()); } }); channel.add(this, new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { @@ -191,9 +193,9 @@ experimentGameWindow.update(); } }); - channel.add(this, new EventTypeProcessor<DisplaySubmitTokenRequest>(DisplaySubmitTokenRequest.class) { - public void handle(DisplaySubmitTokenRequest request) { - experimentGameWindow.updateTokenInstructionsPanel(); + channel.add(this, new EventTypeProcessor<ShowTokenInvestmentScreenRequest>(ShowTokenInvestmentScreenRequest.class) { + public void handle(ShowTokenInvestmentScreenRequest request) { + experimentGameWindow.showTokenInvestmentScreen(); } }); channel.add(this, new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { @@ -204,9 +206,19 @@ }); channel.add(this, new EventTypeProcessor<ShowInstructionsRequest>(ShowInstructionsRequest.class) { public void handle(ShowInstructionsRequest request) { - experimentGameWindow.enableInstructions(); + experimentGameWindow.showInstructions(); } }); + channel.add(this, new EventTypeProcessor<ShowQuizRequest>(ShowQuizRequest.class) { + public void handle(ShowQuizRequest request) { + experimentGameWindow.showQuiz(); + } + }); + channel.add(this, new EventTypeProcessor<ShowGameScreenshotRequest>(ShowGameScreenshotRequest.class) { + public void handle(ShowGameScreenshotRequest request) { + experimentGameWindow.showGameScreenshot(); + } + }); } public ClientDataModel getClientDataModel() { 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/RoundConfiguration.java 2009-11-13 00:23:33 UTC (rev 358) @@ -122,8 +122,8 @@ } public Map<String, String> getQuizAnswers() { - Properties properties = getProperties(); if (isQuizEnabled()) { + Properties properties = getProperties(); Map<String, String> answers = new HashMap<String, String>(); for (int i = 1; properties.containsKey("q" + i); i++) { String key = "q" + i; 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/conf/ServerConfiguration.java 2009-11-13 00:23:33 UTC (rev 358) @@ -64,41 +64,6 @@ return CONFIGURATION_FILE_NAME; } - /** - * Returns the appropriate general instructions text, performing logic for adding - * positions and quizzes. - * - * @param instructionPageNumber - * @param pagesTraversed - * @return - */ - public String getGeneralInstructions( - int instructionPageNumber, - int pagesTraversed, - int clientPosition) - { - // FIXME: get rid of hard coded instruction page constants. - if (instructionPageNumber < 11) { - StringBuilder builder = new StringBuilder(); - if (instructionPageNumber == 4) { - builder.append("Your position: ").append(toPriorityString(clientPosition)); - } - builder.append(getGeneralInstructions(instructionPageNumber)); -// 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) { - builder.append( getQuizQuestion(instructionPageNumber) ); - } - return builder.toString(); - } - else { - return getGeneralInstructions(instructionPageNumber); - } - } - private final static String[] PRIORITY_STRINGS = { "A", "B", "C", "D", "E" }; public String toPriorityString(int clientPriority) { @@ -124,6 +89,10 @@ public String getInitialInstructions() { return assistant.getProperty("initial-instructions"); } + + public String getWelcomeInstructions() { + return assistant.getProperty("welcome-instructions"); + } public Map<String, String> getQuizAnswers() { Properties properties = assistant.getProperties(); @@ -132,6 +101,9 @@ String key = "q" + i; String answer = properties.getProperty(key); answers.put(key, answer); + String quizDescriptiveAnswerKey = "qDescriptiveAnswer" + i; + String quizDescriptiveAnswer = properties.getProperty(quizDescriptiveAnswerKey); + answers.put(quizDescriptiveAnswerKey, quizDescriptiveAnswer); } return answers; } @@ -140,10 +112,8 @@ return assistant.getProperty("general-instructionsq" + pageNumber); } - public String getGeneralInstructions(int pageNumber) { - return assistant.getProperty( - "general-instructions"+pageNumber, - "<b>No instructions available for this round</b>"); + public String getQuizPage(int pageNumber) { + return assistant.getProperty("quiz-page"+pageNumber); } public String getWaterCollectedToTokensTable() { @@ -158,8 +128,8 @@ return assistant.getProperty("investment-instructions"); } - public int getNumberOfGeneralInstructionPages() { - return assistant.getIntProperty("general-instruction-pages", 8); + public int getNumberOfQuestionPages() { + return assistant.getIntProperty("question-pages", 8); } public int getChatDuration() { @@ -179,4 +149,8 @@ ); } + public String getGameScreenshotInstructions() { + return assistant.getProperty("game-screenshot-instructions"); + } + } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/CloseGateEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/CloseGateEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/CloseGateEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,12 +1,16 @@ package edu.asu.commons.irrigation.events; +import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; /** - * @author Sanket + * $Id$ + * * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ */ -public class CloseGateEvent extends TransferFileInformationEvent { +public class CloseGateEvent extends AbstractPersistableEvent { private static final long serialVersionUID = -6932559955912875464L; Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/DisplaySubmitTokenRequest.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/DisplaySubmitTokenRequest.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/DisplaySubmitTokenRequest.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,14 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.FacilitatorRequest; -import edu.asu.commons.net.Identifier; - -public class DisplaySubmitTokenRequest extends AbstractEvent implements FacilitatorRequest { - - private static final long serialVersionUID = -4133284727930840712L; - - public DisplaySubmitTokenRequest(Identifier id) { - super(id); - } -} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ExperimentDurationEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ExperimentDurationEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ExperimentDurationEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,28 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.event.ExperimentUpdateEvent; -import edu.asu.commons.net.Identifier; - -/** - * @author Sanket - * - */ -public class ExperimentDurationEvent extends AbstractEvent implements ExperimentUpdateEvent { - - private static final long serialVersionUID = 5074385986630790547L; - - private final long time; - - public ExperimentDurationEvent(Identifier id,long time) { - super(id); - this.time = time; - } - - public long getTime(){ - return time; - } - - - -} Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FacilitatorEndRoundEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -5,8 +5,11 @@ import edu.asu.commons.net.Identifier; /** + * $Id$ + * + * Updates the facilitator with the end of the round information (used to build the debriefing). + * * @author Sanket - * */ public class FacilitatorEndRoundEvent extends AbstractEvent { @@ -23,7 +26,7 @@ } public boolean isLastRound(){ - return serverDataModel.getRoundConfiguration().getParentConfiguration().isLastRound(); + return serverDataModel.getRoundConfiguration().isLastRound(); } } Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadCompleteEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadCompleteEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadCompleteEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,20 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.net.Identifier; - -/** - * @author Sanket - * - */ -public class FileDownloadCompleteEvent extends AbstractEvent { - - private static final long serialVersionUID = 2566276891605754835L; - - public FileDownloadCompleteEvent(Identifier id) { - super(id); - } - - - -} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadedEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadedEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/FileDownloadedEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,23 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractPersistableEvent; -import edu.asu.commons.net.Identifier; - - - -public class FileDownloadedEvent extends AbstractPersistableEvent { - - private static final long serialVersionUID = 1061602349717830635L; - - private final String fileNumber; - - public FileDownloadedEvent(Identifier id, String fileNumber) { - super(id); - this.fileNumber = fileNumber; - } - - public String getFileNumber() { - return fileNumber; - } - -} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizCompletedEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizCompletedEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizCompletedEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,31 +0,0 @@ -/** - * - */ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.net.Identifier; - -/** - * @author Sanket - * - */ -public class QuizCompletedEvent extends AbstractEvent { - - /** - * - */ - private static final long serialVersionUID = -7081410122722056083L; - - private int instructionNumber = 0; - - public QuizCompletedEvent(Identifier id,int instructionNumber){ - super(id); - this.instructionNumber = instructionNumber; - } - - public int getInstructionNumber(){ - return instructionNumber; - } - -} Copied: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java (from rev 356, irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizCompletedEvent.java) =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/QuizResponseEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -0,0 +1,47 @@ +package edu.asu.commons.irrigation.events; + +import java.util.List; +import java.util.Properties; + +import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.event.ClientRequest; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * A client's quiz responses for a given quiz page. + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class QuizResponseEvent extends AbstractPersistableEvent implements ClientRequest { + + private static final long serialVersionUID = -7081410122722056083L; + + private int quizPage; + + private Properties responses; + + private List<String> incorrectAnswers; + + public QuizResponseEvent(Identifier id, int quizPage, Properties responses, List<String> incorrectAnswers) { + super(id); + this.quizPage = quizPage; + this.responses = responses; + this.incorrectAnswers = incorrectAnswers; + } + + public int getQuizPage(){ + return quizPage; + } + + public Properties getResponses() { + return responses; + } + + public List<String> getIncorrectAnswers() { + return incorrectAnswers; + } +} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ServerGameStateEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ServerGameStateEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ServerGameStateEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,35 +0,0 @@ -package edu.asu.commons.irrigation.events; - - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.irrigation.server.ServerDataModel; -import edu.asu.commons.net.Identifier; - -/** - * @author Sanket - * - */ -public class ServerGameStateEvent extends AbstractEvent { - /** - * - */ - private static final long serialVersionUID = 6430739901754414073L; - - private ServerDataModel serverGameState; - - private long timeLeft; - - public ServerGameStateEvent(Identifier id, ServerDataModel serverGameState, long timeLeft) { - super(id); - this.serverGameState = serverGameState; - this.timeLeft = timeLeft; - } - - public ServerDataModel getServerGameState(){ - return serverGameState; - } - - public long getTimeLeft(){ - return timeLeft; - } -} Added: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowGameScreenshotRequest.java 2009-11-13 00:23:33 UTC (rev 358) @@ -0,0 +1,15 @@ +package edu.asu.commons.irrigation.events; + +import edu.asu.commons.event.AbstractEvent; +import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.net.Identifier; + +public class ShowGameScreenshotRequest extends AbstractEvent implements FacilitatorRequest { + + private static final long serialVersionUID = -344715300306788401L; + + public ShowGameScreenshotRequest(Identifier id) { + super(id); + } + +} Added: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowQuizRequest.java 2009-11-13 00:23:33 UTC (rev 358) @@ -0,0 +1,23 @@ +package edu.asu.commons.irrigation.events; + +import edu.asu.commons.event.AbstractEvent; +import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Facilitator request to display the quiz. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class ShowQuizRequest extends AbstractEvent implements FacilitatorRequest { + + private static final long serialVersionUID = 383560843031641044L; + + public ShowQuizRequest(Identifier id) { + super(id); + } + +} Copied: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java (from rev 356, irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/DisplaySubmitTokenRequest.java) =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java (rev 0) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/ShowTokenInvestmentScreenRequest.java 2009-11-13 00:23:33 UTC (rev 358) @@ -0,0 +1,14 @@ +package edu.asu.commons.irrigation.events; + +import edu.asu.commons.event.AbstractEvent; +import edu.asu.commons.event.FacilitatorRequest; +import edu.asu.commons.net.Identifier; + +public class ShowTokenInvestmentScreenRequest extends AbstractEvent implements FacilitatorRequest { + + private static final long serialVersionUID = -4133284727930840712L; + + public ShowTokenInvestmentScreenRequest(Identifier id) { + super(id); + } +} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/StartDownload.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/StartDownload.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/StartDownload.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,29 +0,0 @@ -package edu.asu.commons.irrigation.events; - -import edu.asu.commons.event.AbstractEvent; -import edu.asu.commons.net.Identifier; - -/** - * @author Sanket - * - */ -public class StartDownload extends AbstractEvent { - - private static final long serialVersionUID = 2790726104971226910L; - private int fileSelected; - - public StartDownload(Identifier id) { - super(id); - } - - public void setFileSelected(int fileSelected){ - this.fileSelected = fileSelected; - } - - public int getFileSelected() { - return fileSelected; - } - - - -} Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/TransferFileInformationEvent.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/TransferFileInformationEvent.java 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/events/TransferFileInformationEvent.java 2009-11-13 00:23:33 UTC (rev 358) @@ -1,32 +0,0 @@ -/** - * - */ -package edu.asu.commons.irrigation.events; - - -import edu.asu.commons.event.AbstractPersistableEvent; -import edu.asu.commons.net.Identifier; - -/** -* @author Sanket -* -*/ -public abstract class TransferFileInformationEvent extends AbstractPersistableEvent { - - private static final long serialVersionUID = -5241129364032790383L; - - private String fileNumber; - - public TransferFileInformationEvent(Identifier id) { - super(id); - } - - public void setFileNumber(String fileNumber) { - this.fileNumber = fileNumber; - } - - public String getFileNumber(){ - return fileNumber; - } - -} 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-13 00:23:33 UTC (rev 358) @@ -14,7 +14,7 @@ import javax.swing.SwingUtilities; import edu.asu.commons.irrigation.events.BeginChatRoundRequest; -import edu.asu.commons.irrigation.events.DisplaySubmitTokenRequest; +import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; import edu.asu.commons.irrigation.server.ClientData; @@ -133,7 +133,7 @@ displayInvestmentButton = new JButton("Show Investment Screen"); displayInvestmentButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { - facilitator.transmit(new DisplaySubmitTokenRequest(facilitator.getId())); + facilitator.transmit(new ShowTokenInvestmentScreenRequest(facilitator.getId())); } }); } 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-11-13 00:23:33 UTC (rev 358) @@ -74,6 +74,7 @@ return getAssignedNumber() - 1; } + // FIXME: logic duplicated with ServerConfiguration.toPriorityString(int priority); private final static String[] PRIORITY_STRINGS = { "A", "B", "C", "D", "E" }; public String getPriorityString() { 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-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-11-13 00:23:33 UTC (rev 358) @@ -21,14 +21,14 @@ import edu.asu.commons.irrigation.events.BeginChatRoundRequest; import edu.asu.commons.irrigation.events.ClientUpdateEvent; import edu.asu.commons.irrigation.events.CloseGateEvent; -import edu.asu.commons.irrigation.events.DisplaySubmitTokenRequest; +import edu.asu.commons.irrigation.events.ShowTokenInvestmentScreenRequest; import edu.asu.commons.irrigation.events.EndRoundEvent; import edu.asu.commons.irrigation.events.FacilitatorEndRoundEvent; import edu.asu.commons.irrigation.events.InfrastructureUpdateEvent; import edu.asu.commons.irrigation.events.InvestedTokensEvent; import edu.asu.commons.irrigation.events.OpenGateEvent; import edu.asu.commons.irrigation.events.PauseRequest; -import edu.asu.commons.irrigation.events.QuizCompletedEvent; +import edu.asu.commons.irrigation.events.QuizResponseEvent; import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; @@ -157,12 +157,12 @@ } } }); - addEventProcessor(new EventTypeProcessor<DisplaySubmitTokenRequest>(DisplaySubmitTokenRequest.class) { + addEventProcessor(new EventTypeProcessor<ShowTokenInvestmentScreenRequest>(ShowTokenInvestmentScreenRequest.class) { @Override - public void handle(DisplaySubmitTokenRequest request) { + public void handle(ShowTokenInvestmentScreenRequest request) { synchronized (clients) { for (Identifier id: clients.keySet()) { - transmit(new DisplaySubmitTokenRequest(id)); + transmit(new ShowTokenInvestmentScreenRequest(id)); } } } @@ -239,9 +239,9 @@ } } }); - addEventProcessor(new EventTypeProcessor<QuizCompletedEvent>(QuizCompletedEvent.class) { + addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { @Override - public void handle(QuizCompletedEvent event) { + public void handle(QuizResponseEvent event) { numberOfCompletedQuizzes++; getLogger().info("Completed quizzes: " + numberOfCompletedQuizzes); if(numberOfCompletedQuizzes == clients.size()*8){ Modified: irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml =================================================================== --- irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-12 22:22:15 UTC (rev 357) +++ irrigation/trunk/src/main/resources/configuration/asu-fall-2009/mixed-pretest/irrigation.xml 2009-11-13 00:23:33 UTC (rev 358) @@ -2,6 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Irrigation experiment server 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> @@ -54,15 +55,113 @@ <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> +You have already earned 5 dollars by showing up for this exercise. You can earn +more, up to an extra 25 dollars. You will participate in this exercise as a part of +a group of five participants. Your group has been formed by randomly assigning you +to FOUR other participants in the room. </p> +<p> +The amount of money you earn will depend on the decisions made by you and the other +members of your group. This exercise mimics decisions people make in irrigation +systems. In each round you will receive 10 tokens which you can invest in the +irrigation infrastructure. Given the capacity of the irrigation infrastructure and +the availability of water, you can grow crops. Tokens earned in a round is the sum +of tokens not invested plus tokens earned by growing crops. Each token is worth 5 +cents. In each round you will first make a decision as to how much to invest in the +irrigation infrastructure. Based on the combined contributions of all 5 participants +in your group in each round, your group can maintain the capacity of the irrigation +infrastructure for growing crops. +</p> + +<p> +We will now start a practice round to help illustrate the experiment. Before each +round in this experiment you will have a chat period of 60 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='game-screenshot-instructions'> +<![CDATA[ +<img src="http://dev.commons.asu.edu/irrigation/images/game-interface-screenshot.jpg"> +<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> + +]]> +</entry> + + <entry key="facilitator-instructions"> <![CDATA[ <h3>Facilitator Instructions</h3> @@ -80,49 +179,15 @@ -<entry key="general-instructions0"> +<entry key="welcome-instructions"> <![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 ... [truncated message content] |
From: <see...@us...> - 2009-11-12 22:22:26
|
Revision: 357 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=357&view=rev Author: seematalele Date: 2009-11-12 22:22:15 +0000 (Thu, 12 Nov 2009) Log Message: ----------- 1) DayByDayDecisionsService is working fine, tested all the calculation with 5 people on one bay. 2) Made changes in the schema in Student, added column named as money. To Do: 1) Implement the timer for DayByDayDecisions 2) Test with Kalin's GUI 3) Test strategy Execution using DayByDayDecisions.java Modified Paths: -------------- mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-12 22:22:15 UTC (rev 357) @@ -216,7 +216,6 @@ `id` bigint(20) NOT NULL AUTO_INCREMENT, `dayNumber` int(11) NOT NULL, `earnings` double DEFAULT NULL, - `money` double DEFAULT NULL, `location_id` bigint(20) NOT NULL, `student_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), @@ -694,6 +693,7 @@ `gameCode` varchar(255) DEFAULT NULL, `gender` varchar(255) DEFAULT NULL, `major` varchar(255) DEFAULT NULL, + `money` double DEFAULT NULL, `semester` varchar(255) DEFAULT NULL, `student_no` int(11) DEFAULT NULL, `timestamp` datetime DEFAULT NULL, @@ -876,4 +876,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-10-30 22:37:53 +-- Dump completed on 2009-11-12 22:20:40 Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-12 22:22:15 UTC (rev 357) @@ -27,18 +27,15 @@ @ManyToOne @JoinColumn(nullable=false) private Location location; + + @ManyToOne + @JoinColumn(nullable=false) + private Student student; //earning will be in pound @Column private Double earnings; - @Column - private Double money; - - @ManyToOne - @JoinColumn(nullable=false) - private Student student; - /*@OneToMany(mappedBy = "dayByDayDecision") @CollectionOfElements(fetch = FetchType.EAGER) private List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions;*/ @@ -58,22 +55,7 @@ public Location getLocation() { return location; } - public void setEarnings(Double earnings) { - this.earnings = earnings; - } - - public Double getEarnings() { - return earnings; - } - public void setMoney(Double money) { - this.money = money; - } - - public Double getMoney() { - return money; - } - public void setStudent(Student student) { this.student = student; } @@ -90,6 +72,14 @@ return dayNumber; } + public void setEarnings(Double earnings) { + this.earnings = earnings; + } + + public Double getEarnings() { + return earnings; + } + /*public void setDayByDayOtherStudentDecisions( List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions) { this.dayByDayOtherStudentDecisions = dayByDayOtherStudentDecisions; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java 2009-11-12 22:22:15 UTC (rev 357) @@ -28,7 +28,7 @@ @Column(nullable=false) public Integer day; - @Column(nullable=false) + @Column(nullable=false,scale=2, precision=8) public Double earnings; public void setId(Long id) { Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-12 22:22:15 UTC (rev 357) @@ -27,23 +27,23 @@ @JoinColumn(nullable=false) private Location location; - @Column(name="current_population", scale=2) + @Column(name="current_population") private Double currentPopulation; - @Column(name="fish_leaving", scale=2) + @Column(name="fish_leaving") private Double fishLeaving; - @Column(name="fish_return", scale=2) + @Column(name="fish_return") private Double fishReturned; @ManyToOne @JoinColumn(nullable=false) private Group group; - @Column(nullable=false,name="max_capacity", scale=2) + @Column(nullable=false,name="max_capacity") private Double maxCapacity; - @Column(nullable=false,name="initial_population", scale=2) + @Column(nullable=false,name="initial_population") private Double initialPopulation; public void setId(Long id) { Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-11-12 22:22:15 UTC (rev 357) @@ -26,7 +26,7 @@ /*@Column(nullable=false,name="max_capacity", scale=2) private Double maxCapacity;*/ - @Column(nullable=false,name="growth_rate", scale=2) + @Column(nullable=false,name="growth_rate") private Double growthRate; /*@Column(nullable=false,name="initial_population", scale=2) Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-12 22:22:15 UTC (rev 357) @@ -38,6 +38,11 @@ private String semester; + + + @Column + private Double money; + @ManyToOne @JoinColumn(nullable = false) private Game game; @@ -129,4 +134,12 @@ return gameCode; } + public void setMoney(Double money) { + this.money = money; + } + + public Double getMoney() { + return money; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-12 22:22:15 UTC (rev 357) @@ -82,17 +82,18 @@ private HibernateGroupLocationDao groupLocationDao; private HibernateGroupDao groupDao; private HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao; + private double totalFishLeaving; static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; static final String getgroupLocation = "SELECT g FROM GroupLocation g where g.group =:group and g.location =:location"; - + public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } - + public void setLocationDao(HibernateLocationDao locationDao) { this.locationDao = locationDao; } @@ -159,146 +160,89 @@ public void allocateStudentForEachBay(Game game) { - List<DayByDayDecisions> studentDecisions = new ArrayList<DayByDayDecisions>(); - //studentDao.find(gameDao.find(game.getId()); - //studentDecisions = getDao(). Query query = getDao().getCurrentSession().createQuery(studentDecisionsForGame); query.setEntity("game", game); Iterator studentDecisionsIterator = query.list().iterator(); - - //getLogger().debug("student Decision Iterator is " + studentDecisionIterator.hasNext()); - while(studentDecisionsIterator.hasNext()) - { - studentDecisions.add((DayByDayDecisions)studentDecisionsIterator.next()); - // getLogger().info("decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); - } - DayByDayDecisions studentDecision = new DayByDayDecisions(); + try{ + while(studentDecisionsIterator.hasNext()) + { + DayByDayDecisions decision = (DayByDayDecisions)studentDecisionsIterator.next(); + studentDecisions.add(decision); + getLogger().info("student decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); + } - List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + //find out different groups in the game + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); - // List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); - // List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); - // List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + queryforGroups.setLong("current_game_id", game.getId()); + Iterator groups = queryforGroups.list().iterator(); + List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); + List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + /** For every group find out the groupLocations objects. + * find out the student decisions for current group. + * Separate the students for each bay + * find out the population for every bay + */ - Map<Long,List<DayByDayDecisions>> bay1StudentMap = new HashMap<Long,List<DayByDayDecisions>>(); - Map<Long,List<DayByDayDecisions>> bay2StudentMap = new HashMap<Long,List<DayByDayDecisions>>(); - Map<Long,List<DayByDayDecisions>> bay3StudentMap = new HashMap<Long,List<DayByDayDecisions>>(); - Map<Long,List<DayByDayDecisions>> harborStudentMap = new HashMap<Long,List<DayByDayDecisions>>(); - - for(int i = 0; i < studentDecisions.size(); i++) - { - studentDecision = studentDecisions.get(i); - if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + while(groups.hasNext()) { - if(!bay1StudentMap.containsKey(studentDecision.getStudent().getGroup().getId() )) - { - //group = decision.getStudent().getGroup(); - List<DayByDayDecisions> decisions = new ArrayList<DayByDayDecisions>(); - decisions.add(studentDecision); - bay1StudentMap.put(studentDecision.getStudent().getGroup().getId(),decisions); - } - else - { - List<DayByDayDecisions> decisions = bay1StudentMap.get(studentDecision.getStudent().getGroup().getId()); - decisions.add(studentDecision); - } + Group currentGroup = (Group) groups.next(); + getLogger().debug("group id in executeStrategy is: " + currentGroup.getId()); - } - else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) - { - if(!bay2StudentMap.containsKey(studentDecision.getStudent().getGroup().getId() )) - { - //group = decision.getStudent().getGroup(); - List<DayByDayDecisions> decisions = new ArrayList<DayByDayDecisions>(); - decisions.add(studentDecision); - bay2StudentMap.put(studentDecision.getStudent().getGroup().getId(),decisions); - } - else - { - List<DayByDayDecisions> decisions = bay1StudentMap.get(studentDecision.getStudent().getGroup().getId()); - decisions.add(studentDecision); - } + groupLocations = groupLocationDao.findAllByProperty("group",currentGroup); + //getLogger().debug("grouplocation size is: " + groupLocations.size()); - } - else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) - { - if(!bay3StudentMap.containsKey(studentDecision.getStudent().getGroup().getId() )) + List<DayByDayDecisions> studentDecisionForCurrentGroup = new ArrayList<DayByDayDecisions>(); + for(DayByDayDecisions tempStudentDecision:studentDecisions) { - //group = decision.getStudent().getGroup(); - List<DayByDayDecisions> decisions = new ArrayList<DayByDayDecisions>(); - decisions.add(studentDecision); - bay3StudentMap.put(studentDecision.getStudent().getGroup().getId(),decisions); + if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) + { + //studentDecisionForCurrentGroup.add(tempStudentDecision); + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { + bay1Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) + { + bay2Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) + { + bay3Students.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harborStudents.add(tempStudentDecision); + } + + } + } - else - { - List<DayByDayDecisions> decisions = bay1StudentMap.get(studentDecision.getStudent().getGroup().getId()); - decisions.add(studentDecision); - } + calculateHarvest(bay1Students,"Bay1",currentGroup,game); + calculateHarvest(bay2Students,"Bay2",currentGroup,game); + calculateHarvest(bay3Students,"Bay3",currentGroup,game); + calculateNewPopulation(currentGroup); } - else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) - { - if(!harborStudentMap.containsKey(studentDecision.getStudent().getGroup().getId() )) - { - //group = decision.getStudent().getGroup(); - List<DayByDayDecisions> decisions = new ArrayList<DayByDayDecisions>(); - decisions.add(studentDecision); - harborStudentMap.put(studentDecision.getStudent().getGroup().getId(),decisions); - } - else - { - List<DayByDayDecisions> decisions = bay1StudentMap.get(studentDecision.getStudent().getGroup().getId()); - decisions.add(studentDecision); - } - } - } - /** - * Calculate the following in the order it is mention - * 1) The actual population of each bay after growth and fish leaving and assign the harvest to each agent. - * 2) Total fish leaving = leaving from bay1 + leaving from bay2 + leaving from bay3 - * 2) Receptivity for each bay - * 3) Total receptivity - * 4) Fish Return for each bay - * 5) New population at each bay - */ - - /*Iterator<Long> keys = bay1StudentMap.keySet().iterator(); - while(keys.hasNext()) + }catch(Exception e) { - Long groupId = keys.next(); - getLogger().info("key is: " + groupId + "values are : " ); - List<DayByDayDecisions> decisions = bay1StudentMap.get(groupId); - for(DayByDayDecisions decision:decisions) - { - getLogger().info("decision is: " + decision.getDayNumber() + "location number: " + decision.getLocation().getLocationName()); - } + e.printStackTrace(); + } - }*/ - - calculateHarvest(bay1StudentMap,"Bay1", game); - /**calculateHarvest(bay2StudentMap,"Bay2"); - calculateHarvest(bay3StudentMap,"Bay3"); - calculateHarvest(harborStudentMap,"Harbor"); **/ - - calculateTotalFishLeaving(game); - - /** calculateFishReturned(); - - calculateNewPopulation();**/ - } //FIXME: max_fish_capacity is hard coded to 5 but actually this value should get from game object - - - - public void calculateHarvest(Map<Long, List<DayByDayDecisions>> bay1StudentMap,String locationName, Game game) + public void calculateHarvest(List<DayByDayDecisions> bayStudents,String locationName, Group currentGroup, Game game) { // TODO Auto-generated method stub double maxFishCapacity = 0.0; @@ -308,117 +252,86 @@ double fishLeaving = 0.0; Long groupId; DayByDayOtherStudentDecisions otherStudents; - - maxFishCapacity = game.getGameConfig().getMaxFishHarvest(); - getLogger().debug("maxFishCapacity is : " + maxFishCapacity); - List<DayByDayDecisions> groupStudentDecisions = new ArrayList<DayByDayDecisions>(); - /*getLogger().debug("bay1StudentMap size is : " + bay1StudentMap.size() + "location name is : " + locationName); - Iterator<Long> keys1 = bay1StudentMap.keySet().iterator(); - while(keys1.hasNext()) - { - Long groupId1 = keys1.next(); - getLogger().info("key is: " + groupId1 + "values are : " ); - List<DayByDayDecisions> decisions = bay1StudentMap.get(groupId1); - for(DayByDayDecisions decision:decisions) - { - getLogger().info("decision is: " + decision.getDayNumber() + "location number: " + decision.getLocation().getLocationName()); - } - - }*/ + maxFishCapacity = game.getGameConfig().getMaxFishHarvest(); + getLogger().debug("location name is : " +locationName + "bay student size is: " + bayStudents.size()); try { - Iterator<Long> keys = bay1StudentMap.keySet().iterator(); - while(keys.hasNext()) - { - Location location = locationDao.findByProperty("locationName","Bay1"); - groupId = keys.next(); - getLogger().debug("group id is : " + groupId + "location id is: " + location.getId()); - groupStudentDecisions = bay1StudentMap.get(groupId); - Group group = groupDao.find(groupId); - GroupLocation groupLocation = new GroupLocation(); - /*groupLocation.setLocation(location); - groupLocation.setGroup(group); + Location location = locationDao.findByProperty("locationName",locationName); - - List<GroupLocation> groupLocations = groupLocationDao.findByExample(groupLocation);*/ - - Query query = groupLocationDao.getCurrentSession().createQuery(getgroupLocation); - query.setEntity("location", location); - query.setEntity("group", group); - Iterator i = query.list().iterator(); - while(i.hasNext()) - { - groupLocation = (GroupLocation)i.next(); - getLogger().debug("groupLocation id is: " + groupLocation.getId()); - } + Group group = groupDao.find(currentGroup.getId()); + GroupLocation groupLocation = new GroupLocation(); + Query query = groupLocationDao.getCurrentSession().createQuery(getgroupLocation); + query.setEntity("location", location); + query.setEntity("group", group); + Iterator i = query.list().iterator(); + while(i.hasNext()) + { + groupLocation = (GroupLocation)i.next(); + getLogger().debug("groupLocation id is: " + groupLocation.getId()); + } - /*if(groupLocations.size()== 1) - { - groupLocation = groupLocations.get(0); - } - else - { - //Error, should result only one result - }*/ + //get current population + actualPopulation = groupLocation.getCurrentPopulation(); - //get current population - actualPopulation = groupLocation.getCurrentPopulation(); + //1)Harvesting + //Find out the amount of fish per agent - //1)Harvesting - //Find out the amount of fish per agent + amountPerAgent = maxFishCapacity * groupLocation.getCurrentPopulation() / groupLocation.getMaxCapacity(); - amountPerAgent = maxFishCapacity * groupLocation.getCurrentPopulation() / groupLocation.getMaxCapacity(); + if((bayStudents.size() * amountPerAgent) > actualPopulation) + { + amountPerAgent = actualPopulation / bayStudents.size(); + getLogger().debug("In IF Loop assigning amount/agent: " + amountPerAgent); + } + //FIXME: allocate this amountPerAgent to each student - if((groupStudentDecisions.size() * amountPerAgent) > actualPopulation) - { - amountPerAgent = actualPopulation / groupStudentDecisions.size(); - } - //FIXME: allocate this amountPerAgent to each student + //calculate the current population after harvesting + actualPopulation = actualPopulation - bayStudents.size() * amountPerAgent; + getLogger().debug("groupStudentDecisions.size is : " + bayStudents.size()+ " fish population after assigning amount/agent: " + actualPopulation); - //calculate the current population after harvesting - actualPopulation = actualPopulation - groupStudentDecisions.size() * amountPerAgent; + //2)Growth + growth = actualPopulation * location.getGrowthRate(); + getLogger().info("Fish growth after harvest at " + locationName + " is: " + growth); - groupLocation.setCurrentPopulation(actualPopulation); + //3) Fish leaving location + fishLeaving = actualPopulation * growth / groupLocation.getMaxCapacity(); + getLogger().info("Fish leaving at " + locationName + " is: " + fishLeaving); - //2)Growth - growth = actualPopulation * location.getGrowthRate(); - getLogger().info("Fish growth at " + locationName + " is: " + growth); + groupLocation.setFishLeaving(fishLeaving); - //3) Fish leaving location - fishLeaving = actualPopulation * growth / groupLocation.getMaxCapacity(); - getLogger().info("Fish leaving at " + locationName + " is: " + fishLeaving); + //4) Population after diffusion + actualPopulation = actualPopulation + growth - fishLeaving; + getLogger().info("Fish population at " + locationName + " after diffusion is: " + actualPopulation); + groupLocation.setCurrentPopulation(actualPopulation); + groupLocationDao.save(groupLocation); - groupLocation.setFishLeaving(fishLeaving); - - //4) Population after diffusion - actualPopulation = actualPopulation + growth - fishLeaving; - getLogger().info("Fish population at " + locationName + " after diffusion is: " + actualPopulation); - groupLocationDao.save(groupLocation); + if(bayStudents.size()!= 0) + { List<DayByDayDecisions> tempStudentDecisions = new ArrayList<DayByDayDecisions>(); - tempStudentDecisions = groupStudentDecisions; - for(DayByDayDecisions dayByDayDecision : groupStudentDecisions) + tempStudentDecisions = bayStudents; + for(DayByDayDecisions dayByDayDecision : bayStudents) { //set earning + Student student = dayByDayDecision.getStudent(); dayByDayDecision.setEarnings(amountPerAgent); //set money + student.setMoney(game.getMoney() * amountPerAgent); + studentDao.save(student); - dayByDayDecision.setMoney(game.getMoney() * amountPerAgent); - //set other students //List<Student> otherStudents = new ArrayList<Student>(); - - + Long currentStudentId = dayByDayDecision.getStudent().getId(); getLogger().debug("For student id is: " + currentStudentId); - + for(DayByDayDecisions students:tempStudentDecisions) { getLogger().debug("temp student id is: " + students.getStudent().getId()); - + if(students.getStudent().getId() != currentStudentId) { getLogger().debug("other student id is: " + students.getStudent().getId()); @@ -426,15 +339,15 @@ otherStudents.setDayByDayDecision(dayByDayDecision); otherStudents.setOtherStudent(students.getStudent()); dayByDayOtherStudentDecisionsDao.save(otherStudents); - + } } //Group group = dayByDayDecisions.getStudent().getGroup(); getDao().save(dayByDayDecision); } - } + }catch(Exception e) { e.printStackTrace(); @@ -442,111 +355,90 @@ } - private void calculateTotalFishLeaving(Game game) { + private void calculateNewPopulation(Group group) { double totalFishLeaving = 0; - - Query query = studentDao.getCurrentSession().createQuery(groupsWithinGame); - - query.setLong("current_game_id", game.getId()); - Iterator groups = query.list().iterator(); - GroupLocation groupLocation = null; - while(groups.hasNext()) - { - Group group = (Group) groups.next(); - getLogger().debug("group id is: " + group.getId()); - groupLocation = groupLocationDao.findByProperty("group",group); - totalFishLeaving = totalFishLeaving + groupLocation.getFishLeaving(); - } - /*List<Student> students = studentDao.findAllByProperty("game", game); - List<Long> groups = null; - for(Student student:students) - { - if(groups == null) - { - groups = new ArrayList<Long>(); - groups.add(student.getGroup().getId()); - } - else if(!groups.contains(student.getGroup().getId())) - { - groups.add(student.getGroup().getId()); - } - }*/ - - setTotalFishLeaving(totalFishLeaving); - - } - - /**INFO: loss rate is 0 - according to the Dr Tobias' document, loss rate for the pilot experiment is 0 - but for single location it will be 1 */ - - private void calculateFishReturned() { - - /*double totalLoss = 0.0; + double totalLoss = 0.0; double lossRate = 0.0; double totalReturn = 0.0; double maxFishCapacity = 5.0; double totalReceptivity = 0.0; double receptivity = 0.0; + getLogger().debug("group id in calculate total fish leaving is: " + group.getId()); + List<GroupLocation> groupLocations = groupLocationDao.findAllByProperty("group",group); + getLogger().debug("grouplocation size is: " + groupLocations.size()); + for(GroupLocation groupLocation : groupLocations) + { + totalFishLeaving = totalFishLeaving + groupLocation.getFishLeaving(); + } + getLogger().debug("total fish leaving is : " + totalFishLeaving); + //setTotalFishLeaving(totalFishLeaving); + + /**INFO: loss rate is 0 - according to the Dr Tobias' document, loss rate for the pilot experiment is 0 + but for single location it will be 1 */ + /** + * Bay receptivity + * String: location name, Double: receptivity + */ Map<String,Double> bayReceptivity = new HashMap<String, Double>(); try { //calculate loss - totalLoss = getTotalFishLeaving() * lossRate; - totalReturn = getTotalFishLeaving() - totalLoss; + totalLoss = totalFishLeaving * lossRate; + totalReturn = totalFishLeaving - totalLoss; getLogger().info("Total Return is: " + totalReturn); //calculate the receptivity for each bay and total receptivity - for(Location location : locationService.getAllLocations()) + for(GroupLocation groupLocation : groupLocations) { - receptivity = 1 - location.getCurrentPopulation() / maxFishCapacity; - getLogger().info(location.getLocationName() + " receptivity is: " + receptivity); - bayReceptivity.put(location.getLocationName(), receptivity); - totalReceptivity = receptivity + totalReceptivity; + if(groupLocation.getLocation().getId()!=1) + { + getLogger().debug(groupLocation.getLocation().getLocationName() + "current population : " + groupLocation.getCurrentPopulation()); + receptivity = 1 - (groupLocation.getCurrentPopulation() /groupLocation.getMaxCapacity()); + getLogger().info(groupLocation.getLocation().getLocationName() + " receptivity is: " + receptivity); + bayReceptivity.put(groupLocation.getLocation().getLocationName(), receptivity); + totalReceptivity = receptivity + totalReceptivity; + } } getLogger().info("Total receptivity is: " + totalReceptivity); //calculte the returning for each bay - *//**FOR i = 1 TO 3 - IF receptivity_total = 0 - returning_i = 0 - ELSE - returning_i = receptivity_i \xD7 totalReturn \xD7 receptivity_i / receptivity_total - END FOR *//* + /**FOR i = 1 TO 3 + IF receptivity_total = 0 + returning_i = 0 + ELSE + returning_i = receptivity_i \xD7 totalReturn \xD7 receptivity_i / receptivity_total + END FOR */ receptivity = 0.0; - for(Location location : locationService.getAllLocations()) + for(GroupLocation groupLocation : groupLocations) { - if(totalReceptivity == 0) + if(groupLocation.getLocation().getId()!=1) { - location.setFishReturned(0.0); + if(totalReceptivity == 0) + { + groupLocation.setFishReturned(0.0); + } + else + { + receptivity = bayReceptivity.get(groupLocation.getLocation().getLocationName()); + groupLocation.setFishReturned(receptivity * totalReturn * receptivity / totalReceptivity); + getLogger().debug("Fish returned to " + groupLocation.getLocation().getLocationName() + "is " + groupLocation.getFishReturned()); + groupLocation.setCurrentPopulation(groupLocation.getCurrentPopulation() + groupLocation.getFishReturned()); + getLogger().debug("New population at " + groupLocation.getLocation().getLocationName() + " is: " + groupLocation.getCurrentPopulation()); + } } - else - { - receptivity = bayReceptivity.get(location.getLocationName()); - location.setFishReturned(receptivity * totalReturn * receptivity / totalReceptivity); - getLogger().debug("Fish returned to " + location.getLocationName() + "is " + location.getFishReturned()); - } + groupLocationDao.save(groupLocation); } }catch(Exception e) { e.printStackTrace(); - }*/ - } - - private void calculateNewPopulation() { - - /*for(Location location:locationService.getAllLocations()) - { - location.setCurrentPopulation(location.getCurrentPopulation() + location.getFishReturned()); - getLogger().debug("New population at " + location.getLocationName() + " is: " + location.getCurrentPopulation()); } - */ + } - } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-12 22:22:15 UTC (rev 357) @@ -150,7 +150,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - pushBlock(game); + //pushBlock(game); flag = true; } else @@ -380,6 +380,9 @@ groupLocation.setInitialPopulation(initCapacity); groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); + groupLocation.setFishLeaving(0.0); + groupLocation.setFishReturned(0.0); + groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); } @@ -393,6 +396,9 @@ groupLocation.setInitialPopulation(initCapacity); groupLocation.setCurrentPopulation(initCapacity); + groupLocation.setFishLeaving(0.0); + groupLocation.setFishReturned(0.0); + getLogger().info("initiali population set is: " + initCapacity); groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); @@ -408,6 +414,9 @@ groupLocation.setInitialPopulation(initCapacity); groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); + groupLocation.setFishLeaving(0.0); + groupLocation.setFishReturned(0.0); + groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); } @@ -422,6 +431,9 @@ groupLocation.setInitialPopulation(initCapacity); groupLocation.setCurrentPopulation(initCapacity); getLogger().info("initiali population set is: " + initCapacity); + groupLocation.setFishLeaving(0.0); + groupLocation.setFishReturned(0.0); + groupLocationDao.save(groupLocation); getLogger().info("group location is created and id is: " + groupLocation.getId()); } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java 2009-11-12 22:22:15 UTC (rev 357) @@ -18,7 +18,7 @@ private boolean running; private RoundService roundService; private LocationService locationService; - private DayByDayDecisionsService dayBydayDecisionService; + private DayByDayDecisionsServiceSortingStudentBayWise dayBydayDecisionService; private StudentService studentService; private ModuleRoundConfig currentModuleRoundConfig; private Game game; @@ -115,11 +115,11 @@ this.locationService = locationService; } - public void setDayBydayDecisionService(DayByDayDecisionsService dayBydayDecisionService) { + public void setDayBydayDecisionService(DayByDayDecisionsServiceSortingStudentBayWise dayBydayDecisionService) { this.dayBydayDecisionService = dayBydayDecisionService; } - public DayByDayDecisionsService getDayBydayDecisionService() { + public DayByDayDecisionsServiceSortingStudentBayWise getDayBydayDecisionService() { return dayBydayDecisionService; } public void setStudentService(StudentService studentService) { Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-09 15:56:48 UTC (rev 356) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-11-12 22:22:15 UTC (rev 357) @@ -75,7 +75,7 @@ msg.setTimestamp(System.currentTimeMillis()); msg.setBody(block); AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); - /*if(block!=null) + if(block!=null) { //int duration = block.getDuration(); @@ -97,8 +97,8 @@ { System.out.println("Game is Over..." + msg); } -*/ + /*AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); logger.info("Ack received from client for message " + msg + "is : " + ack); */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-11-09 15:57:01
|
Revision: 356 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=356&view=rev Author: alllee Date: 2009-11-09 15:56:48 +0000 (Mon, 09 Nov 2009) Log Message: ----------- dead code elimination Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 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-11-07 22:58:44 UTC (rev 355) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-11-09 15:56:48 UTC (rev 356) @@ -44,8 +44,6 @@ //this contains the CanalPanel private JPanel centerPanel; - private ScoreBoxPanel scoreBoxPanel; - private IrrigationClient client; // private Dimension screenSize; @@ -292,54 +290,8 @@ return panel; } -// 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 ScoreBoxPanel getScoreBoxPanel() { - if(scoreBoxPanel == null){ - scoreBoxPanel = new ScoreBoxPanel(); - } - return scoreBoxPanel; - } - - /** - * This method initializes TimeRemainingjProgressBar + * The time left progress bar. * * @return javax.swing.JProgressBar */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (JIRA) <jef...@as...> - 2009-11-08 00:05:14
|
[ http://opensource.asu.edu/jira/browse/COMMONS-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Work on COMMONS-5 started by Allen Lee. > interface and instructions flow improvement > ------------------------------------------- > > Key: COMMONS-5 > URL: http://opensource.asu.edu/jira/browse/COMMONS-5 > Project: The Virtual Commons > Issue Type: Improvement > Components: irrigation > Affects Versions: irrigation.asu.fall.2009 > Reporter: Allen Lee > Assignee: Allen Lee > Fix For: irrigation.asu.fall.2009 > > > Updated flow: > 1. Brief introduction to the experiment > 2. Introduce chat > 3. Do basic chat, just say hi > 4. Introduce token investment screen > 5. Display static screenshot and introduce experiment > 6. Start practice round. > 7. Free text quiz > Allen Lee - 28/Oct/09 02:17 PM - edited Updated flow: 1. Brief introduction to the experiment 2. Introduce chat 3. Do basic chat, just say hi 4. Introduce token investment screen 5. Display static screenshot and introduce experiment 6. Start practice round. 7. Free text quizzes (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. 8. Next is the second practice round. 9. Finally the start of the first round. > zes (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. > 8. Next is the second practice round. > 9. Finally the start of the first round. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Allen L. (JIRA) <jef...@as...> - 2009-11-07 23:31:34
|
[ http://opensource.asu.edu/jira/browse/COMMONS-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee updated COMMONS-5: ---------------------------- Description: Updated flow: 1. Brief introduction to the experiment 2. Introduce chat 3. Do basic chat, just say hi 4. Introduce token investment screen 5. Display static screenshot and introduce experiment 6. Start practice round. 7. Free text quiz (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. 8. Next is the second practice round. 9. Finally the start of the first round. was: Updated flow: 1. Brief introduction to the experiment 2. Introduce chat 3. Do basic chat, just say hi 4. Introduce token investment screen 5. Display static screenshot and introduce experiment 6. Start practice round. 7. Free text quiz Allen Lee - 28/Oct/09 02:17 PM - edited Updated flow: 1. Brief introduction to the experiment 2. Introduce chat 3. Do basic chat, just say hi 4. Introduce token investment screen 5. Display static screenshot and introduce experiment 6. Start practice round. 7. Free text quizzes (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. 8. Next is the second practice round. 9. Finally the start of the first round. zes (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. 8. Next is the second practice round. 9. Finally the start of the first round. > interface and instructions flow improvement > ------------------------------------------- > > Key: COMMONS-5 > URL: http://opensource.asu.edu/jira/browse/COMMONS-5 > Project: The Virtual Commons > Issue Type: Improvement > Components: irrigation > Affects Versions: irrigation.asu.fall.2009 > Reporter: Allen Lee > Assignee: Allen Lee > Fix For: irrigation.asu.fall.2009 > > > Updated flow: > 1. Brief introduction to the experiment > 2. Introduce chat > 3. Do basic chat, just say hi > 4. Introduce token investment screen > 5. Display static screenshot and introduce experiment > 6. Start practice round. > 7. Free text quiz (no more multiple choice). Quiz responses should be recorded and they can only be submitted once. After they are submitted if they got a question wrong the correct answer is displayed along with an explanation. We associate the quiz responses with that student as well. > 8. Next is the second practice round. > 9. Finally the start of the first round. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <al...@us...> - 2009-11-07 22:59:04
|
Revision: 355 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=355&view=rev Author: alllee Date: 2009-11-07 22:58:44 +0000 (Sat, 07 Nov 2009) Log Message: ----------- more refactoring / cleanup in preparation for http://opensource.asu.edu/jira/browse/COMMONS-5 Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 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-11-04 20:24:26 UTC (rev 354) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-11-07 22:58:44 UTC (rev 355) @@ -1,8 +1,6 @@ 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; @@ -26,7 +24,6 @@ import edu.asu.commons.irrigation.events.RegistrationEvent; import edu.asu.commons.irrigation.events.RoundStartedEvent; import edu.asu.commons.irrigation.events.ShowInstructionsRequest; -import edu.asu.commons.irrigation.server.ClientData; import edu.asu.commons.net.ClientDispatcher; import edu.asu.commons.net.DispatcherFactory; import edu.asu.commons.net.Identifier; @@ -34,6 +31,8 @@ /** * $Id$ * + * Irrigation client main entry point / controller that ties together the GUI component, networking logic via the Dispatcher, + * and general game logic. * * @author <a href='mailto:All...@as...'>Allen Lee</a>, Sanket Joshi * @version $Rev$ @@ -52,18 +51,12 @@ private Identifier id; - // private MainIrrigationGameWindow mainIrrigationGameWindow; - private ExperimentGameWindow experimentGameWindow; - IrrigationGameWindow currentWindow = null; - private ClientDataModel clientDataModel; private final EventChannel channel; - Map<Identifier, ClientData> updatedClientDataMap = new LinkedHashMap<Identifier, ClientData>(); - private IrrigationClient() { this(EventChannelFactory.create(), new ServerConfiguration()); } @@ -83,15 +76,14 @@ } public void connect() { - System.err.println("connecting to: " + serverConfiguration.getServerAddress() - + " state: " + state); if (state != ClientState.UNCONNECTED) return; id = clientDispatcher.connect(serverConfiguration.getServerAddress()); if (id == null) { - throw new RuntimeException("Null ID from Dispatcher. Server: <" - + serverConfiguration.getServerAddress() + "> is probably down."); + throw new RuntimeException( + "Null ID from Dispatcher. Server: <" + + serverConfiguration.getServerAddress() + "> is probably down."); } state = ClientState.CONNECTED; } Deleted: 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-11-04 20:24:26 UTC (rev 354) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGameWindow.java 2009-11-07 22:58:44 UTC (rev 355) @@ -1,679 +0,0 @@ -package edu.asu.commons.irrigation.client; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridLayout; -import java.awt.Rectangle; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; - -import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.server.ClientData; - -/** - * $Id$ - * - * Contains the primary open gate button, etc. - * - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ - -public class IrrigationGameWindow extends JPanel { - - private static final long serialVersionUID = -1737783671891265064L; - - private JPanel jPanelIrrigationGameWindow = null; - - private JPanel jPanelIrrigationWindow = null; - - private JPanel jPanelIrrigationWindowLeft = null; - - private JPanel jPanelIrrigationWindowRight = null; - - private JPanel jPanelIrrigationWindowLeftUp = null; - - private JPanel jPanelIrrigationWindowLeftDown = null; - - private JPanel jPanelIrrigationGameWindowLeftUpFiles = null; - - public JButton openGateButton = null; - - private JPanel jPanelIrrigationGameWindowLeftDownButtons = null; - - private JPanel jPanelIrrigationGameWindowLeftDownProgress = null; - - // public JButton StopDownload = null; - - public JProgressBar fileDownloadedProgressBar = null; - - public JPanel jPanelIrrigationGameWindowRightDown = null; - - private JPanel jPanelIrrigationWindowRightUp = null; - - private JPanel jPanelIrrigationGameWindowRightUp2 = null; - - private JPanel jPanelIrrigationGameWindowRightUp1 = null; - - private JPanel jPanelIrrigationGameWindowRightUp3 = null; - - private JLabel availableBandwidthLabel = null; - - public JProgressBar availableBandwidthTxt = null; - - private JLabel profitEarned = null; - - public JTextField moneyEarnedTextField = null; - - private JLabel fileDownloadedtxt = null; - - private IrrigationClient irrigationClient; - - private String name = null; - - public ChartWindowPanel xySeriesDemo; - - public JButton pauseDownload = null; - - private ClientData clientData; // @jve:decl-index=0: - - private JLabel availableFlowCapacityLabel = null; - - private JLabel currentBandwidthAvailableTextjLabel = null; - - private IrrigationGamePanel mainIrrigationWindow; - - public IrrigationGameWindow(Dimension screenSize, IrrigationClient client, - IrrigationGamePanel mainIrrigationWindow) { - this.mainIrrigationWindow = mainIrrigationWindow; - this.irrigationClient = client; - initialize(screenSize); - } - - /** - * Initializes the GUI. - * - * @return void - */ - private void initialize(Dimension screenSize) { - // why use card layout? - this.setLayout(new CardLayout()); - this.setSize(530, 326); - this.add(getJPanelIrrigationGameWindow(), getJPanelIrrigationGameWindow().getName()); - } - - public void startRound(final RoundConfiguration experimentRoundConfiguration) { - /** - * Here the logic would come for the starting of round, initialization , - * starting of the GUI, etc, etc. - */ - initEnable(); - } - - // public void endRound(EndRoundEvent event){ - public void endRound() { - /** - * here the end code and debreifing logic should be written - */ - refreshButtons(); - moneyEarnedTextField.setText("0"); - } - - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindow() { - if (jPanelIrrigationGameWindow == null) { - jPanelIrrigationGameWindow = new JPanel(); - jPanelIrrigationGameWindow.setLayout(new CardLayout()); - jPanelIrrigationGameWindow.setName("jPanel"); - jPanelIrrigationGameWindow.add(getJPanelIrrigationWindow(), getJPanelIrrigationWindow().getName()); - } - return jPanelIrrigationGameWindow; - } - - /** - * Returns the primary irrigation window. - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationWindow() { - if (jPanelIrrigationWindow == null) { - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(1); - jPanelIrrigationWindow = new JPanel(); - jPanelIrrigationWindow.setLayout(gridLayout); - jPanelIrrigationWindow.setName("Primary Irrigation Window"); - jPanelIrrigationWindow.add(getJPanelIrrigationWindowLeft(), null); - jPanelIrrigationWindow.add(getJPanelIrrigationWindowRight(), null); - } - return jPanelIrrigationWindow; - } - - /** - * These methods would be updated externally by irrigationClientGameState. - */ - public void updateFileDownloaded(double percentFileDownloaded) { - - } - - public void updateProfitEarned(final int award) { - moneyEarnedTextField.setText(new Integer(award).toString()); - - } - - /** - * This method initializes jPanel31 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationWindowLeft() { - if (jPanelIrrigationWindowLeft == null) { - GridLayout gridLayout3 = new GridLayout(); - gridLayout3.setRows(2); - jPanelIrrigationWindowLeft = new JPanel(); - jPanelIrrigationWindowLeft.setLayout(gridLayout3); - jPanelIrrigationWindowLeft.add(getJPanelIrrigationWindowLeftUp(), - null); - jPanelIrrigationWindowLeft.add(getJPanelIrrigationWindowLeftDown(), - null); - } - return jPanelIrrigationWindowLeft; - } - - /** - * This method initializes jPanel32 - * - * @return javax.swing.JPanel - */ - public JPanel getJPanelIrrigationWindowRight() { - if (jPanelIrrigationWindowRight == null) { - GridLayout gridLayout5 = new GridLayout(); - gridLayout5.setRows(2); - jPanelIrrigationWindowRight = new JPanel(); - jPanelIrrigationWindowRight.setLayout(gridLayout5); - jPanelIrrigationWindowRight.add( - getJPanelIrrigationGameWindowRightUp1(), null); - jPanelIrrigationWindowRight.add(getJPanelIrrigationWindowRightUp(), - null); - } - return jPanelIrrigationWindowRight; - } - - /** - * This method initializes jPanel311 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationWindowLeftUp() { - if (jPanelIrrigationWindowLeftUp == null) { - jPanelIrrigationWindowLeftUp = new JPanel(); - jPanelIrrigationWindowLeftUp.setLayout(new BorderLayout()); - jPanelIrrigationWindowLeftUp.add(getJPanelIrrigationGameWindowLeftUpFiles(), BorderLayout.CENTER); - } - return jPanelIrrigationWindowLeftUp; - } - - /** - * This method initializes jPanel312 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationWindowLeftDown() { - if (jPanelIrrigationWindowLeftDown == null) { - GridLayout gridLayout4 = new GridLayout(); - gridLayout4.setRows(2); - jPanelIrrigationWindowLeftDown = new JPanel(); - jPanelIrrigationWindowLeftDown.setLayout(gridLayout4); - jPanelIrrigationWindowLeftDown.add( - getJPanelIrrigationGameWindowLeftDownProgress(), null); - jPanelIrrigationWindowLeftDown.add( - getJPanelIrrigationGameWindowLeftDownButtons(), null); - } - return jPanelIrrigationWindowLeftDown; - } - - /** - * This method initializes jPanel3111 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowLeftUpFiles() { - if (jPanelIrrigationGameWindowLeftUpFiles == null) { - jPanelIrrigationGameWindowLeftUpFiles = new JPanel(); - jPanelIrrigationGameWindowLeftUpFiles.setLayout(null); - jPanelIrrigationGameWindowLeftUpFiles.setVisible(true); - jPanelIrrigationGameWindowLeftUpFiles.setBackground(new Color(238, 238, 238)); - jPanelIrrigationGameWindowLeftUpFiles.add(getOpenGateButton(), null); - } - return jPanelIrrigationGameWindowLeftUpFiles; - } - - /** - * This method initializes File1 - * - * @return javax.swing.JButton - */ - private JButton getOpenGateButton() { - if (openGateButton == null) { - openGateButton = new JButton(); - openGateButton.setText("Grow"); - openGateButton.setForeground(Color.black); - openGateButton.setSelected(true); - openGateButton.setBackground(new Color(186, 236, 237)); - openGateButton.setBounds(new Rectangle(48, 5, 63, 15)); - // TODO Auto-generated method stub - openGateButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent e) { - /** - * undisrupted Bandwidth Extensions - */ - if(clientData != null){ - if(clientData.getAvailableFlowCapacity() > 0){ - //file1.setBackground(Color.RED); - openGateButton.setEnabled(false); - openGate(); - } - } - else - System.out.println("ClientData is null"); - } - }); - } - return openGateButton; - } - - /** - * this will start the download for fileNo - * - * @param fileNo - */ - private void openGate() { - /* - * System.out.println("Before downloading file " + fileNo + "Current - * time" + System.currentTimeMillis() / 1000); - */ - - irrigationClient.openGate(); - initEnable(); - - - } - - /** - * This method initializes jPanel3121 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowLeftDownButtons() { - if (jPanelIrrigationGameWindowLeftDownButtons == null) { - jPanelIrrigationGameWindowLeftDownButtons = new JPanel(); - jPanelIrrigationGameWindowLeftDownButtons.setLayout(null); - /* - * jPanelIrrigationGameWindowLeftDownButtons.add(getStopDownload(), - * null); - */ - jPanelIrrigationGameWindowLeftDownButtons.add(getPauseDownload(), - null); - } - return jPanelIrrigationGameWindowLeftDownButtons; - } - - /** - * This method initializes jPanel3122- - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowLeftDownProgress() { - if (jPanelIrrigationGameWindowLeftDownProgress == null) { - fileDownloadedtxt = new JLabel(); - fileDownloadedtxt.setText("% Crop Grown:"); - fileDownloadedtxt.setBounds(new Rectangle(64, 32, 145, 16)); - jPanelIrrigationGameWindowLeftDownProgress = new JPanel(); - jPanelIrrigationGameWindowLeftDownProgress.setLayout(null); - jPanelIrrigationGameWindowLeftDownProgress.add(getFileDownloaded(), - null); - jPanelIrrigationGameWindowLeftDownProgress.add(fileDownloadedtxt, - null); - } - return jPanelIrrigationGameWindowLeftDownProgress; - } - - /** - * This method initializes StopDownload - * - * @return javax.swing.JButton - */ - // Removing the Stop Button Functionality - /* - * private JButton getStopDownload() { if (StopDownload == null) { - * StopDownload = new JButton(); StopDownload.setText("Stop "); - * StopDownload.setBounds(new Rectangle(16, 6, 103, 25)); - * StopDownload.setBackground(new Color(186, 226, 237)); - * StopDownload.setEnabled(false); StopDownload.addActionListener(new - * java.awt.event.ActionListener() { public void - * actionPerformed(java.awt.event.ActionEvent e) { - * PauseDownload.setEnabled(true); StopDownload.setEnabled(true); - * client.stopDownload(fileNo); enableFiles(); initDisable(); } - *//** - * just check this and implement later - * - * @param fileNo - */ - /* - * - * }); } return StopDownload; } - */ - - /** - * This method initializes FileDownloaded - * - * @return javax.swing.JProgressBar - */ - private JProgressBar getFileDownloaded() { - if (fileDownloadedProgressBar == null) { - fileDownloadedProgressBar = new JProgressBar(); - fileDownloadedProgressBar.setBounds(new Rectangle(63, 15, 148, 14)); - fileDownloadedProgressBar.setBackground(Color.white); - fileDownloadedProgressBar.setForeground(Color.green); - fileDownloadedProgressBar - .setFont(new Font("Dialog", Font.BOLD, 12)); - fileDownloadedProgressBar.setStringPainted(true); - } - return fileDownloadedProgressBar; - } - - /** - * This method initializes jPanel321 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationWindowRightUp() { - if (jPanelIrrigationWindowRightUp == null) { - GridLayout gridLayout7 = new GridLayout(); - gridLayout7.setRows(1); - GridLayout gridLayout6 = new GridLayout(); - gridLayout6.setRows(1); - jPanelIrrigationWindowRightUp.add( - getJPanelIrrigationGameWindowRightUp2(), null); - jPanelIrrigationWindowRightUp.add( - getJPanelIrrigationGameWindowRightUp1(), null); - } - return jPanelIrrigationWindowRightUp; - } - - /** - * This method initializes jPanel322 - * - * @return javax.swing.JPanel - */ - - public JPanel getJPanelIrrigationGameWindowRightDown(int file) { - if (jPanelIrrigationGameWindowRightDown == null) { - jPanelIrrigationGameWindowRightDown = new JPanel(); - jPanelIrrigationGameWindowRightDown.setLayout(null); - jPanelIrrigationGameWindowRightDown.setSize(530 / 2, 326 / 2); - jPanelIrrigationGameWindowRightDown.add(getJGraph(file)); - } - return jPanelIrrigationGameWindowRightDown; - } - - public JPanel getJGraph(int numberFileDownloaded) { - // TODO Auto-generated method stub - if (xySeriesDemo == null) { - xySeriesDemo = new ChartWindowPanel(numberFileDownloaded); - xySeriesDemo.setVisible(true); - } - return xySeriesDemo; - } - - /** - * This method initializes jPanel321 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowRightUp1() { - if (jPanelIrrigationWindowRightUp == null) { - GridLayout gridLayout8 = new GridLayout(); - gridLayout8.setRows(3); - jPanelIrrigationWindowRightUp = new JPanel(); - jPanelIrrigationWindowRightUp.setLayout(gridLayout8); - jPanelIrrigationWindowRightUp.add(getJPanel32122(), null); - jPanelIrrigationWindowRightUp.add( - getJPanelIrrigationGameWindowRightUp2(), null); - jPanelIrrigationWindowRightUp.add( - getJPanelIrrigationGameWindowRightUp3(), null); - } - return jPanelIrrigationWindowRightUp; - } - - /** - * This method initializes jPanel3211 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowRightUp2() { - if (jPanelIrrigationGameWindowRightUp2 == null) { - currentBandwidthAvailableTextjLabel = new JLabel(); - currentBandwidthAvailableTextjLabel.setBounds(new Rectangle(180, - 15, 65, 16)); - currentBandwidthAvailableTextjLabel.setText(""); - availableBandwidthLabel = new JLabel(); - availableBandwidthLabel.setText("% of capacity available:"); - availableBandwidthLabel.setBounds(new Rectangle(8, 5, 254, 18)); - jPanelIrrigationGameWindowRightUp2 = new JPanel(); - jPanelIrrigationGameWindowRightUp2.setLayout(null); - jPanelIrrigationGameWindowRightUp2.add( - getAvailableFlowCapacityLabel(), null); - jPanelIrrigationGameWindowRightUp2.add( - currentBandwidthAvailableTextjLabel, null); - } - return jPanelIrrigationGameWindowRightUp2; - } - - /** - * This method initializes jPanel3212 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel32122() { - if (jPanelIrrigationGameWindowRightUp1 == null) { - profitEarned = new JLabel(); - profitEarned.setText("Tokens Collected:"); - profitEarned.setBounds(new Rectangle(17, 18, 114, 21)); - jPanelIrrigationGameWindowRightUp1 = new JPanel(); - jPanelIrrigationGameWindowRightUp1.setLayout(null); - jPanelIrrigationGameWindowRightUp1.add(profitEarned, null); - jPanelIrrigationGameWindowRightUp1.add(getProfitEarnedTextField(), null); - } - return jPanelIrrigationGameWindowRightUp1; - } - - /** - * This method initializes jPanel3213 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanelIrrigationGameWindowRightUp3() { - if (jPanelIrrigationGameWindowRightUp3 == null) { - jPanelIrrigationGameWindowRightUp3 = new JPanel(); - jPanelIrrigationGameWindowRightUp3.setLayout(null); - jPanelIrrigationGameWindowRightUp3.add(availableBandwidthLabel, - null); - jPanelIrrigationGameWindowRightUp3.add(getAvailableBandwidthtxt(), - null); - } - return jPanelIrrigationGameWindowRightUp3; - } - - /** - * This method initializes AvailableBandwidthtxt - * - * @return javax.swing.JProgressBar - */ - private JProgressBar getAvailableBandwidthtxt() { - if (availableBandwidthTxt == null) { - availableBandwidthTxt = new JProgressBar(); - availableBandwidthTxt.setMaximum(25); - availableBandwidthTxt.setBounds(new Rectangle(15, 31, 240, 14)); - availableBandwidthTxt.setStringPainted(true); - availableBandwidthTxt.setBackground(Color.white); - availableBandwidthTxt.setForeground(new Color(51, 153, 255)); - availableBandwidthTxt.setValue(25); - } - return availableBandwidthTxt; - } - - /** - * This method initializes ProfitEarnedtxt - * - * @return javax.swing.JTextField - */ - private JTextField getProfitEarnedTextField() { - if (moneyEarnedTextField == null) { - moneyEarnedTextField = new JTextField(); - moneyEarnedTextField.setText(new Integer(mainIrrigationWindow - .getClientDataModel().getClientData().getAllTokensEarnedThisRound()) - .toString()); - moneyEarnedTextField.setBounds(new Rectangle(161, 17, 86, 21)); - moneyEarnedTextField.setFont(new Font("Dialog", Font.PLAIN, 14)); - moneyEarnedTextField.setEditable(false); - } - return moneyEarnedTextField; - } - - /** - * This method initializes PauseDownload - * - * @return javax.swing.JButton - */ - private JButton getPauseDownload() { - if (pauseDownload == null) { - pauseDownload = new JButton(); - pauseDownload.setBounds(new Rectangle(40, 7, 191, 25)); - pauseDownload.setText("Pause"); - pauseDownload.setBackground(new Color(186, 226, 237)); - pauseDownload.setEnabled(false); - pauseDownload.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent e) { - - if (pauseDownload.getText() == "Pause") { - pauseDownload.setText("Resume"); - // StopDownload.setEnabled(true); - irrigationClient.pause(); - } else if (pauseDownload.getText() == "Resume") { - pauseDownload.setText("Pause"); - irrigationClient.openGate(); - } - } - }); - } - return pauseDownload; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void initEnable() { - // TODO Auto-generated method stub - // StartDownload.setEnabled(false); - // StopDownload.setEnabled(true); - pauseDownload.setEnabled(true); - } - - public void initDisable() { - // TODO Auto-generated method stub - // StartDownload.setEnabled(false); - // StopDownload.setEnabled(false); - pauseDownload.setEnabled(false); - } - - /** - * refreshes the file buttons for the main irrigation window - */ - public void refreshButtons() { - openGateButton.setEnabled(true); - openGateButton.setBackground(new Color(186, 226, 237)); - } - - public void update(ClientData data) { - this.clientData = data; - Runnable createGuiRunnable = new Runnable() { - public void run() { - availableBandwidthTxt.setValue((int) clientData - .getAvailableFlowCapacity()); - if (clientData.getAvailableFlowCapacity() > 25) { - currentBandwidthAvailableTextjLabel.setText(new Double(25) - .toString()); - } else { - currentBandwidthAvailableTextjLabel.setText(new Double( - clientData.getAvailableFlowCapacity()).toString()); - } - - /* - * if(clientData.getAvailableBandwidth() == - * clientData.getMaximumAvailableBandwidth()){ - * bandwidthusedOtherTextjLabel.setText("0"); } else{ - * bandwidthusedOtherTextjLabel.setText(new - * Double(clientData.getMaximumAvailableBandwidth()- - * clientData.getAvailableBandwidth()).toString()); } - */ - -// fileDownloadedProgressBar.setValue((int) clientData.getPercentFileDownload()); - // checks whether the file has been downlaoded - /* - if (clientData.isFileDownloaded()) { - - moneyEarnedTextField.setText(new Integer(clientData.getTotalTokensEarned()) - .toString()); - // StopDownload.setEnabled(false); - pauseDownload.setEnabled(false); - } - else if(clientData.isGateOpen() || clientData.isPaused()){ - initEnable(); - } - /** - * undisrupted Bandwidth extensions - */ - if(clientData.getAvailableFlowCapacity() <= 0 && - irrigationClient.getServerConfiguration().isUndisruptedFlowRequired() ) - { - pauseDownload.setEnabled(false); - } - - } - }; - SwingUtilities.invokeLater(createGuiRunnable); - } - - /** - * This method initializes currentBandwidthAvailablejLabel - * - * @return javax.swing.JLabel - */ - private JLabel getAvailableFlowCapacityLabel() { - if (availableFlowCapacityLabel == null) { - availableFlowCapacityLabel = new JLabel(); - availableFlowCapacityLabel.setText("Your available flow capacity:"); - availableFlowCapacityLabel.setBounds(new Rectangle(17, 15, - 153, 16)); - } - return availableFlowCapacityLabel; - } -} 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-11-04 20:24:26 UTC (rev 354) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-07 22:58:44 UTC (rev 355) @@ -36,8 +36,6 @@ private static final long serialVersionUID = 5900368694556557132L; - public IrrigationGameWindow controlPanel; - private CanalPanel canalPanel; private JPanel jPanelMain = null; @@ -52,16 +50,6 @@ private JProgressBar timeLeftProgressBar; - 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; @@ -72,7 +60,7 @@ private JButton gateSwitchButton; - protected boolean open; + private boolean open; private JTextField waterCollectedTextField; @@ -104,29 +92,10 @@ super(); this.client = client; setName("main irrigation game window"); - initialize(); + initGuiComponents(); } - /** - * 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); - + private void initGuiComponents() { this.setLayout(new BorderLayout(4,4)); this.setSize(1130, 558); this.add(getPanel(),null); @@ -161,15 +130,6 @@ 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(""); - 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(""); mainInterfacePanel = new JPanel(); mainInterfacePanel.setLayout(null); mainInterfacePanel.setName("Main interface panel"); @@ -446,68 +406,18 @@ }); } - // //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 + * end of round interface cleanup. */ - - /* - * 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_LABEL); } - }); open = false; } @@ -517,19 +427,7 @@ */ 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() { @@ -545,40 +443,20 @@ waterSupply)); 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) { centerPanel.add(getCanalPanel(clientDataModel)); - //switch(clientGameState.getPriority()){ - mainInterfacePanel.add(getJPanelUpStreamWindow(),null); mainInterfacePanel.add(getJPanelDownStreamWindow(),null); - //adding the in between Panel mainInterfacePanel.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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-11-04 20:24:37
|
Revision: 354 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=354&view=rev Author: seematalele Date: 2009-11-04 20:24:26 +0000 (Wed, 04 Nov 2009) Log Message: ----------- Created a method getCurrentRoundNo(Game game) method in GameService. Bugs fixed : When first block was sent to the client, lazy initialization error was coming. Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-03 20:19:28 UTC (rev 353) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-04 20:24:26 UTC (rev 354) @@ -284,13 +284,13 @@ calculateHarvest(bay1StudentMap,"Bay1", game); /**calculateHarvest(bay2StudentMap,"Bay2"); calculateHarvest(bay3StudentMap,"Bay3"); - calculateHarvest(harborStudentMap,"Harbor"); + calculateHarvest(harborStudentMap,"Harbor"); **/ calculateTotalFishLeaving(game); - calculateFishReturned(); + /** calculateFishReturned(); - calculateNewPopulation(); **/ + calculateNewPopulation();**/ } @@ -446,14 +446,17 @@ double totalFishLeaving = 0; - Query query = studentDao.getCurrentSession().createQuery(groupsWithinGame); query.setLong("current_game_id", game.getId()); Iterator groups = query.list().iterator(); + GroupLocation groupLocation = null; while(groups.hasNext()) { - getLogger().debug("group id is: " + groups.next()); + Group group = (Group) groups.next(); + getLogger().debug("group id is: " + group.getId()); + groupLocation = groupLocationDao.findByProperty("group",group); + totalFishLeaving = totalFishLeaving + groupLocation.getFishLeaving(); } /*List<Student> students = studentDao.findAllByProperty("game", game); List<Long> groups = null; @@ -468,14 +471,9 @@ { groups.add(student.getGroup().getId()); } - } - */ + }*/ - /* for(Group group : groups) - { - totalFishLeaving = totalFishLeaving + location.getFishLeaving(); - } - setTotalFishLeaving(totalFishLeaving);*/ + setTotalFishLeaving(totalFishLeaving); } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-03 20:19:28 UTC (rev 353) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-04 20:24:26 UTC (rev 354) @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; +import org.hibernate.Query; + import org.hibernate.Hibernate; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +62,11 @@ MessageHandler msgHandler; + static final String roundNo = "SELECT gameRound.seqNo " + + "FROM GameRound gameRound, Game game " + + "where gameRound.gameConfig =:gameConfig and gameRound.round =:currentRound"; + + public GameService() { } @@ -143,7 +150,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - //pushBlock(game); + pushBlock(game); flag = true; } else @@ -178,7 +185,6 @@ int i=0; try { - //while (i<noOfBlocks) { i++; newGameState = getBlock(game); game = newGameState; @@ -194,19 +200,7 @@ initializeCurrentBlock(block); msgHandler.sendBlock(block,newGameState); } - - /*if(block.getDescription().equalsIgnoreCase("Day-by-day decisions game")) - { - //start day by day decision - //getDayBydayDecisionService(). - - } - else if (block.getDescription().equalsIgnoreCase("Communication")) - { - //start communication round - - }*/ - //} + }catch (Exception e) { getLogger().debug(e); } @@ -815,10 +809,10 @@ Hibernate.initialize(questionGroup); // getLogger().debug(questionGroup.getDescription()); List<Question> questions = questionGroup.getQuestions(); - + Hibernate.initialize(questions); for(int j = 0; j < questions.size(); j++) { - Hibernate.initialize(questions.get(j)); + ///Hibernate.initialize(questions.get(j)); if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) { CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); @@ -828,6 +822,7 @@ } } } + Module module = block.getModule(); Hibernate.initialize(module); @@ -892,17 +887,25 @@ setCurrentRound(currentRound); }*/ - - /*private int getCurrentRoundNo() { + // get the game as an parameter + private int getCurrentRoundNo(Game game) { // TODO Auto-generated method stub //FIXME: Game id 1 is hard coded but needs to make it dynamic - //Game game = gameDao.find(1L); - if(getCurrentGame().getCurrentRound() == null) - return 0; - else - return getCurrentGame().getCurrentRound().getRoundNo(); + Integer roundNo = 0; + Game currentGame = getDao().find(game.getId()); + if(currentGame.getCurrentRound() != null) + { + Query query = getDao().getCurrentSession().createQuery(GameService.roundNo); + query.setEntity("round", currentGame.getCurrentRound()); + query.setEntity("gameConfig", currentGame.getGameConfig()); + if(query.list().size() == 1) + roundNo = (Integer) query.list().get(0); + } + + return roundNo; - }*/ + } + public boolean isGameFinished(Game game) { GameConfig gameConfig = game.getGameConfig(); List<GameRound> gameRounds = getGameRoundDao().findAllByProperty("gameConfig",game.getGameConfig()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-03 21:45:35
|
Checking out at 14:45pm (2.5hr today) Seema tells me that the server side code might not be working for an indefinite time. Until then, I'll be working on documenting my code and trying to develop the client side of a chat program. On Tue, Nov 3, 2009 at 2:02 PM, Kalin Jonas <kj...@as...> wrote: > Back at 14:00pm > when left for several minutes after creating a game, the server seems to > shutdown and not push blocks when the game is finally started. > > > On Tue, Nov 3, 2009 at 1:40 PM, Kalin Jonas <kj...@as...> wrote: > >> Lunch break at 13:45pm >> >> >> On Tue, Nov 3, 2009 at 12:35 PM, Kalin Jonas <kj...@as...> wrote: >> >>> I came in today at 12:00pm, and there was a fire drill before I could >>> boot my computer. >>> I spoke with Allen about the reasons for the restructuring of the >>> server-side code. >>> I will be looking for where the error message "Error finding round for >>> Strategy Design!" occurs and try to redo the code that is finding its round. >>> >> >> > |
From: Kalin J. <kj...@as...> - 2009-11-03 21:02:21
|
Back at 14:00pm when left for several minutes after creating a game, the server seems to shutdown and not push blocks when the game is finally started. On Tue, Nov 3, 2009 at 1:40 PM, Kalin Jonas <kj...@as...> wrote: > Lunch break at 13:45pm > > > On Tue, Nov 3, 2009 at 12:35 PM, Kalin Jonas <kj...@as...> wrote: > >> I came in today at 12:00pm, and there was a fire drill before I could boot >> my computer. >> I spoke with Allen about the reasons for the restructuring of the >> server-side code. >> I will be looking for where the error message "Error finding round for >> Strategy Design!" occurs and try to redo the code that is finding its round. >> > > |
From: Kalin J. <kj...@as...> - 2009-11-03 20:40:26
|
Lunch break at 13:45pm On Tue, Nov 3, 2009 at 12:35 PM, Kalin Jonas <kj...@as...> wrote: > I came in today at 12:00pm, and there was a fire drill before I could boot > my computer. > I spoke with Allen about the reasons for the restructuring of the > server-side code. > I will be looking for where the error message "Error finding round for > Strategy Design!" occurs and try to redo the code that is finding its round. > |
From: <kj...@us...> - 2009-11-03 20:19:42
|
Revision: 353 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=353&view=rev Author: kjonas Date: 2009-11-03 20:19:28 +0000 (Tue, 03 Nov 2009) Log Message: ----------- Cleaned project, new swf files. Modified Paths: -------------- mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.swf mentalmodels/trunk/src/main/webapp/test.swf Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/test.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-11-03 20:16:09
|
Revision: 352 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=352&view=rev Author: kjonas Date: 2009-11-03 20:15:55 +0000 (Tue, 03 Nov 2009) Log Message: ----------- Removed distracting pop-up messages Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-10-30 22:46:20 UTC (rev 351) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-11-03 20:15:55 UTC (rev 352) @@ -130,15 +130,15 @@ { var msg:IMessage; - if(event.message.body as actionscript.Block) + if(event.message.body is actionscript.Block) { setBlock(event.message.body as actionscript.Block); } - else if(event.message.body as ArrayCollection) + else if(event.message.body is ArrayCollection) { var students:ArrayCollection = new ArrayCollection(); students = ArrayCollection(event.message.body); - Alert.show("Student size is: " + students.length); +// Alert.show("Student size is: " + students.length); if(students.length !=0) { for(var i:int = 0; i< students.length; i++) @@ -150,7 +150,7 @@ } } } - Alert.show("Current Student Information is: " + "\n"+studentObject.id +"\n"+studentObject.gameCode+"\n"+studentObject.studentNo); +// Alert.show("Current Student Information is: " + "\n"+studentObject.id +"\n"+studentObject.gameCode+"\n"+studentObject.studentNo); } } private function blockResultHandler(event:ResultEvent):void @@ -298,7 +298,7 @@ } else if(curr.getChildAt(j) is StrategyDesignQuestionC) { - Alert.show("Strategy Saving"); +// Alert.show("Strategy Saving"); studentResponse.response = null; studentResponse.question = null; @@ -422,7 +422,7 @@ { if(event.result is ArrayCollection) { - Alert.show(""+(event.result as ArrayCollection).length,"locations received"); +// Alert.show(""+(event.result as ArrayCollection).length,"locations received"); locations = event.result as ArrayCollection; if(instructions != null) { @@ -432,7 +432,7 @@ } private function strategyResultHandler(event:ResultEvent):void { -// Alert.show("Strategy Saved"); + Alert.show("Strategy Saved"); } private function studentResultHandler(event:ResultEvent):void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-11-03 19:35:34
|
I came in today at 12:00pm, and there was a fire drill before I could boot my computer. I spoke with Allen about the reasons for the restructuring of the server-side code. I will be looking for where the error message "Error finding round for Strategy Design!" occurs and try to redo the code that is finding its round. |
From: Kalin J. <kj...@as...> - 2009-11-02 00:40:27
|
checking out at 14:30pm. No idea why the sefver isn't accepting the saved responses from the client. will have to ask seema about it later. On Sun, Nov 1, 2009 at 11:37 AM, Kalin Jonas <kj...@as...> wrote: > Checking in at home at 11:30am. I am going to run a few more tests of the > experiment, and see if I can work on the problems that have been occuring > when sending the responses back to server. I also will look into why the > error message sometimes says that it cannot find the round. > > > On Thu, Oct 29, 2009 at 4:17 PM, Kalin Jonas <kj...@as...> wrote: > >> Checking out at 16:00pm(3hr today) >> It looks like the locations are showing up so that things say Harbor, >> Bay1, etc. again. >> Code appears to be synchronized with Seema's. >> >> >> On Thu, Oct 29, 2009 at 2:06 PM, Kalin Jonas <kj...@as...> wrote: >> >>> I am coming back at 14:00pm. >>> Talking to Seema and Allen, will be testing the new code, and starting >>> looking into the locations problem. >>> >>> >>> On Thu, Oct 29, 2009 at 11:22 AM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Checking out at 11:00 for now. I'm pretty sure the error was because the >>>> daybydaydecisions component was not initialized when it loads. I'm not sure >>>> why, but I'm changing it now. >>>> >>>> >>>> On Thu, Oct 29, 2009 at 10:13 AM, Kalin Jonas <kj...@as...> wrote: >>>> >>>>> Checked out at 14:00(3.25hr yesterday) >>>>> >>>>> checking in today at 10:00am. >>>>> I'll be testing the code, to see if i can replicate the error that >>>>> seema was getting, and figure out what is causing it. >>>>> >>>>> >>>>> On Wed, Oct 28, 2009 at 1:25 PM, Kalin Jonas <kj...@as...> wrote: >>>>> >>>>>> checking back in at 13:15pm >>>>>> >>>>>> >>>>>> On Wed, Oct 28, 2009 at 12:16 PM, Kalin Jonas <kj...@as...> wrote: >>>>>> >>>>>>> checking out for lunch at 12:15pm >>>>>>> >>>>>>> >>>>>>> On Wed, Oct 28, 2009 at 9:56 AM, Kalin Jonas <kj...@as...> wrote: >>>>>>> >>>>>>>> Today I came in at 9:45am, and have read over the last email Seema >>>>>>>> sent me. >>>>>>>> I'll be committing my code and then trying to make the >>>>>>>> ArrayCollection locations pass between the components. >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > |
From: Kalin J. <kj...@as...> - 2009-11-01 18:59:19
|
Checking in at home at 11:30am. I am going to run a few more tests of the experiment, and see if I can work on the problems that have been occuring when sending the responses back to server. I also will look into why the error message sometimes says that it cannot find the round. On Thu, Oct 29, 2009 at 4:17 PM, Kalin Jonas <kj...@as...> wrote: > Checking out at 16:00pm(3hr today) > It looks like the locations are showing up so that things say Harbor, Bay1, > etc. again. > Code appears to be synchronized with Seema's. > > > On Thu, Oct 29, 2009 at 2:06 PM, Kalin Jonas <kj...@as...> wrote: > >> I am coming back at 14:00pm. >> Talking to Seema and Allen, will be testing the new code, and starting >> looking into the locations problem. >> >> >> On Thu, Oct 29, 2009 at 11:22 AM, Kalin Jonas <kj...@as...> wrote: >> >>> Checking out at 11:00 for now. I'm pretty sure the error was because the >>> daybydaydecisions component was not initialized when it loads. I'm not sure >>> why, but I'm changing it now. >>> >>> >>> On Thu, Oct 29, 2009 at 10:13 AM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Checked out at 14:00(3.25hr yesterday) >>>> >>>> checking in today at 10:00am. >>>> I'll be testing the code, to see if i can replicate the error that seema >>>> was getting, and figure out what is causing it. >>>> >>>> >>>> On Wed, Oct 28, 2009 at 1:25 PM, Kalin Jonas <kj...@as...> wrote: >>>> >>>>> checking back in at 13:15pm >>>>> >>>>> >>>>> On Wed, Oct 28, 2009 at 12:16 PM, Kalin Jonas <kj...@as...> wrote: >>>>> >>>>>> checking out for lunch at 12:15pm >>>>>> >>>>>> >>>>>> On Wed, Oct 28, 2009 at 9:56 AM, Kalin Jonas <kj...@as...> wrote: >>>>>> >>>>>>> Today I came in at 9:45am, and have read over the last email Seema >>>>>>> sent me. >>>>>>> I'll be committing my code and then trying to make the >>>>>>> ArrayCollection locations pass between the components. >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >> > |
From: <see...@us...> - 2009-10-30 22:46:26
|
Revision: 351 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=351&view=rev Author: seematalele Date: 2009-10-30 22:46:20 +0000 (Fri, 30 Oct 2009) Log Message: ----------- 1) Created Many to Many relationship between DayByDayDecisions and Student with DayByDayOtherStudentDecisions entity. 2) Created HibernateDayByDayOtherStudentDecisionsDao.java, added in applicationContext.xml and hibernate.cfg.xml 3) Tested calculateHarvest method in DayByDayDecisionsService.java. Working for 3 students. 4) Changed the init-mme.sql to reflect the changes in database schema. 5) Changed the MessageHandler to send the first block only. Bugs - Lazy initialization exception for Block.QuestionGroup, when first block is sent to the client but subsequent blocks are sent successfully. Modified Paths: -------------- mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayByDayOtherStudentDecisionsDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayOtherStudentDecisions.java Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-10-30 22:46:20 UTC (rev 351) @@ -209,6 +209,23 @@ -- Table structure for table `day_by_day_decision` -- +DROP TABLE IF EXISTS `day_by_day_decision`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `day_by_day_decision` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `dayNumber` int(11) NOT NULL, + `earnings` double DEFAULT NULL, + `money` double DEFAULT NULL, + `location_id` bigint(20) NOT NULL, + `student_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`), + KEY `FK5B92B164224FD013` (`location_id`), + KEY `FK5B92B164992B5A41` (`student_id`), + CONSTRAINT `FK5B92B164992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), + CONSTRAINT `FK5B92B164224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `day_by_day_decision` @@ -220,30 +237,31 @@ UNLOCK TABLES; -- --- Table structure for table `day_by_day_decision_student` +-- Table structure for table `day_by_day_decision_otherstudent` -- -DROP TABLE IF EXISTS `day_by_day_decision_student`; +DROP TABLE IF EXISTS `day_by_day_decision_otherstudent`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `day_by_day_decision_student` ( - `day_by_day_decision_id` bigint(20) NOT NULL, - `otherStudents_id` bigint(20) NOT NULL, - UNIQUE KEY `otherStudents_id` (`otherStudents_id`), - KEY `FK19B3660EED8740B` (`day_by_day_decision_id`), - KEY `FK19B366031A9F4B4` (`otherStudents_id`), - CONSTRAINT `FK19B366031A9F4B4` FOREIGN KEY (`otherStudents_id`) REFERENCES `student` (`id`), - CONSTRAINT `FK19B3660EED8740B` FOREIGN KEY (`day_by_day_decision_id`) REFERENCES `day_by_day_decision` (`id`) +CREATE TABLE `day_by_day_decision_otherstudent` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `dayByDayDecision_id` bigint(20) NOT NULL, + `otherStudent_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`), + KEY `FK5751A40675FB192A` (`dayByDayDecision_id`), + KEY `FK5751A40623F64551` (`otherStudent_id`), + CONSTRAINT `FK5751A40623F64551` FOREIGN KEY (`otherStudent_id`) REFERENCES `student` (`id`), + CONSTRAINT `FK5751A40675FB192A` FOREIGN KEY (`dayByDayDecision_id`) REFERENCES `day_by_day_decision` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `day_by_day_decision_student` +-- Dumping data for table `day_by_day_decision_otherstudent` -- -LOCK TABLES `day_by_day_decision_student` WRITE; -/*!40000 ALTER TABLE `day_by_day_decision_student` DISABLE KEYS */; -/*!40000 ALTER TABLE `day_by_day_decision_student` ENABLE KEYS */; +LOCK TABLES `day_by_day_decision_otherstudent` WRITE; +/*!40000 ALTER TABLE `day_by_day_decision_otherstudent` DISABLE KEYS */; +/*!40000 ALTER TABLE `day_by_day_decision_otherstudent` ENABLE KEYS */; UNLOCK TABLES; -- @@ -858,4 +876,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-10-19 22:05:41 +-- Dump completed on 2009-10-30 22:37:53 Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayByDayOtherStudentDecisionsDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayByDayOtherStudentDecisionsDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateDayByDayOtherStudentDecisionsDao.java 2009-10-30 22:46:20 UTC (rev 351) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions; + +public class HibernateDayByDayOtherStudentDecisionsDao extends HibernateDao<DayByDayOtherStudentDecisions> { + + public HibernateDayByDayOtherStudentDecisionsDao() { + super(DayByDayOtherStudentDecisions.class); + } + +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-10-30 22:46:20 UTC (rev 351) @@ -1,20 +1,16 @@ package edu.asu.commons.mme.entity; import java.io.Serializable; -import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; -import org.hibernate.annotations.CollectionOfElements; - @Entity @Table(name="day_by_day_decision") public class DayByDayDecisions implements Serializable { @@ -43,8 +39,9 @@ @JoinColumn(nullable=false) private Student student; + /*@OneToMany(mappedBy = "dayByDayDecision") @CollectionOfElements(fetch = FetchType.EAGER) - private List<Student> otherStudents; + private List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions;*/ public void setId(Long id) { this.id = id; @@ -93,12 +90,13 @@ return dayNumber; } - public void setOtherStudents(List<Student> otherStudents) { - this.otherStudents = otherStudents; + /*public void setDayByDayOtherStudentDecisions( + List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions) { + this.dayByDayOtherStudentDecisions = dayByDayOtherStudentDecisions; } - public List<Student> getOtherStudents() { - return otherStudents; - } + public List<DayByDayOtherStudentDecisions> getDayByDayOtherStudentDecisions() { + return dayByDayOtherStudentDecisions; + }*/ } Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayOtherStudentDecisions.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayOtherStudentDecisions.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayOtherStudentDecisions.java 2009-10-30 22:46:20 UTC (rev 351) @@ -0,0 +1,59 @@ +package edu.asu.commons.mme.entity; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name="day_by_day_decision_otherStudent") +public class DayByDayOtherStudentDecisions implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7785433507972115797L; + + @Id + @GeneratedValue + private Long id; + + @ManyToOne + @JoinColumn(nullable = false) + private DayByDayDecisions dayByDayDecision; + + @ManyToOne + @JoinColumn(nullable = false) + private Student otherStudent; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setDayByDayDecision(DayByDayDecisions dayByDayDecision) { + this.dayByDayDecision = dayByDayDecision; + } + + public DayByDayDecisions getDayByDayDecision() { + return dayByDayDecision; + } + + public void setOtherStudent(Student otherStudent) { + this.otherStudent = otherStudent; + } + + public Student getOtherStudent() { + return otherStudent; + } + +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-10-30 22:46:20 UTC (rev 351) @@ -10,12 +10,14 @@ import org.springframework.transaction.annotation.Transactional; import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; +import edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao; import edu.asu.commons.mme.dao.HibernateGameDao; import edu.asu.commons.mme.dao.HibernateGroupDao; import edu.asu.commons.mme.dao.HibernateGroupLocationDao; import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.dao.HibernateStudentDao; import edu.asu.commons.mme.entity.DayByDayDecisions; +import edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions; import edu.asu.commons.mme.entity.Game; import edu.asu.commons.mme.entity.Group; import edu.asu.commons.mme.entity.GroupLocation; @@ -74,35 +76,39 @@ public class DayByDayDecisionsService extends Service.Base<DayByDayDecisions, HibernateDayByDayDecisionsDao> { - HibernateGameDao gameDao; + private HibernateGameDao gameDao; + private HibernateLocationDao locationDao; + private HibernateStudentDao studentDao; + private HibernateGroupLocationDao groupLocationDao; + private HibernateGroupDao groupDao; + private HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao; + private double totalFishLeaving; + + static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; + static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; + static final String getgroupLocation = "SELECT g FROM GroupLocation g where g.group =:group and g.location =:location"; + public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } - - HibernateLocationDao locationDao; + public void setLocationDao(HibernateLocationDao locationDao) { this.locationDao = locationDao; } - HibernateStudentDao studentDao; public void setStudentDao(HibernateStudentDao studentDao) { this.studentDao = studentDao; } - HibernateGroupLocationDao groupLocationDao; public void setGroupLocationDao(HibernateGroupLocationDao groupLocationDao) { this.groupLocationDao = groupLocationDao; } - HibernateGroupDao groupDao; - public void setGroupDao(HibernateGroupDao groupDao) { this.groupDao = groupDao; } - private double totalFishLeaving; - public double getTotalFishLeaving() { return totalFishLeaving; } @@ -111,10 +117,11 @@ this.totalFishLeaving = totalFishLeaving; } - static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; - static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; - static final String groupLocation = "SELECT * FROM mme.group_location g where g.group =:group and g.location =:location;"; - + public void setDayByDayOtherStudentDecisionsDao( + HibernateDayByDayOtherStudentDecisionsDao dayByDayOtherStudentDecisionsDao) { + this.dayByDayOtherStudentDecisionsDao = dayByDayOtherStudentDecisionsDao; + } + public List<DayByDayDecisions> saveStudentDecision(DayByDayDecisions studentDecision,Game game) { getLogger().debug("Student Id: " + studentDecision.getStudent().getId() + @@ -173,7 +180,6 @@ DayByDayDecisions studentDecision = new DayByDayDecisions(); List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); - //Bay1Service bay1 = new Bay1Service(); // List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); // List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); @@ -261,13 +267,6 @@ * 5) New population at each bay */ - - // bay1.executeStrategy(); - - //print bay1 map for testing - - - /*Iterator<Long> keys = bay1StudentMap.keySet().iterator(); while(keys.hasNext()) { @@ -282,7 +281,7 @@ }*/ - calculateHarvest(bay1StudentMap,"Bay1"); + calculateHarvest(bay1StudentMap,"Bay1", game); /**calculateHarvest(bay2StudentMap,"Bay2"); calculateHarvest(bay3StudentMap,"Bay3"); calculateHarvest(harborStudentMap,"Harbor"); @@ -299,18 +298,22 @@ - public void calculateHarvest(Map<Long, List<DayByDayDecisions>> bay1StudentMap,String locationName) + public void calculateHarvest(Map<Long, List<DayByDayDecisions>> bay1StudentMap,String locationName, Game game) { // TODO Auto-generated method stub - double maxFishCapacity = 5.0; + double maxFishCapacity = 0.0; double amountPerAgent = 0.0; double actualPopulation = 0.0; double growth = 0.0; double fishLeaving = 0.0; Long groupId; + DayByDayOtherStudentDecisions otherStudents; + + maxFishCapacity = game.getGameConfig().getMaxFishHarvest(); + getLogger().debug("maxFishCapacity is : " + maxFishCapacity); List<DayByDayDecisions> groupStudentDecisions = new ArrayList<DayByDayDecisions>(); - getLogger().debug("bay1StudentMap size is : " + bay1StudentMap.size() + "location name is : " + locationName); + /*getLogger().debug("bay1StudentMap size is : " + bay1StudentMap.size() + "location name is : " + locationName); Iterator<Long> keys1 = bay1StudentMap.keySet().iterator(); while(keys1.hasNext()) { @@ -322,7 +325,7 @@ getLogger().info("decision is: " + decision.getDayNumber() + "location number: " + decision.getLocation().getLocationName()); } - } + }*/ try { Iterator<Long> keys = bay1StudentMap.keySet().iterator(); @@ -335,22 +338,30 @@ Group group = groupDao.find(groupId); GroupLocation groupLocation = new GroupLocation(); - groupLocation.setLocation(location); + /*groupLocation.setLocation(location); groupLocation.setGroup(group); - List<GroupLocation> groupLocations = groupLocationDao.findByExample(groupLocation); + List<GroupLocation> groupLocations = groupLocationDao.findByExample(groupLocation);*/ - getLogger().debug("groupLocations size is: " + groupLocations.size()); + Query query = groupLocationDao.getCurrentSession().createQuery(getgroupLocation); + query.setEntity("location", location); + query.setEntity("group", group); + Iterator i = query.list().iterator(); + while(i.hasNext()) + { + groupLocation = (GroupLocation)i.next(); + getLogger().debug("groupLocation id is: " + groupLocation.getId()); + } - if(groupLocations.size()== 1) + /*if(groupLocations.size()== 1) { groupLocation = groupLocations.get(0); } else { //Error, should result only one result - } + }*/ //get current population actualPopulation = groupLocation.getCurrentPopulation(); @@ -381,35 +392,44 @@ groupLocation.setFishLeaving(fishLeaving); - //4) Population after diffusion actualPopulation = actualPopulation + growth - fishLeaving; getLogger().info("Fish population at " + locationName + " after diffusion is: " + actualPopulation); groupLocationDao.save(groupLocation); - + List<DayByDayDecisions> tempStudentDecisions = new ArrayList<DayByDayDecisions>(); + tempStudentDecisions = groupStudentDecisions; for(DayByDayDecisions dayByDayDecision : groupStudentDecisions) { - //set earning dayByDayDecision.setEarnings(amountPerAgent); //set money - dayByDayDecision.setMoney(0.0); + + dayByDayDecision.setMoney(game.getMoney() * amountPerAgent); //set other students - List<Student> otherStudents = new ArrayList<Student>(); + //List<Student> otherStudents = new ArrayList<Student>(); + + Long currentStudentId = dayByDayDecision.getStudent().getId(); - for(DayByDayDecisions students:groupStudentDecisions) + getLogger().debug("For student id is: " + currentStudentId); + + for(DayByDayDecisions students:tempStudentDecisions) { + getLogger().debug("temp student id is: " + students.getStudent().getId()); + if(students.getStudent().getId() != currentStudentId) { - otherStudents.add(students.getStudent()); + getLogger().debug("other student id is: " + students.getStudent().getId()); + otherStudents = new DayByDayOtherStudentDecisions(); + otherStudents.setDayByDayDecision(dayByDayDecision); + otherStudents.setOtherStudent(students.getStudent()); + dayByDayOtherStudentDecisionsDao.save(otherStudents); + } } - dayByDayDecision.setOtherStudents(otherStudents); - //Group group = dayByDayDecisions.getStudent().getGroup(); getDao().save(dayByDayDecision); } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-10-30 22:46:20 UTC (rev 351) @@ -143,7 +143,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - pushBlock(game); + //pushBlock(game); flag = true; } else @@ -191,6 +191,7 @@ { getLogger().debug("game state is NOT null..."); block = newGameState.getCurrentBlock(); + initializeCurrentBlock(block); msgHandler.sendBlock(block,newGameState); } @@ -626,7 +627,7 @@ Game newGame = saveGameState(currentBlock,currentRound,game); getLogger().debug("question group sizes is : " + newGame.getCurrentBlock().getQuestionGroups().size()); //initializeCurrentBlock(newGame.getCurrentBlock()); - initializeGame(newGame); + //initializeGame(newGame); getLogger().debug("Module is " + newGame.getCurrentBlock().getModule().getId() + "Block sent to the server is: " + currentBlock.getDescription()); return newGame; } @@ -747,12 +748,6 @@ GameConfig gameconfig = game.getGameConfig(); Hibernate.initialize(gameconfig); - /*for(Location location:gameconfig.getLocations()) - { - Hibernate.initialize(location); - - }*/ - Round round = game.getCurrentRound(); Hibernate.initialize(round); /*for(GameRound gameRound:round.getGameRounds()) @@ -766,8 +761,6 @@ e.printStackTrace(); } //Hibernate.initialize(gameconfig.getGameRounds()); - - } private void initializeModule(Module module) @@ -809,10 +802,11 @@ } } - @SuppressWarnings("unused") + private void initializeCurrentBlock(Block block) { Hibernate.initialize(block); + Hibernate.initialize(block.getQuestionGroups()); Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); { while(iteratorquestionGrp.hasNext()) Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/utility/MessageHandler.java 2009-10-30 22:46:20 UTC (rev 351) @@ -75,7 +75,7 @@ msg.setTimestamp(System.currentTimeMillis()); msg.setBody(block); AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); - if(block!=null) + /*if(block!=null) { //int duration = block.getDuration(); @@ -97,8 +97,8 @@ { System.out.println("Game is Over..." + msg); } +*/ - /*AcknowledgeMessage ack = msgBroker.routeMessageToService(msg, null); logger.info("Ack received from client for message " + msg + "is : " + ack); */ Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-10-30 22:46:20 UTC (rev 351) @@ -25,6 +25,7 @@ http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> + <!-- Flex related information started --> <flex:message-broker> <flex:message-service @@ -113,6 +114,9 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='dayByDayOtherStudentDecisionsDao' class='edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> <!-- spring managed service layer --> <bean id='gameService' class='edu.asu.commons.mme.service.GameService'> @@ -139,7 +143,9 @@ <property name='groupDao' ref='groupDao'/> <property name='gameDao' ref='gameDao'/> <property name='groupLocationDao' ref='groupLocationDao'/> + <property name='dayByDayOtherStudentDecisionsDao' ref='dayByDayOtherStudentDecisionsDao'/> + </bean> <bean id='roundService' class='edu.asu.commons.mme.service.RoundService'> Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-10-30 22:18:42 UTC (rev 350) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-10-30 22:46:20 UTC (rev 351) @@ -7,21 +7,18 @@ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> + <mapping class='edu.asu.commons.mme.entity.GameConfig'/> <mapping class='edu.asu.commons.mme.entity.Game'/> - <mapping class='edu.asu.commons.mme.entity.Round'/> + <mapping class='edu.asu.commons.mme.entity.Round'/> <mapping class='edu.asu.commons.mme.entity.GameRound'/> <mapping class='edu.asu.commons.mme.entity.Location'/> - <!-- - <mapping class='edu.asu.commons.mme.entity.RoundLocation'/> - --> <mapping class='edu.asu.commons.mme.entity.Communication'/> <mapping class='edu.asu.commons.mme.entity.Group'/> <mapping class='edu.asu.commons.mme.entity.Student'/> <mapping class='edu.asu.commons.mme.entity.GroupLocation'/> - <mapping class='edu.asu.commons.mme.entity.StudentRoundConfig'/> <mapping class='edu.asu.commons.mme.entity.StudentStrategy'/> <mapping class='edu.asu.commons.mme.entity.DayOutput'/> @@ -41,9 +38,10 @@ <mapping class='edu.asu.commons.mme.entity.ModuleRoundConfig'/> <mapping class='edu.asu.commons.mme.entity.InformationWindow'/> <mapping class='edu.asu.commons.mme.entity.BlockInformationWindow'/> + <mapping class='edu.asu.commons.mme.entity.DayByDayDecisions'/> + <mapping class='edu.asu.commons.mme.entity.DayByDayOtherStudentDecisions'/> - </session-factory> </hibernate-configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |