[virtualcommons-svn] SF.net SVN: virtualcommons:[164] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-17 19:19:37
|
Revision: 164 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=164&view=rev Author: kjonas Date: 2009-06-17 19:19:34 +0000 (Wed, 17 Jun 2009) Log Message: ----------- Deletion of unused components, actionscript. Rehaul of structuring of /flex/src/customComponents to reflect structure of questions and their component parts. Further rename of StrategyDesignPage.mxml (originally PlannerPage.mxml) to the present StrategyDesignQuestionC.mxml Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/questions/ mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/ mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/Planner.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/Slider.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/SliderImage.png Removed Paths: ------------- mentalmodels/trunk/flex/src/Forecasting.mxml mentalmodels/trunk/flex/src/MME.mxml mentalmodels/trunk/flex/src/Mental.mxml mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml mentalmodels/trunk/flex/src/Socio_demographic.mxml mentalmodels/trunk/flex/src/actionscript/RoundConfig.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Forecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml mentalmodels/trunk/flex/src/customComponents/LongScale.mxml mentalmodels/trunk/flex/src/customComponents/Planner.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml mentalmodels/trunk/flex/src/display.mxml mentalmodels/trunk/flex/src/images/ Modified: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -19,7 +19,7 @@ <mx:State name="planner"> <mx:AddChild relativeTo="{content}"> - <comp:PlannerPage id="planner"/> + <comp:StrategyDesignPage id="planner"/> </mx:AddChild> </mx:State> @@ -233,9 +233,9 @@ return true; } } - if(obj is PlannerPage) + if(obj is StrategyDesignPage) { - if( (PlannerPage)(obj).accept() ) + if( (StrategyDesignPage)(obj).accept() ) { obj.visible = false; expiredContent.addChild(obj); Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - width="90%" height="70%" clipContent="false" layout="absolute" + width="100%" height="100%" clipContent="false" layout="absolute" currentState="socioDemographic" initialize="init()"> <mx:states> @@ -13,24 +13,12 @@ <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> - <mx:State name="planner"> - <mx:AddChild relativeTo="{content}"> - <comp:PlannerPage id="planner"/> - </mx:AddChild> - </mx:State> - <mx:State name="instructions"> <mx:AddChild relativeTo="{content}"> <comp:InstructionPage_TEMP id="instructions"/> </mx:AddChild> </mx:State> - <mx:State name="forecasting"> - <mx:AddChild relativeTo="{content}"> - <comp:ForecastPage_TEMP id="forecasting"/> - </mx:AddChild> - </mx:State> - <mx:State name="none"> </mx:State> </mx:states> @@ -39,11 +27,11 @@ <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> <mx:Canvas id="content" x="5" y="5" width="1000" height="470"/> - <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> + <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="\xAB Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward \xBB" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> @@ -131,7 +119,7 @@ // var msg:AsyncMessage = new AsyncMessage(); //var client:FlexClient = FlexClient.getInstance(); - //creating new msg with \x93New\x94 to get current state. + //creating new msg with "New"to get current state. //msg.body = "New"; //producer.send(msg); @@ -187,10 +175,6 @@ { (InstructionPage)(obj).forward(); } - if(obj is ForecastPage_TEMP) - { - (ForecastPage_TEMP)(obj).forward(); - } return false; } @@ -207,9 +191,9 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "planner"; - var info:SocioDemographicPage = SocioDemographicPage(obj); + currentState = "instructions"; + var info:SocioDemographicPage = SocioDemographicPage(obj); /* Alert.show(info.getGender()); Alert.show(info.getMajor()); Alert.show(info.getSemester()); @@ -219,34 +203,12 @@ return true; } } - if(obj is PlannerPage) - { - if( (PlannerPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "instructions"; - - return true; - } - } if(obj is InstructionPage_TEMP) { if( (InstructionPage_TEMP)(obj).accept() ) { obj.visible = false; expiredContent.addChild(obj); - currentState = "forecasting"; - //consumer.subscribe(); - return true; - } - } - if(obj is ForecastPage_TEMP) - { - if( (ForecastPage_TEMP)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); return true; Deleted: mentalmodels/trunk/flex/src/Forecasting.mxml =================================================================== --- mentalmodels/trunk/flex/src/Forecasting.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Forecasting.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:local="*" xmlns:comp="customComponents.*"> - <mx:Grid top="10" bottom="10" right="10" left="10"> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> - <mx:VDividedBox width="100%" height="100%" id="vdboxOuter" liveDragging="false"> - <mx:VBox width="100%" height="50%" id="vboxLeftInnerDown" verticalGap="20"> - <mx:VBox width="100%" height="50%" id="vboxLeftInnerUpper" verticalGap="20"> - <mx:Image id="imgIsland" source="../libs/island.png"/> - <mx:ComboBox width="50%" id="cmbUpper"></mx:ComboBox> - </mx:VBox> - <mx:TextArea width="50%" height="70%"/> - <mx:ComboBox width="50%"></mx:ComboBox> - </mx:VBox> - </mx:VDividedBox> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:VBox width="100%" height="100%" id="vboxRightSideMainContainer" verticalGap="10"> - <mx:VBox width="100%" height="20%" id="vboxRightInnerUpper" verticalGap="20"> - <mx:Form width="100%" height="8%" id="frmGeneralInfoOfPlayer_Time"> - <mx:FormItem label="Clock" horizontalAlign="right" fontSize="14" fontWeight="bold"> - <!-- <mx:Text id="txtclock" text="10:50"/> --> - <comp:TimeLabel/> - </mx:FormItem> - <mx:FormItem label="Round Number:" horizontalAlign="right" fontSize="14" fontWeight="bold"> - <mx:Text id="txtroundno" text="1"/> - </mx:FormItem> - <mx:FormItem label="You Are Player Number:" fontSize="14" fontWeight="bold"> - <mx:Text id="txtplayerno" text="2"/> - </mx:FormItem> - <mx:FormItem label="You Are in Group Number:" fontSize="14" fontWeight="bold"> - <mx:Text id="txtgroupno" text="3"/> - </mx:FormItem> - - </mx:Form> - <mx:ProgressBar id="progressbarRoundInfo" label="Round" width="100%" height="10%" minimum="0" maximum="100" indeterminate="false" enabled="true"/> - </mx:VBox> - <mx:VBox width="100%" height="70%" id="vboxRightInnerDown" verticalGap="20"> - <mx:Form width="100%" height="90%" id="frmSurvey"> - <mx:FormHeading label="Survey Questions"/> - <mx:TextArea id="txtaSurvey" width="100%" height="100%" wordWrap="true"/> - </mx:Form> - <mx:HBox width="100%" height="10%" id="hboxButtons" horizontalAlign="center" horizontalGap="20" verticalAlign="middle"> - <mx:Button label="Previous" fontSize="14" id="btnPrevious"/> - <mx:Button label="Next" fontSize="14" id="btnNext"/> - </mx:HBox> - </mx:VBox> - </mx:VBox> - </mx:GridItem> - </mx:GridRow> - </mx:Grid> - -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/MME.mxml =================================================================== --- mentalmodels/trunk/flex/src/MME.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/MME.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" - backgroundGradientAlphas="[1.0, 1.0]" - backgroundGradientColors="[#9DDBED, #BFED9D]" - xmlns:ns1="*" - pageTitle="Fishery Experiment"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import actionscript.RoundConfig; - import mx.controls.Alert; - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - - // request config data from server - private var rndConfig:RoundConfig = getConfig(); - - public function getConfig():RoundConfig - { - // temporary fix: - return new RoundConfig( 1, - new ArrayCollection([0.5, 0.15, 0.05]), - new ArrayCollection([10, 20, 30]), - new ArrayCollection([5, 10, 15])); - } - - [Bindable] public var outputresp : Boolean; - private function resultHandler(event:ResultEvent):void - { - outputresp = event.result as Boolean; - } - - private function faultHandler(event:FaultEvent):void - { - Alert.show(event.fault.faultDetail); - } - - /*private function getData():void - { - outputresp = ss.getStudentFname(); - - }*/ - - private function save():void - { - - changeState(); - /*Alert.show("In save() function"); - Alert.show("year of birth is " + socio_demographic_information1.txtipYOB.text); - Alert.show(socio_demographic_information1.txtipMajor.text); - Alert.show(socio_demographic_information1.study.selectedValue.toString());*/ - //Alert.show(socio_demographic_information1.female.selected?'Correct Answer!':'Wrong Answer', 'Result'); - if(ss.createStudent(socio_demographic_information1.txtipYOB.text, socio_demographic_information1.txtipMajor.text,"Female",socio_demographic_information1.study.selectedValue.toString())) - { - Alert.show("Record is sucessfully added!"); - } - else - Alert.show("Record is NOT sucessfully added!"); - - } - - private function changeState():void - { - this.currentState = 'forecasting'; - } - - - ]]> - </mx:Script> - - <mx:states> - <mx:State name="forecasting"> - <mx:RemoveChild target="{socio_demographic_information1}"/> - <mx:RemoveChild target="{hbox1}"/> - <mx:AddChild relativeTo="{containerContent}" position="lastChild"> - <ns1:Forecasting top="10" bottom="10" right="10" left="10" id="forecasting1"> - </ns1:Forecasting> - </mx:AddChild> - </mx:State> - </mx:states> - <mx:Canvas left="10" right="10" bottom="10" top="10" id="containerMain" label="OutsideContainer"> - <mx:VBox right="10" top="10" bottom="10" left="10"> - <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle" id="hboxheading"> - <mx:Label text="Fishery Experiment" id="lblHeading" enabled="true" fontSize="36" textAlign="center" fontWeight="bold" color="#4D992C"/> - </mx:HBox> - <mx:Canvas width="100%" height="90%" id="containerContent"> - <ns1:Socio_Demographic_Information top="10" left="10" right="0" bottom="10" id="socio_demographic_information1"> - </ns1:Socio_Demographic_Information> - - <mx:HBox x="42" width="100%" height="10%" verticalAlign="bottom" horizontalAlign="center" bottom="5" id="hbox1"> - <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="save()" fontSize="12"/> - </mx:HBox> - </mx:Canvas> - <mx:HBox width="100%" id="hboxfooter" horizontalAlign="center" verticalAlign="bottom"> - <mx:Text text="School of Human Evolution & Social Change - Tempe, AZ 85287-2402 - T: 480-965-6213 / Fax: 480-965-7671" - id="txtFooter"/> - </mx:HBox> - </mx:VBox> - </mx:Canvas> - <mx:RemoteObject id="ss" destination="studentservice" fault="faultHandler(event)" result="resultHandler(event)"/> -</mx:Application> Deleted: mentalmodels/trunk/flex/src/Mental.mxml =================================================================== --- mentalmodels/trunk/flex/src/Mental.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Mental.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ACD1EE, #D989E5]"> - <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> - - - <mx:VBox height="100%" id="vboxGatherInfo"> - <mx:HBox width="100%" id="hboxSubHeading"> - <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> - </mx:HBox> - <mx:RadioButtonGroup id="radiogroupGender"/> - <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle"> - <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButtonGroup id="radiogroup1Gender"/> - <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="left" verticalAlign="middle"> - <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbBirthYear" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for the range: make combo box as text box 4 digit --> - <mx:Array> - <mx:String>1980</mx:String> - <mx:String>1981</mx:String> - <mx:String>1982</mx:String> - <mx:String>1983</mx:String> - <mx:String>1984</mx:String> - <mx:String>1985</mx:String> - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle"> - <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> - <mx:TextInput id="txtMajor" editable="true" enabled="true"/> - - - </mx:HBox> - - <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle"> - <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbEthnicity" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for this one also --> - <mx:Array> - <mx:String>Freshman</mx:String> - <mx:String>Sophomore</mx:String> - <mx:String>Junior</mx:String> - <mx:String>Senior</mx:String> - - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> - <mx:Button label="Submit" id="butSubmit"/> - </mx:HBox> - - </mx:VBox> - -</mx:Application> Deleted: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="698" height="407" textAlign="center"> - <mx:VBox id="vboxouterBox" horizontalAlign="center" verticalAlign="middle" width="100%" height="50%" horizontalCenter="0" top="10" verticalGap="0"> - - - <mx:Form top="5" bottom="5" id="frmSocioDemographic" right="5" left="5" width="50%" height="50%" textAlign="center"> - <mx:FormHeading label="Socio DemographicInformation " id="frmheadingSocioDemographicInfo" fontSize="24" textAlign="left" themeColor="#1200FF" color="#186BE8" width="5%" height="10%"/> - <mx:FormItem id="frmitemStudy" horizontalAlign="left" fontSize="14" required="true"> - <mx:Label text="What year are you in your study?"/> - <mx:RadioButtonGroup id="study"/> - <mx:RadioButton id="freshman" groupName="{study}"> - <mx:label>Freshman</mx:label> - </mx:RadioButton> - <mx:RadioButton id="sophomore" groupName="{study}"> - <mx:label>Sophomore</mx:label> - </mx:RadioButton> - <mx:RadioButton id="junior" groupName="{study}"> - <mx:label>Junior</mx:label> - </mx:RadioButton> - <mx:RadioButton id="senior" groupName="{study}"> - <mx:label>Senior</mx:label> - </mx:RadioButton> - - - - </mx:FormItem> - <mx:FormItem label="What is your major?" id="frmitemMajor" horizontalAlign="left" fontSize="14" required="true"> - <mx:TextInput id="txtipMajor"/> - </mx:FormItem> - <mx:FormItem label="Year of Birth" id="frmitemYOB" horizontalAlign="left" fontSize="14" required="true"> - <mx:TextInput id="txtipYOB" maxChars="4"/> - </mx:FormItem> - <mx:FormItem label="Gender" id="frmitemGender" horizontalAlign="left" fontSize="14" required="true"> - <mx:RadioButtonGroup id="gender"/> - <mx:RadioButton id="male" groupName="{gender}"> - <mx:label>Male</mx:label> - </mx:RadioButton> - <mx:RadioButton id="female" groupName="{gender}"> - <mx:label>Female</mx:label> - </mx:RadioButton> - - </mx:FormItem> - - </mx:Form> - - - </mx:VBox> -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/Socio_demographic.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="80%"> - - <mx:VBox height="100%" id="vboxGatherInfo" width="100%"> - <mx:HBox horizontalAlign="center" verticalAlign="middle" id="hboxSocio_demographic_info"> - <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxSubHeading"> - <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> - </mx:HBox> - <mx:RadioButtonGroup id="radiogroupGender"/> - <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButtonGroup id="radiogroup1Gender"/> - <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="center" verticalAlign="middle"> - <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbBirthYear" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for the range: make combo box as text box 4 digit --> - <mx:Array> - <mx:String>1980</mx:String> - <mx:String>1981</mx:String> - <mx:String>1982</mx:String> - <mx:String>1983</mx:String> - <mx:String>1984</mx:String> - <mx:String>1985</mx:String> - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> - <mx:TextInput id="txtMajor" editable="true" enabled="true"/> - - - </mx:HBox> - - <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbEthnicity" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for this one also --> - <mx:Array> - <mx:String>Freshman</mx:String> - <mx:String>Sophomore</mx:String> - <mx:String>Junior</mx:String> - <mx:String>Senior</mx:String> - - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> - <mx:Button label="Submit" id="butSubmit"/> - </mx:HBox> - - </mx:VBox> - - - -</mx:Canvas> Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,18 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" initialize="init()"> <mx:VBox id="content" minWidth="160"> - <comp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> <mx:HBox> <mx:Button label="Save" click="save()"/> <mx:Button label="Load" click="load()"/> </mx:HBox> - <comp:PlannerPage id="planner"/> + <quest:StrategyDesignQuestionC id="planner"/> </mx:VBox> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 19:19:34 UTC (rev 164) @@ -1,10 +1,10 @@ // ActionScript file package actionscript { - import customComponents.TextQuestionC; - import customComponents.ForecastingQuestionC; - import customComponents.CategoricalQuestionC; - import customComponents.PsychometricQuestionC; + import customComponents.questions.TextQuestionC; + import customComponents.questions.ForecastingQuestionC; + import customComponents.questions.CategoricalQuestionC; + import customComponents.questions.PsychometricQuestionC; import flash.display.DisplayObject; Deleted: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-06-17 19:19:34 UTC (rev 164) @@ -1,35 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - - public class RoundConfig - { - private var number:Number; // what round is it? - - // bay information - private var bayRegen:ArrayCollection; - private var bayMax:ArrayCollection; - private var bayStart:ArrayCollection; - - public function RoundConfig(number:Number, bayRegen:ArrayCollection, bayMax:ArrayCollection, bayStart:ArrayCollection) - { - this.number = number; - this.bayRegen = bayRegen; - this.bayMax = bayMax; - this.bayStart = bayStart; - } - - public function getRegen():ArrayCollection - { return this.bayRegen; } - - public function getMax():ArrayCollection - { return this.bayMax; } - - public function getStart():ArrayCollection - { return this.bayStart; } - - public function getNumber():Number - { return this.number; } - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - - <mx:String id="title"></mx:String> - <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> - <mx:Text htmlText="{description}"/> - </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> - - <mx:HBox id="content"> - <mx:ComboBox id="comboTopic" - dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" - dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - </mx:HBox> - - <mx:Script> - <![CDATA[ - import actionscript.FishUtil; - import actionscript.CategoricalQuestion; - - private function fix(index:int, list:ArrayCollection):int - { - return FishUtil.fix(index, list); - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - saveArray.addItem(comboTopic.selectedIndex); - saveArray.addItem(comboSpecific.selectedIndex); - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - comboTopic.selectedIndex = loadArray.getItemAt(0) as int; - comboSpecific.selectedIndex = loadArray.getItemAt(1) as int; - } - - public function loadFromQuestion(question:CategoricalQuestion):void - { - description = question.question; - - initialize(); -// init(); - } - - ]]> - </mx:Script> - - <!-- the selected element of this array determines which of the elements of - "specifics" will be used as the dataProvider --> - <mx:ArrayCollection id="topics"> - <mx:String>- Select -</mx:String> - <mx:String>topic1</mx:String> - <mx:String>topic2</mx:String> - <mx:String>topic3</mx:String> - </mx:ArrayCollection> - - <!-- each element of this ArrayCollection will serve as a dataProvider --> - <mx:ArrayCollection id="specifics"> - <mx:ArrayCollection id="topic0"> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic1"> - <mx:String>- Select -</mx:String> - <mx:String>specific1.0</mx:String> - <mx:String>specific1.1</mx:String> - <mx:String>specific1.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic2"> - <mx:String>- Select -</mx:String> - <mx:String>specific2.0</mx:String> - <mx:String>specific2.1</mx:String> - <mx:String>specific2.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic3"> - <mx:String>- Select -</mx:String> - <mx:String>specific3.0</mx:String> - <mx:String>specific3.1</mx:String> - <mx:String>specific3.2</mx:String> - </mx:ArrayCollection> - </mx:ArrayCollection> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,161 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - - <mx:ArrayCollection id="sched"/> - - <mx:HBox> - <mx:VBox id="labels"> - </mx:VBox> - - <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" - horizontalScrollPolicy="on" - verticalScrollPolicy="off"/> - <mx:Button label="{dgMain.columns.length}" click="clicked()"/> - </mx:HBox> - - <mx:Script> - <![CDATA[ - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - private var colIndex:Number=0; - [Bindable] - public var numColumns:Number = 3; - [Bindable] - public var numFields:Number = 6; - [Bindable] - public var finished:Boolean = false; - - public function init():void - { - createColumns(); - - /* dgMain.selectedIndex = 0; dgMain.selectedItem.day1 = 5; - dgMain.selectedIndex = 1; dgMain.selectedItem.day1 = 10; - dgMain.selectedIndex = 2; dgMain.selectedItem.day1 = 15; - dgMain.selectedIndex = -1; */ - - setItem(0,0,5); - setItem(1,0,10); - setItem(2,0,15); - } - private function createColumns():void - { - var tempArray:Array = dgMain.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = false; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - if(0 == i) - { - temp.editable = true; - } - - tempArray[i] = temp; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - if(0 == i) - { - var field:Object = new Object(); - sched.addItem(field); - } - } - } - dgMain.columns = tempArray; - - dgMain.height = 23*(numFields+1)+17 - dgMain.width = 30*Math.min(numColumns, 6)+1 - } - - public function clicked():void - { - for(var i:Number = 0; i < numFields; i++) - { -// dgMain.selectedIndex = i; -// dgMain.selectedItem.day2 = Number(dgMain.selectedItem.day1)*0; - var num:Object = getItem(i, colIndex); - var col:DataGridColumn = dgMain.columns[colIndex]; - if(num == null || !(num is Number)) - { - col.setStyle("backgroundColor", "#FF0000"); - break; - } - else - { - col.setStyle("backgroundColor", "#FFFFFF"); - } - } - // all numbers in the current column are actually numbers - // after executing the above loop - -// dgMain.selectedItem.day3 = "success"; - if(i >= numFields) - { - changeColumn(); - dgMain.selectedIndex = -1; - } - } - - public function getItem(field:Number, col:Number):Object - { - return sched.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - sched.getItemAt(field)["day"+(col+1)] = value; - } - - private function changeColumn():void - { - DataGridColumn(dgMain.columns[colIndex]).editable = false; - colIndex++; - if(colIndex == numColumns) - { - colIndex--; - finished = true; - } - DataGridColumn(dgMain.columns[colIndex]).editable = true; - } - - public function changed():void - { - // check the values of the current column - // and point out any errors (TextBox) - } - - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - - var pattern:RegExp = /^\d+$/; - var s:String = StringUtil.trim(String(n)); - -// debug.text = "."+n+"."+pattern.test(s)+(s is String); - - // if it does not match the pattern, it is invalid - return !pattern.test(s); - } - private function outOfBoundsNum(n:Object):Boolean - { - //return Number(n) < minValue || Number(n) > maxValue; - return false; - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> - - <mx:HBox id="gridContainer"> - <mx:VBox id="labels"> - </mx:VBox> - - <!--<mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()"/>--> - </mx:HBox> - - <mx:Label id="lbl" text="{dgh.errorMessage}"/> - <!--<mx:Label id="debug" text="{dgh.debug}"/>--> - - <mx:Script> - <![CDATA[ - import mx.controls.DataGrid; - import actionscript.DataGridHandler; - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - [Bindable] - public var dgh:DataGridHandler; - - [Bindable] - public var numColumns:Number = 15; - [Bindable] - public var numFields:Number = 4; - [Bindable] - public var minValue:Number = 0; - [Bindable] - public var maxValue:Number = 10; - [Bindable] - public var colSum:Number = 30; - - private var errorMessage:String = null; - - public function init():void - { - dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); - gridContainer.addChildAt(dgh.grid, 1); - } - public function changed():void - { - dgh.changed(); - } - public function deactivate():void - { - dgh.deactivate(); - } - public function isFinished():Boolean - { - return dgh.isFinished(); - } - public function getItem(field:Number, col:Number):Object - { - return dgh.getItem(field, col); - } - public function setItem(field:Number, col:Number, value:Object):void - { - dgh.setItem(field, col, value); - } - public function clone():DataGrid - { - return dgh.clone(); - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,290 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" creationComplete="init()"> - - <mx:ArrayCollection id="sched"/> - <mx:ArrayCollection id="schedPeople"/> - <mx:ArrayCollection id="calculated"/> - - <comp:Forecast1 id="newForecast1" visible="false" includeInLayout="false"/> - - <mx:HBox> - <mx:VBox id="labels"> - </mx:VBox> - - <mx:VBox id="dgRows" verticalGap="0"> - <mx:HBox id="dgRow1" horizontalGap="0"> - <mx:DataGrid id="dgMain" - editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/> - </mx:HBox> - - <mx:HBox id="dgRow2"> - <!--<mx:DataGrid id="dgPeople" - editable="false" textAlign="right" dataProvider="{schedPeople}" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/>--> - </mx:HBox> - - <mx:HBox id="dgRow3"> - <!--<mx:DataGrid id="dgCalculated" headerHeight="1" - editable="false" textAlign="right" dataProvider="{calculated}" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/>--> - </mx:HBox> - </mx:VBox> - </mx:HBox> - - <mx:Label id="lbl"/> - - - <mx:Script> - <![CDATA[ - import actionscript.DataGridHandler; - import mx.controls.Button; - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - [Bindable] public var numColumns:Number = 5; - [Bindable] public var numFields:Number = 3; - [Bindable] public var minValue:Number = 0; - [Bindable] public var maxValue:Number = 100; - [Bindable] public var oldForecast1:Forecast1 = null; - - private var dgCalculated:DataGridHandler = new DataGridHandler(numFields+3,numColumns); - - private var errorMessage:String = null; - private var colIndex:Number=0; - private var finished:Boolean = false; - - public function init():void - { - createColumns(); - getPeople(); - - setItem(0,0,5); - setItem(1,0,10); - setItem(2,0,15); - - dgCalculated.deactivate(); - dgRow3.addChild(dgCalculated.grid); - } - private function createColumns():void - { - var tempArray:Array = dgMain.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = false; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - if(0 != i) - { - temp.editable = true; - } - - tempArray[i] = temp; - } - - dgMain.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - sched.addItem(field); - } - - dgMain.height = (23)*(numFields+1)+2; - } - - public function getPeople():void - { - if(oldForecast1 == null) - { - dgRow2.addChild(newForecast1.dgh.grid); - } - else - { - dgRow2.addChild(oldForecast1.clone()); - } - } - - public function getItem(field:Number, col:Number):Object - { - return this.sched.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - this.sched.getItemAt(field)["day"+(col+1)] = value; - } - - public function changed():void - { - calculateValues(); - - markNoError(); - - var error:Boolean = false; - // check the values of the current column - // and point out any errors (TextBox) - for(var col:Number=0; col < numColumns && !error; col++) - { - var colStr:String = "day"+(col+1); - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) - { - var value:Object = getItem(field, col); - if(invalidNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else if(outOfBoundsNum(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else - { - colSum += Number(value); - } - } - } - - if(error) - { - lbl.text = errorMessage; - } - else - { - lbl.text = "Complete."; - } - - } - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - - var pattern:RegExp = /^\d+$/; - var s:String = StringUtil.trim(String(n)); - -// debug.text = "."+n+"."+pattern.test(s)+(s is String); - - // if it does not match the pattern, it is invalid - return !pattern.test(s); - } - private function outOfBoundsNum(n:Object):Boolean - { - return Number(n) < minValue || Number(n) > maxValue; - } - - private function markError(field:Number, col:Number):void - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); - dgMain.selectedIndex = field; - } - private function markNoError():void - { - for(var col:Number=0; col < numColumns; col++) - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); - } - dgMain.selectedIndex = -1; - } - - public function calculateValues():void - { - for(var col:Number=0; col < numColumns; col++) - { - var t_location:Number = 0; // get thru Planner, -1=harbor - - var t_capacity:Array = [10, 20, 30]; - var t_population:Array = new Array(3); - var t_people:Array = new Array(3); - - var t_fish_mined:Number = 0; - var t_fish_mined_total:Number = 0; - - //lbs in bay 1...N - for(var x:Number = 0; x < numFields; x++) - { - t_population[x] = getItem(x, col); //update fishies - t_people[x] = oldForecast1.getItem(x+1,col); //update fishers - if(x == t_location) - { - t_people[x]++; //add this player - } - - var t_fish_each:Number = 5*t_population[x]/t_capacity[x]; - var t_fish_mined_this:Number = t_people[x] * t_fish_each; - if(t_fish_mined_this > t_population[x]) - { - t_fish_each = t_population[x] / t_people[x]; - } - - if(x == t_location) - { - t_fish_mined = t_fish_each; - } - - dgCalculated.setItem(3+x,col,t_population[x]); - } - - //location - dgCalculated.setItem(0,col,t_location); - - //you get - dgCalculated.setItem(1,col, 5* t_fish_mined); // in USD$ - - //others get - dgCalculated.setItem(2,col, 5* (t_fish_mined_total - t_fish_mined)); - - } - - dgCalculated.grid.invalidateList(); - } - - public function isFinished():Boolean - { - for(var col:Number=0; col < numColumns; col++) - { - for(var x:Number = 0; x < numFields; x++) - { - if(getItem(x, col) <= 0) - { - return false; - } - } - } - return true; - } - - public function updateOld():void - { - try{ - dgRow2.removeAllChildren(); - dgRow2.addChild(oldForecast1.clone()); - } - catch(errObject:Error) - { - lbl.text = errObject.message + "\n" + errObject.getStackTrace(); - } - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,292 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - - <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> - - <mx:Script> - <![CDATA[ - import mx.controls.Alert; - import mx.events.FlexEvent; - import mx.controls.DataGrid; - import mx.collections.ArrayCollection; - import mx.controls.Label; - import mx.controls.dataGridClasses.DataGridColumn; - import mx.utils.StringUtil; - - // vital components - [Bindable] public var dataGrid:DataGrid; - [Bindable] public var dataProvider:ArrayCollection; - [Bindable] public var errorMessage:String = ""; - - // Game Data - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:CalculatedViewing - [Bindable] public var numBays:int = 3; - [Bindable] public var numColumns:int = -1; - [Bindable] public var numFields:int = 15; - [Bindable] public var minValue:int = 0; - [Bindable] public var maxValue:int = 5; - [Bindable] public var groupSize:int = 4; - [Bindable] public var finished:Boolean = false; - - // for lining up grids - [Bindable] public var minimumWidth:int = 160; - - // - // public accessible functions - // - - public function init():void - { - createGrid(); - fillGridColumns(); - fillGridFields(); - setGridHeight(); - addChild(dataGrid); - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - for(var field:int = 0; field < dataProvider.length; field++) - { - saveArray.addItem(new ArrayCollection()); - for(var column:int = 0; column < dataGrid.columnCount; column++) - { - (saveArray.getItemAt(field) as ArrayCollection).addItem(getItem(field, column)); - } - } - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - for(var field:int = 0; field < loadArray.length && field < dataProvider.length; field++) - { - var loadSubArray:ArrayCollection = loadArray.getItemAt(field) as ArrayCollection; - for(var column:int = 0; column < loadSubArray.length && column < dataGrid.columnCount; column++) - { - setItem(field, column, loadSubArray.getItemAt(column)); - } - } - redraw(); - } - - public function changed(event:Object=null):void - { - if((style == 0) || (style == 2)) // 0:PeopleEntry, 2:FishEntry - { - errorCheck(); - } - redraw(); - } - - public function getItem(field:Number, col:Number):Object - { - return dataProvider.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - dataProvider.getItemAt(field)["day"+(col+1)] = value; - } - - public function redraw():void - { - dataGrid.invalidateList(); - } - - // - // private Utility functions - // - - private function addLabel(text:String="", html:Boolean=false):void - { - var newLabel:Label = new Label(); - if(text != "" && !html) - { - newLabel.text = text; - } - else if(html) - { - newLabel.htmlText = text; - } - labels.addChild(newLabel); - } - - private function addField():void - { - dataProvider.addItem(new Object()); - } - - private function createGrid():void - { - dataGrid = new DataGrid(); - dataGrid.id = "dataGrid"; - dataGrid.editable = true; - dataGrid.enabled = true; - dataGrid.addEventListener("change", changed); - } - - private function fillGridColumns():void - { - var columnArray:Array = dataGrid.columns; - for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) - { - var newDataGridColumn:DataGridColumn = new DataGridColumn("day"+(columnNumber+1)); - newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... - newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... - - newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry - newDataGridColumn.draggable = false; - newDataGridColumn.sortable = false; - newDataGridColumn.resizable = false; - newDataGridColumn.width = 30; - - columnArray[columnNumber] = newDataGridColumn; - } - dataGrid.columns = columnArray; - - dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry - } - - private function fillGridFields():void - { - dataProvider = new ArrayCollection(); - - var bayNumber:int = 0; - if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing - { - if(style==0) - { - addLabel(" <b>Predict</b>:",true); - } - else - { - addLabel(" <b>You Predicted</b>:",true); - } - - addLabel("# People in Harbor:"); - addField(); - - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# People in Bay " + (bayNumber+1) + ":"); - addField(); - } - } - else if(style==2) - { - addLabel(" <b>Predict:</b>",true); - - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); - addField(); - } - } - else if(style==3) - { - addLabel(" <b>We calculate that:</b>",true); - - addLabel("You will be in location #:"); - addField(); - addLabel("You will get USD:"); - addField(); - addLabel("Others will get USD:"); - addField(); - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); - addField(); - } - } - dataGrid.dataProvider = dataProvider; - numFields = dataProvider.length; - } - - private function setGridHeight():void - { - switch(style) - { - case(0): - case(1): // 0:PeopleEntry, 1:PeopleViewing - dataGrid.height = (23)*(numBays+2)-1; - break; - case(2): // 2:FishEntry - dataGrid.height = (23)*(numBays+1); - break; - case(3): // 3:CalculatedViewing - dataGrid.height = (23)*(numBays+4)-3; - break; - } - } - - private function errorCheck():void - { - markNoError(); - var error:Boolean = false; - - for(var column:Number=0; column < numColumns && !error; column++) - { - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) - { - var value:Object = getItem(field, column); - if(!validNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(!inBounds(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(style == 0) // 0:PeopleEntry - { - colSum += Number(value); - } - } - - if(!error && style == 0 && colSum != groupSize-1) // 0:PeopleEntry - { - errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; - error = true; - markError(-1,column); - } - } - - finished = !error; - } - - private function validNum(n:Object):Boolean - { - if(n == null) return false; - var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits - var s:String = StringUtil.trim(String(n)); - return (n is Number) || pattern.test(s); - } - private function inBounds(n:Object):Boolean - { - return Number(n) >= minValue && Number(n) <= maxValue; - } - public function markError(field:Number, column:Number):void - { - if(style != 0 && style != 2) return; // 0:PeopleEntry, 2:FishEntry - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#ee82ee"); - dataGrid.selectedIndex = field; - } - private function markNoError():void - { - for(var column:Number=0; column < numColumns; column++) - { - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#FFFFFF"); - } - dataGrid.selectedIndex = -1; - } - - ]]> - </mx:Script> - -</mx:HBox> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> - - <mx:VBox id="content"> - <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30"/> - <!--<mx:Button id="next" label="Forecast Fish Movements" click="testNext()"/>--> - </mx:VBox> - - <mx:Script> - <![CDATA[ - import customComponents.*; - import mx.collections.ArrayCollection; - import mx.controls.Alert; - - private var firstPage:Boolean = true; - private var tries:int = 0; - private var f2:Forecast2; - - public function init():void - { - f2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; - } - - public function testNext(evt:Event=null):Boolean - { - if(! firstPage) return false; - - tries++; - if(!(forecastPeople.isFinished() || tries > 1)) - { - Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); - return false; - } - Alert.show("!"); - - f2.oldForecast1 = forecastPeople; - f2.updateOld(); - content.removeAllChildren(); - content.addChild(f2); - firstPage = false; - return true; - } - - public function back():Boolean - { - //if(content.contains(forecastPeople)) return false; - - content.removeAllChildren(); - content.addChild(forecastPeople); - firstPage = true; - return true; - } - - public function forward():Boolean - { - return testNext(); - } - - public function accept():Boolean - { - if(forecastPeople.isFinished()) - { - var forecastFish:Forecast2 = content.getChildAt(1) as Forecast2; - return forecastFish.isFinished(); - } - return false; - } - - ]]> - </mx:Script> - -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,109 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> - - <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> - - <mx:HBox id="buttons"> - <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> - <mx:Button id="btnBack" label="Forecast People" click="back()" enabled="false"/> - </mx:HBox> - - <mx:VBox id="content"/> - - <mx:Script> - <![CDATA[ - import actionscript.ForecastingQuestion; - import mx.collections.ArrayCollection; - - public var style0:ForecastComponent; - public var style1:ForecastComponent; - public var style2:ForecastComponent; - public var style3:ForecastComponent; - - public var peopleSaved:ArrayCollection; - public var fishSaved:ArrayCollection; - - public var numBays:int = 3; - public var numColumnsMin:int = 6; - public var numColumnsMax:int = 15; - - public function init():void - { - createStyle(style0,0); - createStyle(style1,1); - createStyle(style2,2); - createStyle(style3,3); - content.addChild(style0); - } - private function createStyle(style:ForecastComponent,styleNum:int):void - { - style = new ForecastComponent(); - style.style = styleNum; - style.numBays = numBays; - if(styleNum <= 1) - { - style.numColumns = numColumnsMax; - } - else - { - style.numColumns = numColumnsMin; - } - style.initialize(); - style.init(); - } - - public function back():void - { - fishSaved = style2.save(); - content.removeAllChildren(); - content.addChild(style0); - } - public function forward():void - { - peopleSaved = style0.save(); - style1.load(peopleSaved); - content.removeAllChildren(); - content.addChild(style2); // 2:FishEntry - content.addChild(style1); // 1:PeopleView - content.addChild(style3); // 3:Calculated - } - public function accept():Boolean - { - return true; - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - saveArray.addItem(null); - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - (loadArray.getItemAt(0) as Object); - } - - public function loadFromQuestion(question:ForecastingQuestion):void - { - description = question.question; - - initialize(); - init(); - } - - ]]> - </mx:Script> - -</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*" + xmlns:comp="customComponents.*" xmlns:quest="customComponents.questions.*" initialize="init()"> <mx:ArrayCollection id="psychometricLabels"> <mx:String>Very Much</mx:String> <mx:String>Neutral</mx:String> - <!--<mx:String>Not at All... [truncated message content] |