[virtualcommons-svn] SF.net SVN: virtualcommons:[312] irrigation/trunk/src/main/java/edu/asu/ commo
Status: Beta
Brought to you by:
alllee
From: <al...@us...> - 2009-10-21 06:50:56
|
Revision: 312 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=312&view=rev Author: alllee Date: 2009-10-21 05:59:23 +0000 (Wed, 21 Oct 2009) Log Message: ----------- updated contribution text area and continuing to refine game interface layout. Modified Paths: -------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java Removed Paths: ------------- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/Ball.java 2009-10-21 05:59:23 UTC (rev 312) @@ -2,14 +2,8 @@ import java.util.Random; -public class Ball{ +public class Ball { - public boolean isInServer; - - public boolean isInFirstCanal; - - public boolean isInSecondCanal; - private int size = 2; public int x; @@ -19,10 +13,10 @@ public int moveX; public int moveY; - public int xBOUNDSUPPER; - public int xBOUNDSLOWER; - public int yBOUNDSUPPER; - public int yBOUNDSLOWER; + public int xUpperBound; + public int xLowerBound; + public int yUpperBound; + public int yLowerBound; //just one global variable speciying the ten potential positions of the balls private int position; @@ -31,10 +25,10 @@ this.x = generator.nextInt(100); this.y = generator.nextInt(100); - this.xBOUNDSUPPER = 100; - this.yBOUNDSUPPER = 100; - this.xBOUNDSLOWER = 0; - this.yBOUNDSLOWER = 0; + this.xUpperBound = 100; + this.yUpperBound = 100; + this.xLowerBound = 0; + this.yLowerBound = 0; this.moveX = generator.nextInt(15); this.moveY = generator.nextInt(10); /*this.moveX = 3; @@ -44,30 +38,13 @@ } public void setPosition(int position) { - // TODO Auto-generated method stub - - //System.out.println("Setting the position :"+position); - this.position = position; - } public int getBallSize(){ return size; } - public boolean getIsInServer(){ - return isInServer; - } - - public boolean getIsInFirstCanal(){ - return isInFirstCanal; - } - - public boolean getIsInSecondCanal(){ - return isInSecondCanal; - } - public void setX(int x){ this.x = x; } @@ -77,25 +54,14 @@ } public int getPosition() { - // TODO Auto-generated method stub return position; } public int getX() { - // TODO Auto-generated method stub return x; } - /* - * will set the upper and the lower bounds for a ball depending on its position - */ - /*public void setBounds(int position) { - // TODO Auto-generated method stub - - }*/ - public int getY() { - // TODO Auto-generated method stub return y; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalAnimationPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -264,10 +264,10 @@ //still in server else { setBounds(i); - if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ + if(balls[i].x <= balls[i].xUpperBound || balls[i].x >= balls[i].xUpperBound-balls[i].getBallSize()){ balls[i].moveX = balls[i].moveX * -1; } - if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) + if(balls[i].y <= balls[i].yLowerBound || balls[i].y >= balls[i].yUpperBound-balls[i].getBallSize()) balls[i].moveY = balls[i].moveY * -1; } break; @@ -280,9 +280,9 @@ //directly pass in the information setBounds(i); /*System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - +" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER);*/ + +" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER);*/ /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -291,12 +291,12 @@ else{ setBounds(i); /*System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - +" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER); + +" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER); */ - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(2); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -309,7 +309,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -317,10 +317,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(3); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -333,7 +333,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -341,10 +341,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(4); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -356,7 +356,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -364,10 +364,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(5); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -379,7 +379,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -387,17 +387,17 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(6); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } break; case 6: setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ /*balls[i].setX(generator.nextInt(100)); balls[i].setY(100 - gate[0].getHeight()+ generator.nextInt(gate[0].getHeight())); balls[i].setPosition(0); @@ -405,7 +405,7 @@ setBallInTank(i); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } break; @@ -425,7 +425,7 @@ else{ setBounds(i); //System.out.println("X upper :"+balls[i].xBOUNDSUPPER+" Y Upper :"+balls[i].yBOUNDSUPPER - //+" X Lower"+balls[i].xBOUNDSLOWER+" X Upper"+balls[i].xBOUNDSUPPER); + //+" X Lower"+balls[i].xLowerBound+" X Upper"+balls[i].xBOUNDSUPPER); } } } @@ -448,10 +448,10 @@ private void setBounds(int ballIndex) { // ball is in the server if(balls[ballIndex].getPosition() == 0){ - balls[ballIndex].xBOUNDSUPPER = 100; - balls[ballIndex].xBOUNDSLOWER = 0; - balls[ballIndex].yBOUNDSUPPER = 100; - balls[ballIndex].yBOUNDSLOWER = 0; + balls[ballIndex].xUpperBound = 100; + balls[ballIndex].xLowerBound = 0; + balls[ballIndex].yUpperBound = 100; + balls[ballIndex].yLowerBound = 0; //balls[ballIndex].moveX = generator.nextInt(6); //balls[ballIndex].moveY = generator.nextInt(6); //balls[ballIndex].moveX = 3; @@ -461,20 +461,20 @@ if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 1].getY(); //balls[ballIndex].moveX = 3; //balls[ballIndex].moveY = 3; } //the ball is in one of the openings else{ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); balls[ballIndex].moveX = 0; balls[ballIndex].moveY = 3; } Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/CanalPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -86,8 +86,8 @@ } protected void paintComponent(Graphics graphics){ + super.paintComponent(graphics); // needed! updateGUI(); - super.paintComponent(graphics); // needed! Graphics2D graphics2D = (Graphics2D) graphics; graphics2D.setColor(Color.BLUE); graphics2D.fillRect(0,0,serverHeight,serverWidth); @@ -213,7 +213,7 @@ * This will process the balls according to their position */ private void process(int i){ - switch(balls[i].getPosition()){ + switch(balls[i].getPosition()) { case 0: if((balls[i].x >= (serverWidth - gateBuffer ) && balls[i].x <= serverWidth) && (balls[i].y >= serverHeight-(int)(maximumIrrigationCapacity*bandWidthCanalHeightMapping) && balls[i].y <= serverHeight)){ @@ -223,10 +223,10 @@ //still in server else{ setBounds(i); - if(balls[i].x <= balls[i].xBOUNDSLOWER || balls[i].x >= balls[i].xBOUNDSUPPER-balls[i].getBallSize()){ + if(balls[i].x <= balls[i].xLowerBound || balls[i].x >= balls[i].xUpperBound-balls[i].getBallSize()){ balls[i].moveX = balls[i].moveX * -1; } - if(balls[i].y <= balls[i].yBOUNDSLOWER || balls[i].y >= balls[i].yBOUNDSUPPER-balls[i].getBallSize()) + if(balls[i].y <= balls[i].yLowerBound || balls[i].y >= balls[i].yUpperBound-balls[i].getBallSize()) balls[i].moveY = balls[i].moveY * -1; } break; @@ -239,10 +239,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(2); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -257,10 +257,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(3); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -273,7 +273,7 @@ //directly pass in the information setBounds(i); /* balls[i].xBOUNDSUPPER = 420; - balls[i].xBOUNDSLOWER = 400; + balls[i].xLowerBound = 400; balls[i].yBOUNDSUPPER = 150; balls[i].yBOUNDSLOWER = 80; balls[i].moveX = 0; @@ -281,10 +281,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(4); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -298,10 +298,10 @@ } else{ setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(5); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } @@ -313,23 +313,23 @@ //directly pass in the information setBounds(i); } - else{ + else { setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ balls[i].setPosition(6); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } } break; case 6: setBounds(i); - if(balls[i].getX() > balls[i].xBOUNDSUPPER){ + if(balls[i].getX() > balls[i].xUpperBound){ setBallInServer(i); } - if(balls[i].getY() >= balls[i].yBOUNDSUPPER - balls[i].getBallSize() || balls[i].getY() <= balls[i].yBOUNDSLOWER){ + if(balls[i].getY() >= balls[i].yUpperBound - balls[i].getBallSize() || balls[i].getY() <= balls[i].yLowerBound){ balls[i].moveY = balls[i].moveY*-1; } break; @@ -362,10 +362,10 @@ // TODO Auto-generated method stub //ball is in the server if(balls[ballIndex].getPosition() == 0){ - balls[ballIndex].xBOUNDSUPPER = serverWidth; - balls[ballIndex].xBOUNDSLOWER = 0; - balls[ballIndex].yBOUNDSUPPER = serverHeight; - balls[ballIndex].yBOUNDSLOWER = 0; + balls[ballIndex].xUpperBound = serverWidth; + balls[ballIndex].xLowerBound = 0; + balls[ballIndex].yUpperBound = serverHeight; + balls[ballIndex].yLowerBound = 0; //balls[ballIndex].moveX = generator.nextInt(6); //balls[ballIndex].moveY = generator.nextInt(6); //balls[ballIndex].moveX = 3; @@ -375,17 +375,17 @@ if((balls[ballIndex].getPosition() == 1)||(balls[ballIndex].getPosition() == 2) || (balls[ballIndex].getPosition()==3) || (balls[ballIndex].getPosition() == 4) || (balls[ballIndex].getPosition() == 5)||(balls[ballIndex].getPosition() == 6)){ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 1].getY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 1].getX()+gate[balls[ballIndex].getPosition() - 1].getWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 1].getX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 1].getY()/*+gate[balls[ballIndex].getPosition() - 1].getHeight()*/; + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 1].getY(); } //the ball is in one of the openings else{ - balls[ballIndex].xBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); - balls[ballIndex].xBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); - balls[ballIndex].yBOUNDSUPPER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); - balls[ballIndex].yBOUNDSLOWER = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); + balls[ballIndex].xUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX()+gate[balls[ballIndex].getPosition() - 7].getGateWidth(); + balls[ballIndex].xLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsX(); + balls[ballIndex].yUpperBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY()+gate[balls[ballIndex].getPosition() - 7].getOpeningsHeight(); + balls[ballIndex].yLowerBound = gate[balls[ballIndex].getPosition() - 7].getOpeningsY(); //X change in motion balls[ballIndex].moveX = 0; //Y change in motion Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ExperimentGameWindow.java 2009-10-21 05:59:23 UTC (rev 312) @@ -12,7 +12,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.lang.reflect.InvocationTargetException; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -76,8 +75,6 @@ private StringBuilder instructionsBuilder = new StringBuilder(); - private int totalContributedTokensPerGroup; - private JTextArea contributionInformationTextArea; private JButton nextButton; @@ -567,36 +564,34 @@ } - public void updateGraphDisplay(final ClientData clientData) { - totalContributedTokensPerGroup = clientData.getGroupDataModel().getTotalContributedTokens(); - DecimalFormat df = new DecimalFormat("#.##"); - final String contributionInformation = - "Initial infrastructure efficiency: " + clientData.getGroupDataModel().getInitialInfrastructureEfficiency() + "%" - + "\n\nInitial flow capacity: " + clientData.getGroupDataModel().getInitialFlowCapacity() + " cubic feet per second " - + "\n\nActual infrastructure efficiency: " + clientData.getGroupDataModel().getInfrastructureEfficiency() + "%" - + "\n\nActual total flow capacity: " - + df.format(clientData.getGroupDataModel().getMaximumAvailableFlowCapacity()) + " cubic feet per second \n\n" - + "\n\nMaximum tokens that could have been contributed: " - + clientDataModel.getRoundConfiguration().getMaximumTotalInvestedTokens() - + "\n\nTotal tokens contributed: " - + totalContributedTokensPerGroup - + "\n\nYour token contribution: " - + clientData.getInvestedTokens() - + "\n\nTotal flow capacity that could have been generated: " - + clientDataModel.getRoundConfiguration().getMaximumCanalFlowCapacity() - + " cubic feet per second"; - - - + public void displayTokenContributions(final ClientData clientData) { + GroupDataModel groupDataModel = clientData.getGroupDataModel(); + int totalContributedTokensPerGroup = groupDataModel.getTotalContributedTokens(); + final StringBuilder builder = new StringBuilder(); + builder.append("Infrastructure efficiency before investment: ") + .append(groupDataModel.getInitialInfrastructureEfficiency()) + .append("%\n"); + builder.append("Irrigation capacity before investment: ").append(groupDataModel.getInitialFlowCapacity()).append(" cubic feet per second\n\n"); + builder.append( + String.format( + "Your group invested a total of %d tokens, increasing the infrastructure efficiency to %d%%.\n", + groupDataModel.getTotalContributedTokens(), groupDataModel.getInfrastructureEfficiency())); + if (groupDataModel.getFlowCapacity() > groupDataModel.getInitialFlowCapacity()) { + builder.append("Your group's investment has increased the irrigation capacity to "); + } + else { + builder.append("Your group's irrigation capacity after investment is "); + } + builder.append(groupDataModel.getFlowCapacity()).append('.'); SwingUtilities.invokeLater(new Runnable() { public void run() { - contributionInformationTextArea.setText(contributionInformation); + contributionInformationTextArea.setText(builder.toString()); infrastructureEfficiencyChartPanel.initialize(); pieChart.setClientData(clientData); addCenterComponent(getGraphPanel()); } }); - irrigationGamePanel.updateContributions(clientDataModel); + irrigationGamePanel.setClientDataModel(clientDataModel); } public JPanel getGraphPanel() { @@ -607,6 +602,7 @@ graphPanel.add(getPieChartPanel()); contributionInformationTextArea = new JTextArea(); contributionInformationTextArea.setEditable(false); + graphPanel.add(contributionInformationTextArea); } return graphPanel; Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationClient.java 2009-10-21 05:59:23 UTC (rev 312) @@ -170,7 +170,7 @@ public void handle(InfrastructureUpdateEvent event) { System.err.println("Received group update event: " + event); clientDataModel.setGroupDataModel(event.getGroupDataModel()); - experimentGameWindow.updateGraphDisplay(event.getClientData()); + experimentGameWindow.displayTokenContributions(event.getClientData()); } }); channel.add(this, new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/IrrigationGamePanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -46,7 +46,7 @@ //this contains the upstream and downstream Panel private JPanel jPanelUpStreamWindow = null; private JPanel jPanelDownStreamWindow = null; - private JPanel mainIrrigationPanel = null; +// private JPanel mainIrrigationPanel = null; private ScoreBoxPanel scoreBoxPanel; @@ -186,7 +186,7 @@ private JLabel getWaterUsedLabel() { if (waterUsedLabel == null) { - waterUsedLabel = new JLabel("Water units used: "); + waterUsedLabel = new JLabel("Water units collected: "); } return waterUsedLabel; } @@ -293,8 +293,8 @@ private JButton getGateSwitchButton() { if (gateSwitchButton == null) { - gateSwitchButton = new JButton("Open Gate"); - gateSwitchButton.setPreferredSize(new Dimension(60, 60)); + gateSwitchButton = new JButton("Open gate"); + gateSwitchButton.setPreferredSize(new Dimension(100, 100)); gateSwitchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { open = !open; @@ -375,9 +375,9 @@ } return timeRemainingProgressBar; } - //this event gets called every second in the experiment. + /** - * Shoudl be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. + * Should be invoked every second throughout the experiment, from a ClientUpdateEvent sent by the server. */ public void updateClientStatus(final ClientDataModel clientDataModel) { Runnable createGuiRunnable = new Runnable(){ @@ -442,6 +442,8 @@ canalPanel.endRound(); } }; + open = false; + gateSwitchButton.setText("Open gate"); try { SwingUtilities.invokeAndWait(createGuiRunnable); @@ -453,15 +455,8 @@ } - /** - * assigns the priority to the window and prepares the irrigationWindowMap - */ - public void updateContributions(final ClientDataModel clientDataModel) { + public void setClientDataModel(final ClientDataModel clientDataModel) { this.clientDataModel = clientDataModel; - //Here a map is created with the map consisting of the - //irrigation window as the value and the priority value as the key. This is handled here , because - //the event contains the priority for every client, and the priority can act as a unique key for the - //game window. } @@ -469,8 +464,8 @@ * fills in the panels depending on the priority of the client */ public void startRound() { - upperPanel.add(getCanalPanel(), BorderLayout.CENTER); open = false; + upperPanel.add(getCanalPanel(), BorderLayout.CENTER); getScoreBoxPanel().initialize(clientDataModel); getMiddleWindowPanel().initialize(clientDataModel); revalidate(); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/ScoreBoxPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -29,6 +29,7 @@ private void clear() { availableWaterLabels.clear(); waterUsedLabels.clear(); + removeAll(); } public void initialize(ClientDataModel clientDataModel) { @@ -39,20 +40,20 @@ GridLayout gridLayout = new GridLayout(3, columns); setLayout(gridLayout); - add(new JLabel("Position")); + add(new JLabel("Position:")); List<ClientData> clientDataList = clientDataModel.getClientDataSortedByPriority(); for (ClientData clientData : clientDataList) { add(new JLabel(clientData.getPriorityAsString())); } // available water per second - add(new JLabel("Available water per second")); + add(new JLabel("Available water per second:")); for (ClientData clientData: clientDataList) { JLabel availableWaterLabel = new JLabel("" + clientData.getAvailableFlowCapacity()); availableWaterLabels.add(availableWaterLabel); add(availableWaterLabel); } // water used - add(new JLabel("Water used")); + add(new JLabel("Water collected:")); for (ClientData clientData : clientDataList) { JLabel waterUsedLabel = new JLabel("" + clientData.getWaterUsed()); waterUsedLabels.add(waterUsedLabel); Deleted: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/client/SummaryPanel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -1,33 +0,0 @@ -package edu.asu.commons.irrigation.client; - -import javax.swing.JPanel; - -import edu.asu.commons.irrigation.server.ClientData; - - -/** - * $Id$ - * - * - * @author <a href='mailto:All...@as...'>Allen Lee</a> - * @version $Rev$ - */ -public class SummaryPanel extends JPanel { - - private static final long serialVersionUID = 2393688647176774993L; - - private IrrigationClient client; - - - public SummaryPanel(int parameterIndex, IrrigationClient client) { - super(); - this.client = client; - } - - - - public void update(ClientData clientData) { - - } - -} Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/ClientData.java 2009-10-21 05:59:23 UTC (rev 312) @@ -1,11 +1,8 @@ package edu.asu.commons.irrigation.server; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import edu.asu.commons.irrigation.conf.RoundConfiguration; -import edu.asu.commons.irrigation.events.FileDownloadedEvent; import edu.asu.commons.net.Identifier; /** @@ -18,7 +15,7 @@ * minus tokens subtracted by others * minus tokens subtracted by sanctioning others * - * @author <a href='ano...@gm...'>Allen Lee</a>, Deepali Bhagvat + * @author <a href='mailto:all...@as...'>Allen Lee</a>, Deepali Bhagvat * @version $Revision$ */ Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/GroupDataModel.java 2009-10-21 05:59:23 UTC (rev 312) @@ -95,8 +95,8 @@ return Collections.unmodifiableMap(clients); } - public int getCurrentlyAvailableFlowCapacity(){ - return currentlyAvailableFlowCapacity; + public int getAvailableClientFlowCapacity(){ + return Math.min(currentlyAvailableFlowCapacity, getRoundConfiguration().getMaximumClientFlowCapacity()); } public RoundConfiguration getRoundConfiguration() { @@ -197,8 +197,7 @@ } public void allocateFlowCapacity(ClientData clientData) { - RoundConfiguration roundConfiguration = getRoundConfiguration(); - int maximumClientFlowCapacity = roundConfiguration.getMaximumClientFlowCapacity(); + int maximumClientFlowCapacity = getRoundConfiguration().getMaximumClientFlowCapacity(); if (currentlyAvailableFlowCapacity >= maximumClientFlowCapacity) { currentlyAvailableFlowCapacity -= maximumClientFlowCapacity; clientData.setAvailableFlowCapacity(maximumClientFlowCapacity); Modified: irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java =================================================================== --- irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 00:29:19 UTC (rev 311) +++ irrigation/trunk/src/main/java/edu/asu/commons/irrigation/server/IrrigationServer.java 2009-10-21 05:59:23 UTC (rev 312) @@ -316,7 +316,7 @@ group.allocateFlowCapacity(clientData); } else if (clientData.isGateClosed()) { - clientData.init(group.getCurrentlyAvailableFlowCapacity()); + clientData.init(group.getAvailableClientFlowCapacity()); } // right now the clients cannot be paused. else if (clientData.isPaused()) { @@ -341,7 +341,7 @@ private IrrigationServerState state; - private long lastTime; +// private long lastTime; private Duration secondTick = Duration.create(1000L); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |