[virtualcommons-svn] SF.net SVN: virtualcommons:[368] irrigation/trunk/src/main/java/edu/asu/ commo
Status: Beta
Brought to you by:
alllee
From: <al...@us...> - 2009-11-19 03:43:00
|
Revision: 368 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=368&view=rev Author: alllee Date: 2009-11-19 03:42:52 +0000 (Thu, 19 Nov 2009) Log Message: ----------- minor hygiene / refactoring, renaming Modified Paths: -------------- 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/MainIrrigationGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ChatPanel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -177,7 +177,7 @@ } public void initialize(List<Identifier> participants) { - System.err.println("Setting participants: " + participants); + displayMessage("", " ---- chat round starting ---- "); if (HANDLES != null) { return; } @@ -187,7 +187,6 @@ HANDLES[i] = " " + HANDLE_STRING.charAt(i) + " "; chatHandles.put(participants.get(i), HANDLES[i]); } - displayMessage("", " ---- chat round starting ---- "); } public Identifier getClientId() { 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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ClientDataModel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -122,7 +122,7 @@ } public int getIrrigationCapacity() { - return groupDataModel.getIrrigationCapacity(); + return groupDataModel.getWaterDeliveryCapacity(); } 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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -207,6 +207,7 @@ else { setInstructions(instructionsBuilder.toString()); nextButton.setEnabled(false); + disableQuiz(); } } }); @@ -390,7 +391,7 @@ private void setInstructions(String instructions, boolean caretToEnd) { instructionsEditorPane.setText(instructions); - instructionsEditorPane.setCaretPosition(caretToEnd ? instructions.length() : 0); + instructionsEditorPane.setCaretPosition(caretToEnd ? instructions.length() - 1 : 0); } private void displayInstructions(final String instructions) { @@ -473,19 +474,19 @@ builder.append("<ul><li>Infrastructure efficiency before investment: ") .append(groupDataModel.getInfrastructureEfficiencyBeforeInvestment()) .append("%</li>"); - builder.append("<li>Irrigation capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second</li>"); + builder.append("<li>Water delivery capacity before investment: ").append(groupDataModel.getIrrigationCapacityBeforeInvestment()).append(" cubic feet per second</li>"); builder.append( String.format( "<li>Total group investment: %d tokens, increasing the infrastructure efficiency to %d%%</li>", totalContributedTokens, groupDataModel.getInfrastructureEfficiency())); - if (groupDataModel.getIrrigationCapacity() > groupDataModel.getIrrigationCapacityBeforeInvestment()) { - builder.append("<li><b>Your group's investment has increased the irrigation capacity to "); + if (groupDataModel.getWaterDeliveryCapacity() > groupDataModel.getIrrigationCapacityBeforeInvestment()) { + builder.append("<li><b>Your group's investment has increased the water delivery capacity to "); } else { - builder.append("<li>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 water delivery capacity. Your group's water delivery capacity is still "); } - 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>"); + builder.append(groupDataModel.getWaterDeliveryCapacity()).append(" cubic feet of water per second.</li><li>The amount of water available to pass through your irrigation canal is ") + .append(groupDataModel.getActualWaterDeliveryCapacity()).append(" cubic feet per second</li>"); SwingUtilities.invokeLater(new Runnable() { public void run() { contributionInformationEditorPane.setText(builder.toString()); @@ -538,17 +539,17 @@ infrastructureEfficiency = roundConfiguration.getInitialInfrastructureEfficiency(); } else { - infrastructureEfficiency = group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor(); + infrastructureEfficiency = Math.max(0, group.getInfrastructureEfficiency() - roundConfiguration.getInfrastructureDegradationFactor()); } addCenterComponent(getTokenInvestmentPanel()); StringBuilder builder = new StringBuilder(); builder.append( String.format( "<h2>Current infrastructure efficiency: %d%%</h2>" + - "<h2>Current irrigation capacity: %d cubic feet per second</h2>" + + "<h2>Current water delivery capacity: %d cubic feet per second</h2>" + "<h2>Available water supply: %d cubic feet per second</h2>", infrastructureEfficiency, - group.calculateFlowCapacity(infrastructureEfficiency), + group.calculateWaterDeliveryCapacity(infrastructureEfficiency), roundConfiguration.getWaterSupplyCapacity() )); builder.append(getServerConfiguration().getInvestmentInstructions()); @@ -563,18 +564,18 @@ if (! roundConfiguration.isFirstRound()) { instructionsBuilder.append(roundConfiguration.getInstructions()); instructionsBuilder.append("<hr/>"); - int irrigationCapacity = clientDataModel.getGroupDataModel().getIrrigationCapacity(); + int irrigationCapacity = clientDataModel.getGroupDataModel().getWaterDeliveryCapacity(); // int clientCapacity = roundConfiguration.getMaximumClientFlowCapacity(); if (roundConfiguration.shouldResetInfrastructureEfficiency()) { - instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75%."); + instructionsBuilder.append("The irrigation infrastructure efficiency is currently 75% (water delivery capacity of 35 cfps)."); } else { instructionsBuilder.append( - 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/>", + String.format("<p>The <b>irrigation infrastructure efficiency is %d%% (water delivery capacity of %d cfps)</b> but will <b>decline by %d%%</b> during this round." + + "The <b>available water supply is %d cfps</b>.</p><br/><hr/>", clientDataModel.getGroupDataModel().getInfrastructureEfficiency(), + irrigationCapacity, roundConfiguration.getInfrastructureDegradationFactor(), - irrigationCapacity, roundConfiguration.getWaterSupplyCapacity() )); } @@ -637,15 +638,11 @@ /** * 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 + * How do we know when it's done? */ - public void disableQuiz() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - getInstructionsPanel().remove(getQuizNavigationPanel()); - getInstructionsPanel().revalidate(); - } - }); + private void disableQuiz() { + getInstructionsPanel().remove(getQuizNavigationPanel()); + getInstructionsPanel().revalidate(); } public void showGameScreenshot() { 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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/InfrastructureEfficiencyChartPanel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -55,15 +55,15 @@ final XYSeries waterSupplySeries = new XYSeries("Available water supply"); GroupDataModel group = client.getClientDataModel().getGroupDataModel(); final int actualInfrastructureEfficiency = group.getInfrastructureEfficiency(); - final int actualFlowCapacity = group.getIrrigationCapacity(); + final int actualFlowCapacity = group.getWaterDeliveryCapacity(); for (int y = 0; y <= actualFlowCapacity; y++) { actualFlowCapacitySeries.add(actualInfrastructureEfficiency, 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); + for (int x = 0; x <= maximumInfrastructureEfficiency; x++) { + int flowCapacity = group.calculateWaterDeliveryCapacity(x); potentialFlowCapacitySeries.add(x,flowCapacity); waterSupplySeries.add(x, waterSupplyCapacity); } @@ -76,14 +76,15 @@ final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(initialInfrastructureEfficiencySeries); + // the second series gets turned blue. + data.addSeries(waterSupplySeries); data.addSeries(actualFlowCapacitySeries); data.addSeries(potentialFlowCapacitySeries); - data.addSeries(waterSupplySeries); final JFreeChart chart = ChartFactory.createXYLineChart( "Water Delivery Capacity vs. Infrastructure Efficiency", - "Infrastructure Efficiency", - "Water Delivery Capacity", + "Infrastructure Efficiency (%)", + "Water Delivery Capacity (cfps)", data, PlotOrientation.VERTICAL, true, 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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/MainIrrigationGameWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -124,10 +124,10 @@ private JPanel getMainInterfacePanel() { if(mainInterfacePanel == null){ - scoreBoardLabel = new JLabel("EARNINGS GRAPH"); + scoreBoardLabel = new JLabel(""); scoreBoardLabel.setBounds(new Rectangle(582,225+100+35,530,20)); scoreBoardLabel.setHorizontalAlignment(SwingConstants.CENTER); - gateSwitchLabel = new JLabel("DASHBOARD"); + gateSwitchLabel = new JLabel(""); gateSwitchLabel.setBounds(new Rectangle(13,225+100+35,530,20)); gateSwitchLabel.setHorizontalAlignment(SwingConstants.CENTER); mainInterfacePanel = new JPanel(); 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-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/facilitator/FacilitatorWindow.java 2009-11-19 03:42:52 UTC (rev 368) @@ -18,7 +18,6 @@ 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.server.ClientData; import edu.asu.commons.irrigation.server.GroupDataModel; import edu.asu.commons.irrigation.server.ServerDataModel; @@ -52,32 +51,28 @@ private JButton showScreenshotButton; - private JButton displayInvestmentButton; +// private JButton displayInvestmentButton; private StringBuilder builder = new StringBuilder(); - private JButton beginExperimentButton; + private JButton overrideButton; /** * This is the default constructor */ public FacilitatorWindow(Facilitator facilitator) { this.facilitator = facilitator; - initGuiComponents(); + initialize(); } - /** - * - * @return void - */ - private void initGuiComponents() { + private void initialize() { setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(getShowInstructionsButton()); - buttonPanel.add(getBeginChatButton()); - buttonPanel.add(getDisplayInvestmentButton()); buttonPanel.add(getShowScreenshotButton()); + buttonPanel.add(getBeginChatButton()); +// buttonPanel.add(getDisplayInvestmentButton()); buttonPanel.add(getStartRoundButton()); buttonPanel.add(getShowQuizButton()); buttonPanel.add(getStartRoundOverrideButton()); @@ -125,28 +120,28 @@ } private JButton getStartRoundOverrideButton() { - if (beginExperimentButton == null) { - beginExperimentButton = new JButton("Override"); - beginExperimentButton.addActionListener(new ActionListener() { + if (overrideButton == null) { + overrideButton = new JButton("Override"); + overrideButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { facilitator.sendStartRoundOverride(); } }); } - return beginExperimentButton; + return overrideButton; } - private JButton getDisplayInvestmentButton() { - if (displayInvestmentButton == null) { - displayInvestmentButton = new JButton("Show Investment Screen"); - displayInvestmentButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - facilitator.transmit(new ShowTokenInvestmentScreenRequest(facilitator.getId())); - } - }); - } - return displayInvestmentButton; - } +// private JButton getDisplayInvestmentButton() { +// if (displayInvestmentButton == null) { +// displayInvestmentButton = new JButton("Show Investment Screen"); +// displayInvestmentButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent event) { +// facilitator.transmit(new ShowTokenInvestmentScreenRequest(facilitator.getId())); +// } +// }); +// } +// return displayInvestmentButton; +// } public Facilitator getFacilitator() { return facilitator; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-11-18 07:15:06 UTC (rev 367) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-11-19 03:42:52 UTC (rev 368) @@ -96,7 +96,7 @@ totalContributedTokens += clientData.getInvestedTokens(); } updateInfrastructureEfficiency(totalContributedTokens); - currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualFlowCapacity(); + currentlyAvailableFlowCapacity = maximumAvailableWaterFlow = getActualWaterDeliveryCapacity(); } private void updateInfrastructureEfficiency(int totalContributedTokens) { @@ -124,7 +124,7 @@ * @param totalTokens * @return */ - public int calculateFlowCapacity(final int infrastructureEfficiency) { + public int calculateWaterDeliveryCapacity(final int infrastructureEfficiency) { if (infrastructureEfficiency <= 45) { return 0; } @@ -157,15 +157,15 @@ public int getIrrigationCapacityBeforeInvestment() { // return Math.min(calculateFlowCapacity(initialInfrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); - return calculateFlowCapacity(infrastructureEfficiencyBeforeInvestment); + return calculateWaterDeliveryCapacity(infrastructureEfficiencyBeforeInvestment); } /** * Returns the theoretical maximum amount of water that the infrastructure can handle. * This is independent of the actual water supply. */ - public int getIrrigationCapacity() { - return calculateFlowCapacity(infrastructureEfficiency); + public int getWaterDeliveryCapacity() { + return calculateWaterDeliveryCapacity(infrastructureEfficiency); // return Math.min(calculateFlowCapacity(infrastructureEfficiency), getRoundConfiguration().getWaterSupplyCapacity()); } @@ -174,8 +174,8 @@ * of the irrigation capacity and the water supply. * @return */ - public int getActualFlowCapacity() { - return Math.min(getIrrigationCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); + public int getActualWaterDeliveryCapacity() { + return Math.min(getWaterDeliveryCapacity(), getRoundConfiguration().getWaterSupplyCapacity()); } public void resetCurrentlyAvailableFlowCapacity() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |