[virtualcommons-svn] SF.net SVN: virtualcommons:[363] irrigation/trunk/src/main
Status: Beta
Brought to you by:
alllee
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. |