virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 73)
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: <kj...@us...> - 2009-06-16 22:08:14
|
Revision: 162 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=162&view=rev Author: kjonas Date: 2009-06-16 22:08:11 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-13 23:18:00 UTC (rev 161) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-16 22:08:11 UTC (rev 162) @@ -2,7 +2,7 @@ <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" - currentState="forecasting" initialize="init()"> + currentState="socioDemographic" initialize="init()"> <mx:states> <mx:State name="socioDemographic"> @@ -27,7 +27,7 @@ <mx:State name="forecasting"> <mx:AddChild relativeTo="{content}"> - <comp:ForecastingSeema id="forecasting"/> + <comp:ForecastPage_TEMP id="forecasting"/> </mx:AddChild> </mx:State> @@ -41,9 +41,9 @@ <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:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="\xAB 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 »" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward \xBB" click="forward()" right="8" bottom="8"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> @@ -131,7 +131,7 @@ // var msg:AsyncMessage = new AsyncMessage(); //var client:FlexClient = FlexClient.getInstance(); - //creating new msg with “New” to get current state. + //creating new msg with \x93New\x94 to get current state. //msg.body = "New"; //producer.send(msg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-13 23:20:32
|
Revision: 161 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=161&view=rev Author: kjonas Date: 2009-06-13 23:18:00 +0000 (Sat, 13 Jun 2009) Log Message: ----------- save():ArrayCollection and load(ArrayCollection):void methods have been written for each of the following: ForecastComponent.mxml PlannerPage.mxml CategoricalQuestionC.mxml PsychometricQuestionC.mxml TextQuestionC.mxml The methods have been tested by calling the save function, and then loading the resulting ArrayCollection, after modifying the component. The components were observed to return to the state in which they were saved, in terms of the data stored. (see: TestForecast.mxml for manipulation and fiddling.) Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.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/Slider.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -2,14 +2,18 @@ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" 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}"/> <mx:HBox> <mx:Button label="Save" click="save()"/> - <!--<mx:Button label="Load" click="load()"/>--> + <mx:Button label="Load" click="load()"/> </mx:HBox> + + <comp:PlannerPage id="planner"/> + </mx:VBox> <mx:Script> @@ -17,7 +21,8 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - public var saved:ArrayCollection = null; + public var forecastSaved:ArrayCollection = null; + public var plannerSaved:ArrayCollection = null; // try // { @@ -30,17 +35,16 @@ public function init():void { - //forecastComponent0.changed(); + } public function save():void { try { - saved = forecastComponent0.save(); - forecastComponent1.load(saved); - forecastComponent2.load(saved); - forecastComponent3.load(saved); + forecastSaved = forecastComponent0.save(); + + plannerSaved = planner.save(); } catch(error:Error) { @@ -52,7 +56,9 @@ { try { - forecastComponent1.load(saved); + forecastComponent1.load(forecastSaved); + + planner.load(plannerSaved); } catch(error:Error) { Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:Script> <![CDATA[ import actionscript.FishUtil; @@ -9,6 +10,20 @@ 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; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -23,7 +23,7 @@ numbers.removeChildAt(numbers.numChildren-1); } - public function addRow():void + public function addRow():PlannerRow { var newRow:PlannerRow = new PlannerRow(); newRow.valueRequired = this.valueRequired; @@ -33,6 +33,8 @@ grid.addChildAt(newRow, grid.numChildren); numbers.addChild(newNumber); + + return newRow; } public function getPlannerRow(index:Number):PlannerRow @@ -53,19 +55,40 @@ var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); return list; } - public function toArrayCollection():ArrayCollection + public function setPlannerList(index:Number, newValues:ArrayCollection):void { - var array:ArrayCollection = new ArrayCollection(); + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + row = addRow(); + } + row.setLocation(newValues.getItemAt(0) as String); + row.setDays(newValues.getItemAt(1) as Number); + row.setThreshold(newValues.getItemAt(2) as Number); + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); for(var index:Number = 0; index < grid.numChildren; index++) { - var temp:ArrayCollection = getPlannerList(index); - array.addItem(temp); + saveArray.addItem(getPlannerList(index)); } - return array; + return saveArray; } + public function load(loadArray:ArrayCollection):void + { + grid.removeAllChildren(); + numbers.removeAllChildren(); + for(var index:Number = 0; index < loadArray.length; index++) + { + setPlannerList(index, loadArray.getItemAt(index) as ArrayCollection); + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -35,16 +35,34 @@ import mx.collections.ArrayCollection; public function getNotRepeated():ArrayCollection - { return notRepeated.toArrayCollection(); } + { return notRepeated.save(); } public function getRepeated():ArrayCollection - { return repeated.toArrayCollection(); } + { return repeated.save(); } public function accept():Boolean { return true; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(notRepeated.save()); + saveArray.addItem(repeated.save()); + saveArray.addItem(suspendWeight.value); + saveArray.addItem(suspendDays.value); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + notRepeated.load(loadArray.getItemAt(0) as ArrayCollection); + repeated.load(loadArray.getItemAt(1) as ArrayCollection); + suspendWeight.value = loadArray.getItemAt(2) as Number; + suspendDays.value = loadArray.getItemAt(3) as Number; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -28,10 +28,22 @@ } return "Bay " + location.selectedIndex; } + public function setLocation(newValue:String):void + { + if(newValue == "Harbor") location.selectedIndex = 0; + if(newValue == "Bay 1") location.selectedIndex = 1; + if(newValue == "Bay 2") location.selectedIndex = 2; + if(newValue == "Bay 3") location.selectedIndex = 3; + changedLocation(); + } public function getDays():Number { return days.value; } + public function setDays(newValue:Number):void + { + days.value = newValue; + } public function getThreshold():Number { if(location.selectedIndex == 0) @@ -40,6 +52,11 @@ } return threshold.value; } + public function setThreshold(newValue:Number):void + { + if(newValue == -1) return; + threshold.value = newValue; + } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -84,6 +84,20 @@ } } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(slider1.sliderButton.visible); + saveArray.addItem(slider1.sliderButton.x); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + slider1.sliderButton.visible = loadArray.getItemAt(0) as Boolean; + slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -10,7 +10,6 @@ [Embed(source="../images/SliderImage.png")] private var sliderImage:Class; - // Psychometric Variables - (Left = Positive, Right = Negative) public var maxValue:Number = 10; // Leftmost value public static var abstainValue:Number = -999; // Refusal to answer @@ -21,8 +20,7 @@ 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) + [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 Deleted: mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Label id="header"/> - <mx:TextInput id="text"/> - -</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,12 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <!--<mx:String id="title"></mx:String> - <mx:String id="description"></mx:String> - <mx:VBox id="headers" paddingBottom="-3"> - <mx:Label text="{title}" paddingBottom="-8"/> - <mx:Text text="{description}" paddingBottom="-8"/> - </mx:VBox>--> <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> @@ -25,23 +19,23 @@ <mx:Number id="txtWidth">200</mx:Number> <mx:Number id="txtHeight">24</mx:Number> <mx:String id="defaultText"/> - <mx:TextArea id="text" text="{defaultText}" width="{txtWidth}" height="{txtHeight}"/> + <mx:TextArea id="textAnswer" text="{defaultText}" width="{txtWidth}" height="{txtHeight}"/> <mx:Script> <![CDATA[ + import mx.collections.ArrayCollection; - public function back():Boolean + public function save():ArrayCollection { - return false; + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(textAnswer.text); + return saveArray; } - public function forward():Boolean + + public function load(loadArray:ArrayCollection):void { - return false; + textAnswer.text = loadArray.getItemAt(0) as String; } - public function accept():Boolean - { - return true; - } ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-12 23:08:48
|
Revision: 160 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=160&view=rev Author: kjonas Date: 2009-06-12 23:08:38 +0000 (Fri, 12 Jun 2009) Log Message: ----------- ForecastComponent.mxml now contains methods save() and load(). These methods are common to all four "styles". ForecastComponent.mxml also contains value-checking, which only occurs on styles 0 and 2, the two styles that allow data entry. Style 0 checks for number validity, range, and sum (in columns). Style 2 checks for number validity and range only. Error messages are generated and accessible through the public variable errorMessage, but they are not displayed. Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 02:39:11 UTC (rev 159) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 23:08:38 UTC (rev 160) @@ -1,30 +1,65 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" 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}"/> + <mx:HBox> + <mx:Button label="Save" click="save()"/> + <!--<mx:Button label="Load" click="load()"/>--> + </mx:HBox> </mx:VBox> <mx:Script> <![CDATA[ -// import mx.controls.Alert; -// -// public function init():void -// { + import mx.collections.ArrayCollection; + import mx.controls.Alert; + + public var saved:ArrayCollection = null; + // try // { -// forecastComponent.initialize(); -// forecastComponent.init(); +// // } // catch(error:Error) // { // Alert.show(error.message + "\n" + error.getStackTrace()); // } -// } + public function init():void + { + //forecastComponent0.changed(); + } + + public function save():void + { + try + { + saved = forecastComponent0.save(); + forecastComponent1.load(saved); + forecastComponent2.load(saved); + forecastComponent3.load(saved); + } + catch(error:Error) + { + Alert.show(error.message + "\n" + error.getStackTrace()); + } + } + + public function load():void + { + try + { + forecastComponent1.load(saved); + } + catch(error:Error) + { + Alert.show(error.message + "\n" + error.getStackTrace()); + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 02:39:11 UTC (rev 159) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 23:08:38 UTC (rev 160) @@ -5,18 +5,36 @@ <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; - public var dataGrid:DataGrid; - [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); + // 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 = 15; + [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 = 30; - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated + // + // public accessible functions + // + public function init():void { createGrid(); @@ -26,6 +44,60 @@ 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(); @@ -47,37 +119,39 @@ private function createGrid():void { - dataGrid = new DataGrid; + dataGrid = new DataGrid(); dataGrid.id = "dataGrid"; dataGrid.editable = true; dataGrid.enabled = true; + dataGrid.addEventListener("change", changed); } private function fillGridColumns():void { - var newColumnArray:Array = new Array(numColumns); + var columnArray:Array = dataGrid.columns; for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) { - var newDataGridColumn:DataGridColumn = new DataGridColumn(); + 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; - 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 - - newColumnArray[columnNumber] = newDataGridColumn; + columnArray[columnNumber] = newDataGridColumn; } - dataGrid.columns = newColumnArray; + 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 { @@ -126,6 +200,7 @@ } } dataGrid.dataProvider = dataProvider; + numFields = dataProvider.length; } private function setGridHeight():void @@ -139,12 +214,78 @@ case(2): // 2:FishEntry dataGrid.height = (23)*(numBays+1); break; - case(3): // 3:Calculated + 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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-12 02:39:13
|
Revision: 159 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=159&view=rev Author: kjonas Date: 2009-06-12 02:39:11 +0000 (Fri, 12 Jun 2009) Log Message: ----------- ForecastComponent.mxml renders on screen All "modes" render properly. No value-checking implemented. Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> - <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + <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}"/> + </mx:VBox> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> - <mx:ArrayCollection id="sched"/> - <mx:HBox id="gridContainer"> <mx:VBox id="labels"> </mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:VBox id="labels" verticalGap="2"/> + <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> <mx:Script> <![CDATA[ @@ -14,20 +14,49 @@ [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = 15; + [Bindable] public var minimumWidth:int = 30; [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated public function init():void { + createGrid(); + fillGridColumns(); + fillGridFields(); + setGridHeight(); + addChild(dataGrid); + } + + 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.dataProvider = dataProvider; - - dataGrid.initialize(); - + } + + private function fillGridColumns():void + { var newColumnArray:Array = new Array(numColumns); - for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) { var newDataGridColumn:DataGridColumn = new DataGridColumn(); newDataGridColumn.draggable = false; @@ -44,36 +73,76 @@ } dataGrid.columns = newColumnArray; + dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + } + + private function fillGridFields():void + { var bayNumber:int = 0; if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing { - addLabel(); + 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(); + addLabel(" <b>Predict:</b>",true); + for(bayNumber=0; bayNumber<numBays; bayNumber++) { - addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); + addField(); } } - - //end init() + 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; } - public function addLabel(text:String=""):void + private function setGridHeight():void { - var newLabel:Label = new Label(); - if(text != "") + switch(style) { - newLabel.text = text; + 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:Calculated + dataGrid.height = (23)*(numBays+4)-3; + break; } - labels.addChild(newLabel); } ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-06-10 23:47:14
|
Revision: 158 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=158&view=rev Author: alllee Date: 2009-06-10 23:47:06 +0000 (Wed, 10 Jun 2009) Log Message: ----------- simplifying GroupView in preparation for movie creation (movie creation code courtesy of Werner Randelshofer but still untested - see individual licenses attached to files for more info). Modified Paths: -------------- foraging/trunk/ivy.xml foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataAtomOutputStream.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/FilterImageOutputStream.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/QuickTimeOutputStream.java Modified: foraging/trunk/ivy.xml =================================================================== --- foraging/trunk/ivy.xml 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/ivy.xml 2009-06-10 23:47:06 UTC (rev 158) @@ -8,5 +8,6 @@ <dependency org="junit" name="junit" rev="latest.integration"/> <dependency org="edu.asu.commons" name="csidex" rev="latest.integration"/> <dependency org="net.java.dev.jogl" name="jogl" rev="1.1.1-rc6"/> + <dependency org="javax.media" name="jmf" rev="2.1.1e"/> </dependencies> </ivy-module> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/pom.xml 2009-06-10 23:47:06 UTC (rev 158) @@ -59,6 +59,11 @@ <artifactId>jogl</artifactId> <version>1.1.1-rc6</version> </dependency> + <dependency> + <groupId>javax.media</groupId> + <artifactId>jmf</artifactId> + <version>2.1.1e</version> + </dependency> </dependencies> <build> <finalName>foraging</finalName> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java 2009-06-10 23:47:06 UTC (rev 158) @@ -330,7 +330,7 @@ Set<Identifier> clientIds = group.getClientIdentifiers(); Iterator<Identifier> iter = clientIds.iterator(); Identifier clientId = iter.next(); - GroupView groupView = new GroupView(groupViewDimension, clientId, this); + GroupView groupView = new GroupView(groupViewDimension, group); groupView.setup(roundConfiguration); JPanel groupViewPanel = new JPanel(); Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java 2009-06-10 23:47:06 UTC (rev 158) @@ -1,90 +1,74 @@ -package edu.asu.commons.foraging.facilitator; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.util.Map; - -import edu.asu.commons.foraging.client.GridView; -import edu.asu.commons.foraging.conf.RoundConfiguration; -import edu.asu.commons.foraging.model.ClientData; -import edu.asu.commons.foraging.model.ServerDataModel; -import edu.asu.commons.net.Identifier; - - -/** - * $Id$ - * - * @author Deepali Bhagvat - * @author Allen Lee - * @version $Revision$ - */ -public class GroupView extends GridView { - - private static final long serialVersionUID = -4266169284016212828L; - - private Identifier groupId; - - private FacilitatorWindow facilitatorWindow; - - public GroupView(Dimension screenSize, Identifier id, - FacilitatorWindow facilitatorWindow) { - super(screenSize); - this.groupId = id; - this.facilitatorWindow = facilitatorWindow; - } - - public void setup(RoundConfiguration configuration) { - super.setup(configuration); - } - - protected void paintTokens(Graphics2D graphics2D) { - ServerDataModel state = getGameState(); - if (state == null) return; - paintCollection(state.getResourcePositions(groupId), graphics2D, scaledTokenImage); - } - - private ServerDataModel getGameState() { - return facilitatorWindow.getFacilitator().getServerGameState(); - } - - protected void paintSubjects(Graphics2D graphics2D) { - // FIXME: raises an NPE occasionally - investigate. - ServerDataModel state = getGameState(); - if (state == null) - return; - graphics2D.setFont(font); - FontMetrics fontMetrics = graphics2D.getFontMetrics(font); - int characterHeight = fontMetrics.getAscent(); - int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); - Map<Identifier, ClientData> positions = state.getClientDataMap(groupId); - for (Map.Entry<Identifier, ClientData> entry : positions.entrySet()) { - Identifier id = entry.getKey(); - ClientData clientData = entry.getValue(); - Point subjectLocation = clientData.getPosition(); - int scaledX = scaleX(subjectLocation.x); - int scaledY = scaleY(subjectLocation.y); - // boolean shouldFlash = shouldFlash(); - // draw the self image. - if (clientData.isExplicitCollectionMode()) { - graphics2D.drawImage(scaledSelfExplicitCollectionModeImage, scaledX, scaledY, null); - } - else { - graphics2D.drawImage(scaledSelfImage, scaledX, scaledY, null); - } - graphics2D.setColor(Color.WHITE); -// Paint the subject's number - String subjectNumber = String.valueOf( clientData.getAssignedNumber() ); - //Calculate x and y so that the text is center aligned - int characterWidth = fontMetrics.stringWidth(subjectNumber); - int x = (int) (scaledX + ( (dw - characterWidth) / 2)); - int y = (int) (scaledY + characterHeight - verticalCharacterSpacing); - graphics2D.drawString(subjectNumber, x, y); - } - } -} - - - +package edu.asu.commons.foraging.facilitator; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Point; + +import edu.asu.commons.foraging.client.GridView; +import edu.asu.commons.foraging.model.ClientData; +import edu.asu.commons.foraging.model.GroupDataModel; + +/** + * $Id$ + * + * Provides an overview visualization of a particular groups and all participants in the group. + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +public class GroupView extends GridView { + + private static final long serialVersionUID = -8972140468932621959L; + + private GroupDataModel groupDataModel; + + public GroupView(Dimension screenSize) { + super(screenSize); + } + + public GroupView(Dimension screenSize, GroupDataModel groupDataModel) { + super(screenSize); + this.groupDataModel = groupDataModel; + } + + @Override + protected void paintSubjects(Graphics2D graphics2D) { + graphics2D.setFont(super.font); + FontMetrics fontMetrics = graphics2D.getFontMetrics(); + int characterHeight = fontMetrics.getAscent(); + int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); + int yOffset = characterHeight - verticalCharacterSpacing; + for (ClientData clientData: groupDataModel.getClientDataMap().values()) { + Point subjectLocation = clientData.getPosition(); + int scaledX = scaleX(subjectLocation.x); + int scaledY = scaleY(subjectLocation.y); + if (clientData.isExplicitCollectionMode()) { + graphics2D.drawImage(scaledSelfExplicitCollectionModeImage, scaledX, scaledY, this); + } + else { + graphics2D.drawImage(scaledSelfImage, scaledX, scaledY, this); + } + // paint subject number + graphics2D.setColor(Color.WHITE); + String subjectNumber = String.valueOf( clientData.getAssignedNumber() ); + //Calculate x and y so that the text is roughly center aligned + int characterWidth = fontMetrics.stringWidth(subjectNumber); + int x = (int) (scaledX + ( (dw - characterWidth) / 2)); + int y = (int) (scaledY + yOffset); + graphics2D.drawString(subjectNumber, x, y); + } + } + + @Override + protected void paintTokens(Graphics2D graphics2D) { + super.paintCollection(groupDataModel.getResourcePositions(), graphics2D, scaledTokenImage); + } + + public void setGroupDataModel(GroupDataModel groupDataModel) { + this.groupDataModel = groupDataModel; + } + +} Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataAtomOutputStream.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataAtomOutputStream.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataAtomOutputStream.java 2009-06-10 23:47:06 UTC (rev 158) @@ -0,0 +1,317 @@ +package edu.asu.commons.foraging.util; + +/** + * @(#)DataAtomOutputStream.java 1.1 2008-08-11 + * + * Copyright (c) 2008 Werner Randelshofer + * Staldenmattweg 2, CH-6405 Immensee, Switzerland + * All rights reserved. + * + * The copyright of this software is owned by Werner Randelshofer. + * You may not use, copy or modify this software, except in + * accordance with the license agreement you entered into with + * Werner Randelshofer. For details see accompanying license terms. + */ + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * This output stream filter supports common data types used inside + * of QuickTime Data Atoms. + * + * @author Werner Randelshofer + * @version 1.1 2008-08-11 Streamlined API and source code with AVI DataChunkOutputStream. + * <br>1.0.1 2008-06-22 Use ASCII instead of MacRoman for encoding + * type strings. + * <br>1.0 Jun 15, 2008 Created. + */ +public class DataAtomOutputStream extends FilterOutputStream { + + protected static final long MAC_TIMESTAMP_EPOCH = new GregorianCalendar(1904, GregorianCalendar.JANUARY, 1).getTimeInMillis(); + /** + * The number of bytes written to the data output stream so far. + * If this counter overflows, it will be wrapped to Integer.MAX_VALUE. + */ + protected long written; + + public DataAtomOutputStream(OutputStream out) { + super(out); + } + + /** + * Writes an Atom Type identifier (4 bytes). + * @param s A string with a length of 4 characters. + */ + public void writeType(String s) throws IOException { + if (s.length() != 4) { + throw new IllegalArgumentException("type string must have 4 characters"); + } + + try { + out.write(s.getBytes("ASCII"), 0, 4); + incCount(4); + } catch (UnsupportedEncodingException e) { + throw new InternalError(e.toString()); + } + } + + /** + * Writes out a <code>byte</code> to the underlying output stream as + * a 1-byte value. If no exception is thrown, the counter + * <code>written</code> is incremented by <code>1</code>. + * + * @param v a <code>byte</code> value to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public final void writeByte(int v) throws IOException { + out.write(v); + incCount(1); + } + + /** + * Writes <code>len</code> bytes from the specified byte array + * starting at offset <code>off</code> to the underlying output stream. + * If no exception is thrown, the counter <code>written</code> is + * incremented by <code>len</code>. + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + @Override + public synchronized void write(byte b[], int off, int len) + throws IOException { + out.write(b, off, len); + incCount(len); + } + + /** + * Writes the specified byte (the low eight bits of the argument + * <code>b</code>) to the underlying output stream. If no exception + * is thrown, the counter <code>written</code> is incremented by + * <code>1</code>. + * <p> + * Implements the <code>write</code> method of <code>OutputStream</code>. + * + * @param b the <code>byte</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + @Override + public synchronized void write(int b) throws IOException { + out.write(b); + incCount(1); + } + + /** + * Writes an <code>int</code> to the underlying output stream as four + * bytes, high byte first. If no exception is thrown, the counter + * <code>written</code> is incremented by <code>4</code>. + * + * @param v an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeInt(int v) throws IOException { + out.write((v >>> 24) & 0xff); + out.write((v >>> 16) & 0xff); + out.write((v >>> 8) & 0xff); + out.write((v >>> 0) & 0xff); + incCount(4); + } + + /** + * Writes an unsigned 32 bit integer value. + * + * @param v The value + * @throws java.io.IOException + */ + public void writeUInt(long v) throws IOException { + out.write((int) ((v >>> 24) & 0xff)); + out.write((int) ((v >>> 16) & 0xff)); + out.write((int) ((v >>> 8) & 0xff)); + out.write((int) ((v >>> 0) & 0xff)); + incCount(4); + } + + /** + * Writes a signed 16 bit integer value. + * + * @param v The value + * @throws java.io.IOException + */ + public void writeShort(int v) throws IOException { + out.write((int) ((v >> 8) & 0xff)); + out.write((int) ((v >>> 0) & 0xff)); + incCount(2); + } + + /** + * Writes a <code>BCD2</code> to the underlying output stream. + * + * @param v an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeBCD2(int v) throws IOException { + out.write(((v % 100 / 10) << 4) | (v % 10)); + incCount(1); + } + + /** + * Writes a <code>BCD4</code> to the underlying output stream. + * + * @param v an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeBCD4(int v) throws IOException { + out.write(((v % 10000 / 1000) << 4) | (v % 1000 / 100)); + out.write(((v % 100 / 10) << 4) | (v % 10)); + incCount(2); + } + + /** + * Writes a 32-bit Mac timestamp (seconds since 1902). + * @param date + * @throws java.io.IOException + */ + public void writeMacTimestamp(Date date) throws IOException { + long millis = date.getTime(); + long qtMillis = millis - MAC_TIMESTAMP_EPOCH; + long qtSeconds = qtMillis / 1000; + writeUInt(qtSeconds); + } + + /** + * Writes 32-bit fixed-point number divided as 16.16. + * + * @param f an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeFixed16D16(double f) throws IOException { + double v = (f >= 0) ? f : -f; + + int wholePart = (int) v; + int fractionPart = (int) ((v - wholePart) * 65536); + int t = (wholePart << 16) + fractionPart; + + if (f < 0) { + t = t - 1; + } + writeInt(t); + } + /** + * Writes 32-bit fixed-point number divided as 2.30. + * + * @param f an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeFixed2D30(double f) throws IOException { + double v = (f >= 0) ? f : -f; + + int wholePart = (int) v; + int fractionPart = (int) ((v - wholePart) *1073741824); + int t = (wholePart << 30) + fractionPart; + + if (f < 0) { + t = t - 1; + } + writeInt(t); + } + /** + * Writes 16-bit fixed-point number divided as 8.8. + * + * @param f an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeFixed8D8(float f) throws IOException { + float v = (f >= 0) ? f : -f; + + int wholePart = (int) v; + int fractionPart = (int) ((v - wholePart) * 256); + int t = (wholePart << 8) + fractionPart; + + if (f < 0) { + t = t - 1; + } + writeUShort(t); + } + + /** + * Writes a Pascal String. + * + * @param s + * @throws java.io.IOException + */ + public void writePString(String s) throws IOException { + if (s.length() > 0xffff) { + throw new IllegalArgumentException("String too long for PString"); + } + if (s.length() < 256) { + out.write(s.length()); + } else { + out.write(0); + writeShort(s.length()); // increments +2 + } + for (int i=0; i < s.length(); i++) { + out.write(s.charAt(i)); + } + incCount(1 + s.length()); + } + + public void writeLong(long v) throws IOException { + out.write((int) (v >>> 56) & 0xff); + out.write((int) (v >>> 48) & 0xff); + out.write((int) (v >>> 40) & 0xff); + out.write((int) (v >>> 32) & 0xff); + out.write((int) (v >>> 24) & 0xff); + out.write((int) (v >>> 16) & 0xff); + out.write((int) (v >>> 8) & 0xff); + out.write((int) (v >>> 0) & 0xff); + incCount(8); + } + + public void writeUShort(int v) throws IOException { + out.write((int) ((v >> 8) & 0xff)); + out.write((int) ((v >>> 0) & 0xff)); + incCount(2); + } + + /** + * Increases the written counter by the specified value + * until it reaches Long.MAX_VALUE. + */ + protected void incCount(int value) { + long temp = written + value; + if (temp < 0) { + temp = Long.MAX_VALUE; + } + written = temp; + } + + /** + * Returns the current value of the counter <code>written</code>, + * the number of bytes written to this data output stream so far. + * If the counter overflows, it will be wrapped to Integer.MAX_VALUE. + * + * @return the value of the <code>written</code> field. + * @see java.io.DataOutputStream#written + */ + public final long size() { + return written; + } + + +} Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/FilterImageOutputStream.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/FilterImageOutputStream.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/FilterImageOutputStream.java 2009-06-10 23:47:06 UTC (rev 158) @@ -0,0 +1,123 @@ +package edu.asu.commons.foraging.util; + +/** + * @(#)FilterImageOutputStream.java 1.0 15.06.2008 + * + * Copyright (c) 2008 Werner Randelshofer + * Staldenmattweg 2, CH-6405 Immensee, Switzerland + * All rights reserved. + * + * The copyright of this software is owned by Werner Randelshofer. + * You may not use, copy or modify this software, except in + * accordance with the license agreement you entered into with + * Werner Randelshofer. For details see accompanying license terms. + */ + +import java.io.FilterOutputStream; +import java.io.IOException; + +import javax.imageio.stream.ImageOutputStream; + +/** + * FilterImageOutputStream adapts an ImageOutputStream to the FilterOutputStream + * interface. + * + * @author Werner Randelshofer + * @version 1.0 15.06.2008 Created. + */ +public class FilterImageOutputStream extends FilterOutputStream { + private ImageOutputStream imageOutputStream; + + public FilterImageOutputStream(ImageOutputStream imageOutputStream) { + super(null); + this.imageOutputStream = imageOutputStream; + } + + /** + * Writes the specified <code>byte</code> to this output stream. + * <p> + * The <code>write</code> method of <code>FilterOutputStream</code> calls + * the <code>write</code> method of its underlying output stream, that is, + * it performs <tt>out.write(b)</tt>. + * <p> + * Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>. + * + * @param b + * the <code>byte</code>. + * @exception IOException + * if an I/O error occurs. + */ + @Override + public void write(int b) throws IOException { + imageOutputStream.write(b); + } + + /** + * Writes <code>len</code> bytes from the specified <code>byte</code> array + * starting at offset <code>off</code> to this output stream. + * <p> + * The <code>write</code> method of <code>FilterOutputStream</code> calls + * the <code>write</code> method of one argument on each <code>byte</code> + * to output. + * <p> + * Note that this method does not call the <code>write</code> method of its + * underlying input stream with the same arguments. Subclasses of + * <code>FilterOutputStream</code> should provide a more efficient + * implementation of this method. + * + * @param b + * the data. + * @param off + * the start offset in the data. + * @param len + * the number of bytes to write. + * @exception IOException + * if an I/O error occurs. + * @see java.io.FilterOutputStream#write(int) + */ + @Override + public void write(byte b[], int off, int len) throws IOException { + imageOutputStream.write(b, off, len); + } + + /** + * Flushes this output stream and forces any buffered output bytes to be + * written out to the stream. + * <p> + * The <code>flush</code> method of <code>FilterOutputStream</code> calls + * the <code>flush</code> method of its underlying output stream. + * + * @exception IOException + * if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + @Override + public void flush() throws IOException { + System.err.println("!!! - Ignoring flush request, will only flush on close..."); + // System.err.println(this+" discarded flush"); + // imgOut.flush(); + } + + /** + * Closes this output stream and releases any system resources associated + * with the stream. + * <p> + * The <code>close</code> method of <code>FilterOutputStream</code> calls + * its <code>flush</code> method, and then calls the <code>close</code> + * method of its underlying output stream. + * + * @exception IOException + * if an I/O error occurs. + * @see java.io.FilterOutputStream#flush() + * @see java.io.FilterOutputStream#out + */ + @Override + public void close() throws IOException { + try { + flush(); + } + catch (IOException ignored) { + } + imageOutputStream.close(); + } +} Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-06-10 23:47:06 UTC (rev 158) @@ -3,6 +3,8 @@ import java.awt.Dimension; import java.awt.Point; import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; @@ -20,6 +22,7 @@ import edu.asu.commons.experiment.Persister; import edu.asu.commons.experiment.SaveFileProcessor; import edu.asu.commons.experiment.SavedRoundData; +import edu.asu.commons.foraging.client.SubjectView; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.event.ClientPoseUpdate; import edu.asu.commons.foraging.event.HarvestFruitRequest; @@ -74,6 +77,42 @@ convert(args[0]); } + private static class MovieCreatorProcessor extends SaveFileProcessor.Base { + + private VideoFormat videoFormat = VideoFormat.PNG; + + @Override + public void process(SavedRoundData savedRoundData, OutputStream stream) { + try { + QuickTimeOutputStream outputStream = new QuickTimeOutputStream(stream); + ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); + for (PersistableEvent event: savedRoundData.getActions()) { + + } + + } + catch (IOException exception) { + exception.printStackTrace(); + throw new RuntimeException(exception); + } + + + + + } + + @Override + public void process(SavedRoundData savedRoundData, PrintWriter writer) { + throw new UnsupportedOperationException("This method is not suitable for this class (consider removing as requirement for super class)"); + } + + @Override + public String getOutputFileExtension() { + String videoFormatString = videoFormat.toString().toLowerCase(); + return String.format("-%s-movie.%s", videoFormatString, videoFormatString); + } + } + private static class MovementStatisticsProcessor extends SaveFileProcessor.Base { private Map<Identifier, ClientMovementStatistics> clientStatisticsMap = new LinkedHashMap<Identifier, ClientMovementStatistics>(); private Map<GroupDataModel, Integer> resourceCountMap = new HashMap<GroupDataModel, Integer>(); Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java 2009-06-10 23:32:36 UTC (rev 157) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java 2009-06-10 23:47:06 UTC (rev 158) @@ -75,11 +75,10 @@ Processor processor; try { - System.err.println("- create processor for the image datasource ..."); + System.err.println("Creating processor for the image datasource ..."); processor = Manager.createProcessor(ids); } catch (Exception e) { - System.err - .println("Yikes! Cannot create a processor from the data source."); + System.err.println("Yikes! Cannot create a processor from the data source."); return false; } Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/QuickTimeOutputStream.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/QuickTimeOutputStream.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/QuickTimeOutputStream.java 2009-06-10 23:47:06 UTC (rev 158) @@ -0,0 +1,1675 @@ +package edu.asu.commons.foraging.util; + +/** + * @(#)QuickTimeOutputStream.java 1.1 2008-08-11 + * + * Copyright (c) 2008 Werner Randelshofer + * Staldenmattweg 2, CH-6405 Immensee, Switzerland + * All rights reserved. + * + * The copyright of this software is owned by Werner Randelshofer. + * You may not use, copy or modify this software, except in + * accordance with the license agreement you entered into with + * Werner Randelshofer. For details see accompanying license terms. + */ + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.LinkedList; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.FileCacheImageOutputStream; +import javax.imageio.stream.FileImageOutputStream; +import javax.imageio.stream.ImageOutputStream; +import javax.imageio.stream.MemoryCacheImageOutputStream; + +/** + * This class supports writing of images as frames into the video track of + * a QuickTime movie file. + * <p> + * All frames are encoded either using the JPG or the PNG video format. + * Each frame can have an individual encoding quality and duration. + * <p> + * For detailed information about the QuickTime file format see: + * http://developer.apple.com/documentation/QuickTime/QTFF/ + * + * + * @author Werner Randelshofer + * @version 1.1 2008-08-11 Streamlined source code and API with AVIOutputStream. + * <br>1.0.1 2008-06-18 WideDataAtom wrote incorrect header for + * atoms larger than 4 GB. The default value of time scale is now 600. + * Renamed method writeFrame to writeFrame. Added writeFrame methods + * which take a file or an input stream as argument. + * <br>1.0 Jun 15, 2008 Created. + */ +public class QuickTimeOutputStream { + + /** + * Output stream of the QuickTimeOutputStream. + */ + private ImageOutputStream imageOutputStream; + + /** + * Current video formats. + */ + private VideoFormat videoFormat; + /** + * Quality of JPEG encoded video frames. + */ + private float quality = 0.9f; + /** + * Creation time of the movie output stream. + */ + private Date creationTime; + /** + * Width of the video frames. All frames must have the same width. + * The value -1 is used to mark unspecified width. + */ + private int imgWidth = -1; + /** + * Height of the video frames. All frames must have the same height. + * The value -1 is used to mark unspecified height. + */ + private int imgHeight = -1; + /** + * The timeScale of the movie. + * A time value that indicates the time scale for this media—that is, + * the number of time units that pass per second in its time coordinate + * system. + */ + private int timeScale = 600; + + /** + * The states of the movie output stream. + */ + private static enum States { + + STARTED, FINISHED, CLOSED; + } + /** + * The current state of the movie output stream. + */ + private States state = States.FINISHED; + + /** + * QuickTime stores media data in samples. + * A sample is a single element in a sequence of time-ordered data. + * Samples are stored in the mdat atom. + + */ + private static class Sample { + + /** Offset of the sample relative to the start of the QuickTime file. + */ + long offset; + /** Data length of the sample. */ + long length; + /** + * The duration of the sample in time scale units. + */ + int duration; + + /** + * Creates a new sample. + * @param duration + * @param offset + * @param length + */ + public Sample(int duration, long offset, long length) { + this.duration = duration; + this.offset = offset; + this.length = length; + } + } + /** + * List of video frames. + */ + private LinkedList<Sample> videoFrames; + /** + * This atom holds the movie frames. + */ + private WideDataAtom mdatAtom; + + /** + * Atom base class. + */ + private abstract class Atom { + + /** + * The type of the atom. A String with the length of 4 characters. + */ + protected String type; + /** + * The offset of the atom relative to the start of the + * ImageOutputStream. + */ + protected long offset; + + /** + * Creates a new Atom at the current position of the ImageOutputStream. + * @param type The type of the atom. A string with a length of 4 characters. + */ + public Atom(String type) throws IOException { + this.type = type; + offset = imageOutputStream.getStreamPosition(); + } + + /** + * Writes the atom to the ImageOutputStream and disposes it. + */ + public abstract void finish() throws IOException; + + /** + * Returns the size of the atom including the size of the atom header. + * @return The size of the atom. + */ + public abstract long size(); + } + + /** + * A CompositeAtom contains an ordered list of Atoms. + */ + private class CompositeAtom extends Atom { + + private LinkedList<Atom> children; + private boolean finished; + + /** + * Creates a new CompositeAtom at the current position of the + * ImageOutputStream. + * @param type The type of the atom. + */ + public CompositeAtom(String type) throws IOException { + super(type); + imageOutputStream.writeLong(0); // make room for the atom header + children = new LinkedList<Atom>(); + } + + public void add(Atom child) throws IOException { + if (children.size() > 0) { + children.getLast().finish(); + } + children.add(child); + } + + /** + * Writes the atom and all its children to the ImageOutputStream + * and disposes of all resources held by the atom. + * @throws java.io.IOException + */ + public void finish() throws IOException { + if (!finished) { + if (size() > 0xffffffffL) { + throw new IOException("CompositeAtom \"" + type + "\" is too large: " + size()); + } + + long pointer = imageOutputStream.getStreamPosition(); + imageOutputStream.seek(offset); + + DataAtomOutputStream headerData = new DataAtomOutputStream(new FilterImageOutputStream(imageOutputStream)); + headerData.writeInt((int) size()); + headerData.writeType(type); + for (Atom child : children) { + child.finish(); + } + imageOutputStream.seek(pointer); + finished = true; + } + } + + public long size() { + long length = 8; + for (Atom child : children) { + length += child.size(); + } + return length; + } + } + + /** + * Data Atom. + */ + private class DataAtom extends Atom { + + private DataAtomOutputStream data; + private boolean finished; + + /** + * Creates a new DataAtom at the current position of the + * ImageOutputStream. + * @param type The type of the atom. + */ + public DataAtom(String name) throws IOException { + super(name); + imageOutputStream.writeLong(0); // make room for the atom header + data = new DataAtomOutputStream(new FilterImageOutputStream(imageOutputStream)); + } + + public DataAtomOutputStream getOutputStream() { + if (finished) { + throw new IllegalStateException("DataAtom is finished"); + } + return data; + } + + /** + * Returns the offset of this atom to the beginning of the random access file + * @return + */ + public long getOffset() { + return offset; + } + + @Override + public void finish() throws IOException { + if (!finished) { + long sizeBefore = size(); + + if (size() > 0xffffffffL) { + throw new IOException("DataAtom \"" + type + "\" is too large: " + size()); + } + + long pointer = imageOutputStream.getStreamPosition(); + imageOutputStream.seek(offset); + + DataAtomOutputStream headerData = new DataAtomOutputStream(new FilterImageOutputStream(imageOutputStream)); + headerData.writeUInt(size()); + headerData.writeType(type); + imageOutputStream.seek(pointer); + finished = true; + long sizeAfter = size(); + if (sizeBefore != sizeAfter) { + System.err.println("size mismatch " + sizeBefore + ".." + sizeAfter); + } + } + } + + @Override + public long size() { + return 8 + data.size(); + } + } + + /** + * WideDataAtom can grow larger then 4 gigabytes. + */ + private class WideDataAtom extends Atom { + + private DataAtomOutputStream data; + private boolean finished; + + /** + * Creates a new DataAtom at the current position of the + * ImageOutputStream. + * @param type The type of the atom. + */ + public WideDataAtom(String type) throws IOException { + super(type); + imageOutputStream.writeLong(0); // make room for the atom header + imageOutputStream.writeLong(0); // make room for the atom header + data = new DataAtomOutputStream(new FilterImageOutputStream(imageOutputStream)); + } + + public DataAtomOutputStream getOutputStream() { + if (finished) { + throw new IllegalStateException("Atom is finished"); + } + return data; + } + + /** + * Returns the offset of this atom to the beginning of the random access file + * @return + */ + public long getOffset() { + return offset; + } + + @Override + public void finish() throws IOException { + if (!finished) { + long pointer = imageOutputStream.getStreamPosition(); + imageOutputStream.seek(offset); + + DataAtomOutputStream headerData = new DataAtomOutputStream(new FilterImageOutputStream(imageOutputStream)); + + if (size() <= 0xffffffffL) { + headerData.writeUInt(8); + headerData.writeType("wide"); + headerData.writeUInt(size()); + headerData.writeType(type); + } else { + headerData.writeInt(1); // special value for extended size atoms + headerData.writeType(type); + headerData.writeLong(size()); + } + + imageOutputStream.seek(pointer); + finished = true; + } + } + + @Override + public long size() { + long size = 8 + data.size(); + return (size > 0xffffffffL) ? size + 8 : size; + } + } + + /** + * Creates a new output stream with the specified image videoFormat and + * framerate. + * + * @param file the output file + * @param format Selects an encoder for the video format "JPG" or "PNG". + * @throws IOException + * @throws FileNotFoundException + * @exception IllegalArgumentException if videoFormat is null or if + * framerate is <= 0 + */ + public QuickTimeOutputStream(File file, VideoFormat format) throws FileNotFoundException, IOException { + this(new FileImageOutputStream(file), format); +// if (file.exists()) { +// file.delete(); +// } +// imageOutputStream = new FileImageOutputStream(file); + } + + public QuickTimeOutputStream(OutputStream stream) throws IOException { + this(stream, VideoFormat.PNG); + } + + public QuickTimeOutputStream(OutputStream stream, VideoFormat format) throws IOException { + this(new FileCacheImageOutputStream(stream, null), format); + } + + public QuickTimeOutputStream(ImageOutputStream stream, VideoFormat format) { + this.imageOutputStream = stream; + if (format == null) { + throw new IllegalArgumentException("format must not be null"); + } + this.videoFormat = format; + this.videoFrames = new LinkedList<Sample>(); + } + + /** + * Sets the time scale for this media, that is, the number of time units + * that pass per second in its time coordinate system. + * <p> + * The default value is 600. + * + * @param newValue + */ + public void setTimeScale(int newValue) { + if (newValue <= 0) { + throw new IllegalArgumentException("timeScale must be greater 0"); + } + this.timeScale = newValue; + } + + /** + * Returns the time scale of this media. + * + * @return time scale + */ + public int getTimeScale() { + return timeScale; + } + + /** + * Sets the compression quality of the video track. + * A value of 0 stands for "high compression is important" a value of + * 1 for "high image quality is important". + * <p> + * Changing this value affects frames which are subsequently written + * to the QuickTimeOutputStream. Frames which have already been written + * are not changed. + * <p> + * This value has no effect on videos encoded with the PNG format. + * <p> + * The default value is 0.9. + * + * @param newValue + */ + public void setVideoCompressionQuality(float newValue) { + this.quality = newValue; + } + + /** + * Returns the video compression quality. + * + * @return video compression quality + */ + public float getVideoCompressionQuality() { + return quality; + } + + /** + * Sets the dimension of the video track. + * <p> + * You need to explicitly set the dimension, if you add all frames from + * files or input streams. + * <p> + * If you add frames from buffered images, then QuickTimeOutputStream + * can determine the video dimension from the image width and height. + * + * @param width + * @param height + */ + public void setVideoDimension(int width, int height) { + if (width < 1 || height < 1) { + throw new IllegalArgumentException("width and height must be greater zero."); + } + this.imgWidth = width; + this.imgHeight = height; + } + + /** + * Sets the state of the QuickTimeOutpuStream to started. + * <p> + * If the state is changed by this method, the prolog is + * written. + */ + private void ensureStarted() throws IOException { + if (state != States.STARTED) { + creationTime = new Date(); + writeProlog(); + mdatAtom = new WideDataAtom("mdat"); + state = States.STARTED; + } + } + + /** + * Writes a frame to the video track. + * <p> + * If the dimension of the video track has not been specified yet, it + * is derived from the first buffered image added to the QuickTimeOutputStream. + * + * @param image The frame image. + * @param duration The duration of the frame in time scale units. + * + * @throws IllegalArgumentException if the duration is less than 1, or + * if the dimension of the frame does not match the dimension of the video + * track. + * @throws IOException if writing the image failed. + */ + public void writeFrame(BufferedImage image, int duration) throws IOException { + if (duration <= 0) { + throw new IllegalArgumentException("duration must be greater 0"); + } + ensureOpen(); + ensureStarted(); + + // Get the dimensions of the first image + if (imgWidth == -1) { + imgWidth = image.getWidth(); + imgHeight = image.getHeight(); + } else { + // The dimension of the image must match the dimension of the video track + if (imgWidth != image.getWidth() || imgHeight != image.getHeight()) { + throw new IllegalArgumentException("Dimensions of image[" + videoFrames.size() + + "] (width=" + image.getWidth() + ", height=" + image.getHeight() + + ") differs from image[0] (width=" + + imgWidth + ", height=" + imgHeight); + } + } + + long offset = imageOutputStream.getStreamPosition(); + + MemoryCacheImageOutputStream imgOut = new MemoryCacheImageOutputStream(mdatAtom.getOutputStream()); + ImageWriter iw; + ImageWriteParam iwParam; + switch (videoFormat) { + case JPG: + iw = (ImageWriter) ImageIO.getImageWritersByMIMEType("image/jpeg").next(); + iwParam = iw.getDefaultWriteParam(); + iwParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + iwParam.setCompressionQuality(quality); + break; + case PNG: + default: + iw = (ImageWriter) ImageIO.getImageWritersByMIMEType("image/png").next(); + iwParam = iw.getDefaultWriteParam(); + break; + } + iw.setOutput(imgOut); + IIOImage img = new IIOImage(image, null, null); + iw.write(null, img, iwParam); + iw.dispose(); + long length = imageOutputStream.getStreamPosition() - offset; + + videoFrames.add(new Sample(duration, offset, length)); + } + + /** + * Writes a frame from a file to the video track. + * <p> + * This method does not inspect the contents of the file. + * Its your responsibility to only add JPG files if you have chosen + * the JPEG video format, and only PNG files if you have chosen the PNG + * video format. + * <p> + * If you add all frames from files or from input streams, then you + * have to explicitly set the dimension of the video track before you + * call finish() or close(). + * + * @param file The file which holds the image data. + * @param duration The duration of the frame in time scale units. + * + * @throws IllegalStateException if the duration is less than 1. + * @throws IOException if writing the image failed. + */ + public void writeFrame(File file, int duration) throws IOException { + FileInputStream in = null; + try { + in = new FileInputStream(file); + writeFrame(in, duration); + } finally { + if (in != null) { + in.close(); + } + } + } + + /** + * Writes a frame to the video track. + * <p> + * This method does not inspect the contents of the file. + * Its your responsibility to only add JPG files if you have chosen + * the JPEG video format, and only PNG files if you have chosen the PNG + * video format. + * <p> + * If you add all frames from files or from input streams, then you + * have to explicitly set the dimension of the video track before you + * call finish() or close(). + * + * @param in The input stream which holds the image data. + * @param duration The duration of the frame in time scale units. + * + * @throws IllegalArgumentException if the duration is less than 1. + * @throws IOException if writing the image failed. + */ + public void writeFrame(InputStream in, int duration) throws IOException { + if (duration <= 0) { + throw new IllegalArgumentException("duration must be greater 0"); + } + ensureOpen(); + ensureStarted(); + + long offset = imageOutputStream.getStreamPosition(); + OutputStream mdatOut = mdatAtom.getOutputStream(); + byte[] buf = new byte[512]; + int len; + while ((len = in.read(buf)) != -1) { + mdatOut.write(buf, 0, len); + } + long length = imageOutputStream.getStreamPosition() - offset; + videoFrames.add(new Sample(duration, offset, length)); + } + + /** + * Closes the movie file as well as the stream being filtered. + * + * @exception IOException if an I/O error has occurred + */ + public void close() throws IOException { + if (state == States.STARTED) { + finish(); + } + if (state != States.CLOSED) { + imageOutputStream.close(); + state = States.CLOSED; + } + } + + /** + * Finishes writing the contents of the QuickTime output stream without closing + * the underlying stream. Use this method when applying multiple filters + * in succession to the same output stream. + * + * @exception IllegalStateException if the dimension of the video track + * has not been specified or determined yet. + * @exception IOException if an I/O exception has occurred + */ + public void finish() throws IOException { + ensureOpen(); + if (state != States.FINISHED) { + if (imgWidth == -1 || imgHeight == -1) { + throw new IllegalStateException("image width and height must be specified"); + } + + mdatAtom.finish(); + writeEpilog(); + state = States.FINISHED; + imgWidth = imgHeight = -1; + } + } + + /** + * Check to make sure that this stream has not been closed + */ + private void ensureOpen() throws IOException { + if (state == States.CLOSED) { + throw new IOException("Stream closed"); + } + } + + private void writeProlog() throws IOException { + /* File type atom + * + typedef struct { + magic brand; + bcd4 versionYear; + bcd2 versionMonth; + bcd2 versionMinor; + magic[4] compatibleBrands; + } ftypAtom; + */ + DataAtom ftypAtom = new DataAtom("ftyp"); + DataAtomOutputStream d = ftypAtom.getOutputStream(); + d.writeType("qt "); // brand + d.writeBCD4(2005); // versionYear + d.writeBCD2(3); // versionMonth + d.writeBCD2(0); // versionMinor + d.writeType("qt "); // compatibleBrands + d.writeInt(0); // compatibleBrands (0 is used to denote no value) + d.writeInt(0); // compatibleBrands (0 is used to denote no value) + d.writeInt(0); // compatibleBrands (0 is used to denote no value) + ftypAtom.finish(); + } + + private void writeEpilog() throws IOException { + Date modificationTime = new Date(); + int duration = 0; + for (Sample s : videoFrames) { + duration += s.duration; + } + + DataAtom leaf; + + /* Movie Atom ========= */ + CompositeAtom moovAtom = new CompositeAtom("moov"); + + /* Movie Header Atom ------------- + * The data contained in this atom defines characteristics of the entire + * QuickTime movie, such as time scale and duration. It has an atom type + * value of 'mvhd'. + * + * typedef struct { + byte version; + byte[3] flags; + mactimestamp creationTime; + mactimestamp modificationTime; + int timeScale; + int duration; + int preferredRate; + short preferredVolume; + byte[10] reserved; + int[9] matrix; + int previewTime; + int previewDuration; + int posterTime; + int selectionTime; + int selectionDuration; + int currentTime; + int nextTrackId; + } movieHeaderAtom; + */ + leaf = new DataAtom("mvhd"); + moovAtom.add(leaf); + DataAtomOutputStream d = leaf.getOutputStream(); + d.writeByte(0); // version + // A 1-byte specification of the version of this movie header atom. + + d.writeByte(0); // flags[0] + d.writeByte(0); // flags[1] + d.writeByte(0); // flags[2] + // Three bytes of space for future movie header flags. + + d.writeMacTimestamp(creationTime); // creationTime + // A 32-bit integer that specifies the calendar date and time (in + // seconds since midnight, January 1, 1904) when the movie atom was + // created. It is strongly recommended that this value should be + // specified using coordinated universal time (UTC). + + d.writeMacTimestamp(modificationTime); // modificationTime + // A 32-bit integer that specifies the calendar date and time (in + // seconds since midnight, January 1, 1904) when the movie atom was + // changed. BooleanIt is strongly recommended that this value should be + // specified using coordinated universal time (UTC). + + d.writeInt(timeScale); // timeScale + // A time value that indicates the time scale for this movie—that is, + // the number of time units that pass per second in its time coordinate + // system. A time coordinate system that measures time in sixtieths of a + // second, for example, has a time scale of 60. + + d.writeInt(duration); // duration + // A time value that indicates the duration of the movie in time scale + // units. Note that this property is derived from the movie’s tracks. + // The value of this field corresponds to the duration of the longest + // track in the movie. + + d.writeFixed16D16(1d); // preferredRate + // A 32-bit fixed-point number that specifies the rate at which to play + // this movie. A value of 1.0 indicates normal rate. + + d.writeShort(256); // preferredVolume + // A 16-bit fixed-point number that specifies how loud to play this + // movie’s sound. A value of 1.0 indicates full volume. + + d.write(new byte[10]); // reserved; + // Ten bytes reserved for use by Apple. Set to 0. + + d.writeFixed16D16(1f); // matrix[0] + d.writeFixed16D16(0f); // matrix[1] + d.writeFixed2D30(0f); // matrix[2] + d.writeFixed16D16(0f); // matrix[3] + d.writeFixed16D16(1f); // matrix[4] + d.writeFixed2D30(0); // matrix[5] + d.writeFixed16D16(0); // matrix[6] + d.writeFixed16D16(0); // matrix[7] + d.writeFixed2D30(1f); // matrix[8] + // The matrix structure associated with this movie. A matrix shows how + // to map points from one coordinate space into another. See “Matrices” + // for a discussion of how display matrices are used in QuickTime: + // http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap4/chapter_5_section_4.html#//apple_ref/doc/uid/TP40000939-CH206-18737 + + d.writeInt(0); // previewTime + // The time value in the movie at which the preview begins. + + d.writeInt(0); // previewDuration + // The duration of the movie preview in movie time scale units. + + d.writeInt(0); // posterTime + // The time value of the time of the movie poster. + + d.writeInt(0); // selectionTime + // The time value for the start time of the current selection. + + d.writeInt(0); // selectionDuration + // The duration of the current selection in movie time scale units. + + d.writeInt(0); // currentTime; + // The time value for current time position within the movie. + + d.writeInt(2); // nextTrackId + // A 32-bit integer that indicates a value to use for the track ID + // number of the next track added to this movie. Note that 0 is not a + // valid track ID value. + + /* Track Atom ======== */ + CompositeAtom trakAtom = new CompositeAtom("trak"); + moovAtom.add(trakAtom); + + /* Track Header Atom ----------- + * The track header atom specifies the characteristics of a single track + * within a movie. A track header atom contains a size field that + * specifies the number of bytes and a type field that indicates the + * format of the data (defined by the atom type 'tkhd'). + * + typedef struct { + byte version; + byte flag0; + byte flag1; + byte set TrackHeaderFlags flag2; + mactimestamp creationTime; + mactimestamp modificationTime; + int trackId; + byte[4] reserved; + int duration; + byte[8] reserved; + short layer; + short alternateGroup; + short volume; + byte[2] reserved; + int[9] matrix; + int trackWidth; + int trackHeight; + } trackHeaderAtom; */ + leaf = new DataAtom("tkhd"); + trakAtom.add(leaf); + d = leaf.getOutputStream(); + d.write(0); // version + // A 1-byte specification of the version of this track header. + + d.write(0); // flag[0] + d.write(0); // flag[1] + d.write(0xf); // flag[2] + // Three bytes that are reserved for the track header flags. These flags + // indicate how the track is used in the movie. The following flags are + // valid (all flags are enabled when set to 1): + // + // Track enabled + // Indicates that the track is enabled. Flag value is 0x0001. + // Track in movie + // Indicates that the track is used in the movie. Flag value is + // 0x0002. + // Track in preview + // Indicates that the track is used in the movie’s preview. Flag + // value is 0x0004. + // Track in poster + // Indicates that the track is used in the movie’s poster. Flag + // value is 0x0008. + + d.writeMacTimestamp(creationTime); // creationTime + // A 32-bit integer that indicates the calendar date and time (expressed + // in seconds since midnight, January 1, 1904) when the track header was + // created. It is strongly recommended that this value should be + // specified using coordinated universal time (UTC). + + d.writeMacTimestamp(modificationTime); // modificationTime + // A 32-bit integer that indicates the calendar date and time (expressed + // in seconds since midnight, January 1, 1904) when the track header was + // changed. It is strongly recommended that this value should be + // specified using coordinated universal time (UTC). + + d.writeInt(1); // trackId + // A 32-bit integer that uniquely identifies the track. The value 0 + // c... [truncated message content] |
From: <see...@us...> - 2009-06-10 23:33:12
|
Revision: 157 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=157&view=rev Author: seematalele Date: 2009-06-10 23:32:36 +0000 (Wed, 10 Jun 2009) Log Message: ----------- Created new Forecasting component named as ForecastingSeema.mxml which creates Data grid and XML is used as data provider. Created CustomNumericStepper.as which extends NumericStepper. CustomNumericStepper.as is embedded into the each Datagrid column. Added Update button in Forecasting component. Only one column can be edited at a time. Once the first column is filled, you click on Update button; Control automatically shift to next column. The editable column is highlighted with Yellow color. Things needs to be done- 1) When user click Update button, all columns should have some value and also the sum of the column should be (groupsize-1). 2) Update data into the XML whenever data grid is updated. 3) Develop other forecasting component for fish population the similar way or better way. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-09 23:38:59 UTC (rev 156) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-10 23:32:36 UTC (rev 157) @@ -1,14 +1,16 @@ <?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="760" height="510" clipContent="false" layout="absolute" - currentState="socioDemographic" initialize="init()"> + width="90%" height="70%" clipContent="false" layout="absolute" + currentState="forecasting" initialize="init()"> <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> </mx:AddChild> + <mx:SetProperty target="{content}" name="x"/> + <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> <mx:State name="planner"> @@ -25,7 +27,7 @@ <mx:State name="forecasting"> <mx:AddChild relativeTo="{content}"> - <comp:ForecastPage_TEMP id="forecasting"/> + <comp:ForecastingSeema id="forecasting"/> </mx:AddChild> </mx:State> @@ -35,12 +37,15 @@ - <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> + <!-- <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:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> + <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 »" click="forward()" right="8" bottom="8" enabled="false"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + + <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -167,12 +172,8 @@ if(obj is InstructionPage) { - return (InstructionPage)(obj).back(); + (InstructionPage)(obj).back(); } - if(obj is ForecastPage_TEMP) - { - return (ForecastPage_TEMP)(obj).back(); - } return false; } @@ -184,11 +185,11 @@ if(obj is InstructionPage) { - return (InstructionPage)(obj).forward(); + (InstructionPage)(obj).forward(); } if(obj is ForecastPage_TEMP) { - return (ForecastPage_TEMP)(obj).forward(); + (ForecastPage_TEMP)(obj).forward(); } return false; } @@ -198,7 +199,6 @@ if(content.numChildren == 0) { return false; } var obj:DisplayObject = content.getChildAt(0); - var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -216,7 +216,7 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - returnValue = true; + return true; } } if(obj is PlannerPage) @@ -226,7 +226,8 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "instructions"; - returnValue = true; + + return true; } } if(obj is InstructionPage_TEMP) @@ -237,7 +238,7 @@ expiredContent.addChild(obj); currentState = "forecasting"; //consumer.subscribe(); - returnValue = true; + return true; } } if(obj is ForecastPage_TEMP) @@ -248,19 +249,16 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - returnValue = true; + return true; } } - btnBack.enabled = (currentState == "instructions" || currentState == "forecasting"); - btnForward.enabled = btnBack.enabled; - - return returnValue; + return false; } - ]]> </mx:Script> </mx:Application> + Added: mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as 2009-06-10 23:32:36 UTC (rev 157) @@ -0,0 +1,20 @@ +package actionscript +{ + import mx.controls.NumericStepper; + + public class CustomNumericStepper extends mx.controls.NumericStepper + { + + public function CustomNumericStepper() + { + super(); + super.stepSize = 1; + super.maximum = 3; + super.minimum = 0; + + } + + + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml 2009-06-10 23:32:36 UTC (rev 157) @@ -0,0 +1,233 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- <mx:Application> --> + + +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" initialize="init()"> + <mx:Script> + + <![CDATA[ + + import mx.collections.XMLListCollection; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.controls.DataGrid; + import actionscript.DataGridHandler; + import mx.controls.Alert; + import mx.events.DataGridEvent; + import mx.utils.StringUtil; + import mx.collections.ArrayCollection; + import mx.controls.NumericStepper; + import mx.controls.TextInput; + import mx.events.ListEvent; + + import mx.controls.listClasses.IDropInListItemRenderer; + import actionscript.CustomNumericStepper; + + [Bindable] + private var forecast:XML = + <list> + <fishermen> + <name>Harbor</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + + </fishermen> + <fishermen> + <name>Bay1</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + + </fishermen> + <fishermen> + <name>Bay2</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + </fishermen> + <fishermen> + <name>Bay3</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + </fishermen> + + </list>; + + [Bindable] + /*private var initDG:ArrayCollection = new ArrayCollection([ + {Artist:'Pavement', Album:'Slanted and Enchanted', + Price:11.99}, + {Artist:'Pavement', Album:'Brighten the Corners', + Price:11.99 } + ]);*/ + + private var initdg:ArrayCollection = new ArrayCollection(); + //initdg.addItem(name:"Harbor"); + + + [Bindable] + private var fishermenPopulation:XMLListCollection = new XMLListCollection(forecast.fishermen); + + [Bindable] public var numBays:int = 3; + + + [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; + + public var currentColumn:int =1; + + private function init():void + { + // var newColumnArray:Array = new Array(numColumns); + //dg = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); + var cols:Array = dg.columns; + for(var columnNumber:int=0; columnNumber<15; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn(); + + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 50; + + var comp:CustomNumericStepper = new CustomNumericStepper(); + comp.stepSize = 1; + comp.maximum = 3; + comp.minimum = 0; + + // newDataGridColumn.itemEditor = comp; + if(columnNumber == 0) + { + newDataGridColumn.editable = true; + newDataGridColumn.setStyle("backgroundColor", "#FFFF00"); + } + else + { + newDataGridColumn.editable = false; + } + + newDataGridColumn.headerText = "Day"+(columnNumber+1); // 1, 2, 3, ... + + + newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... + // newDataGridColumn.dataField = "name"; + + // newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + + // newColumnArray[columnNumber] = newDataGridColumn; + /*newDataGridColumn.rendererIsEditor = true; + newDataGridColumn.itemRenderer = new ClassFactory(CustomNumericStepper);*/ + newDataGridColumn.itemEditor = new ClassFactory(CustomNumericStepper); + newDataGridColumn.editorDataField = "value"; + + + cols.push(newDataGridColumn); + + } + dg.columns = cols; + + lblSum.text = "Sum must be 4"; + + } + + + 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) < 3 || Number(n) > 0; + return false; + } + + private function updateNextColumn():void + { + dg.columns[currentColumn].setStyle("backgroundColor", "#FFFFFF"); + dg.columns[currentColumn].editable = false; + currentColumn = currentColumn + 1; + dg.columns[currentColumn].editable = true; + dg.columns[currentColumn].setStyle("backgroundColor", "#FFFF00"); + + } + + ]]> +</mx:Script> + + <mx:DataGrid id="dg" width="100%" editable="true" rowCount="5" dataProvider="{fishermenPopulation}"> + <mx:columns> + <mx:DataGridColumn dataField="name" headerText="Fishermen (w/o you) in" sortable="false" draggable="false" width="180" fontSize="13" color="Green" editable="false"/> + </mx:columns> + </mx:DataGrid> +<mx:Label id="lblSum" fontSize="12" fontWeight="bold" textAlign="center" color="#E71039"/> +<mx:Button id="btnUpdate" label="Update" click="updateNextColumn()"/> + + + +</mx:VBox> +<!-- </mx:Application> --> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-09 23:39:01
|
Revision: 156 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=156&view=rev Author: kjonas Date: 2009-06-09 23:38:59 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Modified Paths: -------------- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-09 23:15:43 UTC (rev 155) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-09 23:38:59 UTC (rev 156) @@ -3,14 +3,14 @@ <mx:VBox id="labels" verticalGap="2"/> - <mx:DataGrid id="dataGrid" editable="true" enabled="true" dataProvider="dataProvider"/> - <mx:Script> <![CDATA[ + import mx.controls.DataGrid; import mx.collections.ArrayCollection; import mx.controls.Label; import mx.controls.dataGridClasses.DataGridColumn; + public var dataGrid:DataGrid; [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = 15; @@ -18,6 +18,14 @@ public function init():void { + dataGrid = new DataGrid; + dataGrid.id = "dataGrid"; + dataGrid.editable = true; + dataGrid.enabled = true; + dataGrid.dataProvider = dataProvider; + + dataGrid.initialize(); + var newColumnArray:Array = new Array(numColumns); for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) { @@ -54,6 +62,8 @@ addLabel("# Fish in Bay " + (bayNumber+1) + ":"); } } + + //end init() } public function addLabel(text:String=""):void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-09 23:15:45
|
Revision: 155 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=155&view=rev Author: kjonas Date: 2009-06-09 23:15:43 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Added Paths: ----------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Added: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + + <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + + <mx:Script> + <![CDATA[ +// import mx.controls.Alert; +// +// public function init():void +// { +// try +// { +// forecastComponent.initialize(); +// forecastComponent.init(); +// } +// catch(error:Error) +// { +// Alert.show(error.message + "\n" + error.getStackTrace()); +// } +// } + + ]]> + </mx:Script> + +</mx:Application> Added: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:VBox id="labels" verticalGap="2"/> + + <mx:DataGrid id="dataGrid" editable="true" enabled="true" dataProvider="dataProvider"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated + + public function init():void + { + var newColumnArray:Array = new Array(numColumns); + for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn(); + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 30; + + 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 + + newColumnArray[columnNumber] = newDataGridColumn; + } + dataGrid.columns = newColumnArray; + + var bayNumber:int = 0; + if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing + { + addLabel(); + addLabel("# People in Harbor:"); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# People in Bay " + (bayNumber+1) + ":"); + } + } + else if(style==2) + { + addLabel(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + } + } + } + + public function addLabel(text:String=""):void + { + var newLabel:Label = new Label(); + if(text != "") + { + newLabel.text = text; + } + labels.addChild(newLabel); + } + + ]]> + </mx:Script> + +</mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-09 20:18:50
|
Revision: 154 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=154&view=rev Author: kjonas Date: 2009-06-09 20:17:56 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Trying to fix Forecasting - might start over. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/actionscript/Location.as mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -38,9 +38,9 @@ <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -167,8 +167,12 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).back(); + return (InstructionPage)(obj).back(); } + if(obj is ForecastPage_TEMP) + { + return (ForecastPage_TEMP)(obj).back(); + } return false; } @@ -180,11 +184,11 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).forward(); + return (InstructionPage)(obj).forward(); } if(obj is ForecastPage_TEMP) { - (ForecastPage_TEMP)(obj).forward(); + return (ForecastPage_TEMP)(obj).forward(); } return false; } @@ -194,6 +198,7 @@ if(content.numChildren == 0) { return false; } var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -211,7 +216,7 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - return true; + returnValue = true; } } if(obj is PlannerPage) @@ -221,8 +226,7 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "instructions"; - - return true; + returnValue = true; } } if(obj is InstructionPage_TEMP) @@ -233,7 +237,7 @@ expiredContent.addChild(obj); currentState = "forecasting"; //consumer.subscribe(); - return true; + returnValue = true; } } if(obj is ForecastPage_TEMP) @@ -244,11 +248,14 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - return true; + returnValue = true; } } - return false; + btnBack.enabled = (currentState == "instructions" || currentState == "forecasting"); + btnForward.enabled = btnBack.enabled; + + return returnValue; } Modified: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-06-09 20:17:56 UTC (rev 154) @@ -245,6 +245,7 @@ private function markError(field:Number, col:Number):void { + if(sumOfEachColumn == -1) return; DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#ee82ee"); grid.selectedIndex = field; } @@ -256,5 +257,14 @@ } grid.selectedIndex = -1; } + + public function deactivate():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(grid.columns[col]).editable = false; + } + grid.selectedIndex = -1; + } } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Location.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-09 20:17:56 UTC (rev 154) @@ -11,6 +11,5 @@ public var maxCapacity:int; public var growthRate:Number; public var initialPopulation:int; - public var roundConfigs:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -37,19 +37,19 @@ private var errorMessage:String = null; - //not used - private var colIndex:Number=0; - public function init():void { dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); gridContainer.addChildAt(dgh.grid, 1); -// createColumns(); } public function changed():void { dgh.changed(); } + public function deactivate():void + { + dgh.deactivate(); + } public function isFinished():Boolean { return dgh.isFinished(); @@ -67,167 +67,6 @@ return dgh.clone(); } - - /* 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 = true; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - 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 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; - 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+$/; - 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 clone():DataGrid - { - var dgClone:DataGrid = new DataGrid(); - var schedClone:ArrayCollection = new ArrayCollection(); - dgClone.dataProvider = schedClone; - - var tempArray:Array = dgClone.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; - } - - dgClone.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - schedClone.addItem(field); - for(var k:Number=0; k<numColumns; k++) - { - schedClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); - } - } - - dgClone.height = (23)*(numFields+1)+2; - - return dgClone; - } */ - ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -46,16 +46,11 @@ 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 = 50; - [Bindable] - public var oldForecast1:Forecast1 = null; + [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); @@ -72,7 +67,7 @@ setItem(1,0,10); setItem(2,0,15); - dgCalculated.enabled = false; + dgCalculated.deactivate(); dgRow3.addChild(dgCalculated.grid); } private function createColumns():void @@ -257,8 +252,9 @@ //others get dgCalculated.setItem(2,col, 5* (t_fish_mined_total - t_fish_mined)); - } + + dgCalculated.grid.invalidateList(); } public function isFinished():Boolean @@ -276,6 +272,18 @@ 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> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> +<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"/> @@ -12,28 +12,45 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - private var clicks:int = 0; + 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 { - clicks++; - if(!(forecastPeople.isFinished() || clicks > 1)) + if(! firstPage) return false; + + tries++; + if(!(forecastPeople.isFinished() || tries > 1)) { Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); return false; } - if(clicks > 2) return false; - var f2:Forecast2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; + Alert.show("!"); + f2.oldForecast1 = forecastPeople; + f2.updateOld(); + content.removeAllChildren(); content.addChild(f2); + firstPage = false; return true; } public function back():Boolean { - return false; + //if(content.contains(forecastPeople)) return false; + + content.removeAllChildren(); + content.addChild(forecastPeople); + firstPage = true; + return true; } public function forward():Boolean This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-03 01:29:56
|
Revision: 153 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=153&view=rev Author: seematalele Date: 2009-06-03 01:29:45 +0000 (Wed, 03 Jun 2009) Log Message: ----------- When you click on the Question in the tree it should automatically show the corresponding information. Written code for it but not working at all. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as mentalmodels/trunk/flex/src/actionscript/ASQuestion.as Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -4,14 +4,20 @@ width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ + import customComponents.db.questions.CategoricalSimple; + import customComponents.db.questions.CategoricalRelative; + import customComponents.db.questions.Categorical; + import mx.collections.ArrayCollection; import mx.effects.Fade; import mx.collections.XMLListCollection; import mx.controls.Alert; + import actionscript.*; + /* id field of module, block and questiongroup and questions should come from database, so when module info is transfered to the server, it should return the id for that module */ - + public static var Qid:int = 2; [Bindable] private var company:XML = <list> @@ -27,8 +33,12 @@ <block name="Characterizing Own Strategy" sequenceNo="1" hours="0" min="30" sec="0" id="2"> <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> <question title="Most important goal" type="psychometric" sequenceNo="1" id="1"> - <psychometric scale="bipolar" choice1="Good" choice2="Better" choice3="Best"/> + </question> + <question title="second important goal" type="catgorical" sequenceNo="2" id="2"> + + </question> + </questiongroup> </block> @@ -38,27 +48,29 @@ </list>; [Bindable] + private var companyData:XMLListCollection = new XMLListCollection(company.module); - private var companyData:XMLListCollection = new XMLListCollection(company.module); - private function treeLabel(item:Object):String + public var tempQuestion:ArrayCollection = new ArrayCollection(); + + private function treeLabel(item:Object):String { var node:XML = XML(item); if( node.localName() == "module" ) return node.@title; - - + else if( node.localName() == "block" ) return node.@name; else if( node.localName() == "questiongroup" ) return node.@header; + else if( node.localName() == "question" ) return node.@title; - else - return node.@name; + else + return null; } @@ -70,7 +82,6 @@ private function addModule():void { - currentState = "module"; var obj:DisplayObject = pnlComponent.getChildAt(1); var moduleInfo:Module = Module(obj); @@ -81,7 +92,6 @@ btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - } private function saveModule(event:Event):void @@ -125,7 +135,6 @@ private function addBlock():void - { currentState = "block"; var obj:DisplayObject = pnlComponent.getChildAt(1); @@ -203,8 +212,7 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = true; btnsaveQuestion.enabled = false; - - + } private function saveQuestionGroup(event:Event):void @@ -251,17 +259,16 @@ newNode.@header = questionGroupInfo.getHeader(); newNode.@description = questionGroupInfo.getDescription(); newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); - - - var block:XMLList =company.module.block.(@name == node.@name); - Alert.show(block.@name + "is name of the block"); - if( block.length() > 0 ) - { - block[0].appendChild(newNode); - currentState = "none"; - btnsaveQuestionGroup.enabled = false; + + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestionGroup.enabled = false; - } + } } } } @@ -311,20 +318,40 @@ var newNode:XML = <question/>; newNode.setLocalName("question"); - // newNode.@header = questionInfo.getHeader(); - //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); newNode.@title = questionInfo.getQuestion(); newNode.@type = questionInfo.getType(); + newNode.@id = ++Qid; var questionGroup:XMLList =company.module.block.questiongroup.(@header == node.@header); - Alert.show(questionGroup.@header + "is name of the questionGroup"); + if( questionGroup.length() > 0 ) { questionGroup[0].appendChild(newNode); currentState = "none"; btnsaveQuestion.enabled = false; - } + } + var ques:ASQuestion = new ASQuestion(newNode.@id); + if(questionInfo.getType().toLowerCase() == "categorical") + { + var cat:ASCategorical = new ASCategorical(newNode.@id); + + var compCategorical:Categorical = Categorical(questionInfo.getQuestionInfo()); + if(compCategorical.getCategoricalType().toLowerCase() == "relative") + { + var relative:CategoricalRelative = CategoricalRelative(compCategorical.getCategoricalInfo()); + cat.setDictionary(relative.dict); + } + else + { + var simple:CategoricalSimple = CategoricalSimple(compCategorical.getCategoricalInfo()); + cat.setDictionary(simple.dict); + } + ques.setQtype(cat); + } + + tempQuestion.addItem(ques); + } } } @@ -346,12 +373,7 @@ return; } - /*if( node.localName() != "module" ) - { - Alert.show("Please select the module from tree."); - return; - }*/ - + var children:XMLList = XMLList(node.parent()).children(); for(var i:Number=0; i < children.length(); i++) { @@ -437,12 +459,28 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = true; - + //questionInfo.reset(); //set all fields questionInfo.setType(node.@type); questionInfo.setQuestion(node.@title); questionInfo.setSequenceNo(node.@sequenceNo); + var id:int = node.@id; + var Q:ASQuestion; + for(var i:int = 0; i<tempQuestion.length; i++) + { + Q = tempQuestion[i]; + if(Q.getId() == id ) + { + if(Q.getType().toLowerCase() == "categorical") + { + var cat:ASCategorical = ASCategorical(Q.getQtype()); + Alert.show(cat.dict[0]); + + } + + } + } } @@ -476,8 +514,7 @@ <comp:Question id="question"/> </mx:AddChild> </mx:State> - - + <mx:State name="none"> </mx:State> </mx:states> Added: mentalmodels/trunk/flex/src/actionscript/ASCategorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASCategorical.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,30 @@ +package actionscript +{ + import flash.utils.Dictionary; + + import mx.collections.ArrayCollection; + + public class ASCategorical + { + public var id:int; + + public function ASCategorical(id:int) + { + this.id = id; + } + + public var type:String; + public var dict:Dictionary = new Dictionary(); + + public function setDictionary(dictionary:Dictionary):void + { + dict = dictionary; + } + + public function getDictionary():Dictionary + { + return dict; + } + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,20 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class ASPsychometric + { + public function ASPsychometric() + { + } + + + public var scale:String; + + public var numberOfIntervals:Number; + + public var choices:ArrayCollection; + + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ASQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASQuestion.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,46 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class ASQuestion + { + private var id:int; + public var question:String; + private var type:String; + private var Qtype:Object; + + public function ASQuestion(id:int) + { + this.id = id; + + } + + public function setType(type:String):void + { + this.type = type; + + } + + public function getType():String + { + return type; + } + + public function setQtype(questionInfo:Object):void + { + this.Qtype = questionInfo; + } + + public function getQtype():Object + { + return Qtype; + } + + public function getId():int + { + return id; + } + + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -13,7 +13,7 @@ [Bindable] public var formIsValid:Boolean = false; - + public var questionInfo:Object; // Holds a reference to the currently focussed // control on the form. private var focussedFormControl:DisplayObject; @@ -41,6 +41,17 @@ txtQuestion.text = question; } + public function setQuestionInfo():void + { + + } + + public function getQuestionInfo():Object + { + return questionInfo; + + } + public function setType(type:String):void { cmbType.selectedItem = type; @@ -94,22 +105,20 @@ private function showQuestionType():void { - - if(cmbType.selectedItem == "Categorical") { currentState = "categorical"; var catobj:DisplayObject = canvasQuestionType.getChildAt(0); - var categoricalInfo:Categorical = Categorical(catobj); - categoricalInfo.reset(); + questionInfo = Categorical(catobj); + questionInfo.reset(); } if(cmbType.selectedItem == "Psychometric") { currentState = "psychometric"; var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); - var psychometricInfo:Psychometric = Psychometric(psychobj); - psychometricInfo.reset(); + questionInfo = Psychometric(psychobj); + questionInfo.reset(); } if(cmbType.selectedItem == "Text") @@ -148,12 +157,15 @@ public function reset():void { + currentState = "none"; txtSeqNo.text =""; txtQuestion.text = ""; txtSeqNo.errorString =""; txtQuestion.errorString =""; + cmbType.selectedIndex = 0; + } ]]> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -8,6 +8,8 @@ import mx.events.ValidationResultEvent; import mx.controls.Alert; + public var categoricalInfo:Object; + [Bindable] public var formIsEmpty:Boolean = true; @@ -75,25 +77,37 @@ public function reset():void { - type.selectedValue =""; + currentState = "none"; + rdoRelative.value = null; + rdoSimple.value = null; } private function showRelativeFields():void { currentState = "relative"; var obj:DisplayObject = canvasComponent.getChildAt(0); - var relativeInfo:CategoricalRelative = CategoricalRelative(obj); - relativeInfo.reset(); + categoricalInfo = CategoricalRelative(obj); + categoricalInfo.reset(); } private function showSimpleFields():void { currentState = "simple"; var obj:DisplayObject = canvasComponent.getChildAt(0); - var simpleInfo:CategoricalSimple = CategoricalSimple(obj); - simpleInfo.reset(); + categoricalInfo = CategoricalSimple(obj); + categoricalInfo.reset(); } + public function getCategoricalInfo():Object + { + return categoricalInfo; + } + + public function getCategoricalType():String + { + return currentState.toString(); + } + ]]> </mx:Script> @@ -122,6 +136,8 @@ <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> </mx:FormItem> - <mx:Canvas id="canvasComponent" height="100%" /> + <mx:Canvas id="canvasComponent" height="100%" width="100%"/> + + </mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -262,7 +262,7 @@ </mx:VBox> - <mx:HBox id="vboxSecondHeader" visible="true"> + <mx:HBox id="vboxSecondHeader" visible="false"> <mx:VBox> <mx:Label text="" id="lblHeader1" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> <mx:List id="lstHeader1" wordWrap="true" dataProvider="{header1}" allowMultipleSelection="false" click="showChoices()" variableRowHeight="true"/> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -18,7 +18,13 @@ [Bindable] public var header:ArrayCollection = new ArrayCollection(); + public var dict:Dictionary = new Dictionary(); + public function getChoices():ArrayCollection + { + return header; + } + // Holds a reference to the currently focussed // control on the form. private var focussedFormControl:DisplayObject; @@ -134,6 +140,7 @@ else { header.addItem(txtChoice.text); + dict[txtChoice.text] = null; txtChoice.text = ""; } @@ -153,10 +160,13 @@ } else { - header.removeItemAt(header.getItemIndex(lstHeader.selectedItem)); + header.removeItemAt(header.getItemIndex(lstHeader.selectedItem)); + delete dict[lstHeader.selectedItem]; } } + + ]]> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -176,31 +176,11 @@ } } - - - ]]> </mx:Script> - <!-- <mx:states> - <mx:State name="relative"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalRelative id="relative"/> - </mx:AddChild> - </mx:State> - - <mx:State name="simple"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalSimple id="simple"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"/> - - </mx:states> --> - <mx:FormHeading label="Psychomtric"/> <mx:FormItem label="Type:"> <mx:RadioButtonGroup id="type"/> @@ -208,6 +188,12 @@ <mx:RadioButton id="rdoBipolar" groupName="{type}" label="Bipolar" click="showFields()" /> <mx:RadioButton id="rdoUnipolar" groupName="{type}" label="Unipolar" click="showFields()"/> </mx:FormItem> + + <mx:FormItem label="Number of Interval:"> + <mx:TextInput id="txtinterval" maxChars="2"/> + </mx:FormItem> + + <mx:HBox id="vboxChoices" visible="false"> <mx:VBox> <mx:Label text="Enter the choices below:" id="lblHeader" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> @@ -221,4 +207,5 @@ </mx:VBox> </mx:HBox> + <mx:NumberValidator id ="validateInterval" source="{txtinterval}" property="text" minValue="1" maxValue="99" domain="int"/> </mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-02 22:37:12
|
Revision: 152 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=152&view=rev Author: kjonas Date: 2009-06-02 22:37:05 +0000 (Tue, 02 Jun 2009) Log Message: ----------- FisheryExperimentKalin is a working Demo to be displayed to Robert Tobias the only section that does not work quite as intended is the final section, Forecasting. I am working to manage this. all *QuestionComponents were fitted title and description fields. PsychometricQuestionC must have .initialize and .init() called in order to display properly Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,16 +1,10 @@ <?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, #80FFAA]" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" width="760" height="510" clipContent="false" layout="absolute" - currentState="instructions" initialize="init()"> + currentState="socioDemographic" initialize="init()"> <mx:states> - <mx:State name="instructions"> - <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions"/> - </mx:AddChild> - </mx:State> - <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> @@ -23,7 +17,20 @@ </mx:AddChild> </mx:State> - <mx:State name="none"/> + <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> @@ -69,25 +76,25 @@ { Id = event.result as uint; - Alert.show("Student id is " + Id ); +// Alert.show("Student id is " + Id ); consumer.disconnect(); } private function faultHandler(event:FaultEvent):void { - Alert.show("event fault is " + event.fault.faultDetail); +// Alert.show("event fault is " + event.fault.faultDetail); } private function handleFault(event:MessageFaultEvent):void { - Alert.show("Message event fault is " + event.faultString); +// Alert.show("Message event fault is " + event.faultString); } private function messageHandler(message:IMessage):void { randomNumbers = message.body as String; - Alert.show( ""+randomNumbers); +// Alert.show( ""+randomNumbers); } public function init():void @@ -175,6 +182,10 @@ { (InstructionPage)(obj).forward(); } + if(obj is ForecastPage_TEMP) + { + (ForecastPage_TEMP)(obj).forward(); + } return false; } @@ -184,17 +195,6 @@ { return false; } var obj:DisplayObject = content.getChildAt(0); - if(obj is InstructionPage) - { - if( (InstructionPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "socioDemographic"; - //consumer.subscribe(); - return true; - } - } if(obj is SocioDemographicPage) { var Id:uint = 0; @@ -210,7 +210,7 @@ Alert.show(info.getSemester()); Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); - Alert.show("Before invoking createstudent()"); +// Alert.show("Before invoking createstudent()"); return true; } } @@ -220,11 +220,33 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "none"; + 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; + } + } return false; } Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -40,8 +40,8 @@ </mx:ArrayCollection> </mx:ArrayCollection> - <comp:TextQuestion id="question1"/> - <comp:CategoricalQuestion id="question2" topics="{topicList}" specifics="{specificList}"/> + <comp:TextQuestionC id="question1"/> + <comp:CategoricalQuestionC id="question2" topics="{topicList}" specifics="{specificList}"/> <comp:ForecastQuestion id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -9,31 +9,43 @@ public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); - public var questionGroups:ArrayCollection = new ArrayCollection(); + public var choices2:ArrayCollection = new ArrayCollection(); + public var questions2:ArrayCollection = new ArrayCollection(); + + public var questionGroups1:ArrayCollection = new ArrayCollection(); public var block1:Block = new Block(); public function fillBlock():void { try{ // debg.text += "creating choices\n"; - choices1.addItem("Test1"); - choices1.addItem("Test2"); - choices1.addItem("Test3"); + choices1.addItem("Highly Agree"); + choices1.addItem("Highly Neutral"); + choices1.addItem("Highly Disagree"); + + choices2.addItem("Agree"); + choices2.addItem("Neutral"); // debg.text += "choices1.length="+choices1.length+"\n"; // debg.text += "creating questions\n"; questions1.addItem(new PsychometricQuestion()); PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; - PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; + PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 3; + + questions2.addItem(new PsychometricQuestion()); + PsychometricQuestion(questions2.getItemAt(0)).choices = choices2; + PsychometricQuestion(questions2.getItemAt(0)).numberOfIntervals = 5; // debg.text += "questions1.length="+questions1.length+"\n"; // debg.text += "creating questiongroups\n"; - questionGroups.addItem(new QuestionGroup()); - QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; + questionGroups1.addItem(new QuestionGroup()); + questionGroups1.addItem(new QuestionGroup()); + QuestionGroup(questionGroups1.getItemAt(0)).questions = questions1; + QuestionGroup(questionGroups1.getItemAt(1)).questions = questions2; // debg.text += "questionGroups.length="+questionGroups.length+"\n"; // debg.text += "creating block\n"; - block1.questionGroups = questionGroups; + block1.questionGroups = questionGroups1; // debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; // debg.text += "finished\n"; @@ -52,7 +64,7 @@ <mx:String>testRight</mx:String> </mx:ArrayCollection> <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> - <comp:CategoricalQuestion/> + <comp:CategoricalQuestionC/> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> Added: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:Script> + <![CDATA[ + import actionscript.FishUtil; + + private function fix(index:int, list:ArrayCollection):int + { + return FishUtil.fix(index, list); + } + + ]]> + </mx:Script> + + <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> + + <!-- 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> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -261,6 +261,21 @@ } } + 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; + } + ]]> </mx:Script> Added: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> + + <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 clicks:int = 0; + + public function testNext(evt:Event=null):Boolean + { + clicks++; + if(!(forecastPeople.isFinished() || clicks > 1)) + { + Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); + return false; + } + if(clicks > 2) return false; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + content.addChild(f2); + return true; + } + + public function back():Boolean + { + return false; + } + + 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> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -43,12 +43,28 @@ public function back():Boolean { - return pageDisplay.prevPage(); + var pageSuccess:Boolean = pageDisplay.prevPage(); + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + if(pageSuccess) + { + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + } + return pageSuccess; } public function forward():Boolean { - return pageDisplay.nextPage(); + var pageSuccess:Boolean = pageDisplay.nextPage(); + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + if(pageSuccess) + { + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + } + return pageSuccess; } public function accept():Boolean @@ -67,8 +83,7 @@ ]]> </mx:Script> - <mx:Label text="{currPage+1}"/> - <mx:Label text="{numPages}"/> + <mx:Label id="currPageLabel" text="Page {(currPage+1)} / {numPages}"/> <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> <mx:VBox id="content"/> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,23 +1,89 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> - <mx:ArrayCollection id="pageSet1"> - + <mx:ArrayCollection id="psychometricLabels"> + <mx:String>Very Much</mx:String> + <mx:String>Neutral</mx:String> + <!--<mx:String>Not at All</mx:String>--> </mx:ArrayCollection> - <mx:VBox id="p1"> - <mx:Text text="This is an information window." width="300"/> - <mx:Text text="What is presented in an information window can be selected from the drop-down list above each window!" width="300"/> - <mx:Text text="Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”)." width="300"/> - </mx:VBox> - <mx:VBox id="p2"> - <mx:Text text="num2" width="300"/> - </mx:VBox> - <mx:VBox id="p3"> - <mx:Text text="Welcome to the E-Fishery experiment" width="300"/> - <mx:Text text="In this experiment you will design a strategy to fish an abstract fishing ground together with three other persons. As we are mainly interested in the reasons why you choose a certain strategy, we will ask you a number of questions. For the same reason, there are no ‘correct’ or ‘wrong’ strategies and no ‘correct’ or ‘wrong’ answers. However, since for each pound of fish you get during the experiment you will receive #.### US$, you might be interested in finding a strategy that fits your goals well. For this, you have to understand the dynamics of the (simulated) fish population and anticipate well the behavior of the other persons of your group." width="300"/> - </mx:VBox> + <mx:ArrayCollection id="categoricalTopics"> + <mx:String>- Select -</mx:String> + <mx:String>Your Earnings</mx:String> + <mx:String>Fish Population</mx:String> + <mx:String>Other Players</mx:String> + </mx:ArrayCollection> - <!--<as:PageDisplay pages="{pageSet1}"/>--> + <mx:ArrayCollection id="categoricalSpecifics"> + <mx:ArrayCollection> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Earn as much as possible</mx:String> + <mx:String>Earn more than the others</mx:String> + <mx:String>Earn about the same as the others</mx:String> + <mx:String>Earn less then the others</mx:String> + <mx:String>Earn a fair amount but much less then would be possible</mx:String> + <mx:String>Earn nothing</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Let the fish population grow as much as possible</mx:String> + <mx:String>Keep the fish population at a high stable level</mx:String> + <mx:String>Keep the fish population at a medium stable level</mx:String> + <mx:String>Keep the fish population at a low stable level</mx:String> + <mx:String>Not to completely destroy the fish population</mx:String> + <mx:String>To destroy the fish population</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Act similarly to the others</mx:String> + <mx:String>Act differently than the others</mx:String> + <mx:String>Allow the others to have good earnings</mx:String> + <mx:String>Avoid that the others get good earnings</mx:String> + <mx:String>Act according to rules I expect the others to know</mx:String> + <mx:String>Act against rules I expect the others to know</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + <mx:HBox> + <mx:VBox> + <mx:Label/> + </mx:VBox> + <mx:VBox id="p1"> + <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> + <comp:PsychometricQuestionC id="psychometricQuestion" title="Overall, how much do you like your group?" + labels="{psychometricLabels}" maxValue="3"/> + <comp:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" + topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> + <comp:TextQuestionC id="textQuestion" title="Describe in your own words what the rule, agreement, or other coordination attempt states." + defaultText="Enter your response here..." txtHeight="48"/> + </mx:VBox> + </mx:HBox> + + <mx:Script> + <![CDATA[ + + public function init():void + { + psychometricQuestion.initialize(); + psychometricQuestion.init(); + } + + public function back():Boolean + { + return false; + } + public function forward():Boolean + { + return false; + } + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + </mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,7 +1,7 @@ <?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:Label text="Strategy Design" 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/> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,14 +1,31 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="false"> - <!-- Used for bipolar psychometric scales --> - <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> - <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> - <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> + <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> - <!-- Used for unipolar psychometric scales --> - <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> - <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + <mx:Canvas id="content" minHeight="30" maxHeight="90"> + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + </mx:Canvas> <mx:Script> <![CDATA[ @@ -30,14 +47,14 @@ farright.text = (String)(labels.getItemAt(1)); farleft.visible = true; farright.visible = true; - removeChild(topleft); - removeChild(topmid); - removeChild(topright); + content.removeChild(topleft); + content.removeChild(topmid); + content.removeChild(topright); slider1.isBipolar = false; slider1.x = 100; slider1.y = 0; } - else + else if(labels.length == 3) { topleft.text = (String)(labels.getItemAt(0)); topmid.text = (String)(labels.getItemAt(1)); @@ -45,24 +62,29 @@ topleft.visible = true; topmid.visible = true; topright.visible = true; - removeChild(farleft); - removeChild(farright); + content.removeChild(farleft); + content.removeChild(farright); slider1.isBipolar = true; slider1.x = 0; slider1.y = 36; } - slider1.maxValue = maxValue; - slider1.initialize(); - slider1.init(); - addChild(slider1); -/* var e:Error = new Error(); -e.message = "TEST"; -throw e; */ + initializeSlider(); } } + public function initializeSlider():void + { + slider1.maxValue = maxValue; + slider1.initialize(); + slider1.init(); + if(!(content.contains(slider1))) + { + content.addChild(slider1); + } + } + ]]> </mx:Script> -</mx:Canvas> +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -4,6 +4,7 @@ <mx:Script> <![CDATA[ import mx.controls.Label; + import mx.controls.Text; [Bindable] [Embed(source="../images/SliderImage.png")] @@ -55,7 +56,7 @@ for(var i:Number = 0; i < numTicks; i++) { var tick:Label = new Label(); - tick.text = "."; + tick.htmlText = "<b>.</b>"; tick.x = i*separation - imageWidth/2; tick.y = -10; addChild(tick); @@ -110,7 +111,7 @@ <!-- 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" + borderStyle="solid" borderColor="#000000" borderThickness="1" /> <mx:Image id="sliderButton" x="0" y="0" source="{sliderImage}"/> Modified: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -37,7 +37,7 @@ boxGender.setStyle("backgroundColor", ""); } - if(getYear().length != 4) + if(getYear().length != 4 || Number(getYear()) < 1900) { txtYear.setStyle("backgroundColor", "#FF0000"); ready=false; Added: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <!--<mx:String id="title"></mx:String> + <mx:String id="description"></mx:String> + <mx:VBox id="headers" paddingBottom="-3"> + <mx:Label text="{title}" paddingBottom="-8"/> + <mx:Text text="{description}" paddingBottom="-8"/> + </mx:VBox>--> + <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:Number id="txtWidth">200</mx:Number> + <mx:Number id="txtHeight">24</mx:Number> + <mx:String id="defaultText"/> + <mx:TextArea id="text" text="{defaultText}" width="{txtWidth}" height="{txtHeight}"/> + + <mx:Script> + <![CDATA[ + + public function back():Boolean + { + return false; + } + public function forward():Boolean + { + return false; + } + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-02 00:53:33
|
Revision: 151 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=151&view=rev Author: seematalele Date: 2009-06-02 00:53:24 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Remove functionality of module,block, QuestionGroup and Question is done. When you click on any node in the tree, it displays the corresponding information about that particular node except for questions it shows half information, so this functionality is needed to be done. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/db/Block.mxml mentalmodels/trunk/flex/src/customComponents/db/Module.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -16,17 +16,18 @@ private var company:XML = <list> - <module title="Preexperiment" sequenceNo="1" id="1"> - <block name="Introduction"> + <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> + <block name="Introduction" sequenceNo="1" hours="0" min="3" sec="0" id="1"> <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> </block> </module> - <module title ="Game Round" sequenceNo="2" id="2"> - <block name="Characterizing Own Strategy"> + <module title ="Game Round" sequenceNo="2" hours="1" min="30" sec="0" id="2"> + <block name="Characterizing Own Strategy" sequenceNo="1" hours="0" min="30" sec="0" id="2"> <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> - <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > + <question title="Most important goal" type="psychometric" sequenceNo="1" id="1"> + <psychometric scale="bipolar" choice1="Good" choice2="Better" choice3="Best"/> </question> </questiongroup> @@ -60,6 +61,13 @@ return node.@name; } + + public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean + { + return (hours == 0 && minutes == 0 && seconds == 0); + + } + private function addModule():void { @@ -72,16 +80,7 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - /*var saveModule:Button = new Button; - var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); - Alert.show(isExists.toString()); - if(!pnlComponent.contains(saveModule as DisplayObject)) - { - saveModule.label ="Save Module"; - pnlComponent.addChild(saveModule as DisplayObject); - } - //saveModule.*/ } @@ -105,6 +104,9 @@ newNode.setLocalName("module"); newNode.@title=moduleInfo.getName(); newNode.@sequenceNo =moduleInfo.getSequenceNo(); + newNode.@hours = moduleInfo.getHours(); + newNode.@min = moduleInfo.getMinutes(); + newNode.@sec = moduleInfo.getSeconds(); company.appendChild(newNode); currentState = "none"; btnsaveModule.enabled = false; @@ -119,12 +121,9 @@ } } - public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean - { - return (hours == 0 && minutes == 0 && seconds == 0); - - } + + private function addBlock():void { @@ -137,23 +136,7 @@ btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - //currentState = "block"; - - - - /*var node:XML = tree.selectedItem as XML; - - Alert.show("Selected node is " + node.@title);*/ - - /* var newNode:XML = <block/>; - newNode.@name = "block1"; - var module:XMLList =company.module.(@title == "first module"); - if( module.length() > 0 ) { - - module[0].appendChild(newNode); - // empName.text = ""; - }*/ - + } private function saveBlock(event:Event):void @@ -185,6 +168,11 @@ newNode.setLocalName("block"); newNode.@name=blockInfo.getName(); newNode.@sequenceNo =blockInfo.getSequenceNo(); + newNode.@hours = blockInfo.getHours(); + newNode.@min = blockInfo.getMinutes(); + newNode.@sec = blockInfo.getSeconds(); + + var module:XMLList =company.module.(@title == node.@title); if( module.length() > 0 ) { @@ -264,18 +252,7 @@ newNode.@description = questionGroupInfo.getDescription(); newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); - /*var module:XMLList = company.module.(@title == parentModule.@title); - //Alert.show("ParentModule node is: " + parentModule.@title); - Alert.show("ParentBlock node is: " + module.children().length()); - var blockList:XMLList = module.children(); - var i:int; - //Alert.show(module.length() + "is length of module"); - for (i = 0; i < blockList.length(); i++) - { - if(blockList[i].block.@name == node.@name) - { - Alert.show(blockList[i].block.@name + "is found"); - */ + var block:XMLList =company.module.block.(@name == node.@name); Alert.show(block.@name + "is name of the block"); if( block.length() > 0 ) @@ -285,9 +262,7 @@ btnsaveQuestionGroup.enabled = false; } - //} - //} - } + } } } } @@ -339,12 +314,13 @@ // newNode.@header = questionInfo.getHeader(); //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); - - var block:XMLList =company.module.block.(@name == node.@name); - Alert.show(block.@name + "is name of the block"); - if( block.length() > 0 ) + newNode.@title = questionInfo.getQuestion(); + newNode.@type = questionInfo.getType(); + var questionGroup:XMLList =company.module.block.questiongroup.(@header == node.@header); + Alert.show(questionGroup.@header + "is name of the questionGroup"); + if( questionGroup.length() > 0 ) { - block[0].appendChild(newNode); + questionGroup[0].appendChild(newNode); currentState = "none"; btnsaveQuestion.enabled = false; @@ -355,35 +331,124 @@ } - - private function removeEmployee():void - { - var node:XML = XML(tree.selectedItem); - if( node == null ) return; - if( node.localName() != "employee" ) return; + public function removeItem():void + { + currentState = "none"; + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestion.enabled = false; + btnsaveQuestionGroup.enabled = false; + + var node:XML = XML(tree.selectedItem); + if( node == null ) + { + Alert.show("Please select the Item from tree."); + return; + + } + /*if( node.localName() != "module" ) + { + Alert.show("Please select the module from tree."); + return; + }*/ var children:XMLList = XMLList(node.parent()).children(); - for(var i:Number=0; i < children.length(); i++) { + for(var i:Number=0; i < children.length(); i++) + { - if( children[i].@name == node.@name ) { + if( children[i].@name == node.@name ) + { delete children[i]; } } - } + + } + private function treeChanged(event:Event):void { - /* var selectedNode:int; + var selectedNode:int; - //selectedNode=Tree(event.target).selectedItem; - var obj:DisplayObject = tree.getChildAt(selectedNode); - var newNode:XML = XML(obj); - Alert.show("Selected node is " + newNode.toString());*/ - + var node:XML = XML(tree.selectedItem); + if(node.localName() == "module") + { + currentState = "module"; + var module:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(module); + + btnsaveModule.enabled = true; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + + //set all fields + moduleInfo.setSequenceNo(node.@sequenceNo); + moduleInfo.setName(node.@title); + moduleInfo.setHours(node.@hours); + moduleInfo.setMinutes(node.@min); + moduleInfo.setSeconds(node.@sec); + + } + if(node.localName() == "block") + { + currentState = "block"; + var block:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(block); + btnsaveBlock.enabled = true; + btnsaveModule.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + + //set all fields + blockInfo.setName(node.@name); + blockInfo.setSequenceNo(node.@sequenceNo); + blockInfo.setHours(node.@hours); + blockInfo.setMinutes(node.@min); + blockInfo.setSeconds(node.@sec); + + } + if(node.localName() == "questiongroup") + { + currentState = "questionGroup"; + var questionGroup:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(questionGroup); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = true; + btnsaveQuestion.enabled = false; + + //set all fields + questionGroupInfo.setHeader(node.@header); + questionGroupInfo.setDescription(node.@description); + questionGroupInfo.setSequenceNo(node.@sequenceNo); + + } + + if(node.localName() == "question") + { + currentState = "question"; + var question:DisplayObject = pnlComponent.getChildAt(1); + var questionInfo:Question = Question(question); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = true; + + //set all fields + questionInfo.setType(node.@type); + questionInfo.setQuestion(node.@title); + questionInfo.setSequenceNo(node.@sequenceNo); + + + + } } - - + + ]]> </mx:Script> @@ -413,61 +478,48 @@ </mx:State> - <mx:State name="none"/> + <mx:State name="none"> + </mx:State> </mx:states> <mx:Spacer width="40"/> <mx:HDividedBox width="100%" height="100%" id="hdMain"> <mx:Spacer width="40"/> - <mx:VBox height="100%" id="vboxLeft"> + <mx:VBox height="100%" id="vboxLeft" width ="40%"> <mx:Spacer width="40"/> - <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" + <mx:Tree id="tree" dataProvider="{companyData}" labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" showRoot="true" change="{treeChanged(event)}" height="50%" width="80%" textAlign="center"/> - <mx:Canvas height="35%"> - <mx:Grid x="0" y="0"> + <mx:Spacer height="30"/> + <mx:Canvas height="30%" id="canvas1" width="100%"> + <mx:Grid x="0" y="0" id="grid1" height="100%" width="100%"> <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + <mx:GridItem width="100%" height="100%" id="griditem12"> <mx:Button label="Add Module" id="butAddModule" click="{addModule()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Module" id="butRemModule"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> - </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + <mx:GridItem width="100%" height="100%" id="griditem2"> <mx:Button label="Add Block" id="butAddBlock" click="{addBlock()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Block" id="butremBlock"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> + </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + + <mx:GridRow width="100%" height="100%" id="gridrow1"> + <mx:GridItem width="100%" height="100%" id="griditem6"> <mx:Button label="Add QuestionGroup" id="butAddQuestionGroup" click="{addQuestionGroup()}"/> </mx:GridItem> + <mx:GridItem width="100%" height="100%" id="griditem9"> + <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + </mx:GridItem> + - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove QuestionGroup" id="butremQuestionGroup"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + <mx:GridRow width="100%" height="100%" id="gridrow2"> + <mx:GridItem width="100%" height="100%" id="griditem1"> + <mx:Button label="Remove Item" id="butRemModule" click ="{removeItem()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Question" id="butremQuestion"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> + </mx:GridRow> </mx:Grid> @@ -482,7 +534,7 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" /> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> <mx:Spacer width="40"/> </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/db/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -47,6 +47,34 @@ } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setName(name:String):void + { + txtName.text = name; + } + + + public function setHours(hour:Number):void + { + hours.value = hour; + + } + public function setMinutes(min:Number):void + { + minutes.value = min; + + } + public function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control @@ -116,7 +144,7 @@ <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Description:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> + <mx:TextArea id="txtName" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Duration(hr:min:sec):"> Modified: mentalmodels/trunk/flex/src/customComponents/db/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -49,6 +49,34 @@ } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setName(name:String):void + { + txtName.text = name; + } + + + public function setHours(hour:Number):void + { + hours.value = hour; + + } + public function setMinutes(min:Number):void + { + minutes.value = min; + + } + public function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control Modified: mentalmodels/trunk/flex/src/customComponents/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -27,13 +27,47 @@ return txtQuestion.text; } - /*public function getDescription():String + public function getType():String { - return txtDescription.text; - }*/ + return String(cmbType.selectedItem); + } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setQuestion(question:String):void + { + txtQuestion.text = question; + } + public function setType(type:String):void + { + cmbType.selectedItem = type; + if(cmbType.selectedItem == "Categorical") + { + currentState = "categorical"; + var catobj:DisplayObject = canvasQuestionType.getChildAt(0); + var categoricalInfo:Categorical = Categorical(catobj); + categoricalInfo.reset(); + + } + if(cmbType.selectedItem == "Psychometric") + { + currentState = "psychometric"; + var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); + var psychometricInfo:Psychometric = Psychometric(psychobj); + psychometricInfo.reset(); + + } + if(cmbType.selectedItem == "Text") + { + currentState = "none"; + } + } + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control @@ -61,7 +95,7 @@ { - //Alert.show("selected item is: " + cmbType.selectedItem); + if(cmbType.selectedItem == "Categorical") { currentState = "categorical"; @@ -70,7 +104,7 @@ categoricalInfo.reset(); } - else if(cmbType.selectedItem == "Psychometric") + if(cmbType.selectedItem == "Psychometric") { currentState = "psychometric"; var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); @@ -78,10 +112,11 @@ psychometricInfo.reset(); } - else + if(cmbType.selectedItem == "Text") { currentState = "none"; - } + } + } @@ -135,9 +170,8 @@ <comp:Psychometric id="psychometric"/> </mx:AddChild> </mx:State> - - <mx:State name="none"/> - + <mx:State name="none" /> + </mx:states> @@ -146,7 +180,7 @@ <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Question:"> - <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> + <mx:TextArea id="txtQuestion" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Select Question Type:"> <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> Modified: mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -31,7 +31,23 @@ return txtDescription.text; } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setHeader(header:String):void + { + txtHeader.text = header; + } + + public function setDescription(description:String):void + { + txtDescription.text = description; + + } + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -23,22 +23,7 @@ // control on the form. private var focussedFormControl:DisplayObject; - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-01 16:52:05
|
Revision: 150 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=150&view=rev Author: seematalele Date: 2009-06-01 16:52:02 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Psychometric interface is complete including validation. Following things needs to be done - 1)Remove functionality for all elements 2)Find out way for Psychometric and Categorical Component values in Question.mxml 3)Write methods in QuestionCreatorService class Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/actionscript/Location.as Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/db/ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml mentalmodels/trunk/flex/src/customComponents/db/Module.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/Block.mxml mentalmodels/trunk/flex/src/customComponents/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> @@ -16,25 +16,24 @@ private var company:XML = <list> - <module title="Preexperiment" sequenceNo="200" id="1"> - <block name="John H"> - <questiongroup header="hello" description="world" sequenceNo="200" id="1"/> + <module title="Preexperiment" sequenceNo="1" id="1"> + <block name="Introduction"> + <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> </block> - <block name="Sam K" /> - <block name="Erin M"/> - <block name="Ann B"/> + </module> - <module title="Operations" code="400"> - - <block name="Bill C"/> - <block name="Jill W"/> - </module> - <!-- <module title="Engineering" code="300"> - - <block name="Erin M"/> - <block name="Ann B"/> - </module>--> + <module title ="Game Round" sequenceNo="2" id="2"> + <block name="Characterizing Own Strategy"> + <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> + <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > + </question> + </questiongroup> + + </block> + + </module> + </list>; [Bindable] @@ -54,7 +53,10 @@ else if( node.localName() == "questiongroup" ) return node.@header; - else + else if( node.localName() == "question" ) + return node.@title; + + else return node.@name; } Modified: mentalmodels/trunk/flex/src/actionscript/Location.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Location.as 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-01 16:52:02 UTC (rev 150) @@ -11,5 +11,6 @@ public var maxCapacity:int; public var growthRate:Number; public var initialPopulation:int; + public var roundConfigs:ArrayCollection; } } \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/customComponents/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,138 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> -<mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getName():String - { - return txtName.text; - } - /*public function getDuration():String - { - //return txtMajor.text; - }*/ - - public function getHours():Number - { - return hours.value; - - } - public function getMinutes():Number - { - return minutes.value; - - } - public function getSeconds():Number - { - return seconds.value; - - } - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtName.text = ""; - hours.value =0; - minutes.value =0; - seconds.value =0; - txtSeqNo.errorString =""; - txtName.errorString =""; - - } - - - - ]]> - </mx:Script> - <mx:FormHeading label="Block Information"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Description:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> - </mx:FormItem> - -<mx:FormItem label="Duration(hr:min:sec):"> - <mx:HBox> - <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> - </mx:HBox> - - - - -</mx:FormItem> -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,142 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header1:ArrayCollection = new ArrayCollection(); - - [Bindable] - public var header2:ArrayCollection = new ArrayCollection(); - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (type.selectedValue == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - type.selectedValue =""; - } - - private function showRelativeFields():void - { - currentState = "relative"; - var obj:DisplayObject = canvasComponent.getChildAt(0); - var relativeInfo:CategoricalRelative = CategoricalRelative(obj); - relativeInfo.reset(); - } - - private function showSimpleFields():void - { - currentState = "simple"; - var obj:DisplayObject = canvasComponent.getChildAt(0); - var simpleInfo:CategoricalSimple = CategoricalSimple(obj); - simpleInfo.reset(); - } - - ]]> - </mx:Script> - - - <mx:states> - <mx:State name="relative"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalRelative id="relative"/> - </mx:AddChild> - </mx:State> - - <mx:State name="simple"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalSimple id="simple"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"/> - - </mx:states> - - <mx:FormHeading label="Categorical"/> - <mx:FormItem label="Type:"> - <mx:RadioButtonGroup id="type"/> - - <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> - <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> - </mx:FormItem> - <mx:Canvas id="canvasComponent" height="100%" /> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:Script> - <![CDATA[ - import actionscript.FishUtil; - - private function fix(index:int, list:ArrayCollection):int - { - return FishUtil.fix(index, list); - } - - ]]> - </mx:Script> - - <mx:Label id="header"/> - <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - - - <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:HBox> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,256 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - import flash.utils.Dictionary; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header1:ArrayCollection = new ArrayCollection(); - [Bindable] - public var header:Object = new Object(); - - public var dict:Dictionary = new Dictionary(); - - [Bindable] - public var header2:ArrayCollection = new ArrayCollection(); - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtHeader1.text == "" && txtHeader2.text == "" && txtChoice1.text == "" && txtChoice2.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - txtHeader1.text = ""; - txtHeader2.text = ""; - txtChoice1.text = ""; - txtChoice2.text = ""; - } - - - private function addHeader():void - { - - lblHeader1.text = txtHeader1.text; - lblHeader2.text = txtHeader2.text; - vboxSecondHeader.visible = true; - frmitmAddChoice1.label="Choice for " + txtHeader1.text + ":"; - frmitmAddChoice2.label="Choice for " + txtHeader2.text + ":"; - - } - - private function addChoice1():void - { - if(txtChoice1.text == null || txtChoice1.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice1.label); - return; - - } - header1.addItem(txtChoice1.text); - dict[txtChoice1.text] = new ArrayCollection(); - - txtChoice1.text = ""; - - } - - private function addChoice2():void - { - if(header1.length < 0) - { - Alert.show("There are no choices for "+ txtHeader1.text +"Please Enter the " + frmitmAddChoice1.label); - return; - } - if(txtChoice2.text == null || txtChoice2.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice2.label); - return; - - } - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - - else - { - - //header2.addItem(txtChoice2.text); - if(dict[lstHeader1.selectedItem].hasOwnProperty("addItem")) - { - dict[lstHeader1.selectedItem].addItem(txtChoice2.text); - } - else - Alert.show("addItem property is NOT suceesul"); - //header[lstHeader1.selectedItem] = txtChoice2.text; - txtChoice2.text = ""; - } - - } - - private function removeChoice1():void - { - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - else - { - delete dict[lstHeader1.selectedItem]; - } - } - - private function removeChoice2():void - { - if(lstHeader2.selectedItem == null ||lstHeader2.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - else - { - //header1.removeItemAt(header1.getItemIndex(lstHeader2.selectedItem)); - if(dict[lstHeader1.selectedItem].hasOwnProperty("removeItemAt") && dict[lstHeader1.selectedItem].hasOwnProperty("getItemIndex")) - { - dict[lstHeader1.selectedItem].removeItemAt(dict[lstHeader1.selectedItem].getItemIndex(lstHeader2.selectedItem)); - - } - } - } - - private function showChoices():void - { - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Enter the items in the " + txtHeader1. text); - return; - } - else - { - lstHeader2.dataProvider = dict[lstHeader1.selectedItem]; - } - } - ]]> - </mx:Script> - <mx:VBox id="vboxHeaders"> - <mx:FormItem label="Header1:"> - <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:FormItem label="Header2:"> - <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> - - </mx:VBox> - - <mx:HBox id="vboxSecondHeader" visible="false"> - <mx:VBox> - <mx:Label text="" id="lblHeader1" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> - <mx:List id="lstHeader1" wordWrap="true" dataProvider="{header1}" allowMultipleSelection="false" click="showChoices()"/> - <mx:FormItem id="frmitmAddChoice1"> - <mx:TextInput id="txtChoice1" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnaddChoice1" label="Add Choice1" click="addChoice1()"/> - <mx:Button id="btnremoveChoice1" label="Remove Choice1" click="removeChoice1()"/> - - </mx:VBox> - <mx:Spacer width="50"/> - - - <mx:VBox> - <mx:Label text="" id="lblHeader2" fontWeight="bold" fontSize="12" fontFamily="Verdana"/> - <mx:List id="lstHeader2" wordWrap="false" dataProvider="{header2}" allowMultipleSelection="false" /> - - <mx:FormItem id="frmitmAddChoice2"> - <mx:TextInput id="txtChoice2" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnaddChoice2" label="Add Choice2" click="addChoice2()"/> - <mx:Button id="btnremoveChoice2" label="Remove Choice2" click="removeChoice2()"/> - </mx:VBox> - - - - </mx:HBox> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,158 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header:ArrayCollection = new ArrayCollection(); - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtHeader.text == "" && txtChoice.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - txtHeader.text = ""; - - txtChoice.text = ""; - - } - - private function showRelativeFields():void - { - vboxHeaders.visible = true; - - } - - private function showSimpleFields():void - { - vboxHeaders.visible = false; - vboxSecondHeader.visible = false; - } - - private function addHeader():void - { - - lblHeader.text = txtHeader.text; - vboxSecondHeader.visible = true; - frmitmAddChoice.label="Choice for " + txtHeader.text + ":"; - - } - - private function addChoice():void - { - if(txtChoice.text == null || txtChoice.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice.label); - return; - - } - header.addItem(txtChoice.text); - txtChoice.text = ""; - - } - - - ]]> - </mx:Script> - <mx:VBox id="vboxHeaders"> - <mx:FormItem label="Header:"> - <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> - - </mx:VBox> - - <mx:HBox id="vboxSecondHeader" visible="false"> - <mx:VBox> - <mx:Label text="" id="lblHeader" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> - <mx:List id="lstHeader" wordWrap="true" dataProvider="{header}" allowMultipleSelection="false"/> - <mx:FormItem id="frmitmAddChoice"> - <mx:TextInput id="txtChoice" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:Button id="btnaddChoice" label="Add Choice" click="addChoice()"/> - - </mx:VBox> - - </mx:HBox> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,141 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - - -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> -<mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getName():String - { - return txtName.text; - } - /*public function getDuration():String - { - //return txtMajor.text; - }*/ - - public function getHours():Number - { - return hours.value; - - } - public function getMinutes():Number - { - return minutes.value; - - } - public function getSeconds():Number - { - return seconds.value; - - } - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtName.text = ""; - hours.value =0; - minutes.value =0; - seconds.value =0; - txtSeqNo.errorString =""; - txtName.errorString =""; - - } - - - - ]]> - </mx:Script> - <mx:FormHeading label="Module Information"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Name:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> - </mx:FormItem> - -<mx:FormItem label="Duration(hr:min:sec):"> - <mx:HBox> - <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> - </mx:HBox> - - - - -</mx:FormItem> -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,159 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> - <mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - } - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - - return formIsValid; - - } - - private function showQuestionType():void - { - - - //Alert.show("selected item is: " + cmbType.selectedItem); - if(cmbType.selectedItem == "Categorical") - { - currentState = "categorical"; - var obj:DisplayObject = canvasQuestionType.getChildAt(0); - var categoricalInfo:Categorical = Categorical(obj); - categoricalInfo.reset(); - - } - else - { - currentState = "none"; - } - } - - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtQuestion.text = ""; - - txtSeqNo.errorString =""; - txtQuestion.errorString =""; - - } - - ]]> - </mx:Script> - <mx:states> - <mx:State name="categorical"> - <mx:AddChild relativeTo="{canvasQuestionType}"> - <comp:Categorical id="categorical"/> - </mx:AddChild> - </mx:State> - - <!--<mx:State name="psychometric"> - <mx:AddChild relativeTo="{canvasQuestionType}"> - <comp:Psychometric id="psychometri"/> - </mx:AddChild> - </mx:State>--> - - <mx:State name="none"/> - - </mx:states> - - - <mx:FormHeading label="QuestionGroup"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Question:"> - <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Select Question Type:"> - <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> - <mx:ArrayCollection> - <mx:String>-Select-</mx:String> - <mx:String>Categorical</mx:String> - <mx:String>Psychometric</mx:String> - <mx:String>Text</mx:String> - </mx:ArrayCollection> - </mx:ComboBox> - - </mx:FormItem> - - <mx:Canvas id="canvasQuestionType" height="100%"/> - -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,111 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getHeader():String - { - return txtHeader.text; - } - public function getDescription():String - { - return txtDescription.text; - } - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && txtDescription.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtHeader.text = ""; - txtDescription.text =""; - txtSeqNo.errorString =""; - txtHeader.errorString =""; - txtDescription.errorString =""; - - } - - ]]> - </mx:Script> - - <mx:FormHeading label="QuestionGroup"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Header:"> - <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Decsription:"> - <mx:TextArea id="txtDescription" change="{validateForm(event)}" width="100%" height="100"/> - </mx:FormItem> - - -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/db/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Block.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Block Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Description:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/db/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Module.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="utf-8"?> + + +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="100%" autoLayout="true"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Module Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Name:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper ... [truncated message content] |
From: <kj...@us...> - 2009-05-31 02:24:09
|
Revision: 149 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=149&view=rev Author: kjonas Date: 2009-05-31 02:24:04 +0000 (Sun, 31 May 2009) Log Message: ----------- Problems located and repaired in PsychometricQuestionC and Slider old PsychometricQuestion.mxml file deprecated and deleted displaying a Block in flex is underway; tested for PsychometricQuestionC Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -1,46 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> - - <!--this is a test file, don't hardcode everything like this, it's terrible practice--> - - <mx:ArrayCollection id="ch1"> - <mx:String>blah1</mx:String> - <mx:String>blah1</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="ch2"> - <mx:String>blah2</mx:String> - <mx:String>blah2</mx:String> - <mx:String>blah2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="ch3"> - <mx:String>blah3</mx:String> - <mx:String>blah3</mx:String> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q1"> - <as:PsychometricQuestion choices="{ch1}" numberOfIntervals="5" question="Question1"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q2"> - <as:PsychometricQuestion choices="{ch2}" numberOfIntervals="5" question="Question2"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q3"> - <as:PsychometricQuestion choices="{ch3}" numberOfIntervals="5" question="Question3"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="qgrs"> - <as:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> - <as:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> - <as:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> - </mx:ArrayCollection> - - <as:Block id="blk" questionGroups="{qgrs}"/> - + <mx:Script> <![CDATA[ import actionscript.QuestionGroup; import actionscript.PsychometricQuestion; + import actionscript.Block; public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); @@ -50,29 +15,31 @@ public function fillBlock():void { try{ - debg.text += "creating choices\n"; - choices1.addItem("left"); - choices1.addItem("right"); - debg.text += "choices1.length="+choices1.length+"\n"; +// debg.text += "creating choices\n"; + choices1.addItem("Test1"); + choices1.addItem("Test2"); + choices1.addItem("Test3"); +// debg.text += "choices1.length="+choices1.length+"\n"; - debg.text += "creating questions\n"; +// debg.text += "creating questions\n"; questions1.addItem(new PsychometricQuestion()); PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; - debg.text += "questions1.length="+questions1.length+"\n"; +// debg.text += "questions1.length="+questions1.length+"\n"; - debg.text += "creating questiongroups\n"; +// debg.text += "creating questiongroups\n"; questionGroups.addItem(new QuestionGroup()); QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; - debg.text += "questionGroups.length="+questionGroups.length+"\n"; +// debg.text += "questionGroups.length="+questionGroups.length+"\n"; - debg.text += "creating block\n"; +// debg.text += "creating block\n"; block1.questionGroups = questionGroups; - debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; +// debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; - debg.text += "finished\n"; +// debg.text += "finished\n"; }catch(errObject:Error){ - debg.text += errObject.message + "\n" + errObject.getStackTrace(); + debg.text += "block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace(); } } @@ -82,8 +49,10 @@ <mx:ArrayCollection id="labs"> <mx:String>testLeft</mx:String> <mx:String>testRight</mx:String> + <mx:String>testRight</mx:String> </mx:ArrayCollection> - <comp:PsychometricQuestionC labels="{labs}"/> + <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> + <comp:CategoricalQuestion/> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-31 02:24:04 UTC (rev 149) @@ -99,13 +99,13 @@ var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); pq.id = "q"+question; pq.labels = tempPsych.choices; - pq.maxValue = 3; + pq.maxValue = tempPsych.numberOfIntervals; pq.initialize(); pq.init(); // ERROR FOUND SOMEWHERE IN HERE /* var e:Error = new Error(); -e.message = "haha"; +e.message = "TEST"; throw e; */ tempBox.addChild(pq); } @@ -132,7 +132,7 @@ } pages.addItem(tempBox); - msg += "item added\n"; +// msg += "item added\n"; } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -19,9 +19,9 @@ <mx:ArrayCollection id="topics"> <mx:String>- Select -</mx:String> - <mx:String>topic0</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 --> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -16,7 +16,7 @@ { block = newBlock; try{ - debug.text += "creating pageDisplay...\n"; +// debug.text += "creating pageDisplay...\n"; pageDisplay = new PageDisplay(block, 3); if(pageDisplay == null) { @@ -27,17 +27,18 @@ }catch(errObject:Error){ - debug.text += "fail\n" + errObject.message +"\n"+ errObject.name +"\n"; + debug.text += "pageDisplay creation failure\n" + + errObject.message +"\n"+ errObject.name +"\n"; } - debug.text += "setting currPage...\n"; +// debug.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; - debug.text += "setting numPages...\n"; +// debug.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; - debug.text += "adding currentPage...\n"; +// debug.text += "adding currentPage...\n"; content.addChild(pageDisplay.currentPage); - debug.text += "currentPage added.\n"; +// debug.text += "currentPage added.\n"; } public function back():Boolean Deleted: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -1,56 +0,0 @@ -<?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; - [Bindable] - public var maxValue:Number; - - public 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" maxValue="{maxValue}"/> - -</mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -2,13 +2,13 @@ <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> <!-- 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"/> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> <!-- 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"/> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> <mx:Script> <![CDATA[ @@ -26,27 +26,27 @@ if(labels.length == 2) { - topleft.visible = false; - topmid.visible = false; - topright.visible = false; + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + farleft.visible = true; + farright.visible = true; removeChild(topleft); removeChild(topmid); removeChild(topright); - farleft.text = (String)(labels.getItemAt(0)); - farright.text = (String)(labels.getItemAt(1)); slider1.isBipolar = false; slider1.x = 100; slider1.y = 0; } else { - farleft.visible = false; - farright.visible = false; - removeChild(farleft); - removeChild(farright); topleft.text = (String)(labels.getItemAt(0)); topmid.text = (String)(labels.getItemAt(1)); topright.text = (String)(labels.getItemAt(2)); + topleft.visible = true; + topmid.visible = true; + topright.visible = true; + removeChild(farleft); + removeChild(farright); slider1.isBipolar = true; slider1.x = 0; slider1.y = 36; @@ -55,6 +55,10 @@ slider1.maxValue = maxValue; slider1.initialize(); slider1.init(); + addChild(slider1); +/* var e:Error = new Error(); +e.message = "TEST"; +throw e; */ } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-28 01:22:43
|
Revision: 148 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=148&view=rev Author: seematalele Date: 2009-05-28 00:31:15 +0000 (Thu, 28 May 2009) Log Message: ----------- 2 types of Categorical questions 1)Relative - Example 2 list ?\226?\128?\156focus and goal?\226?\128?\157 but items in one list is reltaed to another item/items. 2)Simple - 1 list with choices. 1)Relative Working fine Problem: Remove Choice1 is not removing the item in the list 1 (Focus list) 2)Simple Interface is build but still needs to do lot of modification like adding list control. Modified Paths: -------------- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml Modified: mentalmodels/trunk/flex/src/customComponents/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-27 20:02:40 UTC (rev 147) +++ mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-28 00:31:15 UTC (rev 148) @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> <mx:Script> <![CDATA[ + import mx.collections.ArrayCollection; import mx.validators.NumberValidator; import mx.validators.Validator; import mx.events.ValidationResultEvent; @@ -13,7 +14,11 @@ [Bindable] public var formIsValid:Boolean = false; - + [Bindable] + public var header1:ArrayCollection = new ArrayCollection(); + + [Bindable] + public var header2:ArrayCollection = new ArrayCollection(); // Holds a reference to the currently focussed // control on the form. private var focussedFormControl:DisplayObject; @@ -90,20 +95,41 @@ private function showRelativeFields():void { - - vboxHeaders.visible = true; - vboxSecondHeader.visible = true; - + currentState = "relative"; + var obj:DisplayObject = canvasComponent.getChildAt(0); + var relativeInfo:CategoricalRelative = CategoricalRelative(obj); + relativeInfo.reset(); } private function showSimpleFields():void { - Alert.show("Simple"); + currentState = "simple"; + var obj:DisplayObject = canvasComponent.getChildAt(0); + var simpleInfo:CategoricalSimple = CategoricalSimple(obj); + simpleInfo.reset(); } - - ]]> + + ]]> </mx:Script> + + <mx:states> + <mx:State name="relative"> + <mx:AddChild relativeTo="{canvasComponent}"> + <comp:CategoricalRelative id="relative"/> + </mx:AddChild> + </mx:State> + + <mx:State name="simple"> + <mx:AddChild relativeTo="{canvasComponent}"> + <comp:CategoricalSimple id="simple"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"/> + + </mx:states> + <mx:FormHeading label="Categorical"/> <mx:FormItem label="Type:"> <mx:RadioButtonGroup id="type"/> @@ -111,43 +137,6 @@ <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> </mx:FormItem> - <mx:VBox> - - <mx:VBox id="vboxHeaders" visible="false"> - <mx:FormItem label="Header1:"> - <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> - </mx:FormItem> + <mx:Canvas id="canvasComponent" height="100%" /> - <mx:FormItem label="Header2:"> - <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:FormItem label="Choice for Header1:"> - <mx:TextInput id="txtchoiceHeader1" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnaddChoice1" label="Add Choice"/> - - </mx:VBox> - - <mx:HBox visible="false" id="vboxSecondHeader"> - <mx:VBox> - <mx:Label text="" id="lblHeader1"/> - <mx:List id="lstHeader1" wordWrap="true"/> - <mx:FormItem label="Choice for Header2:"> - <mx:TextInput id="txtaddChoice2" change="{validateForm(event)}"/> - </mx:FormItem> - - </mx:VBox> - <mx:VBox> - <mx:Label text="" id="lblHeader2"/> - <mx:List id="lstHeader2" wordWrap="true"/> - <mx:Button id="btnaddChoice2" label="Add Choice"/> - </mx:VBox> - - </mx:HBox> - - </mx:VBox> - - </mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml 2009-05-28 00:31:15 UTC (rev 148) @@ -0,0 +1,256 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + import flash.utils.Dictionary; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + [Bindable] + public var header1:ArrayCollection = new ArrayCollection(); + [Bindable] + public var header:Object = new Object(); + + public var dict:Dictionary = new Dictionary(); + + [Bindable] + public var header2:ArrayCollection = new ArrayCollection(); + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + /*public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + }*/ + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtHeader1.text == "" && txtHeader2.text == "" && txtChoice1.text == "" && txtChoice2.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + //validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + + txtHeader1.text = ""; + txtHeader2.text = ""; + txtChoice1.text = ""; + txtChoice2.text = ""; + } + + + private function addHeader():void + { + + lblHeader1.text = txtHeader1.text; + lblHeader2.text = txtHeader2.text; + vboxSecondHeader.visible = true; + frmitmAddChoice1.label="Choice for " + txtHeader1.text + ":"; + frmitmAddChoice2.label="Choice for " + txtHeader2.text + ":"; + + } + + private function addChoice1():void + { + if(txtChoice1.text == null || txtChoice1.text == "") + { + Alert.show("Please Enter the " + frmitmAddChoice1.label); + return; + + } + header1.addItem(txtChoice1.text); + dict[txtChoice1.text] = new ArrayCollection(); + + txtChoice1.text = ""; + + } + + private function addChoice2():void + { + if(header1.length < 0) + { + Alert.show("There are no choices for "+ txtHeader1.text +"Please Enter the " + frmitmAddChoice1.label); + return; + } + if(txtChoice2.text == null || txtChoice2.text == "") + { + Alert.show("Please Enter the " + frmitmAddChoice2.label); + return; + + } + if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") + { + Alert.show("Please Select the Item from " + txtHeader1. text); + return; + } + + else + { + + //header2.addItem(txtChoice2.text); + if(dict[lstHeader1.selectedItem].hasOwnProperty("addItem")) + { + dict[lstHeader1.selectedItem].addItem(txtChoice2.text); + } + else + Alert.show("addItem property is NOT suceesul"); + //header[lstHeader1.selectedItem] = txtChoice2.text; + txtChoice2.text = ""; + } + + } + + private function removeChoice1():void + { + if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") + { + Alert.show("Please Select the Item from " + txtHeader1. text); + return; + } + else + { + delete dict[lstHeader1.selectedItem]; + } + } + + private function removeChoice2():void + { + if(lstHeader2.selectedItem == null ||lstHeader2.selectedItem == "") + { + Alert.show("Please Select the Item from " + txtHeader1. text); + return; + } + else + { + //header1.removeItemAt(header1.getItemIndex(lstHeader2.selectedItem)); + if(dict[lstHeader1.selectedItem].hasOwnProperty("removeItemAt") && dict[lstHeader1.selectedItem].hasOwnProperty("getItemIndex")) + { + dict[lstHeader1.selectedItem].removeItemAt(dict[lstHeader1.selectedItem].getItemIndex(lstHeader2.selectedItem)); + + } + } + } + + private function showChoices():void + { + if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") + { + Alert.show("Please Enter the items in the " + txtHeader1. text); + return; + } + else + { + lstHeader2.dataProvider = dict[lstHeader1.selectedItem]; + } + } + ]]> + </mx:Script> + <mx:VBox id="vboxHeaders"> + <mx:FormItem label="Header1:"> + <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:FormItem label="Header2:"> + <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> + + </mx:VBox> + + <mx:HBox id="vboxSecondHeader" visible="false"> + <mx:VBox> + <mx:Label text="" id="lblHeader1" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> + <mx:List id="lstHeader1" wordWrap="true" dataProvider="{header1}" allowMultipleSelection="false" click="showChoices()"/> + <mx:FormItem id="frmitmAddChoice1"> + <mx:TextInput id="txtChoice1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnaddChoice1" label="Add Choice1" click="addChoice1()"/> + <mx:Button id="btnremoveChoice1" label="Remove Choice1" click="removeChoice1()"/> + + </mx:VBox> + <mx:Spacer width="50"/> + + + <mx:VBox> + <mx:Label text="" id="lblHeader2" fontWeight="bold" fontSize="12" fontFamily="Verdana"/> + <mx:List id="lstHeader2" wordWrap="false" dataProvider="{header2}" allowMultipleSelection="false" /> + + <mx:FormItem id="frmitmAddChoice2"> + <mx:TextInput id="txtChoice2" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnaddChoice2" label="Add Choice2" click="addChoice2()"/> + <mx:Button id="btnremoveChoice2" label="Remove Choice2" click="removeChoice2()"/> + </mx:VBox> + + + + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml 2009-05-28 00:31:15 UTC (rev 148) @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + [Bindable] + public var header:ArrayCollection = new ArrayCollection(); + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + /*public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + }*/ + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtHeader.text == "" && txtChoice.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + //validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + + txtHeader.text = ""; + + txtChoice.text = ""; + + } + + private function showRelativeFields():void + { + vboxHeaders.visible = true; + + } + + private function showSimpleFields():void + { + vboxHeaders.visible = false; + vboxSecondHeader.visible = false; + } + + private function addHeader():void + { + + lblHeader.text = txtHeader.text; + vboxSecondHeader.visible = true; + frmitmAddChoice.label="Choice for " + txtHeader.text + ":"; + + } + + private function addChoice():void + { + if(txtChoice.text == null || txtChoice.text == "") + { + Alert.show("Please Enter the " + frmitmAddChoice.label); + return; + + } + header.addItem(txtChoice.text); + txtChoice.text = ""; + + } + + + ]]> + </mx:Script> + <mx:VBox id="vboxHeaders"> + <mx:FormItem label="Header:"> + <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> + + </mx:VBox> + + <mx:HBox id="vboxSecondHeader" visible="false"> + <mx:VBox> + <mx:Label text="" id="lblHeader" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> + <mx:List id="lstHeader" wordWrap="true" dataProvider="{header}" allowMultipleSelection="false"/> + <mx:FormItem id="frmitmAddChoice"> + <mx:TextInput id="txtChoice" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:Button id="btnaddChoice" label="Add Choice" click="addChoice()"/> + + </mx:VBox> + + </mx:HBox> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-27 20:02:40 UTC (rev 147) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-28 00:31:15 UTC (rev 148) @@ -60,17 +60,20 @@ private function showQuestionType():void { - currentState = "categorical"; - var obj:DisplayObject = canvasQuestionType.getChildAt(0); + //Alert.show("selected item is: " + cmbType.selectedItem); if(cmbType.selectedItem == "Categorical") { - + currentState = "categorical"; + var obj:DisplayObject = canvasQuestionType.getChildAt(0); var categoricalInfo:Categorical = Categorical(obj); categoricalInfo.reset(); - - + } + else + { + currentState = "none"; + } } @@ -150,12 +153,7 @@ </mx:FormItem> <mx:Canvas id="canvasQuestionType" height="100%"/> - - - - - - + <mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> </mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-05-27 20:03:15
|
Revision: 147 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=147&view=rev Author: kjonas Date: 2009-05-27 20:02:40 +0000 (Wed, 27 May 2009) Log Message: ----------- Errors located and repaired in regards to PsychometricQuestion (renamed PsychometricQuestionC to indicate that it is a component and avoid compilation errors) PsychometricQuestionC does not seem to work anymore, cause unknown. Modified Paths: -------------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/TestApp.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/FishUtil.as mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,8 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + <mx:ArrayCollection id="topicList"> + <mx:String>- Select -</mx:String> + <mx:String>Your Earnings</mx:String> + <mx:String>Fish Population</mx:String> + <mx:String>Other Players</mx:String> + </mx:ArrayCollection> + + <mx:ArrayCollection id="specificList"> + <mx:ArrayCollection> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Earn as much as possible</mx:String> + <mx:String>Earn more than the others</mx:String> + <mx:String>Earn about the same as the others</mx:String> + <mx:String>Earn less then the others</mx:String> + <mx:String>Earn a fair amount but much less then would be possible</mx:String> + <mx:String>Earn nothing</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Let the fish population grow as much as possible</mx:String> + <mx:String>Keep the fish population at a high stable level</mx:String> + <mx:String>Keep the fish population at a medium stable level</mx:String> + <mx:String>Keep the fish population at a low stable level</mx:String> + <mx:String>Not to completely destroy the fish population</mx:String> + <mx:String>To destroy the fish population</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Act similarly to the others</mx:String> + <mx:String>Act differently than the others</mx:String> + <mx:String>Allow the others to have good earnings</mx:String> + <mx:String>Avoid that the others get good earnings</mx:String> + <mx:String>Act according to rules I expect the others to know</mx:String> + <mx:String>Act against rules I expect the others to know</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + <comp:TextQuestion id="question1"/> - <comp:CategoricalQuestion id="question2"/> + <comp:CategoricalQuestion id="question2" topics="{topicList}" specifics="{specificList}"/> <comp:ForecastQuestion id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/TestApp.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestApp.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/TestApp.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -23,10 +23,10 @@ <mx:String>label2</mx:String> </mx:ArrayCollection> - <comp:PsychometricQuestion id="slider3" labels="{slider3Labels}"/> - <mx:Label id="slideinfo3" text="{slider3.slider.getVal}"/> + <comp:PsychometricQuestionC id="slider3" labels="{slider3Labels}"/> + <mx:Label id="slideinfo3" text="{slider3.slider1.getVal}"/> - <comp:PsychometricQuestion id="slider4" labels="{slider4Labels}"/> - <mx:Label id="slideinfo4" text="{slider4.slider.getVal}"/> + <comp:PsychometricQuestionC id="slider4" labels="{slider4Labels}"/> + <mx:Label id="slideinfo4" text="{slider4.slider1.getVal}"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -37,8 +37,59 @@ <as:Block id="blk" questionGroups="{qgrs}"/> + <mx:Script> + <![CDATA[ + import actionscript.QuestionGroup; + import actionscript.PsychometricQuestion; + + public var choices1:ArrayCollection = new ArrayCollection(); + public var questions1:ArrayCollection = new ArrayCollection(); + public var questionGroups:ArrayCollection = new ArrayCollection(); + public var block1:Block = new Block(); + + public function fillBlock():void + { + try{ + debg.text += "creating choices\n"; + choices1.addItem("left"); + choices1.addItem("right"); + debg.text += "choices1.length="+choices1.length+"\n"; + + debg.text += "creating questions\n"; + questions1.addItem(new PsychometricQuestion()); + PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; + PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; + debg.text += "questions1.length="+questions1.length+"\n"; + + debg.text += "creating questiongroups\n"; + questionGroups.addItem(new QuestionGroup()); + QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; + debg.text += "questionGroups.length="+questionGroups.length+"\n"; + + debg.text += "creating block\n"; + block1.questionGroups = questionGroups; + debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; + + debg.text += "finished\n"; + }catch(errObject:Error){ + debg.text += errObject.message + "\n" + errObject.getStackTrace(); + } + } + + ]]> + </mx:Script> + <mx:ArrayCollection id="labs"> + <mx:String>testLeft</mx:String> + <mx:String>testRight</mx:String> + </mx:ArrayCollection> + <comp:PsychometricQuestionC labels="{labs}"/> - <comp:InstructionPage id="iPage" block="{blk}"/> + <mx:Button id="forward" click="iPage.forward()" label="forward"/> + <mx:Button id="back" click="iPage.back()" label="back"/> + <mx:Text id="debg" text=""/> + + <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> + </mx:Application> Added: mentalmodels/trunk/flex/src/actionscript/FishUtil.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/FishUtil.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/FishUtil.as 2009-05-27 20:02:40 UTC (rev 147) @@ -0,0 +1,18 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + public class FishUtil + { + public function FishUtil() {} + + public static function fix(index:int, list:ArrayCollection):int + { + if( index < 0 ) return 0; + if( index >= list.length ) return list.length - 1; + return index; + } + } + +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-27 20:02:40 UTC (rev 147) @@ -1,7 +1,7 @@ // ActionScript file package actionscript { - import customComponents.PsychometricQuestion; + import customComponents.PsychometricQuestionC; import flash.display.DisplayObject; @@ -28,33 +28,45 @@ 3+2*N / TextArea,ComboBox,PsychometricQuestion,Forecasting / the question itself */ +public var msg:String = ""; public var pages:ArrayCollection; - public var minPagesRead:Number; - public var currentPageNumber:Number; - public var highestPageReached:Number; + public var minPagesRead:int; + public var currentPageNumber:int; + public var highestPageReached:int; public var currBlock:Block; - public function PageDisplay(currBlock:Block, minPagesRead:Number=1) + public function PageDisplay(newBlock:Block, minimumPagesRead:int=1) { - this.currBlock = currBlock; - this.minPagesRead = minPagesRead; - this.currentPageNumber = 0; - this.highestPageReached = currentPageNumber; + currBlock = newBlock; + minPagesRead = minimumPagesRead; + currentPageNumber = 0; + highestPageReached = currentPageNumber; loadPages(); } public function loadPages():void { - this.pages = new ArrayCollection(); + 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) { @@ -84,11 +96,17 @@ else if(tempQuestion is actionscript.PsychometricQuestion) { var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); - var pq:customComponents.PsychometricQuestion = new customComponents.PsychometricQuestion(); + var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); pq.id = "q"+question; pq.labels = tempPsych.choices; - pq.slider.maxValue = 3; - pq.init(); + pq.maxValue = 3; + pq.initialize(); + + pq.init(); // ERROR FOUND SOMEWHERE IN HERE + +/* var e:Error = new Error(); +e.message = "haha"; +throw e; */ tempBox.addChild(pq); } else @@ -107,16 +125,21 @@ desc.htmlText = questionGroup.description; tempBox.addChildAt(head,0); tempBox.addChildAt(desc,1); - pages.addItem(tempBox); } + else + { + msg += "no Questions found\n"; + } + pages.addItem(tempBox); + msg += "item added\n"; } } public function finished():Boolean { return highestPageReached >= minPagesRead - 1; } - public function get length():Number + public function get length():int { return pages.length; } public function get currentPage():DisplayObject @@ -138,12 +161,7 @@ } public function nextPage():Boolean { - currentPageNumber++; - if(currentPageNumber >= pages.length) - { - currentPageNumber = pages.length - 1; - return false; - } + currentPageNumber = FishUtil.fix(currentPageNumber + 1, pages); if( currentPageNumber > highestPageReached ) { @@ -153,12 +171,7 @@ } public function prevPage():Boolean { - currentPageNumber--; - if(currentPageNumber < 0) - { - currentPageNumber = 0; - return false; - } + currentPageNumber = FishUtil.fix(currentPageNumber - 1, pages); return true; } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:Script> + <![CDATA[ + import actionscript.FishUtil; + + private function fix(index:int, list:ArrayCollection):int + { + return FishUtil.fix(index, list); + } + + ]]> + </mx:Script> <mx:Label id="header"/> <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> @@ -7,6 +18,7 @@ <mx:ArrayCollection id="topics"> + <mx:String>- Select -</mx:String> <mx:String>topic0</mx:String> <mx:String>topic1</mx:String> <mx:String>topic2</mx:String> @@ -15,33 +27,25 @@ <!-- each element of this ArrayCollection will serve as a dataProvider --> <mx:ArrayCollection id="specifics"> <mx:ArrayCollection id="topic0"> - <mx:String>specific0.0</mx:String> - <mx:String>specific0.1</mx:String> - <mx:String>specific0.2</mx:String> </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:Script> - <![CDATA[ - - public function fix(index:Number, list:ArrayCollection):Number - { - if( index < 0 ) return 0; - if( index >= list.length ) return list.length - 1; - return index; - } - - ]]> - </mx:Script> - </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -7,13 +7,12 @@ <mx:Script> <![CDATA[ - import mx.messaging.channels.StreamingAMFChannel; import customComponents.*; import mx.collections.ArrayCollection; public function init():void { - for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); + for(var x:int=0;x<4;x++)for(var y:int=0;y<15;y++)forecastPeople.setItem(x,y,7.5); } public function testNext(evt:Event=null):void Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> <mx:Script> <![CDATA[ @@ -7,17 +7,37 @@ import actionscript.PageDisplay; import mx.collections.ArrayCollection; - public var block:Block; - public var pageDisplay:PageDisplay; - [Bindable] public var numPages:Number; - [Bindable] public var currPage:Number; + [Bindable] public var block:Block; + [Bindable] public var pageDisplay:PageDisplay; + [Bindable] public var numPages:int = 1; + [Bindable] public var currPage:int = 0; - public function init():void + public function init(newBlock:Block):void { - pageDisplay = new PageDisplay(block, block.questionGroups.length); + block = newBlock; + try{ + debug.text += "creating pageDisplay...\n"; + pageDisplay = new PageDisplay(block, 3); + if(pageDisplay == null) + { + debug.text += "pageDisplay is null"; + } +// pageDisplay = new PageDisplay(block, block.questionGroups.length); + + + + }catch(errObject:Error){ + debug.text += "fail\n" + errObject.message +"\n"+ errObject.name +"\n"; + } + + debug.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; + debug.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; + + debug.text += "adding currentPage...\n"; content.addChild(pageDisplay.currentPage); + debug.text += "currentPage added.\n"; } public function back():Boolean @@ -43,104 +63,12 @@ return false; } - // Mutilate the following code: - - /* private var allPageList:ArrayCollection; - - // Variables with default settings - [Bindable] - public var currPageNumber:Number = 0; - public var pagesRead:Number = 1; - - public function init_obsolete():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(); - } */ - ]]> </mx:Script> - <mx:Label text="{currPage+1} / {numPages}"/> + <mx:Label text="{currPage+1}"/> + <mx:Label text="{numPages}"/> +<mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> <mx:VBox id="content"/> Added: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <!-- 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"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var labels:ArrayCollection; + [Bindable] public var maxValue:Number; + [Bindable] public var slider1:Slider; + + public function init():void + { + if(labels != null) + { + slider1 = new Slider(); + + if(labels.length == 2) + { + topleft.visible = false; + topmid.visible = false; + topright.visible = false; + removeChild(topleft); + removeChild(topmid); + removeChild(topright); + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + slider1.isBipolar = false; + slider1.x = 100; + slider1.y = 0; + } + else + { + farleft.visible = false; + farright.visible = false; + removeChild(farleft); + removeChild(farright); + topleft.text = (String)(labels.getItemAt(0)); + topmid.text = (String)(labels.getItemAt(1)); + topright.text = (String)(labels.getItemAt(2)); + slider1.isBipolar = true; + slider1.x = 0; + slider1.y = 36; + } + + slider1.maxValue = maxValue; + slider1.initialize(); + slider1.init(); + } + } + + ]]> + </mx:Script> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml ___________________________________________________________________ Added: svn:executable + * Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ @@ -27,8 +27,8 @@ // prepare Slider in default (abstain) position public function init():void { - this.addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); - this.addEventListener(MouseEvent.MOUSE_UP, mouseMove); + addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); + addEventListener(MouseEvent.MOUSE_UP, mouseMove); if(isBipolar) { @@ -58,7 +58,7 @@ tick.text = "."; tick.x = i*separation - imageWidth/2; tick.y = -10; - this.addChild(tick); + addChild(tick); } } @@ -73,13 +73,12 @@ if(sliderButton.visible) { getVal = value; - return value; } else { getVal = abstainValue; - return abstainValue; } + return getVal; } private function updateValue():void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-27 01:15:53
|
Revision: 146 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=146&view=rev Author: seematalele Date: 2009-05-27 01:15:31 +0000 (Wed, 27 May 2009) Log Message: ----------- Added Categorical.mxml Created the interface. Some part is tested, some part needs to be tested. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-22 00:49:28 UTC (rev 145) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -294,8 +294,8 @@ { currentState = "question"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(obj); - questionGroupInfo.reset(); + var questionInfo:Question = Question(obj); + questionInfo.reset(); btnsaveModule.enabled = false; btnsaveBlock.enabled = false; @@ -334,8 +334,8 @@ var newNode:XML = <question/>; newNode.setLocalName("question"); - newNode.@header = questionInfo.getHeader(); - newNode.@description = questionInfo.getDescription(); + // newNode.@header = questionInfo.getHeader(); + //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); var block:XMLList =company.module.block.(@name == node.@name); @@ -480,7 +480,7 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" /> <mx:Spacer width="40"/> </mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + /*public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + }*/ + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (type.selectedValue == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + //validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + + type.selectedValue =""; + } + + private function showRelativeFields():void + { + + vboxHeaders.visible = true; + vboxSecondHeader.visible = true; + + } + + private function showSimpleFields():void + { + Alert.show("Simple"); + } + + ]]> + </mx:Script> + + <mx:FormHeading label="Categorical"/> + <mx:FormItem label="Type:"> + <mx:RadioButtonGroup id="type"/> + + <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> + <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> + </mx:FormItem> + <mx:VBox> + + <mx:VBox id="vboxHeaders" visible="false"> + <mx:FormItem label="Header1:"> + <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:FormItem label="Header2:"> + <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:FormItem label="Choice for Header1:"> + <mx:TextInput id="txtchoiceHeader1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnaddChoice1" label="Add Choice"/> + + </mx:VBox> + + <mx:HBox visible="false" id="vboxSecondHeader"> + <mx:VBox> + <mx:Label text="" id="lblHeader1"/> + <mx:List id="lstHeader1" wordWrap="true"/> + <mx:FormItem label="Choice for Header2:"> + <mx:TextInput id="txtaddChoice2" change="{validateForm(event)}"/> + </mx:FormItem> + + </mx:VBox> + <mx:VBox> + <mx:Label text="" id="lblHeader2"/> + <mx:List id="lstHeader2" wordWrap="true"/> + <mx:Button id="btnaddChoice2" label="Add Choice"/> + </mx:VBox> + + </mx:HBox> + + </mx:VBox> + + +</mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-22 00:49:28 UTC (rev 145) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%"> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> <mx:Script> <![CDATA[ import mx.validators.NumberValidator; @@ -52,10 +52,28 @@ // helper method and update the value of formIsValid // accordingly. validate(validateSeqNo); + return formIsValid; } + private function showQuestionType():void + { + + currentState = "categorical"; + var obj:DisplayObject = canvasQuestionType.getChildAt(0); + //Alert.show("selected item is: " + cmbType.selectedItem); + if(cmbType.selectedItem == "Categorical") + { + + var categoricalInfo:Categorical = Categorical(obj); + categoricalInfo.reset(); + + + } + } + + private function validate(validator:Validator):Boolean { // Get a reference to the component that is the @@ -94,7 +112,24 @@ ]]> </mx:Script> + <mx:states> + <mx:State name="categorical"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Categorical id="categorical"/> + </mx:AddChild> + </mx:State> + <!--<mx:State name="psychometric"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Psychometric id="psychometri"/> + </mx:AddChild> + </mx:State>--> + + <mx:State name="none"/> + + </mx:states> + + <mx:FormHeading label="QuestionGroup"/> <mx:FormItem label="Sequence Number:"> <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> @@ -103,22 +138,23 @@ <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Select Question Type:"> - <mx:ComboBox id="cmbType" change="{validateForm(event)}" width="100%"> + <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> <mx:ArrayCollection> <mx:String>-Select-</mx:String> <mx:String>Categorical</mx:String> <mx:String>Psychometric</mx:String> + <mx:String>Text</mx:String> </mx:ArrayCollection> </mx:ComboBox> </mx:FormItem> - <mx:FormItem> - <mx:Panel width="250" height="200" layout="absolute"> + + <mx:Canvas id="canvasQuestionType" height="100%"/> - </mx:Panel> - </mx:FormItem> + + <mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-22 00:49:37
|
Revision: 145 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=145&view=rev Author: seematalele Date: 2009-05-22 00:49:28 +0000 (Fri, 22 May 2009) Log Message: ----------- Added Block and QuestionGroup custom component. Working perfectly. Validation is also done. Added Question component also but it needs lot of improvement. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/Block.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-21 22:53:03 UTC (rev 144) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -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, #80FFAA]" - width="760" height="510" clipContent="false" layout="absolute" currentState="none"> + width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ import mx.effects.Fade; @@ -9,22 +9,28 @@ import mx.collections.XMLListCollection; import mx.controls.Alert; +/* id field of module, block and questiongroup and questions should come from database, +so when module info is transfered to the server, it should return the id for that module */ + [Bindable] private var company:XML = - <list> - <module title="Preexperiment" sequenceNo="200"> + + <module title="Preexperiment" sequenceNo="200" id="1"> <block name="John H"> - <item name="item"/> + <questiongroup header="hello" description="world" sequenceNo="200" id="1"/> + </block> - <block name="Sam K"/> + <block name="Sam K" /> + <block name="Erin M"/> + <block name="Ann B"/> </module> - <!--<module title="Operations" code="400"> + <module title="Operations" code="400"> <block name="Bill C"/> <block name="Jill W"/> </module> - <module title="Engineering" code="300"> + <!-- <module title="Engineering" code="300"> <block name="Erin M"/> <block name="Ann B"/> @@ -34,21 +40,25 @@ [Bindable] private var companyData:XMLListCollection = new XMLListCollection(company.module); - private function treeLabel(item:Object):String + private function treeLabel(item:Object):String { var node:XML = XML(item); if( node.localName() == "module" ) - return node.@title; - else + + + else if( node.localName() == "block" ) return node.@name; - + else if( node.localName() == "questiongroup" ) + return node.@header; + else + return node.@name; + } private function addModule():void - { currentState = "module"; @@ -56,6 +66,10 @@ var moduleInfo:Module = Module(obj); moduleInfo.reset(); btnsaveModule.enabled = true; + + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; /*var saveModule:Button = new Button; var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); Alert.show(isExists.toString()); @@ -71,7 +85,7 @@ private function saveModule(event:Event):void { - //btnsaveModule.enabled = false; + var obj:DisplayObject = pnlComponent.getChildAt(1); var moduleInfo:Module = Module(obj); @@ -92,6 +106,7 @@ company.appendChild(newNode); currentState = "none"; btnsaveModule.enabled = false; + // pnlComponent.removeChildAt(1); } @@ -111,14 +126,22 @@ private function addBlock():void { + currentState = "block"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(obj); + blockInfo.reset(); + btnsaveBlock.enabled = true; + btnsaveModule.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + //currentState = "block"; - btnsaveModule.enabled = true; - + - var node:XML = tree.selectedItem as XML; + /*var node:XML = tree.selectedItem as XML; - Alert.show("Selected node is " + node.@title); + Alert.show("Selected node is " + node.@title);*/ /* var newNode:XML = <block/>; newNode.@name = "block1"; @@ -131,30 +154,206 @@ } - private function addItem():void - + private function saveBlock(event:Event):void { - var newNode:XML = <item/>; - newNode.@name = "item1"; - var module:XMLList =company.module.(@title == "first module"); - var i:int; - for (i = 0; i < module.length(); i++) - { - if(module[i].block.@name == "block1") - { - var item:XMLList =company.module.block.(@name == "block1"); - if( item.length() > 0 ) - { + + var obj:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(obj); + + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the module from tree to which block should be added."); + } + else + { - item[0].appendChild(newNode); - - } - } - } - - } + var isBlockFormValid:Boolean = blockInfo.validateForm(event); + if(isBlockFormValid) + { + var durationflag:Boolean = this.isDurationValid(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()); + if(durationflag) + { + Alert.show("Please enter the valid duration for the given block."); + } + else + { + var newNode:XML = <block/> + newNode.setLocalName("block"); + newNode.@name=blockInfo.getName(); + newNode.@sequenceNo =blockInfo.getSequenceNo(); + var module:XMLList =company.module.(@title == node.@title); + if( module.length() > 0 ) + { + module[0].appendChild(newNode); + currentState = "none"; + btnsaveBlock.enabled = false; + + } + + } + } + else + { + Alert.show("Please fill the form correctly"); + } + } + + } - + private function addQuestionGroup():void + { + currentState = "questionGroup"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = true; + btnsaveQuestion.enabled = false; + + + } + + private function saveQuestionGroup(event:Event):void + { + + + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the block from tree to which Question Group should be added."); + return; + } + else + { + + //if(tree.getParentItem(tree.selectedItem) == null) + if(node.localName() == "module") + { + Alert.show("You can not add QuestionGroup to Module."); + return; + } + else + { + if(node.localName() == "questiongroup" ) + { + Alert.show("You can not add QuestionGroup to QuestionGroup."); + return; + } + + else + { + //find out the parent module + var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + var isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); + + if(isQuestionGroupFormValid) + { + + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + newNode.@header = questionGroupInfo.getHeader(); + newNode.@description = questionGroupInfo.getDescription(); + newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); + + /*var module:XMLList = company.module.(@title == parentModule.@title); + //Alert.show("ParentModule node is: " + parentModule.@title); + Alert.show("ParentBlock node is: " + module.children().length()); + var blockList:XMLList = module.children(); + var i:int; + //Alert.show(module.length() + "is length of module"); + for (i = 0; i < blockList.length(); i++) + { + if(blockList[i].block.@name == node.@name) + { + Alert.show(blockList[i].block.@name + "is found"); + */ + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestionGroup.enabled = false; + + } + //} + //} + } + } + } + } + } + private function addQuestion():void + { + currentState = "question"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = true; + } + + private function saveQuestion(event:Event):void + { + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the block from tree to which Question Group should be added."); + return; + } + else + { + + //if(tree.getParentItem(tree.selectedItem) == null) + if(node.localName() != "questiongroup") + { + Alert.show("You can add Question to QuestionGroup only."); + return; + } + else + { + //find out the parent module + var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionInfo:Question = Question(obj); + var isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); + + if(isQuestionGroupFormValid) + { + + var newNode:XML = <question/>; + newNode.setLocalName("question"); + newNode.@header = questionInfo.getHeader(); + newNode.@description = questionInfo.getDescription(); + newNode.@sequenceNo = questionInfo.getSequenceNo(); + + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestion.enabled = false; + + } + } + } + } + + } + + private function removeEmployee():void { var node:XML = XML(tree.selectedItem); @@ -193,27 +392,36 @@ </mx:AddChild> </mx:State> - <!--<mx:State name="block"> + <mx:State name="block"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + <comp:Block id="block"/> </mx:AddChild> </mx:State> - <mx:State name="item"> + <mx:State name="questionGroup"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:PlannerPage id="planner"/> + <comp:QuestionGroup id="questionGroup"/> </mx:AddChild> - </mx:State>--> + </mx:State> + <mx:State name="question"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Question id="question"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"/> </mx:states> - + <mx:Spacer width="40"/> <mx:HDividedBox width="100%" height="100%" id="hdMain"> + <mx:Spacer width="40"/> <mx:VBox height="100%" id="vboxLeft"> + <mx:Spacer width="40"/> <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" showRoot="true" change="{treeChanged(event)}" - height="224" width="179" /> + height="50%" width="80%" textAlign="center"/> <mx:Canvas height="35%"> <mx:Grid x="0" y="0"> @@ -239,14 +447,26 @@ </mx:GridRow> <mx:GridRow width="100%" height="100%"> <mx:GridItem width="100%" height="100%"> - <mx:Button label="Add Item" id="butAddItem" click="{addItem()}"/> + <mx:Button label="Add QuestionGroup" id="butAddQuestionGroup" click="{addQuestionGroup()}"/> </mx:GridItem> + <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Item" id="butremItem"/> + <mx:Button label="Remove QuestionGroup" id="butremQuestionGroup"/> </mx:GridItem> <mx:GridItem width="100%" height="100%"> </mx:GridItem> </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + </mx:GridItem> + + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Question" id="butremQuestion"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> </mx:Grid> </mx:Canvas> @@ -256,10 +476,12 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveModule" label="Save Module" enabled="false" click="{saveModule(event)}"/> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" /> + <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" click="{saveBlock(event)}"/> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveItem" enabled="false" label="Save Item" /> + <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> + <mx:Spacer width="40"/> </mx:HBox> </mx:Panel> Added: mentalmodels/trunk/flex/src/customComponents/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Block.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Block Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Description:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-21 22:53:03 UTC (rev 144) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -113,6 +113,7 @@ ]]> </mx:Script> + <mx:FormHeading label="Module Information"/> <mx:FormItem label="Sequence Number:"> <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> Added: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + } + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtQuestion.text = ""; + + txtSeqNo.errorString =""; + txtQuestion.errorString =""; + + } + + ]]> + </mx:Script> + + <mx:FormHeading label="QuestionGroup"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Question:"> + <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Select Question Type:"> + <mx:ComboBox id="cmbType" change="{validateForm(event)}" width="100%"> + <mx:ArrayCollection> + <mx:String>-Select-</mx:String> + <mx:String>Categorical</mx:String> + <mx:String>Psychometric</mx:String> + </mx:ArrayCollection> + </mx:ComboBox> + + </mx:FormItem> + <mx:FormItem> + <mx:Panel width="250" height="200" layout="absolute"> + + </mx:Panel> + </mx:FormItem> + + + +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getHeader():String + { + return txtHeader.text; + } + public function getDescription():String + { + return txtDescription.text; + } + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && txtDescription.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtHeader.text = ""; + txtDescription.text =""; + txtSeqNo.errorString =""; + txtHeader.errorString =""; + txtDescription.errorString =""; + + } + + ]]> + </mx:Script> + + <mx:FormHeading label="QuestionGroup"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Header:"> + <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Decsription:"> + <mx:TextArea id="txtDescription" change="{validateForm(event)}" width="100%" height="100"/> + </mx:FormItem> + + +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-05-21 22:53:21
|
Revision: 144 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=144&view=rev Author: alllee Date: 2009-05-21 22:53:03 +0000 (Thu, 21 May 2009) Log Message: ----------- slightly cleaned up version of JMF's sample code for JpegImagesToMovie class (from http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/JpegImagesToMovie.html). Significant modifications to come, going to see if it's possible to take snapshots via the ServerDataModel to generate an image to feed into ImageSourceStream... Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreator.java 2009-05-21 22:53:03 UTC (rev 144) @@ -0,0 +1,541 @@ +package edu.asu.commons.foraging.util; + +/* + * Modified source from: + * @(#)JpegImagesToMovie.java 1.3 01/03/13 + * + * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved. + * + * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, + * modify and redistribute this software in source and binary code form, + * provided that i) this copyright notice and license appear on all copies of + * the software; and ii) Licensee does not utilize the software in a manner + * which is disparaging to Sun. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY + * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE + * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS + * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, + * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER + * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF + * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * This software is not designed or intended for use in on-line control of + * aircraft, air traffic, aircraft navigation or aircraft communications; or in + * the design, construction, operation or maintenance of any nuclear + * facility. Licensee represents and warrants that it will not use or + * redistribute the Software for such purposes. + */ + +import java.awt.Dimension; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.List; + +import javax.media.Buffer; +import javax.media.ConfigureCompleteEvent; +import javax.media.ControllerEvent; +import javax.media.ControllerListener; +import javax.media.DataSink; +import javax.media.EndOfMediaEvent; +import javax.media.Format; +import javax.media.Manager; +import javax.media.MediaLocator; +import javax.media.PrefetchCompleteEvent; +import javax.media.Processor; +import javax.media.RealizeCompleteEvent; +import javax.media.ResourceUnavailableEvent; +import javax.media.Time; +import javax.media.control.TrackControl; +import javax.media.datasink.DataSinkErrorEvent; +import javax.media.datasink.DataSinkEvent; +import javax.media.datasink.DataSinkListener; +import javax.media.datasink.EndOfStreamEvent; +import javax.media.format.VideoFormat; +import javax.media.protocol.ContentDescriptor; +import javax.media.protocol.DataSource; +import javax.media.protocol.FileTypeDescriptor; +import javax.media.protocol.PullBufferDataSource; +import javax.media.protocol.PullBufferStream; + +/** + * This program takes a list of JPEG image files and converts them into a + * QuickTime movie. + */ +public class MovieCreator implements ControllerListener, DataSinkListener { + + public boolean createMovie(int width, int height, int frameRate, List<String> inFiles, MediaLocator outML) { + ImageDataSource ids = new ImageDataSource(width, height, frameRate, inFiles); + + Processor processor; + try { + System.err.println("- create processor for the image datasource ..."); + processor = Manager.createProcessor(ids); + } catch (Exception e) { + System.err + .println("Yikes! Cannot create a processor from the data source."); + return false; + } + + processor.addControllerListener(this); + + // Put the Processor into configured state so we can set + // some processing options on the processor. + processor.configure(); + if (!waitForState(processor, Processor.Configured)) { + System.err.println("Failed to configure the processor."); + return false; + } + + // Set the output content descriptor to QuickTime. + processor.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.QUICKTIME)); + + // Query for the processor for supported formats. + // Then set it on the processor. + TrackControl[] trackControls = processor.getTrackControls(); + Format[] formats = trackControls[0].getSupportedFormats(); + if (formats == null || formats.length <= 0) { + System.err.println("The mux does not support the input format: " + + trackControls[0].getFormat()); + return false; + } + + trackControls[0].setFormat(formats[0]); + + System.err.println("Setting the track format to: " + formats[0]); + + // We are done with programming the processor. Let's just + // realize it. + processor.realize(); + if (!waitForState(processor, Processor.Realized)) { + System.err.println("Failed to realize the processor."); + return false; + } + + // Now, we'll need to create a DataSink. + DataSink dataSink; + if ((dataSink = createDataSink(processor, outML)) == null) { + System.err.println("Failed to create a DataSink for the given output MediaLocator: " + + outML); + return false; + } + + dataSink.addDataSinkListener(this); + fileDone = false; + + System.err.println("start processing..."); + + // OK, we can now start the actual transcoding. + try { + processor.start(); + dataSink.start(); + } catch (IOException e) { + System.err.println("IO error during processing"); + e.printStackTrace(); + return false; + } + + // Wait for EndOfStream event. + waitForFileDone(); + + // Cleanup. + try { + dataSink.close(); + } catch (Exception e) { + e.printStackTrace(); + } + processor.removeControllerListener(this); + + System.err.println("...done processing."); + + return true; + } + + /** + * Create the DataSink. + */ + DataSink createDataSink(Processor processor, MediaLocator outML) { + + DataSource ds = processor.getDataOutput(); + + if (ds == null) { + System.err.println("Something is really wrong: the processor does not have an output DataSource"); + return null; + } + + DataSink dataSink; + + try { + System.err.println("- create DataSink for: " + outML); + dataSink = Manager.createDataSink(ds, outML); + dataSink.open(); + } catch (Exception e) { + System.err.println("Cannot create the DataSink: " + e); + return null; + } + + return dataSink; + } + + Object waitSync = new Object(); + boolean stateTransitionOK = true; + + /** + * Block until the processor has transitioned to the given state. Return + * false if the transition failed. + */ + boolean waitForState(Processor p, int state) { + synchronized (waitSync) { + try { + while (p.getState() < state && stateTransitionOK) + waitSync.wait(); + } catch (Exception e) { + } + } + return stateTransitionOK; + } + + /** + * Controller Listener. + */ + public void controllerUpdate(ControllerEvent event) { + + if (event instanceof ConfigureCompleteEvent + || event instanceof RealizeCompleteEvent + || event instanceof PrefetchCompleteEvent) { + synchronized (waitSync) { + stateTransitionOK = true; + waitSync.notifyAll(); + } + } else if (event instanceof ResourceUnavailableEvent) { + synchronized (waitSync) { + stateTransitionOK = false; + waitSync.notifyAll(); + } + } else if (event instanceof EndOfMediaEvent) { + event.getSourceController().stop(); + event.getSourceController().close(); + } + } + + Object waitFileSync = new Object(); + boolean fileDone = false; + boolean fileSuccess = true; + + /** + * Block until file writing is done. + */ + boolean waitForFileDone() { + synchronized (waitFileSync) { + try { + while (!fileDone) + waitFileSync.wait(); + } catch (Exception e) { + } + } + return fileSuccess; + } + + /** + * Event handler for the file writer. + */ + public void dataSinkUpdate(DataSinkEvent evt) { + + if (evt instanceof EndOfStreamEvent) { + synchronized (waitFileSync) { + fileDone = true; + waitFileSync.notifyAll(); + } + } else if (evt instanceof DataSinkErrorEvent) { + synchronized (waitFileSync) { + fileDone = true; + fileSuccess = false; + waitFileSync.notifyAll(); + } + } + } + + public static void main(String args[]) { + + if (args.length == 0) + usage(); + + // Parse the arguments. + int i = 0; + int width = -1, height = -1, frameRate = 1; + List<String> inputFiles = new ArrayList<String>(); + String outputURL = null; + + while (i < args.length) { + + if (args[i].equals("-w")) { + i++; + if (i >= args.length) + usage(); + width = new Integer(args[i]).intValue(); + } else if (args[i].equals("-h")) { + i++; + if (i >= args.length) + usage(); + height = new Integer(args[i]).intValue(); + } else if (args[i].equals("-f")) { + i++; + if (i >= args.length) + usage(); + frameRate = new Integer(args[i]).intValue(); + } else if (args[i].equals("-o")) { + i++; + if (i >= args.length) + usage(); + outputURL = args[i]; + } else { + inputFiles.add(args[i]); + } + i++; + } + + if (outputURL == null || inputFiles.size() == 0) + usage(); + + // Check for output file extension. + if (!outputURL.endsWith(".mov") && !outputURL.endsWith(".MOV")) { + System.err + .println("The output file extension should end with a .mov extension"); + usage(); + } + + if (width < 0 || height < 0) { + System.err.println("Please specify the correct image size."); + usage(); + } + + // Check the frame rate. + if (frameRate < 1) + frameRate = 1; + + // Generate the output media locators. + MediaLocator oml; + + if ((oml = createMediaLocator(outputURL)) == null) { + System.err.println("Cannot build media locator from: " + outputURL); + System.exit(0); + } + + MovieCreator imageToMovie = new MovieCreator(); + imageToMovie.createMovie(width, height, frameRate, inputFiles, oml); + + System.exit(0); + } + + static void usage() { + System.err.println("Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL> <input JPEG file 1> <input JPEG file 2> ..."); + System.exit(-1); + } + + /** + * Create a media locator from the given string. + */ + static MediaLocator createMediaLocator(String url) { + + MediaLocator ml; + + if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null) + return ml; + + if (url.startsWith(File.separator)) { + if ((ml = new MediaLocator("file:" + url)) != null) + return ml; + } else { + String file = "file:" + System.getProperty("user.dir") + + File.separator + url; + if ((ml = new MediaLocator(file)) != null) + return ml; + } + + return null; + } + + // ///////////////////////////////////////////// + // + // Inner classes. + // ///////////////////////////////////////////// + + /** + * A DataSource to read from a list of JPEG image files and turn that into a + * stream of JMF buffers. The DataSource is not seekable or positionable. + */ + class ImageDataSource extends PullBufferDataSource { + + ImageSourceStream streams[]; + + ImageDataSource(int width, int height, int frameRate, List<String> images) { + streams = new ImageSourceStream[1]; + streams[0] = new ImageSourceStream(width, height, frameRate, images); + } + + public void setLocator(MediaLocator source) { + } + + public MediaLocator getLocator() { + return null; + } + + /** + * Content type is of RAW since we are sending buffers of video frames + * without a container format. + */ + public String getContentType() { + return ContentDescriptor.RAW; + } + + public void connect() { + } + + public void disconnect() { + } + + public void start() { + } + + public void stop() { + } + + /** + * Return the ImageSourceStreams. + */ + public PullBufferStream[] getStreams() { + return streams; + } + + /** + * We could have derived the duration from the number of frames and + * frame rate. But for the purpose of this program, it's not necessary. + */ + public Time getDuration() { + return DURATION_UNKNOWN; + } + + public Object[] getControls() { + return new Object[0]; + } + + public Object getControl(String type) { + return null; + } + } + + /** + * The source stream to go along with ImageDataSource. + */ + class ImageSourceStream implements PullBufferStream { + List<String> images; + int width, height; + VideoFormat format; + + int nextImage = 0; // index of the next image to be read. + boolean ended = false; + public ImageSourceStream(int width, int height, int frameRate, + List<String> images) { + this.width = width; + this.height = height; + this.images = images; + + format = new VideoFormat(VideoFormat.JPEG, new Dimension(width, + height), Format.NOT_SPECIFIED, Format.byteArray, + (float) frameRate); + } + + /** + * We should never need to block assuming data are read from files. + */ + public boolean willReadBlock() { + return false; + } + + /** + * This is called from the Processor to read a frame worth of video + * data. + */ + public void read(Buffer buf) throws IOException { + + // Check if we've finished all the frames. + if (nextImage >= images.size()) { + // We are done. Set EndOfMedia. + System.err.println("Done reading all images."); + buf.setEOM(true); + buf.setOffset(0); + buf.setLength(0); + ended = true; + return; + } + + String imageFile = (String) images.get(nextImage); + nextImage++; + + System.err.println(" - reading image file: " + imageFile); + + // Open a random access file for the next image. + RandomAccessFile raFile; + raFile = new RandomAccessFile(imageFile, "r"); + + byte data[] = null; + + // Check the input buffer type & size. + + if (buf.getData() instanceof byte[]) + data = (byte[]) buf.getData(); + + // Check to see the given buffer is big enough for the frame. + if (data == null || data.length < raFile.length()) { + data = new byte[(int) raFile.length()]; + buf.setData(data); + } + + // Read the entire JPEG image from the file. + raFile.readFully(data, 0, (int) raFile.length()); + + System.err.println(" read " + raFile.length() + " bytes."); + + buf.setOffset(0); + buf.setLength((int) raFile.length()); + buf.setFormat(format); + buf.setFlags(buf.getFlags() | Buffer.FLAG_KEY_FRAME); + + // Close the random access file. + raFile.close(); + } + + /** + * Return the format of each video frame. That will be JPEG. + */ + public Format getFormat() { + return format; + } + + public ContentDescriptor getContentDescriptor() { + return new ContentDescriptor(ContentDescriptor.RAW); + } + + public long getContentLength() { + return 0; + } + + public boolean endOfStream() { + return ended; + } + + public Object[] getControls() { + return new Object[0]; + } + + public Object getControl(String type) { + return null; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2009-05-21 20:08:37
|
Migrate dev.commons.asu.edu infrastructure to virtual host ---------------------------------------------------------- Key: VC-6 URL: https://dev.commons.asu.edu/jira/browse/VC-6 Project: Virtual Commons Issue Type: Task Reporter: Allen Lee Assignee: Allen Lee Migrate all infrastructure webapps from dev.commons.asu.edu to the virtual host. This includes Confluence, JIRA, Archiva, and Crowd. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://dev.commons.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <kj...@us...> - 2009-05-20 20:23:32
|
Revision: 143 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=143&view=rev Author: kjonas Date: 2009-05-20 20:23:22 +0000 (Wed, 20 May 2009) Log Message: ----------- created *Question components and corresponding actionscript files Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml Added: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml (rev 0) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + + <comp:TextQuestion id="question1"/> + <comp:CategoricalQuestion id="question2"/> + <comp:ForecastQuestion id="question3"/> + +</mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:actionscript="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> <!--this is a test file, don't hardcode everything like this, it's terrible practice--> @@ -18,24 +18,24 @@ </mx:ArrayCollection> <mx:ArrayCollection id="q1"> - <actionscript:Psychometric choices="{ch1}" numberOfIntervals="5" question="Question1"/> + <as:PsychometricQuestion choices="{ch1}" numberOfIntervals="5" question="Question1"/> </mx:ArrayCollection> <mx:ArrayCollection id="q2"> - <actionscript:Psychometric choices="{ch2}" numberOfIntervals="5" question="Question2"/> + <as:PsychometricQuestion choices="{ch2}" numberOfIntervals="5" question="Question2"/> </mx:ArrayCollection> <mx:ArrayCollection id="q3"> - <actionscript:Psychometric choices="{ch3}" numberOfIntervals="5" question="Question3"/> + <as:PsychometricQuestion choices="{ch3}" numberOfIntervals="5" question="Question3"/> </mx:ArrayCollection> <mx:ArrayCollection id="qgrs"> - <actionscript:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> - <actionscript:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> - <actionscript:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> </mx:ArrayCollection> - <actionscript:Block id="blk" questionGroups="{qgrs}"/> + <as:Block id="blk" questionGroups="{qgrs}"/> Added: mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] + public class CategoricalQuestion extends Question + { + public var choices:Object; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingQuestion")] + public class ForecastingQuestion extends Question + { + public var dayNo:int; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-20 20:23:22 UTC (rev 143) @@ -39,7 +39,6 @@ public function PageDisplay(currBlock:Block, minPagesRead:Number=1) { this.currBlock = currBlock; - this.pages = new ArrayCollection(); this.minPagesRead = minPagesRead; this.currentPageNumber = 0; this.highestPageReached = currentPageNumber; @@ -49,6 +48,9 @@ public function loadPages():void { + this.pages = new ArrayCollection(); + + for(var group:int=0; group<currBlock.questionGroups.length; group++) { var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); @@ -65,24 +67,24 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is actionscript.Forecasting) + if(tempQuestion is actionscript.ForecastingQuestion) { // ??? how is this going to be worked in ??? //tempBox.addChild(new mx.containers.HBox()); } - else if(tempQuestion is Categorical) + else if(tempQuestion is actionscript.CategoricalQuestion) { - var tempCat:Categorical = Categorical(tempQuestion); + var tempCat:CategoricalQuestion = CategoricalQuestion(tempQuestion); var cq:ComboBox = new ComboBox(); cq.id = "q"+question; cq.dataProvider = tempCat.choices; cq.initialize(); tempBox.addChild(cq); } - else if(tempQuestion is Psychometric) + else if(tempQuestion is actionscript.PsychometricQuestion) { - var tempPsych:Psychometric = Psychometric(tempQuestion); - var pq:PsychometricQuestion = new PsychometricQuestion(); + var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); + var pq:customComponents.PsychometricQuestion = new customComponents.PsychometricQuestion(); pq.id = "q"+question; pq.labels = tempPsych.choices; pq.slider.maxValue = 3; Added: mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,13 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] + public class PsychometricQuestion extends Question + { + public var scale:String; + public var numberOfIntervals:int; + public var choices:ArrayCollection; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Label id="header"/> + <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> + <mx:ComboBox id="comboSpecific" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> + + + <mx:ArrayCollection id="topics"> + <mx:String>topic0</mx:String> + <mx:String>topic1</mx:String> + <mx:String>topic2</mx:String> + </mx:ArrayCollection> + + <!-- each element of this ArrayCollection will serve as a dataProvider --> + <mx:ArrayCollection id="specifics"> + <mx:ArrayCollection id="topic0"> + <mx:String>specific0.0</mx:String> + <mx:String>specific0.1</mx:String> + <mx:String>specific0.2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic1"> + <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>specific2.0</mx:String> + <mx:String>specific2.1</mx:String> + <mx:String>specific2.2</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + + <mx:Script> + <![CDATA[ + + public function fix(index:Number, list:ArrayCollection):Number + { + if( index < 0 ) return 0; + if( index >= list.length ) return list.length - 1; + return index; + } + + ]]> + </mx:Script> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label id="header"/> + <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> + <mx:Button id="next" label="Next" click="testNext()"/> + + <mx:Script> + <![CDATA[ + import mx.messaging.channels.StreamingAMFChannel; + import customComponents.*; + import mx.collections.ArrayCollection; + + public function init():void + { + for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); + } + + public function testNext(evt:Event=null):void + { + if(!forecastPeople.isFinished()) return; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + this.addChild(f2); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -6,6 +6,8 @@ import mx.collections.ArrayCollection; public var labels:ArrayCollection; + [Bindable] + public var maxValue:Number; public function init():void { @@ -49,6 +51,6 @@ <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"/> + <comp:Slider id="slider" initialize="false" maxValue="{maxValue}"/> </mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> + + <mx:ArrayCollection id="questions"/> + + <mx:Script> + <![CDATA[ + import actionscript.Question; + + public function getItemAt(index:Number):Question + { + if(questions != null && questions.length > 0) + { + return questions.getItemAt(index) as Question; + } + return null; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Label id="header"/> + <mx:TextInput id="text"/> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-05-19 17:42:41
|
Revision: 142 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=142&view=rev Author: alllee Date: 2009-05-19 17:42:25 +0000 (Tue, 19 May 2009) Log Message: ----------- adding new weighted spatial metric calculation to save file converter Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-05-19 01:11:57 UTC (rev 141) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-05-19 17:42:25 UTC (rev 142) @@ -230,13 +230,29 @@ clientDistribution.tokens++; } } - for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { - Identifier id = entry.getKey(); - ClientSpatialDistribution spatialDistribution = entry.getValue(); - spatialDistribution.calculateStandardDeviation(); - writer.println(String.format("%s, %s, %s", id, spatialDistribution.standardizedColumnDistribution, spatialDistribution.standardizedRowDistribution)); - System.err.println("spatial distribution for id: " + id + spatialDistribution); + // calculate for group + ArrayList<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + for (GroupDataModel group: groups) { + writer.println("Group # " + groups.indexOf(group) + "\n----------------------"); + writer.println("Identifier, # tokens, row stdev, column stdev"); + double groupWeightedSpatialMetric = 0.0d; + int totalTokens = 0; + for (Identifier id: group.getClientIdentifiers()) { + ClientSpatialDistribution spatialDistribution = clientSpatialDistributionMap.get(id); + spatialDistribution.calculateStandardDeviation(); + groupWeightedSpatialMetric += spatialDistribution.weightedSpatialMetric; + writer.println(String.format("%s, %s, %s, %s", id, spatialDistribution.tokens, spatialDistribution.rowStandardDeviation, spatialDistribution.columnStandardDeviation)); + totalTokens += spatialDistribution.tokens; + } + groupWeightedSpatialMetric /= totalTokens; + writer.println(groupWeightedSpatialMetric); } +// for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { +// Identifier id = entry.getKey(); +// ClientSpatialDistribution spatialDistribution = entry.getValue(); +// spatialDistribution.calculateStandardDeviation(); +// writer.println(String.format("%s, %s", id, spatialDistribution.weightedSpatialMetric)); +// } } @Override @@ -250,10 +266,11 @@ private double standardizedRowDistribution; private int[] columnCounts; private double standardizedColumnDistribution; - private int tokens = 0; private double rowStandardDeviation; private double columnStandardDeviation; + private double weightedSpatialMetric; + private ClientSpatialDistribution(Dimension boardSize) { rowCounts = new int[boardSize.height]; columnCounts = new int[boardSize.width]; @@ -269,6 +286,7 @@ double averageTokens = (double) tokens / (double) rowCounts.length; standardizedRowDistribution = (rowStandardDeviation / averageTokens); standardizedColumnDistribution = (columnStandardDeviation / averageTokens); + weightedSpatialMetric = tokens * (rowStandardDeviation + columnStandardDeviation); } private double stdDev(int[] counts) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-19 01:12:06
|
Revision: 141 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=141&view=rev Author: seematalele Date: 2009-05-19 01:11:57 +0000 (Tue, 19 May 2009) Log Message: ----------- Made changes in Module.mxml and InitialiseDatabase.mxml. Worked on - Validation for module - Tested and working perfectly. Added functionality of getting selected current module in the tree. This functionality is used to add block for that particular module. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-15 22:36:12 UTC (rev 140) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-19 01:11:57 UTC (rev 141) @@ -4,6 +4,7 @@ width="760" height="510" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ + import mx.effects.Fade; import mx.collections.XMLListCollection; import mx.controls.Alert; @@ -51,48 +52,83 @@ { currentState = "module"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(obj); + moduleInfo.reset(); + btnsaveModule.enabled = true; /*var saveModule:Button = new Button; - saveModule.label ="Save Module"; + var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); + Alert.show(isExists.toString()); + if(!pnlComponent.contains(saveModule as DisplayObject)) + { + saveModule.label ="Save Module"; - pnlComponent.addChild(saveModule as DisplayObject); + pnlComponent.addChild(saveModule as DisplayObject); + } //saveModule.*/ } - private function saveModule():void + private function saveModule(event:Event):void { - - Alert.show("in add module"); + //btnsaveModule.enabled = false; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(obj); - var newNode:XML = <module/> - newNode.setLocalName("module"); + var isModuleFormValid:Boolean = moduleInfo.validateForm(event); + if(isModuleFormValid) + { + var durationflag:Boolean = this.isDurationValid(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds()); + if(durationflag) + { + Alert.show("Please enter the valid duration for the given module."); + } + else + { + var newNode:XML = <module/> + newNode.setLocalName("module"); + newNode.@title=moduleInfo.getName(); + newNode.@sequenceNo =moduleInfo.getSequenceNo(); + company.appendChild(newNode); + currentState = "none"; + btnsaveModule.enabled = false; + + } + + } + else + { + Alert.show("Please fill the form correctly"); + } - newNode.@title="first module"; - newNode.@sequenceNo ="1"; - - company.appendChild(newNode); - <!-- var newNode:XML = <employee/>; - // newNode.@name = empName.text; - var dept:XMLList =company.department.(@title == "Operations"); - if( dept.length() > 0 ) { - - dept[0].appendChild(newNode); - // empName.text = ""; - }--> } + public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean + { + return (hours == 0 && minutes == 0 && seconds == 0); + + } - private function addBlock():void { - var newNode:XML = <block/>; + //currentState = "block"; + btnsaveModule.enabled = true; + + + + var node:XML = tree.selectedItem as XML; + + Alert.show("Selected node is " + node.@title); + + /* var newNode:XML = <block/>; newNode.@name = "block1"; var module:XMLList =company.module.(@title == "first module"); if( module.length() > 0 ) { module[0].appendChild(newNode); // empName.text = ""; - } + }*/ + } private function addItem():void @@ -134,13 +170,26 @@ } } + + private function treeChanged(event:Event):void + { + /* var selectedNode:int; + + //selectedNode=Tree(event.target).selectedItem; + var obj:DisplayObject = tree.getChildAt(selectedNode); + var newNode:XML = XML(obj); + Alert.show("Selected node is " + newNode.toString());*/ + + } + + ]]> </mx:Script> <mx:states> <mx:State name="module"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:Module id="module"/> + <comp:Module id="module"/> </mx:AddChild> </mx:State> @@ -162,9 +211,9 @@ <mx:HDividedBox width="100%" height="100%" id="hdMain"> <mx:VBox height="100%" id="vboxLeft"> <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" - labelFunction="treeLabel" - showRoot="true" - height="224" width="179"/> + labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" + showRoot="true" change="{treeChanged(event)}" + height="224" width="179" /> <mx:Canvas height="35%"> <mx:Grid x="0" y="0"> @@ -202,9 +251,19 @@ </mx:Canvas> </mx:VBox> - <mx:Panel id = "pnlComponent" height="100%"> - + <mx:Panel id = "pnlComponent" height="100%" layout="vertical"> + <mx:HBox width="100%"> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveModule" label="Save Module" enabled="false" click="{saveModule(event)}"/> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" /> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveItem" enabled="false" label="Save Item" /> + <mx:Spacer width="40"/> + + </mx:HBox> </mx:Panel> </mx:HDividedBox> + </mx:Application> Modified: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-15 22:36:12 UTC (rev 140) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-19 01:11:57 UTC (rev 141) @@ -1,27 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> - <!--<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" > - - <mx:Label text="Module Information" fontWeight="bold" width="150" textAlign="center" fontSize="12"/> - <mx:HBox> - <mx:Label text="Sequence Number:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtSeqNo" width="75" maxChars="3"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Name:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtName" width="120" maxChars="255"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Duration:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtDuration" width="75" maxChars="6"/> - </mx:HBox> -</mx:VBox>--> + <mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> <mx:Script> <![CDATA[ - + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + public function getSequenceNo():String { return txtSeqNo.text; @@ -30,36 +28,113 @@ { return txtName.text; } - public function getMajor():String + /*public function getDuration():String { - return txtMajor.text; + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + } - public function getSemester():String + public function getMinutes():Number { - return txtSemester.text; + return minutes.value; + } + public function getSeconds():Number + { + return seconds.value; + + } + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + ]]> </mx:Script> <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3"/> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Name:"> - <mx:TextInput id="txtName"/> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Duration(hr:min:sec):"> <mx:HBox> <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1"/> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> </mx:HBox> + + </mx:FormItem> - - </mx:Form> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + + +</mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-15 22:36:23
|
Revision: 140 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=140&view=rev Author: seematalele Date: 2009-05-15 22:36:12 +0000 (Fri, 15 May 2009) Log Message: ----------- Created InitialiseDatabase.mxml and Module.mxml for facilitator to add questions into the database. Needs lot of modification. Added Paths: ----------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Added: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml (rev 0) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-15 22:36:12 UTC (rev 140) @@ -0,0 +1,210 @@ +<?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, #80FFAA]" + width="760" height="510" clipContent="false" layout="absolute" currentState="none"> + <mx:Script> + <![CDATA[ + + import mx.collections.XMLListCollection; + import mx.controls.Alert; + + [Bindable] + private var company:XML = + + <list> + <module title="Preexperiment" sequenceNo="200"> + <block name="John H"> + <item name="item"/> + </block> + <block name="Sam K"/> + </module> + <!--<module title="Operations" code="400"> + + <block name="Bill C"/> + <block name="Jill W"/> + </module> + <module title="Engineering" code="300"> + + <block name="Erin M"/> + <block name="Ann B"/> + </module>--> + </list>; + + [Bindable] + + private var companyData:XMLListCollection = new XMLListCollection(company.module); + private function treeLabel(item:Object):String + { + + var node:XML = XML(item); + + if( node.localName() == "module" ) + + return node.@title; + else + return node.@name; + + + } + private function addModule():void + + { + + currentState = "module"; + /*var saveModule:Button = new Button; + saveModule.label ="Save Module"; + + pnlComponent.addChild(saveModule as DisplayObject); + //saveModule.*/ + + } + + private function saveModule():void + { + + Alert.show("in add module"); + + var newNode:XML = <module/> + newNode.setLocalName("module"); + + newNode.@title="first module"; + newNode.@sequenceNo ="1"; + + company.appendChild(newNode); + <!-- var newNode:XML = <employee/>; + // newNode.@name = empName.text; + var dept:XMLList =company.department.(@title == "Operations"); + if( dept.length() > 0 ) { + + dept[0].appendChild(newNode); + // empName.text = ""; + }--> + } + + + private function addBlock():void + + { + var newNode:XML = <block/>; + newNode.@name = "block1"; + var module:XMLList =company.module.(@title == "first module"); + if( module.length() > 0 ) { + + module[0].appendChild(newNode); + // empName.text = ""; + } + } + + private function addItem():void + + { + var newNode:XML = <item/>; + newNode.@name = "item1"; + var module:XMLList =company.module.(@title == "first module"); + var i:int; + for (i = 0; i < module.length(); i++) + { + if(module[i].block.@name == "block1") + { + var item:XMLList =company.module.block.(@name == "block1"); + if( item.length() > 0 ) + { + + item[0].appendChild(newNode); + + } + } + } + + } + + + private function removeEmployee():void + { + var node:XML = XML(tree.selectedItem); + if( node == null ) return; + if( node.localName() != "employee" ) return; + + var children:XMLList = XMLList(node.parent()).children(); + for(var i:Number=0; i < children.length(); i++) { + + if( children[i].@name == node.@name ) { + delete children[i]; + } + + } + } + ]]> + </mx:Script> + + <mx:states> + <mx:State name="module"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Module id="module"/> + </mx:AddChild> + </mx:State> + + <!--<mx:State name="block"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + </mx:AddChild> + </mx:State> + + <mx:State name="item"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:PlannerPage id="planner"/> + </mx:AddChild> + </mx:State>--> + + <mx:State name="none"/> + </mx:states> + + <mx:HDividedBox width="100%" height="100%" id="hdMain"> + <mx:VBox height="100%" id="vboxLeft"> + <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" + labelFunction="treeLabel" + showRoot="true" + height="224" width="179"/> + + <mx:Canvas height="35%"> + <mx:Grid x="0" y="0"> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Module" id="butAddModule" click="{addModule()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Module" id="butRemModule"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Block" id="butAddBlock" click="{addBlock()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Block" id="butremBlock"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Item" id="butAddItem" click="{addItem()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Item" id="butremItem"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + </mx:Grid> + + </mx:Canvas> + </mx:VBox> + <mx:Panel id = "pnlComponent" height="100%"> + + </mx:Panel> + </mx:HDividedBox> + +</mx:Application> Added: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-15 22:36:12 UTC (rev 140) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> + + <!--<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" > + + <mx:Label text="Module Information" fontWeight="bold" width="150" textAlign="center" fontSize="12"/> + <mx:HBox> + <mx:Label text="Sequence Number:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtSeqNo" width="75" maxChars="3"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Name:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtName" width="120" maxChars="255"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Duration:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtDuration" width="75" maxChars="6"/> + </mx:HBox> +</mx:VBox>--> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> +<mx:Script> + <![CDATA[ + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + public function getMajor():String + { + return txtMajor.text; + } + public function getSemester():String + { + return txtSemester.text; + } + + + ]]> + </mx:Script> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3"/> + </mx:FormItem> + <mx:FormItem label="Name:"> + <mx:TextInput id="txtName"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1"/> + </mx:HBox> + + +</mx:FormItem> + + </mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-05-13 00:57:32
|
Revision: 139 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=139&view=rev Author: alllee Date: 2009-05-13 00:57:19 +0000 (Wed, 13 May 2009) Log Message: ----------- adding chat request parsing and spatial distribution statistics Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-05-04 20:29:59 UTC (rev 138) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-05-13 00:57:19 UTC (rev 139) @@ -1,5 +1,6 @@ package edu.asu.commons.foraging.util; +import java.awt.Dimension; import java.awt.Point; import java.io.File; import java.io.PrintWriter; @@ -37,6 +38,14 @@ import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Utils; +/** + * $Id$ + * + * Save file processors for binary savefiles for the foraging experiment. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ public class ForagingSaveFileConverter { @@ -48,7 +57,9 @@ new AllDataProcessor(), new AggregateTimeIntervalProcessor(), new SummaryProcessor(), - new MovementStatisticsProcessor())); + new CollectedTokenSpatialDistributionProcessor(), + new MovementStatisticsProcessor() + )); Persister.processSaveFiles(allSaveFilesDirectory, processors); return true; } @@ -82,6 +93,7 @@ MovementEvent movementEvent = (MovementEvent) event; Identifier id = movementEvent.getId(); GroupDataModel groupDataModel = serverDataModel.getGroup(id); + // only count movements when the resource count is > 0 if (resourceCountMap.get(groupDataModel) > 0) { clientStatisticsMap.get(id).move(movementEvent.getDirection()); } @@ -105,7 +117,7 @@ resourceCountMap.put(groupDataModel, resources - 1); } } - System.err.println("resource count map should be all zeroed out: " + resourceCountMap); +// System.err.println("resource count map: " + resourceCountMap); // tally their very last movement counts // (since ClientMovementStatistics only adds to the movement distribution when they change direction) for (ClientMovementStatistics summary: clientStatisticsMap.values()) { @@ -140,6 +152,9 @@ } + /** + * Helper class to keep track of client movements. + */ private static class ClientMovementStatistics { private final Identifier id; private Direction lastDirection; @@ -192,7 +207,89 @@ throw new RuntimeException("Identifier id: " + id + " -- allMoves: " + allMoves + " not equal to sum of all moves: " + sum); } } + } + + private static class CollectedTokenSpatialDistributionProcessor extends SaveFileProcessor.Base { + @Override + public void process(SavedRoundData savedRoundData, PrintWriter writer) { + ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); + SortedSet<PersistableEvent> actions = savedRoundData.getActions(); + Map<Identifier, ClientSpatialDistribution> clientSpatialDistributionMap = new HashMap<Identifier, ClientSpatialDistribution>(); + Dimension boardSize = new Dimension(serverDataModel.getBoardWidth(), serverDataModel.getBoardHeight()); + for (ClientData clientData : serverDataModel.getClientDataMap().values()) { + clientSpatialDistributionMap.put(clientData.getId(), new ClientSpatialDistribution(boardSize)); + } + for (PersistableEvent event : actions) { + if (event instanceof TokenCollectedEvent) { + TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; + Point point = tokenCollectedEvent.getLocation(); + Identifier id = tokenCollectedEvent.getId(); + ClientSpatialDistribution clientDistribution = clientSpatialDistributionMap.get(id); + clientDistribution.columnCounts[point.x]++; + clientDistribution.rowCounts[point.y]++; + clientDistribution.tokens++; + } + } + for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { + Identifier id = entry.getKey(); + ClientSpatialDistribution spatialDistribution = entry.getValue(); + spatialDistribution.calculateStandardDeviation(); + writer.println(String.format("%s, %s, %s", id, spatialDistribution.standardizedColumnDistribution, spatialDistribution.standardizedRowDistribution)); + System.err.println("spatial distribution for id: " + id + spatialDistribution); + } + } + + @Override + public String getOutputFileExtension() { + return "-spatial-distribution.txt"; + } + } + + private static class ClientSpatialDistribution { + private int[] rowCounts; + private double standardizedRowDistribution; + private int[] columnCounts; + private double standardizedColumnDistribution; + private int tokens = 0; + private double rowStandardDeviation; + private double columnStandardDeviation; + private ClientSpatialDistribution(Dimension boardSize) { + rowCounts = new int[boardSize.height]; + columnCounts = new int[boardSize.width]; + Arrays.fill(rowCounts, 0); + Arrays.fill(columnCounts, 0); + } + public String toString() { + return String.format("tokens: %d, row: %s, col: %s", tokens, standardizedRowDistribution, standardizedColumnDistribution); + } + private void calculateStandardDeviation() { + rowStandardDeviation = stdDev(rowCounts); + columnStandardDeviation = stdDev(columnCounts); + double averageTokens = (double) tokens / (double) rowCounts.length; + standardizedRowDistribution = (rowStandardDeviation / averageTokens); + standardizedColumnDistribution = (columnStandardDeviation / averageTokens); + } + + private double stdDev(int[] counts) { + // calculate mean + int totalTokensInRow = sum(counts); + double size = (double) counts.length; + double mean = (double) totalTokensInRow / size; + double sumOfSquares = 0; + for (int count : counts) { + double difference = count - mean; + sumOfSquares += (difference * difference); + } + return Math.sqrt(sumOfSquares / size); + } + private int sum(int[] count) { + int total = 0; + for (int tokens: count) { + total += tokens; + } + return total; + } } private static class SummaryProcessor extends SaveFileProcessor.Base { @@ -227,6 +324,45 @@ Utils.join(',', group.getResourceDistribution().keySet()) )); } + // FIXME: should update later once we fix rolling chat logs. + Map<GroupDataModel, SortedSet<ChatRequest>> chatRequestMap = new HashMap<GroupDataModel, SortedSet<ChatRequest>>(); + SortedSet<ChatRequest> allChatRequests = savedRoundData.getChatRequests(); + if (! allChatRequests.isEmpty()) { + ChatRequest first = allChatRequests.first(); + for (ChatRequest request: savedRoundData.getChatRequests()) { + // FIXME: hack to deal with rolling chat logs, eventually should only have per-round chat requests + // in savedRoundData. +// if (request.getCreationTime() < lastCreationTime) { +// continue; +// } + + GroupDataModel group = serverDataModel.getGroup(request.getSource()); + if (chatRequestMap.containsKey(group)) { + chatRequestMap.get(group).add(request); + } + else { + TreeSet<ChatRequest> chatRequests = new TreeSet<ChatRequest>(); + chatRequests.add(request); + chatRequestMap.put(group, chatRequests); + } + } + // FIXME: hack to deal with rolling chat logs + // set last creation time to the last chat request that occurred so in the next chat round + // we'll know if we repeated a chat request. +// ChatRequest last = allChatRequests.last(); +// lastCreationTime = last.getCreationTime(); +// System.err.println("last creation time: " + lastCreationTime + " - " + last); + for (GroupDataModel group: groups) { + SortedSet<ChatRequest> chatRequests = chatRequestMap.get(group); + if (chatRequests != null) { + writer.println("Group #" + groups.indexOf(group)); + for (ChatRequest request: chatRequests) { + writer.println(String.format("%s: %s (%s)", request.getSource(), request.toString(), (request.getCreationTime() - first.getCreationTime())/1000L)); + } + } + } + } + } @Override public String getOutputFileExtension() { @@ -257,14 +393,14 @@ // RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); SortedSet<PersistableEvent> actions = savedRoundData.getActions(); ServerDataModel model = (ServerDataModel) savedRoundData.getDataModel(); - Map<Identifier, ClientStats> clientStats = createClientStats(model); + Map<Identifier, ClientMovementTokenCount> clientMovementTokenCounts = createClientMovementTokenCounts(model); List<GroupDataModel> groups = new ArrayList<GroupDataModel>(model.getGroups()); Map<Identifier, ClientData> clientDataMap = model.getClientDataMap(); for (PersistableEvent event: actions) { if (event instanceof MovementEvent) { MovementEvent movementEvent = (MovementEvent) event; ClientData clientData = clientDataMap.get(event.getId()); - ClientStats client = clientStats.get(event.getId()); + ClientMovementTokenCount client = clientMovementTokenCounts.get(event.getId()); client.moves++; GroupDataModel group = clientData.getGroupDataModel(); String line = String.format("%s, %s, %d, %d, %s, %s", @@ -280,7 +416,7 @@ else if (event instanceof TokenCollectedEvent) { TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; ClientData clientData = clientDataMap.get(event.getId()); - ClientStats client = clientStats.get(event.getId()); + ClientMovementTokenCount client = clientMovementTokenCounts.get(event.getId()); Point location = tokenCollectedEvent.getLocation(); client.tokens++; GroupDataModel group = clientData.getGroupDataModel(); @@ -314,7 +450,7 @@ private void processData3d(SavedRoundData savedRoundData, PrintWriter writer) { RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); ServerDataModel dataModel = (ServerDataModel) savedRoundData.getDataModel(); - Map<Identifier, ClientStats> clientStatsMap = createClientStats(dataModel); + Map<Identifier, ClientMovementTokenCount> clientStatsMap = createClientMovementTokenCounts(dataModel); SortedSet<PersistableEvent> actions = savedRoundData.getActions(); for (PersistableEvent event: actions) { if (event instanceof ChatRequest) { @@ -340,7 +476,7 @@ } else if (event instanceof HarvestFruitRequest) { HarvestFruitRequest request = (HarvestFruitRequest) event; - ClientStats clientStats = clientStatsMap.get(event.getId()); + ClientMovementTokenCount clientStats = clientStatsMap.get(event.getId()); clientStats.tokens += roundConfiguration.getTokensPerFruits(); Resource resource = request.getResource(); String line = String.format("%s, %s, %d, %d, %d, %d, %d, %d, %s", @@ -358,7 +494,7 @@ else if (event instanceof HarvestResourceRequest) { HarvestResourceRequest request = (HarvestResourceRequest) event; Resource resource = request.getResource(); - ClientStats clientStats = clientStatsMap.get(event.getId()); + ClientMovementTokenCount clientStats = clientStatsMap.get(event.getId()); clientStats.tokens += roundConfiguration.calculateTokens(resource.getAge()); String line = String.format("%s, %s, %d, %d, %d, %d, %d, %d, %s", savedRoundData.toSecondString(event), @@ -384,7 +520,7 @@ // populate the ordered identifiers, try directly from the participant tokens map that // is persisted in later versions of the experiment. ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); - Map<Identifier, ClientStats> clientStatistics = createClientStats(serverDataModel); + Map<Identifier, ClientMovementTokenCount> clientStatistics = createClientMovementTokenCounts(serverDataModel); for (ClientData clientData: serverDataModel.getClientDataMap().values()) { clientData.initializePosition(); } @@ -461,7 +597,7 @@ List<Integer> tokensLeft = getTokensLeft(groups); List<Double> distances = getClientDistances(groups); for (Identifier id : orderedIdentifiers) { - ClientStats stats = clientStatistics.get(id); + ClientMovementTokenCount stats = clientStatistics.get(id); movesTaken.add(stats.moves); harvestedTokens.add(stats.tokens); stats.reset(); @@ -478,7 +614,7 @@ currentInterval++; } // next, process the current persistable event - ClientStats stats = clientStatistics.get(event.getId()); + ClientMovementTokenCount stats = clientStatistics.get(event.getId()); if (event instanceof MovementEvent) { MovementEvent movementEvent = (MovementEvent) event; serverDataModel.moveClient(movementEvent.getId(), movementEvent.getDirection()); @@ -567,7 +703,7 @@ } - private static class ClientStats { + private static class ClientMovementTokenCount { private int moves = 0; private int tokens = 0; public void reset() { @@ -576,12 +712,12 @@ } } - public static Map<Identifier, ClientStats> createClientStats(ServerDataModel model) { - Map<Identifier, ClientStats> clientStats = new HashMap<Identifier, ClientStats>(); + public static Map<Identifier, ClientMovementTokenCount> createClientMovementTokenCounts(ServerDataModel model) { + Map<Identifier, ClientMovementTokenCount> clientStats = new HashMap<Identifier, ClientMovementTokenCount>(); for (Identifier id: model.getClientDataMap().keySet()) { - clientStats.put(id, new ClientStats()); + clientStats.put(id, new ClientMovementTokenCount()); } return clientStats; } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |