[virtualcommons-svn] SF.net SVN: virtualcommons:[82] mentalmodels/trunk/flex
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-03-06 22:31:16
|
Revision: 82 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=82&view=rev Author: kjonas Date: 2009-03-06 22:31:03 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Initial revision of Custom Components for Fishery Experiment Added Paths: ----------- mentalmodels/trunk/flex/src/ mentalmodels/trunk/flex/src/customComponents/ 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/InstructionPage.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/PsychometricQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml Added: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,161 @@ +<?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="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" + horizontalScrollPolicy="on" + verticalScrollPolicy="off"/> + <mx:Button label="{dg1.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(); + + /* dg1.selectedIndex = 0; dg1.selectedItem.day1 = 5; + dg1.selectedIndex = 1; dg1.selectedItem.day1 = 10; + dg1.selectedIndex = 2; dg1.selectedItem.day1 = 15; + dg1.selectedIndex = -1; */ + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dg1.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); + } + } + } + dg1.columns = tempArray; + + dg1.height = 23*(numFields+1)+17 + dg1.width = 30*Math.min(numColumns, 6)+1 + } + + public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.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 + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.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(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.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\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> Added: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,200 @@ +<?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="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()"/> + </mx:HBox> + + <mx:Label id="lbl"/> + <mx:Label id="debug"/> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 15; + [Bindable] + public var numFields:Number = 4; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 10; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + } + private function createColumns():void + { + var tempArray:Array = dg1.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 = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dg1.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); + } + + dg1.height = 22*numFields+24 + } + + /* public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.columns[colIndex]; + if(num == null || num == "" || Number(num)*0 != 0) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.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(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.columns[colIndex]).editable = true; + } */ + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + var value:Object; + + // 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++) + { + value = 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\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(dg1.columns[col]).setStyle("backgroundColor", "#3333FF"); + dg1.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dg1.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,208 @@ +<?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="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + + <mx:Label id="lbl"/> + + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 6; + [Bindable] + public var numFields:Number = 3; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 50; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dg1.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; + } + + dg1.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); + } + + dg1.height = 22*numFields+24 + } + + /* public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.columns[colIndex]; + if(num == null || num == "" || Number(num)*0 != 0) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.selectedIndex = -1; + } + } + private function changeColumn():void + { + DataGridColumn(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.columns[colIndex]).editable = true; + } */ + + 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; + } + + public function changed():void + { + 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\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(dg1.columns[col]).setStyle("backgroundColor", "#3333FF"); + dg1.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dg1.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] + public var numPages:Number; //temporary hard-coded value *fix this* + + // Contains ArrayCollections filled with DisplayObjects + // *see: getDisp(pageNum, index) + private var allPageList:ArrayCollection; + + // Variables with default settings + [Bindable] + public var currPageNumber:Number = 0; + public var pagesRead:Number = 1; + + public function init():void + { + numPages = loadAllPages(); + showPage(); + } + + public function loadAllPages():Number + { + allPageList = new ArrayCollection(); + // load allPageList from file - return length + var done:Boolean = false; + do + { + var tempPage:ArrayCollection = new ArrayCollection(); + + var doneItems:Boolean = false; + do + { + var tempItem:DisplayObject = new PsychometricQuestion(); + ((PsychometricQuestion)(tempItem)).labels = new ArrayCollection(["Big", "Small"]); + + tempPage.addItem(tempItem); + doneItems = true; + }while(!doneItems) + + allPageList.addItem(tempPage); + done = true; + }while(!done) + + return allPageList.length; + } + + private function getPage(pageNum:Number):ArrayCollection + { + if(pageNum < 0 || allPageList == null || pageNum >= allPageList.length) + { return null; } + + return (ArrayCollection)(allPageList.getItemAt(pageNum)); + } + + private function getDisp(pageNum:Number, index:Number):DisplayObject + { + var tempList:ArrayCollection = getPage(pageNum); + + if(tempList == null || index < 0 || index >= tempList.length) + { return null; } + + return (DisplayObject)(tempList.getItemAt(index)); + } + public function showPage():Boolean + { + try + { + var list:ArrayCollection = getPage(currPageNumber); + for(var index:Number = 0; index < list.length; index++) + { + content.addChild(getDisp(currPageNumber, index)); + } + + if(currPageNumber >= pagesRead) + { + pagesRead = currPageNumber+1; + } + return true; + } + catch(error:Error) + {} + return false; + } + + private function fixNum():Boolean + { + if(currPageNumber < 0) + { + currPageNumber = 0; + return false; + } + if(currPageNumber >= numPages) + { + currPageNumber = numPages - 1; + return false; + } + return showPage(); + } + + public function back():Boolean + { + currPageNumber--; + return fixNum(); + } + + public function forward():Boolean + { + currPageNumber++; + return fixNum(); + } + + public function accept():Boolean + { + return pagesRead >= numPages; + } + + ]]> + </mx:Script> + + <mx:Label text="{currPageNumber+1} / {numPages}"/> + + <mx:VBox id="content"/> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30"> + + <mx:Image source="../libs/LongScale.jpg" y="0"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="495" height="20" y="0" + minimum="-15" maximum="15" snapInterval="1" value="0" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30" layout="absolute"> + + <mx:Image x="10" y="0" source="../libs/LongSlider.jpg" /> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()" + width="350" height="200" + borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + + public var valueRequired:Boolean = false; + + private function init():void + { + if(valueRequired) + { + addRow(); + } + } + + public function childRemoved():void + { + numbers.removeChildAt(numbers.numChildren-1); + } + + public function addRow():void + { + var newRow:PlannerRow = new PlannerRow(); + newRow.valueRequired = this.valueRequired; + var newNumber:Label = new Label(); + newNumber.text = "" + (numbers.numChildren+1); + newNumber.height = 22; + + grid.addChildAt(newRow, grid.numChildren); + numbers.addChild(newNumber); + } + + public function getPlannerRow(index:Number):PlannerRow + { + if(index < grid.numChildren && index >= 0) + { + return (PlannerRow)(grid.getChildAt(index)); + } + return null; + } + public function getPlannerList(index:Number):ArrayCollection + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + return null; + } + var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); + return list; + } + public function toArrayCollection():ArrayCollection + { + var array:ArrayCollection = new ArrayCollection(); + + for(var index:Number = 0; index < grid.numChildren; index++) + { + var temp:ArrayCollection = getPlannerList(index); + array.addItem(temp); + } + + return array; + } + + ]]> + </mx:Script> + + <mx:HBox id="newButtonBox"> + <mx:Label text="" width="12"/> + <mx:Button id="newButton" label="New" click="addRow()" width="60"/> + <!--<mx:Label text="-" width="80" textAlign="center"/> + <mx:Label text="-" width="50" textAlign="center"/> + <mx:Label text="-" width="80" textAlign="center"/>--> + </mx:HBox> + + <mx:HBox id="headerBox"> + <mx:Label text="#" fontWeight="bold" paddingBottom="-3" width="12"/> + <mx:Label text="Remove" fontWeight="bold" paddingBottom="-3" width="60" textAlign="center"/> + <mx:Label text="Location" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + <mx:Label text="Days" fontWeight="bold" paddingBottom="-3" width="50" textAlign="center"/> + <mx:Label text="Threshold" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + </mx:HBox> + + <mx:HBox horizontalScrollPolicy="off" height="147" width="100%"> + <mx:VBox id="numbers" width="12"/> + <mx:VBox id="grid" childRemove="childRemoved()"/> + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label text="Planning Stage" fontSize="24"/> + <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." + width="600"/> + <mx:Label/> + + <mx:HBox> + <mx:VBox> + <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> + <comp:Planner id="notRepeated"/> + </mx:VBox> + <mx:VBox> + <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> + <comp:Planner id="repeated" valueRequired="true"/> + </mx:VBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Suspend repetition:" fontWeight="bold" width="130"/> + <mx:Label text="If during one repetition"/> + <mx:NumericStepper id="suspendWeight" value="5" minimum="0.1" maximum="100" stepSize="0.1" height="20" width="50"/> + <mx:Label text="lbs could not be fished,"/> + </mx:HBox> + <mx:HBox> + <mx:Label width="113"/> + <mx:Label text="then stay in the harbor for"/> + <mx:NumericStepper id="suspendDays" value="1" minimum="0" maximum="30" stepSize="1" height="20" width="50"/> + <mx:Label text="days before starting the next repetition."/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public function getNotRepeated():ArrayCollection + { return notRepeated.toArrayCollection(); } + + public function getRepeated():ArrayCollection + { return repeated.toArrayCollection(); } + + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public var valueRequired:Boolean = false; + + public function deleteMe():void + { + if(!valueRequired || parent.numChildren > 1) + { + parent.removeChild(this); + } + } + + public function changedLocation():void + { + threshold.visible = (location.selectedIndex != 0); + threshold.enabled = threshold.visible; + } + + public function getLocation():String + { + if(location.selectedIndex == 0) + { + return "Harbor"; + } + return "Bay " + location.selectedIndex; + } + public function getDays():Number + { + return days.value; + } + public function getThreshold():Number + { + if(location.selectedIndex == 0) + { + return -1; + } + return threshold.value; + } + + ]]> + </mx:Script> + + <mx:ArrayCollection id="locs"> + <mx:Object label="Harbor" data="Harbor"/> + <mx:Object label="Bay 1" data="Bay 1"/> + <mx:Object label="Bay 2" data="Bay 2"/> + <mx:Object label="Bay 3" data="Bay 3"/> + </mx:ArrayCollection> + + + <mx:Button id="deleteRow" label="Del" click="deleteMe()" width="60"/> + <mx:ComboBox id="location" dataProvider="{locs}" change="changedLocation()" width="80"/> + <mx:NumericStepper id="days" value="1" minimum="1" maximum="30" stepSize="1" width="50"/> + <mx:NumericStepper id="threshold" value="0.5" stepSize="0.1" minimum="0" maximum="100" enabled="false" visible="false" width="80"/> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:comp="customComponents.*"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var labels:ArrayCollection; + + private function init():void + { + if(labels != null) + { + if(labels.length == 2) + { + this.removeChild(topleft); + this.removeChild(topmid); + this.removeChild(topright); + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + slider.isBipolar = false; + slider.x = 100; + slider.y = 0; + } + else + { + this.removeChild(farleft); + this.removeChild(farright); + topleft.text = (String)(labels.getItemAt(0)); + topmid.text = (String)(labels.getItemAt(1)); + topright.text = (String)(labels.getItemAt(2)); + slider.isBipolar = true; + slider.x = 0; + slider.y = 36; + } + } + slider.init(); + } + + ]]> + </mx:Script> + + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> + + <comp:Slider id="slider" initialize="false"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="260" height="30"> + + <mx:Image source="../libs/ShortScale.jpg"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="255" height="20" top="10" + minimum="0" maximum="15" snapInterval="1" value="15" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.controls.Label; + + // Psychometric Variables - (Left = Positive, Right = Negative) + public var maxValue:Number = 10; // Leftmost value + public static var abstainValue:Number = -999; // Refusal to answer + private static var unipolarWidth:Number = 200; + private static var bipolarWidth:Number = 400; + private static var imageWidth:Number = 4; + + private var minValue:Number; // Rightmost value + private var value:Number; // value selected + + [Bindable] + public var getVal:Number; // (for binding: same value as last getValue() method call) + public var isBipolar:Boolean; // double slider = true, single slider = false + + // prepare Slider in default (abstain) position + public function init():void + { + this.addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); + this.addEventListener(MouseEvent.MOUSE_UP, mouseMove); + + if(isBipolar) + { + sliderBar.width = bipolarWidth + imageWidth; + minValue = -maxValue; + } + else + { + sliderBar.width = unipolarWidth + imageWidth; + minValue = 0; + } + + addTicks(); + reset(); + } + + private function addTicks():void + { + var numTicks:Number = maxValue - minValue + 1; + var separation:Number = (sliderBar.width - imageWidth) / (numTicks-1) + + var ticks:Array = new Array(numTicks); + + for(var i:Number = 0; i < numTicks; i++) + { + var tick:Label = new Label(); + tick.text = "."; + tick.x = i*separation - imageWidth/2; + tick.y = -10; + this.addChild(tick); + } + } + + private function mouseMove(event:MouseEvent):void + { + sliderButton.visible = true; + updateValue(); + } + + public function getValue():Number + { + if(sliderButton.visible) + { + getVal = value; + return value; + } + else + { + getVal = abstainValue; + return abstainValue; + } + } + + private function updateValue():void + { + var separation:Number = (sliderBar.width - imageWidth) / (maxValue - minValue) + var index:Number = Math.round((mouseX-imageWidth/2) / separation); // snap to nearest valid position + + value = maxValue - index; // flips scale so positive numbers on left + getValue(); // updates the bindable "getVal" variable + + var xPos:Number = index * separation; + sliderButton.move(xPos, 0); + } + + public function reset():void + { + sliderButton.visible = false; + updateValue(); + sliderButton.move(0,0); + } + + ]]> + </mx:Script> + + <!-- change X value to 1/2 the width of the sliderButton image --> + <mx:HBox id="sliderBar" + height="3" x="0" y="15" + borderStyle="solid" borderColor="#F0F0F0" borderThickness="2" + /> + + <mx:Image id="sliderButton" + x="0" y="0" + source="../libs/SliderImage.png" + /> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public function getGender():String + { + if(radioMale.selected) { return "M"; } + if(radioFemale.selected) { return "F"; } + return "Err"; + } + public function getYear():String + { + return txtYear.text; + } + public function getMajor():String + { + return txtMajor.text; + } + public function getSemester():String + { + return txtSemester.text; + } + + public function accept():Boolean + { + // if any field is of improper length, this section is not completed + // flag/unflag an area with red if incomplete/complete + var ready:Boolean=true; + + if(getGender().length != 1) + { + boxGender.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + boxGender.setStyle("backgroundColor", ""); + } + + if(getYear().length != 4) + { + txtYear.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtYear.setStyle("backgroundColor", "#FFFFFF"); + } + + if(getMajor().length == 0) + { + txtMajor.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtMajor.setStyle("backgroundColor", "#FFFFFF"); + } + + if(getSemester().length == 0) + { + txtSemester.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtSemester.setStyle("backgroundColor", "#FFFFFF"); + } + + boxGender.enabled = !ready; + txtYear.enabled = !ready; + txtMajor.enabled = !ready; + txtSemester.enabled = !ready; + // all datamembers are the desired length + return ready; + } + + ]]> + </mx:Script> + + <mx:VBox width="220" horizontalAlign="center"> + <mx:Label text="Personal Data" fontSize="18"/> + <mx:Label text="Please fill out the following fields:"/> + </mx:VBox> + + <mx:HBox> + <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> + <mx:HBox id="boxGender"> + <mx:RadioButton groupName="gender" label="M" id="radioMale"/> + <mx:RadioButton groupName="gender" label="F" id="radioFemale"/> + </mx:HBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtYear" width="75" maxChars="4"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtMajor" width="120" maxChars="100"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + creationComplete="init()"> + + <mx:Script> + <![CDATA[ + [Bindable] private var showTime:String; + + private function init():void{ + // Update every second + var tmr:Timer = new Timer(1000); + tmr.addEventListener(TimerEvent.TIMER, changeTime); + tmr.start(); + } + + private function changeTime(event:TimerEvent):void{ + // Get Server Time + var serv:Date = new Date(); // *fix this* + + // Display Server Time + showTime = serv.toLocaleTimeString(); + } + ]]> + </mx:Script> + + <mx:Label text="{showTime}"/> + +</mx:Canvas> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |