virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 56)
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: Kalin J. <kj...@as...> - 2009-12-18 18:44:36
|
Working from home today at 11:45am I will be working on commenting the rest of my code this time. |
From: <kj...@us...> - 2009-12-13 20:46:39
|
Revision: 414 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=414&view=rev Author: kjonas Date: 2009-12-13 20:46:31 +0000 (Sun, 13 Dec 2009) Log Message: ----------- added comments to actionscript/PageDisplay.as, custom/InstructionPage.mxml, and custom/SocioDemographicPage.mxml Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-10 21:56:15 UTC (rev 413) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-13 20:46:31 UTC (rev 414) @@ -39,6 +39,9 @@ return newLoc; } + // requires a block, and a list of locations. + // the "minimumPagesRead" variable will not let the student finish the block until that + // many pages have been viewed. public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) { currBlock = newBlock; @@ -47,9 +50,11 @@ highestPageReached = currentPageNumber; this.locations = locations; + // generates the objects that will be displayed on each "page" in the block loadPages(); } + // generates the objects that will be displayed on each "page" in the block public function loadPages():void { pages = new ArrayCollection(); @@ -65,6 +70,7 @@ return; } + // for each "questionGroup" in the block, make a "page" for(var group:int=0; group<currBlock.questionGroups.length; group++) { var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); @@ -73,16 +79,11 @@ if(questionGroup.questions != null && questionGroup.questions.length != 0) { + // for each question, try to make a component appear on screen for(var question:int=0; question<questionGroup.questions.length; question++) { var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); -// //This should be handled inside the question itself. -// var txt:Text = new Text(); -// txt.width = 300; -// txt.htmlText = tempQuestion.question; -// tempBox.addChild(txt); - if(tempQuestion is Categorical) { var cq:CategoricalQuestionC = new CategoricalQuestionC(); @@ -101,6 +102,8 @@ } else { + // these questions don't have a *Question class associated with them + // they are differentiated by Question.type:String if(tempQuestion == null || tempQuestion.type == null) { var tq:TextQuestionC = new TextQuestionC(); @@ -146,6 +149,7 @@ tempBox.addChild(ffq); } + // when all else fails, text question else { tq = new TextQuestionC(); @@ -165,8 +169,7 @@ var head:Text = new Text(); var desc:Text = new Text(); head.setStyle("fontSize", 12); - head.width = 600; - desc.width = 600; + head.width = desc.width = 600; head.htmlText = questionGroup.header; desc.htmlText = questionGroup.description; if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); @@ -176,6 +179,8 @@ // msg += "item added\n"; } + // if this is a communication round + // trying to add a communication component to the first page if(gameObject == null) return; if(gameObject.currentRound != null) { @@ -194,17 +199,21 @@ } } - public function componentsNotFinished(force:Boolean=false):Boolean + // returns true if all components on all pages are all finished + public function componentsFinished(force:Boolean=false):Boolean { - var returnValue:Boolean = false; + var returnValue:Boolean = true; var curr:VBox; var messages:String = ""; + // for each page for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) { curr = pages.getItemAt(pageNumber) as VBox; + var tempQuestion:DisplayObject; - var tempQuestion:DisplayObject; + // for each Strategy or DaybyDay decisions component + // if it is not complete, set the return value to false for(var i:int=0; i < curr.numChildren; i++) { tempQuestion = (curr.getChildAt(i) as DisplayObject); @@ -214,7 +223,7 @@ messages += "D"; if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) { - returnValue = true; + returnValue = false; } } else if(tempQuestion is StrategyDesignQuestionC) @@ -222,7 +231,7 @@ messages += "S"; if(!(tempQuestion as StrategyDesignQuestionC).accept()) { - returnValue = true; + returnValue = false; } } else @@ -232,35 +241,54 @@ } // Alert.show(messages + returnValue); } - return returnValue && !force; + + // if the force value is true, return true anyways + // else return the return value generated + return returnValue || force; } + + // returns whether the user has read enough pages, or if it's being forced public function finished(force:Boolean=false):Boolean - { return highestPageReached >= minPagesRead - 1 || force; } + { + return highestPageReached >= minPagesRead - 1 || force; + } public function get length():int - { return pages.length; } + { + return pages.length; + } + // returns the current page as a DisplayObject (VBox) + // This should be displayed public function get currentPage():DisplayObject { - if(pages != null && pages.length > 0) // pages? + if(pages != null && pages.length > 0) { - if(currentPageNumber < 0) currentPageNumber = 0; - if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; - return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT + // fix the pagenumber + currentPageNumber = fix(currentPageNumber, 0, pages.length-1); + + // return a valid result if any pages at all exist + return (DisplayObject)(pages.getItemAt(currentPageNumber)); } - return null; // no pages + return null; // no pages exist } + + // go to the next page, update highest page reached if necessary public function nextPage():Boolean { currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); highestPageReached = Math.max(currentPageNumber, highestPageReached) return true; } + + // go to the previous page public function prevPage():Boolean { currentPageNumber = fix(currentPageNumber - 1, 0, pages.length-1); return true; } + + // makes sure that a pagenumber is valid private function fix(n:Number,min:Number,max:Number):Number { if(n < min) return min; @@ -268,6 +296,7 @@ return n; } + // resets several types of questions to "abstain" public function reset():void { var curr:VBox = currentPage as VBox; Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-12-10 21:56:15 UTC (rev 413) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-12-13 20:46:31 UTC (rev 414) @@ -16,8 +16,8 @@ import mx.collections.ArrayCollection; [Bindable] public var gameObject:actionscript.Game = null; - [Bindable] public var moduleNumber:int = 1; - [Bindable] public var module:Module; + //[Bindable] public var moduleNumber:int = 1; + //[Bindable] public var module:Module; [Bindable] public var blockNumber:int = 0; [Bindable] public var block:Block; [Bindable] public var pageDisplay:PageDisplay; @@ -26,6 +26,7 @@ [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + // saved for use in information windows, etc public var savedForecastPeople:ArrayCollection = null; public var savedForecastFish:ArrayCollection = null; public var savedStrategyDesign:ArrayCollection = null; @@ -38,6 +39,8 @@ return newLoc; } + // makes sure the pageDisplay has been created + // then gives it gameObject public function setGameObject(newGameObject:actionscript.Game):void { this.gameObject = newGameObject; @@ -69,11 +72,15 @@ // init(module.blocks.getItemAt(blockNumber) as Block); // } + // this runs the first time a block is received + // creates a pagedisplay + // assigns pagedisplay a block + // displays first page to user public function init(newBlock:Block):void { block = newBlock; try{ -// debug2.text += "creating pageDisplay...\n"; + //debug2.text += "creating pageDisplay...\n"; var minPagesRead:int = 0; pageDisplay = null; if(block != null && block.questionGroups != null) @@ -86,9 +93,8 @@ debug2.text += "pageDisplay is null\n"; pageDisplay = new PageDisplay(makeBlock(),0,locations); } -// pageDisplay = new PageDisplay(block, block.questionGroups.length); - }catch(errObject:Error){ + // worst case scenario... still needs to have a pagedisplay debug2.text += "pageDisplay creation failure\n" + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; pageDisplay = new PageDisplay(makeBlock(),0,locations); @@ -96,13 +102,16 @@ } setGameObject(this.gameObject); + // set page numbers currPage = pageDisplay.currentPageNumber; numPages = pageDisplay.pages.length; + // add to display content.removeAllChildren(); content.addChild(pageDisplay.currentPage); } + // try to turn the page back public function back():Boolean { preTurn(); @@ -114,6 +123,7 @@ return pageSuccess; } + // try to turn the page forward public function forward():Boolean { preTurn(); @@ -124,6 +134,8 @@ } return pageSuccess; } + + // save the first forecasting component, if it exists private function preTurn():void { var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); @@ -135,12 +147,12 @@ } } } + // load values into new forecasting component, if it exists private function postTurn():void { currPage = pageDisplay.currentPageNumber; currPageLabel.htmlText = - "Module: "+moduleNumber+ - "<br>Block: "+(blockNumber+1)+ + "Block: "+(blockNumber+1)+ "<br>Page: "+(currPage+1)+" / "+numPages; content.removeAllChildren(); @@ -157,11 +169,12 @@ } + // try finishing the block public function accept(force:Boolean=false):Boolean { try { - if(pageDisplay.componentsNotFinished(force)) + if(! pageDisplay.componentsFinished(force)) { Alert.show("You must complete all required sections of the Block.","Cannot Advance"); } @@ -181,6 +194,7 @@ return false; } + // reset questions to abstain values public function reset():void { if(pageDisplay != null) @@ -189,6 +203,7 @@ } } + // save all components that we can, for use in infowindows etc public function saveData():void { var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); @@ -225,6 +240,7 @@ block = (loadArray.getItemAt(0) as Block); } + // creates a dummy block, in case something goes wrong creating the pagedisplay public function makeBlock():Block { var block:Block = new Block(); @@ -246,7 +262,7 @@ ]]> </mx:Script> - <mx:Text id="currPageLabel" htmlText="Module: {moduleNumber}<br>Block: {(blockNumber+1)}<br>Page: {(currPage+1)} / {numPages}"/> + <mx:Text id="currPageLabel" htmlText="Block: {(blockNumber+1)}<br>Page: {(currPage+1)} / {numPages}"/> <mx:VBox id="content"/> <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-12-10 21:56:15 UTC (rev 413) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-12-13 20:46:31 UTC (rev 414) @@ -37,13 +37,16 @@ var red:String = "#FF0000"; var white:String = "#FFFFFF"; - if(getGender().length != 1) // possible genders are: "M", "F", "Err" + // possible genders are: "M", "F", "Err" + if(getGender().length != 1) { boxGender.setStyle(bgcolor, red); ready=false; }else{ boxGender.setStyle(bgcolor, ""); } + + // age must be less than 180 years ago var today:Date = new Date(); if(getYear().length != 4 || Number(getYear()) < today.fullYear - 180 || Number(getYear()) > today.fullYear) { @@ -131,7 +134,7 @@ <mx:HBox> <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> <mx:ComboBox id="cbxSemester" selectedIndex="0" dataProvider="{new ArrayCollection(['Freshman','Sophomore','Junior','Senior','Graduate/Other'])}"/> - <!--<mx:TextInput id="txtSemester" width="75" maxChars="6"/>--> + <!--<mx:TextInput id="txtSemester" width="75" maxChars="7"/>--> </mx:HBox> <mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-12-13 20:45:08
|
checking out at 13:30pm committing changes in code/comments On Sun, Dec 13, 2009 at 10:33 AM, Kalin Jonas <kj...@as...> wrote: > working from home today at 10:30 am > commenting code in pagedisplay.as, and question files > > > On Fri, Dec 11, 2009 at 4:06 PM, Kalin Jonas <kj...@as...> wrote: > >> Checking out at 4:00(4hr) >> I spoke with seema in great length about the server, and feel more >> confident with the layout of this project. >> over the weekend, i will continue commenting my coe (3hrs) and commit at >> the end of the weekend. >> >> >> On Fri, Dec 11, 2009 at 12:13 PM, Kalin Jonas <kj...@as...> wrote: >> >>> coming in today at 12:00 >>> I'll be adding comments to code until seema is free to discuss the server >>> >>> >>> On Thu, Dec 10, 2009 at 2:59 PM, Kalin Jonas <kj...@as...> wrote: >>> >>>> I have added comments to two of the most important files to the >>>> client-side of the project as per Seema's request. >>>> We decided that Friday would be the best day to try and discuss the >>>> process of creating a service, so that I might be able to work on areas of >>>> the project that were previously strictly Seema's due to lack of knowledge. >>>> I will continue adding comments to the files on the flex side. >>>> Checking out at 15:00pm (4.5hr) >>>> >>>> >>>> On Thu, Dec 10, 2009 at 10:35 AM, Kalin Jonas <kj...@as...> wrote: >>>> >>>>> Coming in to work at 10:30am >>>>> Seema and I are discussing the latest changes. >>>>> >>>> >>>> >>> >> > |
From: Kalin J. <kj...@as...> - 2009-12-13 17:34:08
|
working from home today at 10:30 am commenting code in pagedisplay.as, and question files On Fri, Dec 11, 2009 at 4:06 PM, Kalin Jonas <kj...@as...> wrote: > Checking out at 4:00(4hr) > I spoke with seema in great length about the server, and feel more > confident with the layout of this project. > over the weekend, i will continue commenting my coe (3hrs) and commit at > the end of the weekend. > > > On Fri, Dec 11, 2009 at 12:13 PM, Kalin Jonas <kj...@as...> wrote: > >> coming in today at 12:00 >> I'll be adding comments to code until seema is free to discuss the server >> >> >> On Thu, Dec 10, 2009 at 2:59 PM, Kalin Jonas <kj...@as...> wrote: >> >>> I have added comments to two of the most important files to the >>> client-side of the project as per Seema's request. >>> We decided that Friday would be the best day to try and discuss the >>> process of creating a service, so that I might be able to work on areas of >>> the project that were previously strictly Seema's due to lack of knowledge. >>> I will continue adding comments to the files on the flex side. >>> Checking out at 15:00pm (4.5hr) >>> >>> >>> On Thu, Dec 10, 2009 at 10:35 AM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Coming in to work at 10:30am >>>> Seema and I are discussing the latest changes. >>>> >>> >>> >> > |
From: Kalin J. <kj...@as...> - 2009-12-11 23:06:40
|
Checking out at 4:00(4hr) I spoke with seema in great length about the server, and feel more confident with the layout of this project. over the weekend, i will continue commenting my coe (3hrs) and commit at the end of the weekend. On Fri, Dec 11, 2009 at 12:13 PM, Kalin Jonas <kj...@as...> wrote: > coming in today at 12:00 > I'll be adding comments to code until seema is free to discuss the server > > > On Thu, Dec 10, 2009 at 2:59 PM, Kalin Jonas <kj...@as...> wrote: > >> I have added comments to two of the most important files to the >> client-side of the project as per Seema's request. >> We decided that Friday would be the best day to try and discuss the >> process of creating a service, so that I might be able to work on areas of >> the project that were previously strictly Seema's due to lack of knowledge. >> I will continue adding comments to the files on the flex side. >> Checking out at 15:00pm (4.5hr) >> >> >> On Thu, Dec 10, 2009 at 10:35 AM, Kalin Jonas <kj...@as...> wrote: >> >>> Coming in to work at 10:30am >>> Seema and I are discussing the latest changes. >>> >> >> > |
From: Kalin J. <kj...@as...> - 2009-12-11 19:13:23
|
coming in today at 12:00 I'll be adding comments to code until seema is free to discuss the server On Thu, Dec 10, 2009 at 2:59 PM, Kalin Jonas <kj...@as...> wrote: > I have added comments to two of the most important files to the client-side > of the project as per Seema's request. > We decided that Friday would be the best day to try and discuss the process > of creating a service, so that I might be able to work on areas of the > project that were previously strictly Seema's due to lack of knowledge. > I will continue adding comments to the files on the flex side. > Checking out at 15:00pm (4.5hr) > > > On Thu, Dec 10, 2009 at 10:35 AM, Kalin Jonas <kj...@as...> wrote: > >> Coming in to work at 10:30am >> Seema and I are discussing the latest changes. >> > > |
From: Kalin J. <kj...@as...> - 2009-12-10 21:59:19
|
I have added comments to two of the most important files to the client-side of the project as per Seema's request. We decided that Friday would be the best day to try and discuss the process of creating a service, so that I might be able to work on areas of the project that were previously strictly Seema's due to lack of knowledge. I will continue adding comments to the files on the flex side. Checking out at 15:00pm (4.5hr) On Thu, Dec 10, 2009 at 10:35 AM, Kalin Jonas <kj...@as...> wrote: > Coming in to work at 10:30am > Seema and I are discussing the latest changes. > |
From: <kj...@us...> - 2009-12-10 21:56:24
|
Revision: 413 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=413&view=rev Author: kjonas Date: 2009-12-10 21:56:15 +0000 (Thu, 10 Dec 2009) Log Message: ----------- added comments to custom/FisheryExperimentCore.mxml and FisheryExperimentShell.mxml Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-12-08 20:47:25 UTC (rev 412) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-12-10 21:56:15 UTC (rev 413) @@ -9,6 +9,8 @@ [Bindable] public var progressBarWidth:Number = 600; private var repetitions:int = 100; + // This timer ticks every 100 milliseconds + // repetitions need to be seconds * 10 public function setProgressBarTime(hours:int,minutes:int,seconds:int):void { repetitions = seconds * 10; @@ -23,18 +25,16 @@ } public function timerTick(event:TimerEvent):void { - tick(progressTimer.currentCount/progressTimer.repeatCount); + // set to current/total % of the full progressbar's width + progressBarBlock.width = progressBarWidth*(progressTimer.currentCount/progressTimer.repeatCount); } - private function tick(percentBlock:Number):void - { - progressBarBlock.width = progressBarWidth*percentBlock; - } ]]></mx:Script> <mx:HBox id="shell" horizontalGap="30" y="{(height - shell.height)/2}" x="{(width - shell.width)/2}"> + <!-- information windows --> <mx:VBox id="vbxInfo"> <mx:TitleWindow id="InformationWindowA" width="400" height="220" title="Information Window A" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> @@ -54,6 +54,7 @@ <mx:Button id="btnResetPopups" label="Reset Popups" click="{closedFunction(1);closedFunction(2)}"/> </mx:VBox> + <!-- END information windows --> <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> <mx:VBox id="progressBars" x="0" y="0" verticalGap="0"> @@ -84,15 +85,20 @@ import mx.managers.PopUpManager; import mx.messaging.events.MessageFaultEvent; + // These are the actual windows that pop up and can be moved around public var popupA:InformationWindowPopup = null; public var popupB:InformationWindowPopup = null; + // Lists that contain the data that goes into information windows public var allInfoWindowsA:ArrayCollection = null; public var allInfoWindowsB:ArrayCollection = null; public var allInfoWindowsDescriptions:ArrayCollection = null; + + // used to update things like daybydaydecisions within information windows public var updateObjectA:InformationWindowCreator = null; public var updateObjectB:InformationWindowCreator = null; + // list of the windows available for this block public var currInfoWindowsA:ArrayCollection = null; public var currInfoWindowsB:ArrayCollection = null; public var currInfoWindowsDescriptions:ArrayCollection = null; @@ -109,8 +115,18 @@ var str:String = msg.body as String; Alert.show("String came from server: " + str); } + public function init():void { + initWindows(); + } + + // Since the FisheryExperimentShell file is largely concerned with + // information windows, this function creates lists of all possible windows + // A and B copies must be generated, as Flex will not allow us to display the + // same component in two different locations + public function initWindows():void + { // temporarily store all 3 objects returned... allInfoWindowsA = makeWindows(); allInfoWindowsB = makeWindows(); @@ -127,36 +143,36 @@ // Display only the default windows. selectCurrentWindows( new ArrayCollection() ); - } + // pops up window 1 or 2 (A or B) + // This function takes all the data from an information window and puts it into + // a larger popup that can be dragged around the screen. public function popupInformationWindow(window:int):void { var temp:DisplayObject = null; + // first, create the popup (object. this does not make it visible) var popupNew:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; popupNew.closedFunction = closedFunction; popupNew.window = window; var old:TitleWindow = null; - if(window == 1) - { - old = InformationWindowA; - popupA = popupNew; - btnPickerA.enabled = cbxPickerA.enabled = false; - } - else if(window == 2) - { - old = InformationWindowB; - popupB = popupNew; - btnPickerB.enabled = cbxPickerB.enabled = false; - } - else - { + // set up some variables + if(window == 1){ + old = InformationWindowA; // data source + popupA = popupNew; // data destination + btnPickerA.enabled = cbxPickerA.enabled = false; // only one "A" popup at a time + }else if(window == 2){ + old = InformationWindowB; // data source + popupB = popupNew; // data destination + btnPickerB.enabled = cbxPickerB.enabled = false; // only one "B" popup at a time + }else{ return; } + // transfer all data, scale to full size while(old != null && old.numChildren > 0) { temp = old.removeChildAt(0); @@ -165,14 +181,17 @@ popupNew.addChild(temp); } + // show the popup itself PopUpManager.centerPopUp(popupNew); } + // Closing all popups public function closedFunction(window:int):void { var temp:DisplayObject = null; if(popupA != null && window == 1) { + // transfer all data, scale to 75% while(popupA.numChildren > 0) { temp = popupA.removeChildAt(0); @@ -180,12 +199,14 @@ temp.scaleY = 0.75; InformationWindowA.addChild(temp); } + // destroy the popup PopUpManager.removePopUp(popupA); popupA = null; } if(popupB != null && window == 2) { + // transfer all data, scale to 75% while(popupB.numChildren > 0) { temp = popupB.removeChildAt(0) @@ -193,14 +214,18 @@ temp.scaleY = 0.75; InformationWindowB.addChild(temp); } + // destroy the popup PopUpManager.removePopUp(popupB); popupB = null; } + // allow "A" and "B" to be popped up again btnPickerA.enabled = btnPickerB.enabled = true; cbxPickerA.enabled = cbxPickerB.enabled = true; } + // generates and returns a list of all possible information windows + // and saves their descriptions to a single arraycollection public function makeWindows():ArrayCollection { var windowData:ArrayCollection = InformationWindowCreator.makeWindows(); @@ -209,19 +234,26 @@ return windowData; } + // only enable the user to see the windows associated with the current block public function selectCurrentWindows(selectedWindows:ArrayCollection):void { + // these windows are mandatory: 0,2,3 var mustHaveWindows:ArrayCollection = new ArrayCollection([0,2,3]); + // close all popups. closedFunction(1); closedFunction(2); + // drop data from previous executions currInfoWindowsA = new ArrayCollection(); currInfoWindowsB = new ArrayCollection(); currInfoWindowsDescriptions = new ArrayCollection(); + // sort through all possible windows for(var i:int = 0; i < allInfoWindowsA.length; i++) { + // if any window is in the list for the block, or mandatory + // then add it to the lists of current windows if(selectedWindows.contains(i) || mustHaveWindows.contains(i)) { currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(i)); @@ -229,20 +261,25 @@ currInfoWindowsDescriptions.addItem(allInfoWindowsDescriptions.getItemAt(i)); } } - cbxPickerA.dataProvider = currInfoWindowsDescriptions; cbxPickerB.dataProvider = currInfoWindowsDescriptions; + // refresh the information windows on the sides cbxChanged(); } + // refreshes which information window is shown (ex: user switches selection, or new block) public function cbxChanged():void { var temp:DisplayObject = null; + + // if a valid selection is made if(cbxPickerA.selectedIndex >= 0 && cbxPickerA.selectedIndex <= currInfoWindowsA.length && cbxPickerA.enabled) { + // discard old data InformationWindowA.removeAllChildren(); + // transfer all data, scale to 75% var windowA:ArrayCollection = currInfoWindowsA.getItemAt(cbxPickerA.selectedIndex) as ArrayCollection; for(var i:int = 0; i < windowA.length; i++) { @@ -253,10 +290,13 @@ } } + // if a valid selection is made if(cbxPickerB.selectedIndex >= 0 && cbxPickerB.selectedIndex <= currInfoWindowsB.length && cbxPickerB.enabled) { + // discard old data InformationWindowB.removeAllChildren(); + // transfer all data, scale to 75% var windowB:ArrayCollection = currInfoWindowsB.getItemAt(cbxPickerB.selectedIndex) as ArrayCollection; for(var j:int = 0; j < windowB.length; j++) { @@ -268,16 +308,20 @@ } } + // new block is received public function loadBlock(block:Block):void { if(block != null) { + // store the new block currentBlock = block; + var tempArray:ArrayCollection = new ArrayCollection(); - var i:int = 0; var temp:Object = null; + // search the block's information windows for all valid "BlockInformationWindow" objects + // add the valid ones to the list of desired windows and update the display var str:String = currentBlock.informationWindows.length + " of them.\n"; for(i = 0; i < currentBlock.informationWindows.length; i++) { Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-12-08 20:47:25 UTC (rev 412) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-12-10 21:56:15 UTC (rev 413) @@ -5,6 +5,8 @@ width="720" height="490"> <mx:states> + <!-- This state has nothing but the sociodemographic information + It is used to get the game ID to connect to the server --> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> <comp:SocioDemographicPage id="socioDemographic" @@ -14,6 +16,7 @@ <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> + <!-- This is a temporary state that jumpstarts the "instructions" state for the first time --> <mx:State name="instructionsLoad"> <mx:AddChild relativeTo="{content}"> <comp:InstructionPage id="instructions" initialize="gotoInstructions()" x="0" y="0" @@ -21,25 +24,28 @@ </mx:AddChild> </mx:State> + <!-- This state displays Blocks received from the server using InstructionPage --> <mx:State name="instructions" enterState="instructions.init(currentBlock)"> <mx:RemoveChild target="{instructions}"/> <mx:AddChild relativeTo="{content}" target="{instructions}"/> <mx:SetProperty target="{instructions}" name="visible" value="true"/> </mx:State> + <!-- This state is used between Blocks (ex: a student finishes a block early) --> <mx:State name="wait"> <mx:AddChild relativeTo="{content}"> <mx:Label id="lblWaiting" text="Waiting for next Block from server..." fontSize="16"/> </mx:AddChild> </mx:State> + <!-- This state should only show up when the game is completely finished --> <mx:State name="none"> - <!--<mx:RemoveChild target="{instructions}"/>--> <mx:AddChild relativeTo="{expiredContent}" target="{instructions}"/> <mx:SetProperty target="{instructions}" name="visible" value="false"/> <mx:AddChild relativeTo="{content}"> <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> </mx:AddChild> + <!-- disable navigation buttons --> <mx:SetProperty target="{btnAccept}" name="enabled" value="false"/> <mx:SetProperty target="{btnReset}" name="enabled" value="false"/> <mx:SetProperty target="{btnBack}" name="enabled" value="false"/> @@ -47,9 +53,12 @@ </mx:State> </mx:states> + <!-- Content - SocioDemographicPage or InstructionPage or "THE END" (visible to user) + ExpiredContent - holds sociodemographic and instructionpage so they aren't destroyed (invisible to user) --> <mx:Canvas id="content" x="0" y="0" width="720" height="460"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> + <!-- Navigation Buttons --> <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="100"> <mx:Button id="btnBack" label="« Back" click="back()" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" /> @@ -57,7 +66,7 @@ <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> </mx:HBox> - + <!-- services that control the connection to the server --> <mx:RemoteObject id="studentService" destination="studentService" fault="faultHandler(event)"> <mx:method name="createStudent" result="studentResultHandler(event)"/> </mx:RemoteObject> @@ -68,7 +77,8 @@ <mx:method name="getAllLocations" result="locationResultHandler(event)"/> </mx:RemoteObject> - + <!-- Using Consumer instead of service so that the server can control + when responses are sent to multiple clients, (ex: end of block) --> <mx:Consumer id="consumer" destination="mme" message="messageHandler(event)" fault="faultMsgHandler(event)" channelSet="{cs}" /> <mx:ChannelSet id="cs"> @@ -106,22 +116,21 @@ // Important Variables // public var gameObject:actionscript.Game = null; -// public var currentModule:Module = null; -// public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + public var instructionsLoaded:Boolean = false; + [Bindable] public var studentObject:actionscript.Student; + [Bindable] public var roundObject:actionscript.Round; + // should be set when created by the FisheryExperimentShell (aka "shell") public var shell:FisheryExperimentShell = null; + // information window objects given by the shell public var updateObjectA:InformationWindowCreator = null; public var updateObjectB:InformationWindowCreator = null; - public var instructionsLoaded:Boolean = false; - [Bindable] public var studentObject:actionscript.Student; - [Bindable] public var roundObject:actionscript.Round; - public function faultMsgHandler(msgevent:MessageFaultEvent):void { Alert.show("Error in getting message: " + msgevent.faultString); @@ -131,6 +140,10 @@ { var msg:IMessage; + // Responds to receiving a Block or Game by initializing the new block included + // Responds to ArrayCollection by assuming it is of Student objects + // This code assigns group and student numbers based on the object whose id + // matches studentObject if(event.message.body is actionscript.Block) { setBlock(event.message.body as actionscript.Block); @@ -163,32 +176,36 @@ // Alert.show("Current Student Information is: " + "\n"+studentObject.id +"\n"+studentObject.gameCode+"\n"+studentObject.studentNo); } } - private function blockResultHandler(event:ResultEvent):void - { - setBlock(event.result as actionscript.Block); - } + + // new block received private function setBlock(block:Block):void { -// Alert.show(currentState); + // if the game is over, pop up an error message if(currentState == "none") { Alert.show("Block received in End of Game state.","Unexpected Block"); } + // if we're waiting for a block, call the function to load the new block else if(currentState == "wait") { loadNextBlock(block); } + // if we're not finished with the last block, force it to complete, then load the new block else if(currentState == "instructions") { -// Alert.show("FORCING"); accept(true); loadNextBlock(block); } + // if we're not ready for any blocks, show an error + // This will cause a crash for this client + // but this should never happen else if(currentState == "socioDemographic") { currentState = "none"; Alert.show("Block received in Socio Demographic state.","Unexpected Block"); } + // If somehow receiving a second block before loading the first is finished + // avoid conflicts and corrupt data by crashing else if(currentState == "instructionsLoad") { currentState = "none"; @@ -200,24 +217,34 @@ { var newLoc:Location = new Location(); //newLoc.maxCapacity = maxCapacity; - newLoc.growthRate = growth; //newLoc.initialPopulation = maxCapacity / 2.0; + newLoc.growthRate = growth; return newLoc; } - public function init():void { - + // asks server to get the list of all locations getLocations(); } + // asks server to get the list of all locations + private function getLocations():void + { + locationService.getAllLocations(); + } + + // this method executed when the instructionsLoad private function gotoInstructions():void { + // enable navigation btnForward.enabled = btnBack.enabled = btnReset.enabled = true; + instructionsLoaded = true; currentState = "instructions"; } + + // sends answers to questions to the server private function sendBlockQuestions():void { if(currentBlock == null) return; @@ -226,10 +253,12 @@ var studentResponse:StudentResponse; var pages:ArrayCollection = instructions.pageDisplay.pages; + // for each page... for(var i:int=0; i<pages.length; i++) { var curr:VBox = pages.getItemAt(i) as VBox + // for each question... for(var j:int=0; j<curr.numChildren; j++) { studentResponse = new StudentResponse(); @@ -238,6 +267,7 @@ var row:int, col:int; + // try to get a student response and send it if(curr.getChildAt(j) is TextQuestionC) { studentResponse.question = (curr.getChildAt(j) as TextQuestionC).question; @@ -308,7 +338,6 @@ } else if(curr.getChildAt(j) is StrategyDesignQuestionC) { -// Alert.show("Strategy Saving"); studentResponse.response = null; studentResponse.question = null; @@ -326,6 +355,7 @@ answeringService.saveStrategy(tempDBObjects); } + // if there was a question found, add it to the list to submit if(studentResponse.question != null) { responseList.addItem(studentResponse); @@ -333,14 +363,11 @@ } } + // submit the list of answers answeringService.saveQuestion(responseList); } - private function getLocations():void - { - locationService.getAllLocations(); - } - + // save the last instances of each key component to the shell for use in information windows private function saveDataToShell():void { if(instructions.savedDayByDayDecisions != null) @@ -362,6 +389,7 @@ } } + // When a new block is received, this method is executed private function loadNextBlock(nextBlock:Block):void { // save questions from previous Block @@ -372,7 +400,7 @@ saveDataToShell(); } - // update with new block + // update reference to recently received block currentBlock = nextBlock; if(currentBlock == null @@ -384,6 +412,8 @@ return; } + // If this is the first block, make sure instructions have been loaded first + // (instructionsLoad state will proceed to instructions afterward) if(!instructionsLoaded) { currentState = "instructionsLoad"; @@ -393,46 +423,18 @@ gotoInstructions(); } + // tell shell that a new block has arrived shell.loadBlock(currentBlock); - // start timer to alert students to hurry + // start timer shell.setProgressBarTime(0,0,currentBlock.duration); shell.progressBarInit(); } -// private function moduleResultHandler(event:ResultEvent):void -// { -// currentModule = (event.result as actionscript.Module); -// -// if(currentModule == null) -// { -// currentState = "none"; -// } -// else if(currentModule.blocks == null || currentModule.blocks.length < 1 || -// (currentModule.blocks.getItemAt(0) as Block) == null || -// (currentModule.blocks.getItemAt(0) as Block).questionGroups == null || -// (currentModule.blocks.getItemAt(0) as Block).questionGroups.length < 1) -// { -// currentState = "none"; -// } -// else if(!instructionsLoaded) -// { -// currentState = "instructionsLoad"; -// } -// else -// { -// gotoInstructions(); -// } -// } - public function getLocation():void - { - - } private function locationResultHandler(event:ResultEvent):void { if(event.result is ArrayCollection) { -// Alert.show(""+(event.result as ArrayCollection).length,"locations received"); locations = event.result as ArrayCollection; if(instructions != null) { @@ -442,16 +444,17 @@ } private function strategyResultHandler(event:ResultEvent):void { - Alert.show("Strategy Saved"); + //Alert.show("Strategy Saved"); } + // complete student object received from server private function studentResultHandler(event:ResultEvent):void { studentObject = event.result as actionscript.Student; if(studentObject == null) { - Alert.show("event.result is null"); + Alert.show("event.result is null in studentResultHandler()"); } else { @@ -466,44 +469,37 @@ Alert.show("Fault:\n"+event.fault.message + "\n" + event.fault.getStackTrace()); } + // navigation public function back():Boolean { - if(content.numChildren == 0) - { return false; } + if(content.numChildren == 0) return false; var obj:DisplayObject = content.getChildAt(0); - if(obj is InstructionPage) - { - try - { + if(obj is InstructionPage){ + try{ return (InstructionPage)(obj).back(); - } - catch(err:Error){} + }catch(err:Error){} } return false; } public function forward():Boolean { - if(content.numChildren == 0) - { return false; } + if(content.numChildren == 0) return false; var obj:DisplayObject = content.getChildAt(0); - if(obj is InstructionPage) - { - try - { + if(obj is InstructionPage){ + try{ return (InstructionPage)(obj).forward(); - } - catch(err:Error){} + }catch(err:Error){} } return false; } + // user says they are done with the block/sociodem public function accept(force:Boolean=false):Boolean { - if(content.numChildren == 0) - { return false; } + if(content.numChildren == 0) return false; var obj:DisplayObject = content.getChildAt(0); var returnValue:Boolean = false; @@ -515,6 +511,7 @@ obj.visible = false; expiredContent.addChild(obj); + // feed the info for a student into an object and send to server var newStudent:actionscript.Student = new actionscript.Student(); newStudent.birthYear = (int)((obj as SocioDemographicPage).getYear()); newStudent.gender = (obj as SocioDemographicPage).getGender(); @@ -524,10 +521,10 @@ studentService.createStudent(newStudent); + // move from sociodemographic state to waiting for next block currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; - //getNextBlock(); returnValue = true; } } @@ -541,9 +538,7 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; - //consumer.subscribe(); - //getNextBlock(); returnValue = true; } } @@ -553,11 +548,13 @@ } } + // enable navigation if the current state is instructions btnBack.enabled = btnForward.enabled = btnReset.enabled = (currentState == "instructions"); return returnValue; } + // try to reset questions on any instruction pages public function reset():void { if(content.getChildAt(0) is InstructionPage) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-12-10 17:43:30
|
Coming in to work at 10:30am Seema and I are discussing the latest changes. |
From: Kalin J. <kj...@as...> - 2009-12-08 20:54:17
|
Checking out at 13:45 today I tried to put the communication component into the PageDisplay.as file, but it seems that the GameObject is null when it shouldn't be. hopefully I can work this out next time I come in. On Tue, Dec 8, 2009 at 10:50 AM, Kalin Jonas <kj...@as...> wrote: > Coming in to work today at 10:45 > I am trying to put the communication component into the experiment, as i > forgot to do earlier. > |
From: <kj...@us...> - 2009-12-08 20:47:33
|
Revision: 412 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=412&view=rev Author: kjonas Date: 2009-12-08 20:47:25 +0000 (Tue, 08 Dec 2009) Log Message: ----------- updated 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-12-08 20:42:02
|
Revision: 411 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=411&view=rev Author: kjonas Date: 2009-12-08 20:41:37 +0000 (Tue, 08 Dec 2009) Log Message: ----------- renamed from custom/Communication.mxml to custom/CommunicationC.mxml added code into actionscript/PageDisplay.as to display custom/CommunicationC.mxml components to the client during the first question_group of a communication round. (this seems not to work, as the gameObject or its currentRound is null Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/test.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/Student.as mentalmodels/trunk/flex/src/custom/Communication.mxml Deleted: mentalmodels/trunk/flex/src/Student.as =================================================================== --- mentalmodels/trunk/flex/src/Student.as 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/Student.as 2009-12-08 20:41:37 UTC (rev 411) @@ -1,11 +0,0 @@ -package -{ - [Bindable] - [RemoteClass(alias="student.Student")] - public class Student - { - public var fname:String; - public var lname:String; - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-08 20:41:37 UTC (rev 411) @@ -1,285 +1,303 @@ -// ActionScript file -package actionscript -{ - import actionscript.questions.*; - - import custom.questions.*; - import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; - import custom.questions.forecasting.*; - import custom.questions.psychometric.PsychometricQuestionC; - import custom.questions.strategyDesign.StrategyDesignQuestionC; - - import flash.display.DisplayObject; - - import mx.collections.ArrayCollection; - import mx.containers.VBox; - import mx.controls.Text; - - [Bindable] - public class PageDisplay - { - public var msg:String = ""; - - public var gameObject:actionscript.Game = null; - public var pages:ArrayCollection; - public var minPagesRead:int; - public var currentPageNumber:int; - public var highestPageReached:int; - - public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - - public var currBlock:Block; - - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - - public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) - { - currBlock = newBlock; - minPagesRead = minimumPagesRead; - currentPageNumber = 0; - highestPageReached = currentPageNumber; - this.locations = locations; - - loadPages(); - } - - public function loadPages():void - { - pages = new ArrayCollection(); - - if(currBlock == null) - { - msg += "block is null"; - return; - } - if(currBlock.questionGroups == null || currBlock.questionGroups.length == 0) - { - msg += "no QuestionGroups found\n"; - return; - } - - for(var group:int=0; group<currBlock.questionGroups.length; group++) - { - var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); - var tempBox:VBox = new VBox(); - tempBox.visible = true; - - if(questionGroup.questions != null && questionGroup.questions.length != 0) - { - for(var question:int=0; question<questionGroup.questions.length; question++) - { - var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); - -// //This should be handled inside the question itself. -// var txt:Text = new Text(); -// txt.width = 300; -// txt.htmlText = tempQuestion.question; -// tempBox.addChild(txt); - - if(tempQuestion is Categorical) - { - var cq:CategoricalQuestionC = new CategoricalQuestionC(); - cq.loadFromQuestion(Categorical(tempQuestion)); - cq.id = "q"+question; - - tempBox.addChild(cq); - } - else if(tempQuestion is Psychometric) - { - var pq:PsychometricQuestionC = new PsychometricQuestionC(); - pq.loadFromQuestion(Psychometric(tempQuestion)); - pq.id = "q"+question; - - tempBox.addChild(pq); - } - else - { - if(tempQuestion == null || tempQuestion.type == null) - { - var tq:TextQuestionC = new TextQuestionC(); - tq.loadFromQuestion(Question(tempQuestion)); - tq.id = "q"+question; - - tempBox.addChild(tq); - } - else if(tempQuestion.type.toLowerCase() == "strategydesign") - { - var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); - sdq.locations = locations; - sdq.setRound(gameObject.currentRound); - sdq.loadFromQuestion(Question(tempQuestion)); - sdq.id = "q"+question; - - tempBox.addChild(sdq); - } - else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") - { - var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); - ddq.locations = locations; - ddq.loadFromQuestion(Question(tempQuestion)); - ddq.id = "q"+question; - - tempBox.addChild(ddq); - } - else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") - { - var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); - fpq.locations = locations; - fpq.loadFromQuestion(tempQuestion); - fpq.id = "q"+question; - - tempBox.addChild(fpq); - } - else if(tempQuestion.type.toLowerCase() == "forecastingfish") - { - var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); - ffq.locations = locations; - ffq.loadFromQuestion(tempQuestion); - ffq.id = "q"+question; - - tempBox.addChild(ffq); - } - else - { - tq = new TextQuestionC(); - tq.loadFromQuestion(Question(tempQuestion)); - tq.id = "q"+question; - - tempBox.addChild(tq); - } - } - } - } - else - { -// msg += "no Questions found\n"; -// Alert.show(msg); - } - var head:Text = new Text(); - var desc:Text = new Text(); - head.setStyle("fontSize", 12); - head.width = 600; - desc.width = 600; - head.htmlText = questionGroup.header; - desc.htmlText = questionGroup.description; - if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); - if(head.htmlText.length != 0) tempBox.addChildAt(head,0); - - pages.addItem(tempBox); -// msg += "item added\n"; - } - - } - - public function componentsNotFinished(force:Boolean=false):Boolean - { - var returnValue:Boolean = false; - var curr:VBox; - var messages:String = ""; - - for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) - { - curr = pages.getItemAt(pageNumber) as VBox; - - var tempQuestion:DisplayObject; - for(var i:int=0; i < curr.numChildren; i++) - { - tempQuestion = (curr.getChildAt(i) as DisplayObject); - - if(tempQuestion is DayByDayDecisionsQuestionC) - { - messages += "D"; - if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) - { - returnValue = true; - } - } - else if(tempQuestion is StrategyDesignQuestionC) - { - messages += "S"; - if(!(tempQuestion as StrategyDesignQuestionC).accept()) - { - returnValue = true; - } - } - else - { - messages += "x"; - } - } -// Alert.show(messages + returnValue); - } - return returnValue && !force; - } - public function finished(force:Boolean=false):Boolean - { return highestPageReached >= minPagesRead - 1 || force; } - public function get length():int - { return pages.length; } - - public function get currentPage():DisplayObject - { - if(pages != null && pages.length > 0) // pages? - { - if(currentPageNumber < 0) currentPageNumber = 0; - if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; - return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT - } - - return null; // no pages - } - public function nextPage():Boolean - { - currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); - highestPageReached = Math.max(currentPageNumber, highestPageReached) - return true; - } - public function prevPage():Boolean - { - currentPageNumber = fix(currentPageNumber - 1, 0, pages.length-1); - return true; - } - private function fix(n:Number,min:Number,max:Number):Number - { - if(n < min) return min; - if(n > max) return max; - return n; - } - - public function reset():void - { - var curr:VBox = currentPage as VBox; - var messages:String = ""; - - if(curr != null) - { - var tempQuestion:DisplayObject; - for(var i:int=0; i < curr.numChildren; i++) - { - tempQuestion = (curr.getChildAt(i) as DisplayObject); - - if(tempQuestion is PsychometricQuestionC) - { - (tempQuestion as PsychometricQuestionC).slider1.reset(); - messages += "P"; - } - else if(tempQuestion is CategoricalQuestionC) - { - (tempQuestion as CategoricalQuestionC).comboTopic.selectedIndex = 0; - (tempQuestion as CategoricalQuestionC).comboSpecific.selectedIndex = -1; - messages += "C"; - } - else - { - messages += "x"; - } - } -// Alert.show(messages); - } - } - } +// ActionScript file +package actionscript +{ + import actionscript.questions.*; + + import custom.CommunicationC; + import custom.questions.*; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.*; + import custom.questions.psychometric.PsychometricQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; + + import flash.display.DisplayObject; + + import mx.collections.ArrayCollection; + import mx.containers.VBox; + import mx.controls.Alert; + import mx.controls.Text; + + [Bindable] + public class PageDisplay + { + public var msg:String = ""; + + public var gameObject:actionscript.Game = null; + public var pages:ArrayCollection; + public var minPagesRead:int; + public var currentPageNumber:int; + public var highestPageReached:int; + + public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + + public var currBlock:Block; + + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.growthRate = growth; + return newLoc; + } + + public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) + { + currBlock = newBlock; + minPagesRead = minimumPagesRead; + currentPageNumber = 0; + highestPageReached = currentPageNumber; + this.locations = locations; + + loadPages(); + } + + public function loadPages():void + { + pages = new ArrayCollection(); + + if(currBlock == null) + { + msg += "block is null"; + return; + } + if(currBlock.questionGroups == null || currBlock.questionGroups.length == 0) + { + msg += "no QuestionGroups found\n"; + return; + } + + for(var group:int=0; group<currBlock.questionGroups.length; group++) + { + var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); + var tempBox:VBox = new VBox(); + tempBox.visible = true; + + if(questionGroup.questions != null && questionGroup.questions.length != 0) + { + for(var question:int=0; question<questionGroup.questions.length; question++) + { + var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); + +// //This should be handled inside the question itself. +// var txt:Text = new Text(); +// txt.width = 300; +// txt.htmlText = tempQuestion.question; +// tempBox.addChild(txt); + + if(tempQuestion is Categorical) + { + var cq:CategoricalQuestionC = new CategoricalQuestionC(); + cq.loadFromQuestion(Categorical(tempQuestion)); + cq.id = "q"+question; + + tempBox.addChild(cq); + } + else if(tempQuestion is Psychometric) + { + var pq:PsychometricQuestionC = new PsychometricQuestionC(); + pq.loadFromQuestion(Psychometric(tempQuestion)); + pq.id = "q"+question; + + tempBox.addChild(pq); + } + else + { + if(tempQuestion == null || tempQuestion.type == null) + { + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } + else if(tempQuestion.type.toLowerCase() == "strategydesign") + { + var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.locations = locations; + sdq.setRound(gameObject.currentRound); + sdq.loadFromQuestion(Question(tempQuestion)); + sdq.id = "q"+question; + + tempBox.addChild(sdq); + } + else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") + { + var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.locations = locations; + ddq.loadFromQuestion(Question(tempQuestion)); + ddq.id = "q"+question; + + tempBox.addChild(ddq); + } + else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") + { + var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.locations = locations; + fpq.loadFromQuestion(tempQuestion); + fpq.id = "q"+question; + + tempBox.addChild(fpq); + } + else if(tempQuestion.type.toLowerCase() == "forecastingfish") + { + var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.locations = locations; + ffq.loadFromQuestion(tempQuestion); + ffq.id = "q"+question; + + tempBox.addChild(ffq); + } + else + { + tq = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } + } + } + } + else + { +// msg += "no Questions found\n"; +// Alert.show(msg); + } + var head:Text = new Text(); + var desc:Text = new Text(); + head.setStyle("fontSize", 12); + head.width = 600; + desc.width = 600; + head.htmlText = questionGroup.header; + desc.htmlText = questionGroup.description; + if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); + if(head.htmlText.length != 0) tempBox.addChildAt(head,0); + + pages.addItem(tempBox); +// msg += "item added\n"; + } + + if(gameObject == null) return; + if(gameObject.currentRound != null) + { + if(gameObject.currentRound.communicationFlag) + { + var comm:CommunicationC = new custom.CommunicationC(); + comm.id = "q"+question; + comm.initialize(); + + (pages.getItemAt(0) as VBox).addChild(comm); + } + } + else + { + Alert.show("gameObject.currentRound == null"); + } + } + + public function componentsNotFinished(force:Boolean=false):Boolean + { + var returnValue:Boolean = false; + var curr:VBox; + var messages:String = ""; + + for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) + { + curr = pages.getItemAt(pageNumber) as VBox; + + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is DayByDayDecisionsQuestionC) + { + messages += "D"; + if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) + { + returnValue = true; + } + } + else if(tempQuestion is StrategyDesignQuestionC) + { + messages += "S"; + if(!(tempQuestion as StrategyDesignQuestionC).accept()) + { + returnValue = true; + } + } + else + { + messages += "x"; + } + } +// Alert.show(messages + returnValue); + } + return returnValue && !force; + } + public function finished(force:Boolean=false):Boolean + { return highestPageReached >= minPagesRead - 1 || force; } + public function get length():int + { return pages.length; } + + public function get currentPage():DisplayObject + { + if(pages != null && pages.length > 0) // pages? + { + if(currentPageNumber < 0) currentPageNumber = 0; + if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; + return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT + } + + return null; // no pages + } + public function nextPage():Boolean + { + currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); + highestPageReached = Math.max(currentPageNumber, highestPageReached) + return true; + } + public function prevPage():Boolean + { + currentPageNumber = fix(currentPageNumber - 1, 0, pages.length-1); + return true; + } + private function fix(n:Number,min:Number,max:Number):Number + { + if(n < min) return min; + if(n > max) return max; + return n; + } + + public function reset():void + { + var curr:VBox = currentPage as VBox; + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is PsychometricQuestionC) + { + (tempQuestion as PsychometricQuestionC).slider1.reset(); + messages += "P"; + } + else if(tempQuestion is CategoricalQuestionC) + { + (tempQuestion as CategoricalQuestionC).comboTopic.selectedIndex = 0; + (tempQuestion as CategoricalQuestionC).comboSpecific.selectedIndex = -1; + messages += "C"; + } + else + { + messages += "x"; + } + } +// Alert.show(messages); + } + } + } } \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -1,127 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSelfComm}" creationComplete="init()"> - - <mx:Consumer id="consumer" destination="mme" message="messageHandler(event.message)" fault="faultMsgHandler(event)" channelSet="{cs}" /> - <mx:ChannelSet id="cs"> - <!-- <mx:StreamingAMFChannel url="http://localhost:8080/messagebroker/streamingamf"/> --> - <mx:AMFChannel url="http://localhost:8080/mme/messagebroker/amflongpolling"/> - <mx:AMFChannel url="http://localhost:8080/mme/messagebroker/amfpolling"/> - </mx:ChannelSet> - <mx:Producer id="producer" destination="mme" channelSet="{cs}"/> - <mx:RemoteObject id="comunication" destination="communicationService" fault="faultHandler(event)"> - <mx:method name="saveCommunication"/> - </mx:RemoteObject> - - <mx:Script> - <![CDATA[ - import actionscript.Group; - import actionscript.Communication; - import actionscript.Student; - import mx.controls.Label; - import mx.controls.Text; - import mx.messaging.messages.IMessage; - import mx.messaging.events.MessageAckEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.events.MessageEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.controls.Alert; - import mx.messaging.messages.AsyncMessage; - - import mx.messaging.Producer; - import mx.messaging.Consumer; - - import mx.rpc.events.FaultEvent; - - public var student:actionscript.Student; - public var testDBD:TestDayByDayDecisions = new TestDayByDayDecisions(); - public function init():void - { - /* var testDBD:TestDayByDayDecisions = new TestDayByDayDecisions(); - student = testDBD.studentObject; - var group:actionscript.Group = testDBD.getGroup(); - var subTopic:String = student.gameCode + group.id.toString() + student.id.toString();*/ - - consumer.subtopic = "test1.1"; - consumer.subscribe(); - - producer.subtopic = "test1.1"; - - } - public function faultMsgHandler(msgevent:MessageFaultEvent):void - { - Alert.show("Error in getting message: " + msgevent.faultString); - } - - private function faultHandler(event:FaultEvent):void - { - Alert.show("Fault:\n"+event.fault.message + "\n" + event.fault.getStackTrace()); - } - public function btnSend_click():void - { - var message:IMessage = new AsyncMessage(); - var comm:actionscript.Communication = new actionscript.Communication(); - comm.message = txtMessage.text; - comm.date = new Date(); - comm.student = new actionscript.Student(); - comm.student.birthYear = 1982; - comm.student.gender = "F"; - comm.student.major = "CSE" - comm.student.semester = "1"; - comm.student.gameCode = "test1" - comm.student.id = 1; - - message.body = comm; - //producer.send(message); - - txtMessage.text = ""; - //<service>.<method>(txtMessage.text); - comunication.saveCommunication(comm); - } - public function btnSelfComm_click():void - { - var comm:actionscript.Communication = new actionscript.Communication(); - comm.message = txtMessage.text; - comm.date = new Date(); - comm.student = new actionscript.Student(); comm.student.id = 1; - txtMessage.text = ""; - commReceived(comm); - } - - public function commReceived(comm:actionscript.Communication):void - { - if(comm.message == null || comm.message.length == 0) return; - vbxMessages.addChild(commToText(comm)); - vbxMessages.verticalScrollPosition = vbxMessages.maxVerticalScrollPosition; - } - - private function messageHandler(message:IMessage):void - { - commReceived(message.body as actionscript.Communication); - } - private function strToText(str:String):Text - { - var newText:Text = new Text(); - newText.text = str; - return newText; - } - private function commToText(comm:actionscript.Communication):Text - { - var newText:Text = new Text(); - newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; - return newText; - } - - ]]> - </mx:Script> - - - <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> - <mx:HBox> - <mx:TextInput id="txtMessage" width="500"/> - <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> - <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> - </mx:HBox> - - -</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/CommunicationC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSend}"> + + <mx:Script> + <![CDATA[ + import mx.messaging.events.MessageEvent; + import mx.rpc.events.FaultEvent; + import actionscript.Communication; + import actionscript.Student; + import mx.controls.Label; + import mx.controls.Text; + + public var student:Student = null; + + public function faultHandler(event:FaultEvent):void + { + // Silent Failure + } + public function messageHandler(event:MessageEvent):void + { + if(event.message.body is actionscript.Communication) + { + commReceived(event.message.body as actionscript.Communication); + } + } + + public function btnSend_click():void + { + var tempCommunication:actionscript.Communication = new actionscript.Communication(); + tempCommunication.date = new Date(); + tempCommunication.message = txtMessage.text; + tempCommunication.student = this.student; + txtMessage.text = ""; + + //<service>.<method>(tempCommunication); + } + public function btnSelfComm_click():void + { + var comm:actionscript.Communication = new actionscript.Communication(); + comm.message = txtMessage.text; + comm.date = new Date(); + comm.student = new actionscript.Student(); comm.student.id = 1; + txtMessage.text = ""; + + commReceived(comm); + } + + public function commReceived(comm:actionscript.Communication):void + { + if(comm.message == null || comm.message.length == 0) return; + vbxMessages.addChild(commToText(comm)); + vbxMessages.verticalScrollPosition = vbxMessages.maxVerticalScrollPosition; + } + + private function strToText(str:String):Text + { + var newText:Text = new Text(); + newText.text = str; + return newText; + } + private function commToText(comm:actionscript.Communication):Text + { + var newText:Text = new Text(); + newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; + return newText; + } + + ]]> + </mx:Script> + + <mx:RemoteObject id="communicationService" destination="communicationService" fault="faultHandler(event)"> + <mx:method name="sendCommunication" result="messageHandler(event)"/> + </mx:RemoteObject> + + <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> + <mx:HBox> + <mx:TextInput id="txtMessage" width="500"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> + <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> + </mx:HBox> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/test.mxml =================================================================== --- mentalmodels/trunk/flex/src/test.mxml 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/test.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -1,94 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:actionscript="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:actionscript="actionscript.*" xmlns:custom="custom.*"> - <actionscript:Student id="stu" birthYear="1991" gender="M" major="cse" gameCode="{gc.text}"/> - <mx:TextInput id="gc" text="test3"/> - - <mx:ArrayCollection id="strat"> - <actionscript:StudentStrategy days="1" repeatedDecision="true" location="{locs.getItemAt(0) as Location}"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="locs"> - </mx:ArrayCollection> - - <mx:HBox> - <mx:Button label="roundService.getBlock()" click="roundService.getBlock()"/> - <mx:Button label="roundService.getCurrentRound()" click="roundService.getCurrentRound()"/> - <mx:Button label="startupService.createStudent()" click="startupService.createStudent(stu)"/> - <mx:Button label="answeringService.saveStrategy()" click="answeringService.saveStrategy(strat)"/> - <mx:Button label="locationService.getAllLocations()" click="locationService.getAllLocations()"/> - </mx:HBox> - - <mx:HBox> - <mx:VBox> - <mx:Label text="location"/> - <mx:NumericStepper stepSize="1" value="0" enabled="{locs.length != 0}"/> - </mx:VBox> - <mx:VBox> - <mx:Label text="???"/> - <mx:NumericStepper stepSize="1" value="0"/> - </mx:VBox> - </mx:HBox> - - <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> - <mx:method name="getBlock" result="resultHandler(event)"/> - <mx:method name="getCurrentRound" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="startupService" destination="startupService" fault="faultHandler(event)"> - <mx:method name="createStudent" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="answeringService" destination="answeringService" fault="faultHandler(event)"> - <mx:method name="saveStrategy" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="locationService" destination="locationService" fault="faultHandler(event)"> - <mx:method name="getAllLocations" result="resultHandler(event)"/> - </mx:RemoteObject> - - <mx:Script> - <![CDATA[ - import actionscript.Location; - import actionscript.Round; - import mx.core.UIComponent; - import mx.controls.Alert; - import mx.rpc.events.FaultEvent; - import mx.rpc.events.ResultEvent; - - public function resultHandler(event:ResultEvent):void - { - var str:String = ""; - str += "event == null : " + (event == null) + "\n"; - str += "event.result == null : " + (event.result == null) + "\n"; - - Alert.show(str, "resultHandler()"); - - var array:ArrayCollection = (event.result as ArrayCollection); - if(array != null) - { - Alert.show("ArrayCollection"); - var first:Object = array.getItemAt(0); - if((first as Location) != null) - { - Alert.show("ArrayCollection of Locations"); - locs = array; - } - } - -// var round:actionscript.Round = event.result as actionscript.Round; -// Alert.show("round no is : " + round.roundNo + " " + round.id); - //Alert.show - - } - - public function faultHandler(event:FaultEvent):void - { - var str:String = ""; - str += "event.fault.message:\n" + (event.fault.message) + "\n\n"; - str += "event.fault.getStackTrace():\n*START*\n" + (event.fault.getStackTrace()) + "\n*END*"; - - Alert.show(str, "faultHandler()"); - } - - ]]> - </mx:Script> - + <custom:CommunicationC/> + </mx:Application> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-12-08 17:51:10
|
Coming in to work today at 10:45 I am trying to put the communication component into the experiment, as i forgot to do earlier. |
From: Kalin J. <kj...@as...> - 2009-12-07 20:20:11
|
Checking out at 13:00pm I do not know what to work on for the moment, and seema has not responded to my messages. On Mon, Dec 7, 2009 at 12:12 PM, Kalin Jonas <kj...@as...> wrote: > Checking in at home today at 12:00 noon > I will be working on whatever part of the experiment seema gives me to work > on today > > > On Tue, Dec 1, 2009 at 12:09 PM, Kalin Jonas <kj...@as...> wrote: > >> I am checking out for now at 12:00noon (2hrs) >> I have finished adding the actionscript methods that will work with >> consumer etc to make the component work, but it just needs to be connected >> to server, which I have to leave up to seema, as I don't quite know how to >> implement consumer etc. >> >> I will be leaving for the day unless I get an email before 2pm, as I have >> class/plans after that. >> >> >> On Tue, Dec 1, 2009 at 10:03 AM, Kalin Jonas <kj...@as...> wrote: >> >>> I came in to work today at 10:00 am >>> I will work on the communication component: adding the mxml for the >>> service that it will use. >>> >>> >>> On Sun, Nov 29, 2009 at 3:11 PM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Checking out at 3:00pm >>>> I have completed the Communication interface as listed below. >>>> It needs to have a service to connect to the server, and code needs to >>>> be written to push the communication objects to all clients connected, but >>>> the interface is done. >>>> >>>> >>>> On Sun, Nov 29, 2009 at 12:18 PM, Kalin Jonas <kj...@as...> wrote: >>>> >>>>> Checking in from home today at 12:00 noon >>>>> I will be working on a communications interface with the following >>>>> design: >>>>> >>>>> - Large Box for messages received/sent >>>>> - Small Box for typing a message >>>>> - Button for sending a message (Enter key should also send) >>>>> >>>>> I am going to try to give it the following functionality: >>>>> >>>>> - Client concatenates user number & sends a message to server when >>>>> Enter/Button pressed (Server should assign timestamp and push the message to >>>>> all clients) >>>>> - Client receives a message from the server (does not matter who it >>>>> is from) and puts it in the Large Box. >>>>> >>>>> >>>> >>> >> > |
From: Kalin J. <kj...@as...> - 2009-12-07 19:12:59
|
Checking in at home today at 12:00 noon I will be working on whatever part of the experiment seema gives me to work on today On Tue, Dec 1, 2009 at 12:09 PM, Kalin Jonas <kj...@as...> wrote: > I am checking out for now at 12:00noon (2hrs) > I have finished adding the actionscript methods that will work with > consumer etc to make the component work, but it just needs to be connected > to server, which I have to leave up to seema, as I don't quite know how to > implement consumer etc. > > I will be leaving for the day unless I get an email before 2pm, as I have > class/plans after that. > > > On Tue, Dec 1, 2009 at 10:03 AM, Kalin Jonas <kj...@as...> wrote: > >> I came in to work today at 10:00 am >> I will work on the communication component: adding the mxml for the >> service that it will use. >> >> >> On Sun, Nov 29, 2009 at 3:11 PM, Kalin Jonas <kj...@as...> wrote: >> >>> Checking out at 3:00pm >>> I have completed the Communication interface as listed below. >>> It needs to have a service to connect to the server, and code needs to be >>> written to push the communication objects to all clients connected, but the >>> interface is done. >>> >>> >>> On Sun, Nov 29, 2009 at 12:18 PM, Kalin Jonas <kj...@as...> wrote: >>> >>>> Checking in from home today at 12:00 noon >>>> I will be working on a communications interface with the following >>>> design: >>>> >>>> - Large Box for messages received/sent >>>> - Small Box for typing a message >>>> - Button for sending a message (Enter key should also send) >>>> >>>> I am going to try to give it the following functionality: >>>> >>>> - Client concatenates user number & sends a message to server when >>>> Enter/Button pressed (Server should assign timestamp and push the message to >>>> all clients) >>>> - Client receives a message from the server (does not matter who it >>>> is from) and puts it in the Large Box. >>>> >>>> >>> >> > |
From: <al...@us...> - 2009-12-04 19:42:06
|
Revision: 410 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=410&view=rev Author: alllee Date: 2009-12-04 19:41:59 +0000 (Fri, 04 Dec 2009) Log Message: ----------- several NPE bug fixes: - added null check for active monitors - fixed NPE in sanction handling where ClientData.latestSanctions was null (http://opensource.asu.edu/jira/browse/COMMONS-9) Modified Paths: -------------- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/ClientData.java Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-12-04 18:32:03 UTC (rev 409) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-12-04 19:41:59 UTC (rev 410) @@ -63,7 +63,10 @@ } public Identifier getMonitorId() { - return groupDataModel.getActiveMonitor().getId(); + if (groupDataModel.getActiveMonitor() != null) { + return groupDataModel.getActiveMonitor().getId(); + } + return Identifier.NULL; } public boolean isSanctioningAllowed() { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 18:32:03 UTC (rev 409) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 19:41:59 UTC (rev 410) @@ -795,7 +795,7 @@ activeRegulation = "No regulation specified."; } setInstructions( - "<h3>The following regulation received the most votes:</h3><pre>" + activeRegulation + "</pre>"); + "<h3>The following regulation received the most votes:</h3><p>" + activeRegulation + "</p>"); addCenterComponent(instructionsScrollPane); startRegulationDisplayTimer(); } Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-12-04 18:32:03 UTC (rev 409) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-12-04 19:41:59 UTC (rev 410) @@ -180,14 +180,14 @@ graphics2D.fillRect(x, y, getCellWidth(), getCellHeight()); graphics2D.drawImage(scaledBeingSanctionedImage, x, y, this); } - else if (id.equals(dataModel.getMonitorId())) { - graphics2D.drawImage(scaledMonitorImage, x, y, this); - } else if (dataModel.isSanctioning(id)) { graphics2D.setColor(Color.WHITE); graphics2D.fillRect(x, y, getCellWidth(), getCellHeight()); graphics2D.drawImage(scaledSanctioningImage, x, y, this); } + else if (id.equals(dataModel.getMonitorId())) { + graphics2D.drawImage(scaledMonitorImage, x, y, this); + } else if (id.equals(dataModel.getId())) { if (dataModel.isExplicitCollectionMode()) { graphics2D.drawImage(scaledSelfExplicitCollectionModeImage, x, y, this); Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java 2009-12-04 18:32:03 UTC (rev 409) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/event/SubmitRegulationRequest.java 2009-12-04 19:41:59 UTC (rev 410) @@ -13,7 +13,7 @@ * @version $Revision: 1 $ */ -public class SubmitRegulationRequest extends AbstractEvent { +public class SubmitRegulationRequest extends AbstractPersistableEvent { private static final long serialVersionUID = 475300882222383637L; Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/ClientData.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/ClientData.java 2009-12-04 18:32:03 UTC (rev 409) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/ClientData.java 2009-12-04 19:41:59 UTC (rev 410) @@ -49,7 +49,7 @@ private volatile boolean collecting; private volatile boolean explicitCollectionMode; private Duration freezeDuration; - private LinkedList<RealTimeSanctionRequest> latestSanctions; + private LinkedList<RealTimeSanctionRequest> latestSanctions = new LinkedList<RealTimeSanctionRequest>(); private AnimationData animationData; private boolean subjectsFieldOfVisionEnabled; @@ -290,9 +290,7 @@ } public void resetLatestSanctions() { - if (latestSanctions != null) { - latestSanctions.clear(); - } + latestSanctions.clear(); } private void resetCurrentTokens() { @@ -397,9 +395,6 @@ if (tokensFieldOfVisionEnabled) { viewTokensRadius = roundConfiguration.getViewTokensRadius(); } - if (roundConfiguration.isRealTimeSanctioningEnabled()) { - latestSanctions = new LinkedList<RealTimeSanctionRequest>(); - } if (roundConfiguration.isPrivateProperty()) { setPosition (new Point(roundConfiguration.getResourceWidth() / 2, roundConfiguration.getResourceDepth() / 2)); } 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-12-04 19:39:10
|
[ http://opensource.asu.edu/jira/browse/COMMONS-9?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved COMMONS-9. ----------------------------- Resolution: Fixed Fixed in svn, ClientData.latestSanctions wasn't getting initialized properly (only when RealTimeSanctioning was enabled). Should happen anytime sanctioning is available. > NPE > --- > > Key: COMMONS-9 > URL: http://opensource.asu.edu/jira/browse/COMMONS-9 > Project: The Virtual Commons > Issue Type: Bug > Reporter: Allen Lee > Assignee: Allen Lee > > SEVERE: Attempting to recover from exception: java.lang.NullPointerException > java.lang.NullPointerException > at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.handleRealTimeSanctionRequest(ForagingServer.java:596) > at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.handleEnforcementSanctionRequest(ForagingServer.java:479) > at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.access$4000(ForagingServer.java:206) > at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine$16.handleInExperimentThread(ForagingServer.java:402) > at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine$16.handleInExperimentThread(ForagingServer.java:393) > at edu.asu.commons.event.EventTypeProcessor$1.execute(EventTypeProcessor.java:56) > at edu.asu.commons.experiment.AbstractExperiment$1.run(AbstractExperiment.java:171) > at java.lang.Thread.run(Thread.java:619) -- 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-12-04 19:31:05
|
NPE --- Key: COMMONS-9 URL: http://opensource.asu.edu/jira/browse/COMMONS-9 Project: The Virtual Commons Issue Type: Bug Reporter: Allen Lee Assignee: Allen Lee SEVERE: Attempting to recover from exception: java.lang.NullPointerException java.lang.NullPointerException at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.handleRealTimeSanctionRequest(ForagingServer.java:596) at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.handleEnforcementSanctionRequest(ForagingServer.java:479) at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine.access$4000(ForagingServer.java:206) at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine$16.handleInExperimentThread(ForagingServer.java:402) at edu.asu.commons.foraging.server.ForagingServer$ForagingStateMachine$16.handleInExperimentThread(ForagingServer.java:393) at edu.asu.commons.event.EventTypeProcessor$1.execute(EventTypeProcessor.java:56) at edu.asu.commons.experiment.AbstractExperiment$1.run(AbstractExperiment.java:171) at java.lang.Thread.run(Thread.java:619) -- 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-12-04 19:27:09
|
[ http://opensource.asu.edu/jira/browse/COMMONS-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee updated COMMONS-8: ---------------------------- Description: regulation panel and enforcement panel / voting display needs a lot of UI love get rid of side-scrolling text. was:regulation panel and enforcement panel / voting display needs a lot of UI love > regulation and voting panel displays are terrible > ------------------------------------------------- > > Key: COMMONS-8 > URL: http://opensource.asu.edu/jira/browse/COMMONS-8 > Project: The Virtual Commons > Issue Type: Improvement > Reporter: Allen Lee > Assignee: Allen Lee > > regulation panel and enforcement panel / voting display needs a lot of UI love > get rid of side-scrolling text. -- 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-12-04 19:25:06
|
[ http://opensource.asu.edu/jira/browse/COMMONS-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee updated COMMONS-8: ---------------------------- Summary: regulation and voting panel displays are terrible (was: regulation panel display is still terrible) Description: regulation panel and enforcement panel / voting display needs a lot of UI love (was: regulation panel display needs a lot of UI love) > regulation and voting panel displays are terrible > ------------------------------------------------- > > Key: COMMONS-8 > URL: http://opensource.asu.edu/jira/browse/COMMONS-8 > Project: The Virtual Commons > Issue Type: Improvement > Reporter: Allen Lee > Assignee: Allen Lee > > regulation panel and enforcement panel / voting display needs a lot of UI love -- 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-12-04 19:25:06
|
regulation panel display is still terrible ------------------------------------------ Key: COMMONS-8 URL: http://opensource.asu.edu/jira/browse/COMMONS-8 Project: The Virtual Commons Issue Type: Improvement Reporter: Allen Lee Assignee: Allen Lee regulation panel display needs a lot of UI love -- 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-12-04 19:22:11
|
images aren't always loading properly (resize fixes it sometimes) ----------------------------------------------------------------- Key: COMMONS-7 URL: http://opensource.asu.edu/jira/browse/COMMONS-7 Project: The Virtual Commons Issue Type: Bug Components: foraging Reporter: Allen Lee Assignee: Allen Lee Priority: Critical Images in the foraging experiment aren't always loaded properly. -- 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-12-04 18:59:21
|
[ http://opensource.asu.edu/jira/browse/COMMONS-1?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved COMMONS-1. ----------------------------- Resolution: Fixed indirectly fixed > parse % sign in infrastructure efficiency quizzes > ------------------------------------------------- > > Key: COMMONS-1 > URL: http://opensource.asu.edu/jira/browse/COMMONS-1 > Project: The Virtual Commons > Issue Type: Improvement > Affects Versions: irrigation.asu.fall.2009 > Reporter: Allen Lee > Assignee: Allen Lee > Priority: Minor > Fix For: irrigation.asu.fall.2009 > > > Marty noticed that students often type in the % sign when entering an answer for the infrastructure efficiency quizzes (i.e., 49% instead of just 49). Should strip out the % sign if added and parse it correctly. -- 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-12-04 18:32:15
|
Revision: 409 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=409&view=rev Author: alllee Date: 2009-12-04 18:32:03 +0000 (Fri, 04 Dec 2009) Log Message: ----------- stuff Modified Paths: -------------- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GridView.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 18:24:23 UTC (rev 408) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 18:32:03 UTC (rev 409) @@ -281,7 +281,7 @@ private void startRegulationVotingTimer() { if (timer == null) { - duration = Duration.create(dataModel.getRoundConfiguration().getRegulationVotingtDuration()); + duration = Duration.create(dataModel.getRoundConfiguration().getRegulationVotingDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GridView.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GridView.java 2009-12-04 18:24:23 UTC (rev 408) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GridView.java 2009-12-04 18:32:03 UTC (rev 409) @@ -34,7 +34,7 @@ protected Image tokenImage, otherSubjectImage, selfImage, selfExplicitCollectionModeImage, beingSanctionedImage, sanctioningImage, monitorImage; protected Image scaledTokenImage, scaledOtherSubjectImage, scaledSelfImage, - scaledSelfExplicitCollectionModeImage, scaledBeingSanctionedImage, scaledSanctioningImage, scaledMoniterImage; + scaledSelfExplicitCollectionModeImage, scaledBeingSanctionedImage, scaledSanctioningImage, scaledMonitorImage; /** * Use these for the dimensions when drawing. @@ -93,7 +93,7 @@ scaledSelfExplicitCollectionModeImage = selfExplicitCollectionModeImage.getScaledInstance(cellWidth, cellHeight, IMAGE_SCALING_STRATEGY); scaledBeingSanctionedImage = beingSanctionedImage.getScaledInstance(cellWidth, cellHeight, IMAGE_SCALING_STRATEGY); scaledSanctioningImage = sanctioningImage.getScaledInstance(cellWidth, cellHeight, IMAGE_SCALING_STRATEGY); - scaledMoniterImage = monitorImage.getScaledInstance(cellWidth, cellHeight, IMAGE_SCALING_STRATEGY); + scaledMonitorImage = monitorImage.getScaledInstance(cellWidth, cellHeight, IMAGE_SCALING_STRATEGY); } /** Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-12-04 18:24:23 UTC (rev 408) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-12-04 18:32:03 UTC (rev 409) @@ -180,8 +180,8 @@ graphics2D.fillRect(x, y, getCellWidth(), getCellHeight()); graphics2D.drawImage(scaledBeingSanctionedImage, x, y, this); } - else if (dataModel.isMonitor()) { - graphics2D.drawImage(scaledMoniterImage, x, y, this); + else if (id.equals(dataModel.getMonitorId())) { + graphics2D.drawImage(scaledMonitorImage, x, y, this); } else if (dataModel.isSanctioning(id)) { graphics2D.setColor(Color.WHITE); @@ -189,7 +189,6 @@ graphics2D.drawImage(scaledSanctioningImage, x, y, this); } else if (id.equals(dataModel.getId())) { - // self image if (dataModel.isExplicitCollectionMode()) { graphics2D.drawImage(scaledSelfExplicitCollectionModeImage, x, y, this); } Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-12-04 18:24:23 UTC (rev 408) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-12-04 18:32:03 UTC (rev 409) @@ -279,18 +279,18 @@ } public int getChatDuration() { - return getIntProperty("chat-duration", 10); + return getIntProperty("chat-duration", 120); } public int getRegulationSubmissionDuration() { - return getIntProperty("regulation-submission-duration", 20); + return getIntProperty("regulation-submission-duration", 60); } public int getRegulationDisplayDuration() { - return getIntProperty("regulation-display-duration", 60); + return getIntProperty("regulation-display-duration", 30); } - public int getRegulationVotingtDuration() { + public int getRegulationVotingDuration() { return getIntProperty("regulation-voting-duration", 60); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-12-04 18:24:31
|
Revision: 408 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=408&view=rev Author: alllee Date: 2009-12-04 18:24:23 +0000 (Fri, 04 Dec 2009) Log Message: ----------- latest revision Modified Paths: -------------- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/RegulationPanel.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/RegulationData.java foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/EnforcementPanel.java 2009-12-04 18:24:23 UTC (rev 408) @@ -3,16 +3,12 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -70,14 +66,15 @@ }; public EnforcementPanel (ForagingClient client) { + this(); this.client = client; this.clientId = client.getId(); } private Identifier clientId; private JPanel votingPanel; - private JButton reset; - private JButton sendMyVotes; +// private JButton reset; +// private JButton sendMyVotes; private JPanel instructionsPanel; private SixChoicePanel[] newPanel; @@ -108,6 +105,7 @@ String instructions = client.getDataModel().getRoundConfiguration().getVotingInstructions(); JTextArea instructionText = new JTextArea(instructions,3,50); + instructionText.setWrapStyleWord(true); JScrollPane scrollForRegulationText = new JScrollPane(instructionText); instructionPanel.add(scrollForRegulationText); @@ -130,13 +128,13 @@ private void updateVotingPanel(int currentActive){ int r,c,i; SixChoicePanel temp = null; - boolean enableSendButton = true; +// boolean enableSendButton = true; for(r = 0; r < noOfEnforcements; r++) { - if(newPanel[r].currentRanking == -1)enableSendButton = false; +// if(newPanel[r].currentRanking == -1)enableSendButton = false; if((newPanel[currentActive].currentRanking == newPanel[r].currentRanking) && (r != currentActive)) { @@ -184,11 +182,11 @@ votingPanel.setVisible(true); add(votingPanel, BorderLayout.CENTER); - if(enableSendButton) { - sendMyVotes.setEnabled(true); - buttonPanel.setVisible(true); - add(buttonPanel, BorderLayout.SOUTH); - } +// if(enableSendButton) { +// sendMyVotes.setEnabled(true); +// buttonPanel.setVisible(true); +// add(buttonPanel, BorderLayout.SOUTH); +// } revalidate(); } @@ -242,49 +240,49 @@ } add(votingPanel, BorderLayout.CENTER); - reset = new JButton("Reset All Ranks"); - reset.setAlignmentX(Component.CENTER_ALIGNMENT); - reset.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - for(int i=0; i<noOfEnforcements; i++) { - for(int j=0; j<noOfEnforcements; j++) { - newPanel[i].option[j].setEnabled(true); - newPanel[i].group.clearSelection(); - newPanel[i].currentRanking = -1; - } - } - } - }); - sendMyVotes = new JButton("Send votes"); - sendMyVotes.setAlignmentX(Component.CENTER_ALIGNMENT); - sendMyVotes.setEnabled(false); - sendMyVotes.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - - int n = JOptionPane.showConfirmDialog( - null, "Are you sure to submit your votes ?"+ - "\nBelow is order of your voting" + - getVoteString(), - "Confirm and send votes", - JOptionPane.YES_NO_OPTION); - - if (n == JOptionPane.YES_OPTION) { - GameWindow2D.duration.expire(); - } - if (n == JOptionPane.NO_OPTION) { - - } - - } - }); - buttonPanel = new JPanel(); - //buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); - buttonPanel.setLayout(new GridLayout(1,2)); - buttonPanel.add(reset); - buttonPanel.add(sendMyVotes); - buttonPanel.setVisible(true); - buttonPanel.repaint(); - add(buttonPanel, BorderLayout.SOUTH); +// reset = new JButton("Reset All Ranks"); +// reset.setAlignmentX(Component.CENTER_ALIGNMENT); +// reset.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// for(int i=0; i<noOfEnforcements; i++) { +// for(int j=0; j<noOfEnforcements; j++) { +// newPanel[i].option[j].setEnabled(true); +// newPanel[i].group.clearSelection(); +// newPanel[i].currentRanking = -1; +// } +// } +// } +// }); +// sendMyVotes = new JButton("Send votes"); +// sendMyVotes.setAlignmentX(Component.CENTER_ALIGNMENT); +// sendMyVotes.setEnabled(false); +// sendMyVotes.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// +// int n = JOptionPane.showConfirmDialog( +// null, "Are you sure to submit your votes ?"+ +// "\nBelow is order of your voting" + +// getVoteString(), +// "Confirm and send votes", +// JOptionPane.YES_NO_OPTION); +// +// if (n == JOptionPane.YES_OPTION) { +// GameWindow2D.duration.expire(); +// } +// if (n == JOptionPane.NO_OPTION) { +// +// } +// +// } +// }); +// buttonPanel = new JPanel(); +// //buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); +// buttonPanel.setLayout(new GridLayout(1,2)); +// buttonPanel.add(reset); +// buttonPanel.add(sendMyVotes); +// buttonPanel.setVisible(true); +// buttonPanel.repaint(); +// add(buttonPanel, BorderLayout.SOUTH); } public void initialize() { @@ -331,20 +329,21 @@ public JPanel getEnforcementPanel(int i){ enforcementPanel = new JPanel(); enforcementPanel.setBackground(color); - enforcementPanel.setLayout(new BoxLayout(enforcementPanel, BoxLayout.X_AXIS)); + enforcementPanel.setLayout(new BoxLayout(enforcementPanel, BoxLayout.Y_AXIS)); enforcementPanel.setBorder(BorderFactory.createTitledBorder(title)); //create Text area and JSCroll pane for it JTextArea regulationText = new JTextArea(title,3,50); regulationText.setText(description); - JScrollPane scrollForRegulationText = new JScrollPane(regulationText,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + regulationText.setWrapStyleWord(true); + JScrollPane scrollForRegulationText = new JScrollPane(regulationText); enforcementPanel.add(scrollForRegulationText); rankPanel = new JPanel(); rankPanel.setBackground(color); - rankPanel.setLayout(new BoxLayout(rankPanel, BoxLayout.Y_AXIS)); - rankPanel.setBorder(BorderFactory.createTitledBorder("Ranks")); + rankPanel.setLayout(new BoxLayout(rankPanel, BoxLayout.X_AXIS)); + rankPanel.setBorder(BorderFactory.createTitledBorder("Rank")); group = new ButtonGroup(); int length = buttonLabels.length; // Assumes even length Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2009-12-04 18:24:23 UTC (rev 408) @@ -235,8 +235,8 @@ } private void startRegulationDisplayTimer(){ - if (timer == null) { - final Duration duration = Duration.create(dataModel.getRoundConfiguration().getRegulationDisplayDuration()); + if (timer == null) { + final Duration duration = Duration.create(dataModel.getRoundConfiguration().getRegulationDisplayDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { if (duration.hasExpired()) { @@ -256,9 +256,9 @@ private void startEnforcementVotingTimer() { - if (timer == null) { - //FIXME: Need to fetch this value from the round4.xml - duration = Duration.create(dataModel.getRoundConfiguration().getEnforcementVotingDuration()); + if (timer == null) { + //FIXME: Need to fetch this value from the round4.xml + duration = Duration.create(dataModel.getRoundConfiguration().getEnforcementVotingDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { if (duration.hasExpired()) { @@ -280,8 +280,8 @@ private void startRegulationVotingTimer() { - if (timer == null) { - duration = Duration.create(dataModel.getRoundConfiguration().getRegulationVotingtDuration()); + if (timer == null) { + duration = Duration.create(dataModel.getRoundConfiguration().getRegulationVotingtDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { @@ -307,10 +307,10 @@ } } - + private void startRegulationSubmissionTimer() { - if (timer == null) { - duration = Duration.create(dataModel.getRoundConfiguration().getRegulationSubmissionDuration()); + if (timer == null) { + duration = Duration.create(dataModel.getRoundConfiguration().getRegulationSubmissionDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { if (duration.hasExpired()) { @@ -330,9 +330,9 @@ } } private void startChatTimer() { - if (timer == null) { - // final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); - final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); + if (timer == null) { + // final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); + final Duration duration = Duration.create(dataModel.getRoundConfiguration().getChatDuration()); timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent event) { if (duration.hasExpired()) { @@ -421,7 +421,7 @@ subjectWindow.setBackground(Color.WHITE); subjectWindow.setForeground(Color.BLACK); subjectWindow.add(subjectView, BorderLayout.CENTER); -// setBackground(SubjectView.FIELD_OF_VISION_COLOR); + // setBackground(SubjectView.FIELD_OF_VISION_COLOR); setBackground(Color.WHITE); // replace with progress bar. timeLeftLabel = new JLabel("Connecting ..."); @@ -432,16 +432,16 @@ // getSanctioningPanel().initializeVotingPaneWithRegulations(); -// regulationVotingPane = new JPanel(); -// //regulationVotingPane.setLayout(new BoxLayout(regulationVotingPane, BoxLayout.LINE_AXIS)); -// regulationVotingPane.setLayout(new BorderLayout(4,4)); -// -// regulationVotingIntructions = new JEditorPane(); -// regulationVotingIntructions.setContentType("text/html"); -// regulationVotingIntructions.setEditorKit(new HTMLEditorKit()); -// regulationVotingIntructions.setEditable(false); -// regulationVotingIntructions.setBorder(BorderFactory.createTitledBorder("Regulation voting instructions")); -// regulationVotingIntructionsScrollPane = new JScrollPane(regulationVotingIntructions); + // regulationVotingPane = new JPanel(); + // //regulationVotingPane.setLayout(new BoxLayout(regulationVotingPane, BoxLayout.LINE_AXIS)); + // regulationVotingPane.setLayout(new BorderLayout(4,4)); + // + // regulationVotingIntructions = new JEditorPane(); + // regulationVotingIntructions.setContentType("text/html"); + // regulationVotingIntructions.setEditorKit(new HTMLEditorKit()); + // regulationVotingIntructions.setEditable(false); + // regulationVotingIntructions.setBorder(BorderFactory.createTitledBorder("Regulation voting instructions")); + // regulationVotingIntructionsScrollPane = new JScrollPane(regulationVotingIntructions); labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); @@ -531,11 +531,11 @@ case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_3: case KeyEvent.VK_4: case KeyEvent.VK_5: case KeyEvent.VK_6: case KeyEvent.VK_7: case KeyEvent.VK_8: case KeyEvent.VK_9: - if (! dataModel.isSanctioningAllowed()) { - // get rid of magic constants - displayErrorMessage("You aren't allowed to reduce other participants tokens at this time.", 1); - return; - } + if (! dataModel.isSanctioningAllowed()) { + // get rid of magic constants + displayErrorMessage("You aren't allowed to reduce other participants tokens at this time.", 1); + return; + } if (client.canPerformRealTimeSanction()) { //System.out.println("Can do sanctioning"); int assignedNumber = keyChar - 48; @@ -768,26 +768,34 @@ } public void displayActiveEnforcementMechanism() { - SwingUtilities.invokeLater(new Runnable() { + SwingUtilities.invokeLater(new Runnable() { public void run() { - instructionsBuilder.append("<hr/><h2>Active regulation</h2><hr/><p>").append(dataModel.getActiveRegulation()).append("</p>"); - instructionsBuilder.append("<hr/><h2>Active enforcement mechanism</h2><hr/><p>").append(dataModel.getActiveEnforcementMechanism().getDescription()).append("</p>"); - setInstructions(instructionsBuilder.toString()); + String activeRegulation = dataModel.getActiveRegulation().getText(); + if (activeRegulation == null || activeRegulation.trim().isEmpty()) { + activeRegulation = "No regulation specified."; + } + instructionsBuilder.append("<hr/><h2>Active regulation</h2><hr/><p>").append(activeRegulation).append("</p>"); + instructionsBuilder.append("<hr/><h2>Active enforcement mechanism</h2><hr/><p>").append(dataModel.getActiveEnforcementMechanism().getDescription()).append("</p>"); + setInstructions(instructionsBuilder.toString()); addCenterComponent(instructionsScrollPane); } }); } private void displayVotingWaitMessage() { - setInstructions("<h3>Please wait while we finish collecting information from all the participants.</h3>"); - addCenterComponent(instructionsScrollPane); + setInstructions("<h3>Please wait while we finish collecting information from all the participants.</h3>"); + addCenterComponent(instructionsScrollPane); } public void displayActiveRegulation() { SwingUtilities.invokeLater(new Runnable() { public void run() { - setInstructions( - "<h3>The following regulation received the most votes:</h3><pre>" + dataModel.getActiveRegulation() + "</pre>"); + String activeRegulation = dataModel.getActiveRegulation().getText(); + if (activeRegulation == null || activeRegulation.trim().isEmpty()) { + activeRegulation = "No regulation specified."; + } + setInstructions( + "<h3>The following regulation received the most votes:</h3><pre>" + activeRegulation + "</pre>"); addCenterComponent(instructionsScrollPane); startRegulationDisplayTimer(); } @@ -837,7 +845,7 @@ } public void initializeEnforcementVotingPanel() { - // TODO: revisit + // TODO: revisit SwingUtilities.invokeLater(new Runnable() { public void run() { EnforcementPanel enforcementPanel = getEnforcementPanel(); @@ -861,26 +869,26 @@ } public void initializeRegulationPanel() { -// getRegulationPanel().initialize(); - // System.out.println("Initialization done"); - addCenterComponent(getSubmitRegulationPanel()); - startRegulationSubmissionTimer(); + // getRegulationPanel().initialize(); + // System.out.println("Initialization done"); + addCenterComponent(getSubmitRegulationPanel()); + startRegulationSubmissionTimer(); } - + private JPanel submitRegulationPanel; private JTextArea regulationTextArea; private JPanel getSubmitRegulationPanel() { - if (submitRegulationPanel == null) { - submitRegulationPanel = new JPanel(new BorderLayout()); - regulationTextArea = new JTextArea(); - submitRegulationPanel.add(regulationTextArea, BorderLayout.CENTER); - regulationTextArea.setBorder(BorderFactory.createTitledBorder("Type your regulation here")); - HtmlEditorPane editorPane = createInstructionsEditorPane(); - JScrollPane scrollPane = new JScrollPane(editorPane); - editorPane.setText(dataModel.getRoundConfiguration().getRegulationInstructions()); - submitRegulationPanel.add(scrollPane, BorderLayout.PAGE_START); - } - return submitRegulationPanel; + if (submitRegulationPanel == null) { + submitRegulationPanel = new JPanel(new BorderLayout()); + regulationTextArea = new JTextArea(); + submitRegulationPanel.add(regulationTextArea, BorderLayout.CENTER); + regulationTextArea.setBorder(BorderFactory.createTitledBorder("Type your regulation here")); + HtmlEditorPane editorPane = createInstructionsEditorPane(); + JScrollPane scrollPane = new JScrollPane(editorPane); + editorPane.setText(dataModel.getRoundConfiguration().getRegulationInstructions()); + submitRegulationPanel.add(scrollPane, BorderLayout.PAGE_START); + } + return submitRegulationPanel; } public void initializeChatPanel() { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/RegulationPanel.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/RegulationPanel.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/client/RegulationPanel.java 2009-12-04 18:24:23 UTC (rev 408) @@ -3,8 +3,6 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; @@ -12,9 +10,7 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.JButton; import javax.swing.JEditorPane; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -52,6 +48,7 @@ private ForagingClient client; public RegulationPanel (ForagingClient client) { + this(); this.client = client; // client.getEventChannel().add(this, new EventTypeProcessor<RegulationEvent>(RegulationEvent.class) { // public void handle(final RegulationEvent regulationEvent) { @@ -80,15 +77,13 @@ // }); } - public RegulationPanel () - { + public RegulationPanel() { // regulations = new ArrayList<RegulationData>(); + // FIXME: get rid of hardcoded constants, this should be dynamic based on the size of the group. newPanel = new SixChoicePanel[5]; noOfRegulations = 5; } - private RegulationData votedRegulation; - private int noOfRegulations; private int[] currentRankingInformation; @@ -97,9 +92,9 @@ private JPanel votingPanel; private JPanel instructionsPanel; - private JPanel buttonPanel; - private JButton sendMyVotes; - private JButton reset; +// private JPanel buttonPanel; +// private JButton sendMyVotes; +// private JButton reset; private String[] votes = { "1", "2", "3","4", "5"}; @@ -126,11 +121,6 @@ // } // } // } - - public RegulationData getVotedRegulation(){ - return this.votedRegulation; - } - private void addStylesToMessageWindow() { StyledDocument styledDocument = messageWindow.getStyledDocument(); // and why not have something like... StyleContext.getDefaultStyle() to @@ -146,11 +136,11 @@ .addStyle("italic", defaultStyle), true); } - // FIXME: extremely inefficient, refactor after experiment. + // FIXME: messy, refactor after experiment. private void updateVotingPanel(int currentActive){ int r,c,i; SixChoicePanel temp = null; - boolean enableSendButton = true; +// boolean enableSendButton = true; // System.out.println("Active panel: "+SixChoicePanel.currentActive); // The below for loop is used to clear off radio button of the panel whose ranking conflicts @@ -160,7 +150,7 @@ for(r = 0; r < noOfRegulations; r++) { System.out.print(newPanel[r].currentRanking+" "); - if(newPanel[r].currentRanking == -1)enableSendButton = false; +// if(newPanel[r].currentRanking == -1) enableSendButton = false; if((newPanel[currentActive].currentRanking == newPanel[r].currentRanking) && (r != currentActive)) { @@ -206,11 +196,11 @@ votingPanel.setVisible(true); add(votingPanel, BorderLayout.CENTER); - if(enableSendButton) { - sendMyVotes.setEnabled(true); - buttonPanel.setVisible(true); - add(buttonPanel, BorderLayout.SOUTH); - } +// if(enableSendButton) { +// sendMyVotes.setEnabled(true); +// buttonPanel.setVisible(true); +// add(buttonPanel, BorderLayout.SOUTH); +// } revalidate(); } @@ -288,61 +278,70 @@ // end //for(int i=0; i<5; i++) { - int i = 0; - for (RegulationData regulationData : client.getDataModel().getSubmittedRegulations()) { + List<RegulationData> submittedRegulations = client.getDataModel().getSubmittedRegulations(); +// List<RegulationData> submittedRegulations = +// Arrays.asList(new RegulationData(new Identifier.Base(), "Regulation 1", 0), +// new RegulationData(new Identifier.Base(), "Regulation 2", 1), +// new RegulationData(new Identifier.Base(), "Regulation 3", 2), +// new RegulationData(new Identifier.Base(), "Regulation 4", 3), +// new RegulationData(new Identifier.Base(), "Regulation 5", 4)); + + for (RegulationData regulationData : submittedRegulations) { + System.err.println("creating six choice panel from regulation data: " + regulationData); // FIXME: are you aware that this code is completely unnecessary? You're creating a StringBuilder for no reason at all - // regulationData.getText() is already a String! // StringBuilder sb = new StringBuilder(); // sb.append(regulationData.getText()); -// String s = sb.toString(); - newPanel[i] = new SixChoicePanel(regulationData.getText(), votes, regulationData.getIndex(), getColor(i)); +// String s = sb.toString(); + int index = regulationData.getIndex(); + + newPanel[index] = new SixChoicePanel(votes, index, getColor(index)); // votingPanel.add(newPanel[i].getRegulationPanel(i,client.getDataModel().getRoundConfiguration().getRegulationInstructions())); - votingPanel.add(newPanel[i].getRegulationPanel(i,regulationData.getText())); - i++; + votingPanel.add(newPanel[index].getRegulationPanel(index,regulationData.getText())); } add(votingPanel, BorderLayout.CENTER); - reset = new JButton("Reset All Ranks"); - reset.setAlignmentX(Component.CENTER_ALIGNMENT); - reset.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - for(int i=0; i<noOfRegulations; i++) { - for(int j=0; j<noOfRegulations; j++) { - newPanel[i].option[j].setEnabled(true); - newPanel[i].group.clearSelection(); - newPanel[i].currentRanking = -1; - } - } - } - }); - sendMyVotes = new JButton("Send votes"); - sendMyVotes.setAlignmentX(Component.CENTER_ALIGNMENT); - sendMyVotes.setEnabled(false); - sendMyVotes.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { +// reset = new JButton("Reset All Ranks"); +// reset.setAlignmentX(Component.CENTER_ALIGNMENT); +// reset.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// for(int i=0; i<noOfRegulations; i++) { +// for(int j=0; j<noOfRegulations; j++) { +// newPanel[i].option[j].setEnabled(true); +// newPanel[i].group.clearSelection(); +// newPanel[i].currentRanking = -1; +// } +// } +// } +// }); +// sendMyVotes = new JButton("Send votes"); +// sendMyVotes.setAlignmentX(Component.CENTER_ALIGNMENT); +// sendMyVotes.setEnabled(false); +// sendMyVotes.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// +// int n = JOptionPane.showConfirmDialog( +// null, "Are you sure to submit your votes ?"+ +// "\nBelow is order of your voting" + +// getVoteString(), +// "Confirm and send votes", +// JOptionPane.YES_NO_OPTION); +// +// if (n == JOptionPane.YES_OPTION) { +// GameWindow2D.duration.expire(); +// } +// if (n == JOptionPane.NO_OPTION) { +// +// } +// +// } +// }); +// buttonPanel = new JPanel(); +// buttonPanel.setLayout(new GridLayout(1,2)); +// buttonPanel.add(reset); +// buttonPanel.add(sendMyVotes); - int n = JOptionPane.showConfirmDialog( - null, "Are you sure to submit your votes ?"+ - "\nBelow is order of your voting" + - getVoteString(), - "Confirm and send votes", - JOptionPane.YES_NO_OPTION); - - if (n == JOptionPane.YES_OPTION) { - GameWindow2D.duration.expire(); - } - if (n == JOptionPane.NO_OPTION) { - - } - - } - }); - buttonPanel = new JPanel(); - buttonPanel.setLayout(new GridLayout(1,2)); - buttonPanel.add(reset); - buttonPanel.add(sendMyVotes); - - add(buttonPanel, BorderLayout.SOUTH); +// add(buttonPanel, BorderLayout.SOUTH); } private JPanel getInstructionPanel() @@ -352,9 +351,11 @@ instructionPanel.setLayout(new BoxLayout(instructionPanel, BoxLayout.X_AXIS)); instructionPanel.setBorder(BorderFactory.createTitledBorder("Regulation Instruction")); - String instructions = client.getDataModel().getRoundConfiguration().getVotingInstructions(); - JTextArea instructionText = new JTextArea(instructions); +// String instructions = client.getDataModel().getRoundConfiguration().getVotingInstructions(); + String instructions = "Voting instructions"; + JTextArea instructionText = new JTextArea(instructions, 3, 50); instructionText.setWrapStyleWord(true); + instructionText.setEditable(false); JScrollPane scrollForRegulationText = new JScrollPane(instructionText,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); instructionPanel.add(scrollForRegulationText); @@ -383,11 +384,17 @@ //dummy regulation instructions are //regulationsInstructionsPane.setText(client.getDataModel().getRoundConfiguration().getRegulationInstructions()); - regulationsInstructionsPane.setText(client.getDataModel().getRoundConfiguration().getRegulationInstructions()); +// regulationsInstructionsPane.setText(client.getDataModel().getRoundConfiguration().getRegulationInstructions()); + + setInstructions("Regulation instructions"); add(regulationsInstructionsScrollPane, BorderLayout.NORTH); add(messageScrollPane, BorderLayout.CENTER); } + + public void setInstructions(String instructions) { + regulationsInstructionsPane.setText(instructions); + } public void clear() { participants.clear(); @@ -406,7 +413,7 @@ JRadioButton option []; Color color; - public SixChoicePanel(String title, String[] buttonLabels, int regulationID, Color color ) { + public SixChoicePanel(String[] buttonLabels, int regulationID, Color color ) { //this.title = title; this.buttonLabels = buttonLabels; this.regulationID = regulationID; @@ -433,19 +440,20 @@ public JPanel getRegulationPanel(int i, String information){ regulationPanel = new JPanel(); regulationPanel.setBackground(color); - regulationPanel.setLayout(new BoxLayout(regulationPanel, BoxLayout.X_AXIS)); + regulationPanel.setLayout(new BoxLayout(regulationPanel, BoxLayout.Y_AXIS)); regulationPanel.setBorder(BorderFactory.createTitledBorder("Regulation "+(i+1))); //create Text area and JSCroll pane for it - JTextArea regulationText = new JTextArea(information,3,50); - JScrollPane scrollForRegulationText = new JScrollPane(regulationText,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + JTextArea regulationText = new JTextArea(information, 3, 50); + regulationText.setWrapStyleWord(true); + JScrollPane scrollForRegulationText = new JScrollPane(regulationText); regulationPanel.add(scrollForRegulationText); rankPanel = new JPanel(); rankPanel.setBackground(color); - rankPanel.setLayout(new BoxLayout(rankPanel, BoxLayout.Y_AXIS)); - rankPanel.setBorder(BorderFactory.createTitledBorder("Ranks")); + rankPanel.setLayout(new BoxLayout(rankPanel, BoxLayout.X_AXIS)); + rankPanel.setBorder(BorderFactory.createTitledBorder("Rank")); group = new ButtonGroup(); int length = buttonLabels.length; // Assumes even length Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-12-04 18:24:23 UTC (rev 408) @@ -283,7 +283,7 @@ } public int getRegulationSubmissionDuration() { - return getIntProperty("regulation-submission-duration", 60); + return getIntProperty("regulation-submission-duration", 20); } public int getRegulationDisplayDuration() { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-12-04 18:24:23 UTC (rev 408) @@ -150,12 +150,16 @@ for (ClientData clientData : clients.values()) { int[] regulationRankings = clientData.getRegulationRankings(); logger.info("client: " + clientData.getId() + " ranked regulations: "+ regulationRankings); - for (int index = 0; index < numberOfRegulations; index++) { - regulationVotingTally[index] += rankToValue(regulationRankings[index]); - submittedRegulations.get(index).setRank(regulationVotingTally[index]); - if (regulationVotingTally[index] > maxRankingValue) { - maxRankingValue = regulationVotingTally[index]; - maxRankingIndex = index; + for (int rank = 0; rank < numberOfRegulations; rank++) { + int actualRegulationIndex = regulationRankings[rank]; + if (actualRegulationIndex == -1) { + continue; + } + regulationVotingTally[actualRegulationIndex] += rankToValue(rank); + submittedRegulations.get(actualRegulationIndex).setRank(regulationVotingTally[actualRegulationIndex]); + if (regulationVotingTally[actualRegulationIndex] > maxRankingValue) { + maxRankingValue = regulationVotingTally[actualRegulationIndex]; + maxRankingIndex = actualRegulationIndex; } } } @@ -182,12 +186,19 @@ double maxRankingValue = 0.0d; for (ClientData clientData: clients.values()) { int[] enforcementRankings = clientData.getEnforcementRankings(); - for (int index = 0; index < enforcementRankings.length; index++) { - enforcementVotingTally[index] += rankToValue(enforcementRankings[index]); + logger.info("XXX: enforcement rankings: " + enforcementRankings); + for (int rank = 0; rank < enforcementRankings.length; rank++) { + // 0 is top choice + int actualEnforcementIndex = enforcementRankings[rank]; + if (actualEnforcementIndex == -1) { + // nothing selected for this rank + continue; + } + enforcementVotingTally[actualEnforcementIndex] += rankToValue(rank); // keep a tally of the max index so we don't have to make another pass. - if (enforcementVotingTally[index] > maxRankingValue) { - maxRankingValue = enforcementVotingTally[index]; - maxRankingIndex = index; + if (enforcementVotingTally[actualEnforcementIndex] > maxRankingValue) { + maxRankingValue = enforcementVotingTally[actualEnforcementIndex]; + maxRankingIndex = actualEnforcementIndex; } } } @@ -235,6 +246,7 @@ clientData.setRegulationData(submittedRegulation); submittedRegulations.add(submittedRegulation); submittedRegulation.setIndex(submittedRegulations.size() - 1); + System.err.println("submitted regulation: " + submittedRegulation); } public boolean hasReceivedAllRegulations() { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/RegulationData.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/RegulationData.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/model/RegulationData.java 2009-12-04 18:24:23 UTC (rev 408) @@ -24,8 +24,13 @@ private int index; public RegulationData(Identifier id, String text) { + this(id, text, -1); + } + + public RegulationData(Identifier id, String text, int index) { this.id = id; this.text = text; + this.index = index; } /** @@ -71,7 +76,7 @@ } public String toString() { - return text; + return String.format("regulation from %s and index %d : %s", id, index, text); } public int compareTo(RegulationData regulationData) { Modified: foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java =================================================================== --- foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2009-12-04 17:05:29 UTC (rev 407) +++ foraging/branches/deepak-branch-fall-09/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2009-12-04 18:24:23 UTC (rev 408) @@ -280,6 +280,7 @@ // FIXME: start new implementation here. addEventProcessor(new EventTypeProcessor<EnforcementRankingRequest>(EnforcementRankingRequest.class) { public void handle(final EnforcementRankingRequest request) { + logger.info("received enforcement ranking request: " + request.getRankings()); GroupDataModel group = serverDataModel.getGroup(request.getId()); group.submitEnforcementRanking(request); if (group.hasReceivedAllEnforcementRankings()) { @@ -457,7 +458,7 @@ } private void sendEnforcementUpdate(GroupDataModel group) { - EnforcementMechanism enforcementMechanism = group.generateEnforcementRankings(); + group.generateEnforcementRankings(); for (Identifier id: group.getClientIdentifiers()) { transmit(new EnforcementMechanismUpdateEvent(id, group)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |